Skip to content

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

Merged
merged 7 commits into from
Jan 1, 2016
Merged

AzureRT PR - CLU Test Updates #1566

merged 7 commits into from
Jan 1, 2016

Conversation

huangpf
Copy link
Contributor

@huangpf huangpf commented Dec 31, 2015

No description provided.

fi

queryString=Standard_G1
result=`echo "$vmSizeResult" | grep -q "$queryString"`
Copy link
Contributor Author

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?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

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.

Copy link
Member

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

Copy link
Member

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

Copy link
Contributor Author

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.

Copy link
Member

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

Copy link
Contributor Author

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.

markcowl added a commit that referenced this pull request Jan 1, 2016
AzureRT PR - CLU Test Updates
@markcowl markcowl merged commit 23f9e70 into Azure:clu Jan 1, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants