Skip to content
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

[JUJU-1195]rewrite to bash based nw clouds display test #14455

Merged
Changes from all commits
Commits
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
67 changes: 67 additions & 0 deletions tests/suites/cli/display_clouds.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,72 @@ EOF
fi
}

run_assess_clouds() {
Copy link
Member

Choose a reason for hiding this comment

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

need to rename: run_clouds

echo

mkdir -p "${TEST_DIR}/juju"
echo "" >>"${TEST_DIR}/juju/public-clouds.yaml"
Copy link
Member

Choose a reason for hiding this comment

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

I do not think we need to create a subfolder juju. Other tests writes directly to TEST_DIR

echo "" >>"${TEST_DIR}/juju/credentials.yaml"

CLOUD_LIST=$(JUJU_DATA="${TEST_DIR}/juju" juju clouds --client --format=json 2>/dev/null | jq 'with_entries(select(.value.defined != "built-in"))')
EXPECTED={}
if [ "${CLOUD_LIST}" != "${EXPECTED}" ]; then
Copy link
Member

Choose a reason for hiding this comment

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

for this purpose we use check, check_contains or diff (see /includes/check.sh).

echo "expected ${EXPECTED}, got ${CLOUD_LIST}"
exit 1
fi

CLOUDS=$(
cat <<'EOF'
clouds:
finfolk-vmaas:
auth-types:
- oauth1
endpoint: http://10.125.0.10:5240/MAAS/
type: maas
vsphere:
auth-types:
- userpass
endpoint: 10.247.0.3
regions:
QA:
endpoint: 10.247.0.3
type: vsphere
EOF
)

echo "${CLOUDS}" >>"${TEST_DIR}/juju/clouds.yaml"
CLOUD_LIST=$(JUJU_DATA="${TEST_DIR}/juju" juju clouds --client --format=json 2>/dev/null | jq -S 'with_entries(select(
.value.defined != "built-in")) | with_entries((select(.value.defined == "local")
| del(.value.defined) | del(.value.description)))')
EXPECTED=$(echo "${CLOUDS}" | yq -I0 -oj | jq -S '.[] | del(.clouds) | .[] |= ({endpoint} as $endpoint | .[] |= walk(
(objects | select(contains($endpoint))) |= del(.endpoint)
))')
if [ "${CLOUD_LIST}" != "${EXPECTED}" ]; then
echo "expected ${EXPECTED}, got ${CLOUD_LIST}"
exit 1
fi

CLOUD_LIST=$(JUJU_DATA="${TEST_DIR}/juju" juju show-cloud finfolk-vmaas --format yaml --client 2>/dev/null | yq -I0 -oj | jq -S 'with_entries((select(.value!= null)))')
EXPECTED=$(
cat <<'EOF' | jq -S
{
"auth-types": [
"oauth1"
],
"defined": "local",
"description": "Metal As A Service",
"endpoint": "http://10.125.0.10:5240/MAAS/",
"type": "maas"
}
EOF
)

if [ "${CLOUD_LIST}" != "${EXPECTED}" ]; then
echo "expected ${EXPECTED}, got ${CLOUD_LIST}"
exit 1
fi
}

test_display_clouds() {
if [ "$(skip 'test_display_clouds')" ]; then
echo "==> TEST SKIPPED: display clouds"
Expand All @@ -57,5 +123,6 @@ test_display_clouds() {
cd .. || exit

run "run_show_clouds"
run "run_assess_clouds"
)
}