Skip to content

WebApp bash tests and modifications #1593

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 31 commits into from
Jan 7, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
a067a55
ParentResource intialized .
amarzavery Dec 17, 2015
0bf6336
app service plan tests
amarzavery Dec 18, 2015
a407e81
Merge branch 'clu' of github.com:amarzavery/azure-powershell into web…
Dec 18, 2015
f056ae3
Merge branch 'webapp-test' of github.com:haocs/azure-powershell into …
Dec 21, 2015
327d46c
Merge branch 'clu' of github.com:Azure/azure-powershell into clu
amarzavery Dec 21, 2015
12fd03d
Merge branch 'webapp-test' of github.com:haocs/azure-powershell into …
Dec 21, 2015
2a4f0e7
Merge branch 'clu' of https://github.com/Azure/azure-powershell into clu
Dec 22, 2015
673a370
Adding web app slot test for CLU.
Dec 22, 2015
4ea06eb
Merge branch 'webapp-test' of https://github.com/haocs/azure-powershe…
Dec 22, 2015
fb87554
Added more tests for webapp
Dec 23, 2015
8d8af06
More tests added to Webapp.
Dec 23, 2015
579bbaf
Fixed cmdlet pipeline bug in bash.
Dec 24, 2015
e985097
Merge branch 'clu' of https://github.com/Azure/azure-powershell into clu
Dec 27, 2015
1e63c74
Merge branch 'webapp-test' of https://github.com/haocs/azure-powershe…
Dec 27, 2015
a09ef96
Merge branch 'clu' of github.com:Azure/azure-powershell into clu
amarzavery Dec 30, 2015
260e083
webapp list as stream
amarzavery Jan 5, 2016
75b5e22
Merge branch 'clu' of github.com:Azure/azure-powershell into clu
amarzavery Jan 5, 2016
88d0269
03-WebApp.sh
amarzavery Jan 5, 2016
7c1e6b2
Merge branch 'clu' of github.com:Azure/azure-powershell into clu
amarzavery Jan 5, 2016
1b86e5c
Websites list
amarzavery Jan 5, 2016
e6ebd8a
Merge branch 'clu' of github.com:amarzavery/azure-powershell into clu
amarzavery Jan 5, 2016
e80bcfd
modification for bash tests
amarzavery Jan 6, 2016
aea4da6
Merge branch 'clu' of github.com:Azure/azure-powershell into clu
amarzavery Jan 6, 2016
cc5bf19
modifications to webapp tests
amarzavery Jan 7, 2016
907e11d
small modification
amarzavery Jan 7, 2016
c5d59cd
monor mods
amarzavery Jan 7, 2016
62f1f04
Merge branch 'clu' of https://github.com/amarzavery/azure-powershell …
amarzavery Jan 7, 2016
6a30804
Merge branch 'clu' of https://github.com/Azure/azure-powershell into clu
amarzavery Jan 7, 2016
4528080
code review feedback
amarzavery Jan 7, 2016
36b9116
fix failing tests
amarzavery Jan 7, 2016
fc8a145
reverting changes
amarzavery Jan 7, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions examples/webapp-management/01-AppServicePlan.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/bin/bash
set -e
printf "\n=== Managing App Service Plans in Azure ===\n"

#setup
printf "\nSetup: Creating a new resource group: %s at location: %s.\n" "$groupName" "$location"
export whpName=`randomName testplan`
tier="Standard"
size="Medium"
capacity=2
skuName="S2"
azure group create --name "$groupName" --location "$location"

printf "\n1. Create a new app service plan %s " "$whpName"
azure app service plan create -n "$whpName" -g "$groupName" -l "$location" --tier "$tier" --size "$size" --workers "$capacity"

printf "\n2. Get information about the app service plan : %s.\n" "$whpName"
whpInfo=`azure app service plan get --name $whpName --group $groupName`

printf "\nValidating app service plan name: %s\n" "$whpName"
[ $(echo $whpInfo | jq '.name' --raw-output) == "$whpName" ]
[ $(echo $whpInfo | jq '.location' --raw-output) == "West US" ]
[ $(echo $whpInfo | jq '.sku.tier' --raw-output) == "$tier" ]
[ $(echo $whpInfo | jq '.sku.name' --raw-output) == "$skuName" ]
[ $(echo $whpInfo | jq '.sku.capacity' --raw-output) -eq $capacity ]

printf "\n3. Set the appservice plan: %s " "$whpName"
newTier="Shared"
newCapacity=0
newSize="Medium"
setPlanInfo=`azure app service plan set -n $whpName -g $groupName --tier $newTier --workers --workers $newCapacity --size $newSize`
[ $(echo $setPlanInfo | jq '.name' --raw-output) == "$whpName" ]
[ $(echo $setPlanInfo | jq '.sku.tier' --raw-output) == "$newTier" ]
[ $(echo $setPlanInfo | jq '.sku.capacity' --raw-output) -eq $newCapacity ]
[ $(echo $setPlanInfo | jq '.sku.name' --raw-output) == "D1" ]
[ $(echo $setPlanInfo | jq '.["properties.geoRegion"]' --raw-output) == "West US" ]

whpName2=`randomName testplan`
printf "\n4. Creating a new app service plan: %s" "$whpName2"
location2="East US"
azure app service plan create -n "$whpName2" -g "$groupName" -l "$location2" --tier "$tier" --size "$size" --workers "$capacity"

printf "\n5. Get All app service plans by name: %s" "$whpName2"
whpInfo2=`azure app service plan get --name $whpName2`
[ $(echo $whpInfo | jq '.name' --raw-output) == "$whpName2" ]
[ $(echo $whpInfo | jq '.location' --raw-output) == "$location2" ]
[ $(echo $whpInfo | jq '.sku.tier' --raw-output) == "$tier" ]
[ $(echo $whpInfo | jq '.sku.name' --raw-output) == "$skuName" ]
[ $(echo $whpInfo | jq '.sku.capacity' --raw-output) -eq $capacity ]

printf "\n6. Get All app service plans by resource group: %s" "$groupName"
plansByGroup=`azure app service plan get --group $groupName`
[ $plansByGroup == *"$whpName"* ]
[ $plansByGroup == *"$whpName2"* ]

printf "\n7. Get All app service plans by location: %s" "$location2"
plansByLocation=`azure app service plan get -l $location2`
[ $plansByLocation == *"$whpName2"* ]

printf "\n8. Get All app service plans in a subscription."
plansInSubscription=`azure app service plan get`
[ $plansInSubscription == *"$whpName"* ]
[ $plansInSubscription == *"$whpName2"* ]

printf "\n9. Remove app service plan: %s." "$whpName"
azure app service plan remove -n $whpName -g $groupName

printf "\n10. Remove app service plan: %s." "$whpName2"
azure app service plan remove -n $whpName2 -g $groupName
142 changes: 142 additions & 0 deletions examples/webapp-management/02-WebAppSlot.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
#!/bin/bash
set -e
printf "\n=== Managing Web App Slot in Azure ===\n"

pingwebapp() {
# a helper function to ping a webapp
}

#setup
printf "\nSetup: Creating a new resource group: %s at location: %s.\n" "$groupName" "$location"

appName=`randomName testweb`
slotname1="staging"
slotname2="testing"
planName=`randomName testplan`
tier="Standard"
apiversion="2015-08-01"
resourceType="Microsoft.Web/sites"

azure group create --name "$groupName" --location "$location"

printf "\n1. Create a new app service plan %s " "$planName"
azure app service plan create -n "$planName" -g "$groupName" -l "$location" --tier "$tier"

printf "\n2. Create a new web app %s " "$appName"
webappInfo=`azure webapp create -g "$groupName" -n "$appName" -l "$location" --plan "$planName"`

printf "\nValidating web app name %s " "$appName"
[ $(echo $webappInfo | jq '.name' --raw-output) == "$appName" ]

printf "\n3. Create a web app slot %s " "$slotname1"
slot1=`azure webapp slot create -g "$groupName" --plan "$planName" -n "$appName" --slot "$slotname1"`
appWithSlotName1="$appName/$slotname1"

printf "\nValidating web app slot %s " "$slotname1"
[ $(echo $slot1 | jq '.name' --raw-output) == "$appWithSlotName1" ]

printf "\nValidating web app slot get for %s " "$slotname1"
slot1=`azure webapp slot get -g "$groupName" -n "$appName" --slot "$slotname1"`
[ $(echo $slot1 | jq '.name' --raw-output) == "$appWithSlotName1" ]

printf "\nValidating web app slot via pipline obj for %s " "$slotname1"
slot1=`echo "$webappInfo" | azure webapp slot get --slot "$slotname1"`

printf "\n4. Create another web app slot %s " "$slotname2"
slot2=`azure webapp slot create -g "$groupName" --plan "$planName" -n "$appName" --slot "$slotname2"`
appWithSlotName2="$appName/$slotname2"

printf "\n5. Get the webapp slots:"
slots=`azure webapp slot get -g "$groupName" -n "$appName"`
slotN1=`echo $slots | jq '.[0].name'`
slotN2=`echo $slots | jq '.[1].name'`
slotNames=`echo $slotN1 $slotN2`

printf "\nValidating web app slots %s " "$slotname1 and $slotname2"
[[ $slotNames == *"$appWithSlotName1"* ]]
[[ $slotNames == *"$appWithSlotName2"* ]]

printf "\n6. Change web app slot %s service plan" "$slotname2"
printf "\n7. Set web app slot %s config properties" "$slotname2"
printf "\n8. Set web app slot %s settings and connection strings" "$slotname2"

printf "\n9. Get web app slot %s publishing profile" "$slotname1"
printf "\n10. Get web app slot %s publishing profile via pipline obj" "$slotname1"

printf "\n11. Get web app slot metrics %s " "$slotname1"
for i in {1..10}
do
pingwebapp $slot1
done

endTime=`date +"%A, %B %d, %Y %X"`
startTime=`date +"%A, %B %d, %Y %X" --date "3 hour ago"`
$metricsNames="\"('CPU', 'Requests')\""

# !Not able to test since complex object issue.
metrics=`azure webapp slot metrics get -g "$groupName" -n "$appName" --slot "$slotname1" --granularity PT1M --starttime "$startTime" --endtime "$endTime" --metrics "$metricsNames"`

printf "\nValidating web app slot metrics %s " "$slotname1"
for i in $metricsNames
do
[ $(echo $metrics ) == "$i" ]
done

# !Not able to test pipeline for now
printf "\nValidating web app slot metrics via pipline obj %s " "$slotname1"

printf "\n12. Stop web app slot: %s." "$slotname1"
slot1=`echo "$slot1" | azure webapp slot stop`
printf "\nValidating web app slot %s stopped " "$slotname1"
[ $(echo $slot1 | jq '."properties.state"' --raw-output) == "Stopped" ]

printf "\n13 Stop web app slot: %s." "$slotname1"
slot1=`echo "$slot1" | azure webapp slot start`
printf "\nValidating web app slot %s running " "$slotname1"
[ $(echo $slot1 | jq '."properties.state"' --raw-output) == "Running" ]

printf "\n14 Stop web app slot: %s." "$slotname1"
slot1=`echo "$slot1" | azure webapp slot stop`
printf "\nValidating web app slot %s stopped " "$slotname1"
[ $(echo $slot1 | jq '."properties.state"' --raw-output) == "Stopped" ]

printf "\n15 Stop web app slot: %s." "$slotname1"
slot1=`echo "$slot1" | azure webapp slot start`
printf "\nValidating web app slot %s running " "$slotname1"
[ $(echo $slot1 | jq '."properties.state"' --raw-output) == "Running" ]

printf "\n16 Restart web app slot: %s." "$slotname1"
slot1=`echo "$slot1" | azure webapp slot restart`
printf "\nValidating web app slot %s Running " "$slotname1"
[ $(echo $slot1 | jq '."properties.state"' --raw-output) == "Running" ]

printf "\n17 Restart web app slot: %s." "$slotname1"
slot1=`echo "$slot1" | azure webapp slot restart`
printf "\nValidating web app slot %s Running " "$slotname1"
[ $(echo $slot1 | jq '."properties.state"' --raw-output) == "Running" ]

# Clone ------
# !Not able to test since complex object input issue.
# printf "\n10. Clone web app slot: %s." "$slotname1"
# slotClone=`azure web app slot clone`
# appWithSlotNameClone="$appName/slotname1"

# printf "\nValidating cloned web app slot %s " "$slotname1"
# [ $(echo $slotClone | jq '.name' --raw-output) == "$appWithSlotNameClone" ]

# printf "\nValidating web app slot get for %s " "$slotname1"
# slot1=`azure webapp slot get -g "$groupName" -n "$appName" --slot "$slotname1"`
# [ $(echo $slot1 | jq '.name' --raw-output) == "$appWithSlotNameClone" ]
#-------

# Cleanup
printf "\n20. Remove web app slot: %s." "$slotname1"
azure webapp slot remove -g "$groupName" -n "$appName" --slot "$slotname1"

printf "\n20. Remove web app: %s." "$appName"
azure webapp remove -g "$groupName" -n "$appName"

printf "\n20. Remove app service plan: %s." "$planName"
azure app service plan remove -g "$groupName" -n "$planName"

printf "\n20. Remove resource group: %s." "$groupName"
Loading