-
Notifications
You must be signed in to change notification settings - Fork 4k
AzureRT PR - CLU Test Updates #1566
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
Conversation
fi | ||
|
||
queryString=Standard_G1 | ||
result=`echo "$vmSizeResult" | grep -q "$queryString"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stankovski @hovsepm @markcowl
What's the correct way to do string operations and test the not-containing case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like one of the options: http://stackoverflow.com/questions/229551/string-contains-in-bash
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I had try the [[
method, but the test runner throws error. @stankovski Could you please help try it on your end? Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code worked for me:
vmSizeResult="Test string with Standard_A0"
queryString=Standard_A0
if [[ $vmSizeResult != *$queryString* ]]; then
printf "\nFailure: VM Size Not Found: '%s'.\n" "$queryString"
exit 1
else
printf "\nSuccess: VM Size Found in Results: '%s'.\n" "$queryString"
fi
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't forget the spaces around [[
- they are important
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would throw the following error [[: command not found
, using the same code above. Any configuration I need to make? Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is a working test:
#!/bin/bash
set -e
printf "\n=== Managing Virtual Machine Sizes in Azure Compute ===\n"
printf "\n1. Showing VM size results in location: %s.\n" "$location"
azure vmsize get --location "$location"
printf "\n2. Checking VM size results in location: %s.\n" "$location"
vmSizeResult=`azure vmsize get --location "$location"`
if [[ $vmSizeResult == "" ]]; then
echo "Failure: No VM sizes!" 1>&2
exit 1
else
echo "Success: Non-empty Results."
fi
filterResult=`azure vmsize get --location "$location" | cat | jq 'select(.name | contains("Standard_A0"))' --raw-output`
if [[ "$filterResult" == "" ]]; then
echo "Failure: Standard_A0 vm size not found." 1>&2
exit 1
else
echo "Success: Standard_A0 vm size found."
fi
filterResult=`azure vmsize get --location "$location" | cat | jq 'select(.name | contains("Standard_G1"))' --raw-output`
if [[ "$filterResult" == "" ]]; then
echo "Failure: Standard_G1 vm size not found." 1>&2
exit 1
else
echo "Success: Standard_G1 vm size found."
fi
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @stankovski . bash 4.0
works. I have updated the PR. Could you please help review again? Thanks.
No description provided.