From 57e214eea8e2b970ec09df8ba565a0b6a0f0d2b1 Mon Sep 17 00:00:00 2001 From: Pete Wall Date: Tue, 21 Jun 2022 13:47:55 -0500 Subject: [PATCH] Fix test failure caused by change in production slug Also remove the GitHub actions, which had not fully materialized Signed-off-by: Pete Wall --- .github/workflows/release.yml | 26 ------- Makefile | 12 ++-- action.yml | 29 -------- ci/pipeline.yaml | 2 +- {test-scripts => ci/tasks}/download-asset.sh | 0 ci/tasks/download-asset.yaml | 2 +- entrypoint.sh | 74 -------------------- test-scripts/external-test-inputs.json | 20 ------ test-scripts/external-test-runner.sh | 41 ----------- test/common_steps.go | 16 ++++- test/external/debugging_test.go | 32 ++++----- test/external/download_test.go | 9 --- 12 files changed, 38 insertions(+), 225 deletions(-) delete mode 100644 .github/workflows/release.yml delete mode 100644 action.yml rename {test-scripts => ci/tasks}/download-asset.sh (100%) delete mode 100755 entrypoint.sh delete mode 100644 test-scripts/external-test-inputs.json delete mode 100755 test-scripts/external-test-runner.sh diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 88ccb2a..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: release -on: - push: - -jobs: - release: - name: release - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - test_latest_version_v1: - runs-on: ubuntu-latest - name: latest v1 - env: - MARKETPLACE_CLI_VERSION: "0.4.9" - steps: - - uses: actions/checkout@v2 - with: - marketplace_api_token: "testtoken" - version: "v0.4.9" - - name: test on Runner - run: | - sudo ./entrypoint.sh \ No newline at end of file diff --git a/Makefile b/Makefile index 905af4b..77fe55f 100644 --- a/Makefile +++ b/Makefile @@ -136,16 +136,16 @@ else MKPCLI_STRICT_DECODING=true ginkgo -r test/external endif -test-external-scripts: - cd test-scripts && ./external-test-runner.sh - test: deps lint test-units test-features test-external test-external-with-strict-decoding -test-all: test test-external-scripts +lint: lint-go lint-bash -lint: deps-golangci-lint deps-shellcheck +lint-go: deps-golangci-lint golangci-lint run - shellcheck test-scripts/*.sh + +BASH_SRC = $(shell find . -name "*.sh" ) +lint-bash: $(BASH_SRC) deps-shellcheck + shellcheck $(BASH_SRC) # #### DEVOPS #### .PHONY: set-pipeline diff --git a/action.yml b/action.yml deleted file mode 100644 index 886e3fd..0000000 --- a/action.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: "install-marketplace-cli-action" -description: "Install Marketplace CLI on a Linux" -inputs: - version: - description: "1=latest version of v1, 2=latest version of v2, #.#.#=specific version" - required: false - default: "v0.4.9" - marketplace_api_token: - description: "API token to manage products on VMWare market place" - required: true -outputs: - version: - description: "The Marketplace CLI version that was installed" - value: ${{ steps.set-output.outputs.version }} - -runs: - using: "composite" - steps: - - id: set-env-vars - run: | - echo "MARKETPLACE_CLI_VERSION=${{ inputs.version }}" >> $GITHUB_ENV - shell: bash - - id: print-version - run: sudo --preserve-env ${{ github.action_path }}/entrypoint.sh - shell: bash - - id: set-output - run: echo "::set-output name=version::$(mkpcli version)" - shell: bash - \ No newline at end of file diff --git a/ci/pipeline.yaml b/ci/pipeline.yaml index 466e112..6ceeb58 100644 --- a/ci/pipeline.yaml +++ b/ci/pipeline.yaml @@ -408,7 +408,7 @@ jobs: params: MARKETPLACE_ENV: production ASSET_TYPE: image - PRODUCT_SLUG: vmware-tanzu-rabbitmq1 + PRODUCT_SLUG: datastax-kubernetes-operator-for-apache-cassandra PRODUCT_VERSION: "1.0.0" on_error: put: slack diff --git a/test-scripts/download-asset.sh b/ci/tasks/download-asset.sh similarity index 100% rename from test-scripts/download-asset.sh rename to ci/tasks/download-asset.sh diff --git a/ci/tasks/download-asset.yaml b/ci/tasks/download-asset.yaml index e203002..93e06a1 100644 --- a/ci/tasks/download-asset.yaml +++ b/ci/tasks/download-asset.yaml @@ -17,4 +17,4 @@ inputs: - name: source run: - path: source/test-scripts/download-asset.sh + path: source/ci/tasks/download-asset.sh diff --git a/entrypoint.sh b/entrypoint.sh deleted file mode 100755 index e47626e..0000000 --- a/entrypoint.sh +++ /dev/null @@ -1,74 +0,0 @@ -#!/bin/bash -set -e - -### Usage -### ---------------------------------------- -### Set MARKETPLACE_CLI_VERSION env var or pass arg -### Print ls - export VERBOSE=true -### ./entrypoint.sh "$MARKETPLACE_CLI_VERSION" -### ---------------------------------------- - - - -_ROOT_DIR="${PWD}" -_WORKDIR="${_ROOT_DIR}/vmware-mkpcli" -#_MARKETPLACE_CLI_VERSION=${"0.2.4":-$MARKETPLACE_CLI_VERSION} # Use env or arg - -_MARKETPLACE_CLI_VERSION="v0.4.9" - -_MKP_CLI_VERSION=${_MARKETPLACE_CLI_VERSION} -_DOWNLOAD_URL="" -_DOWNLOAD_FILENAME="mkpcli-linux" - - - -msg_log(){ - msg=$1 - echo -e ">> [LOG]: ${msg}" -} - - -set_workdir(){ - env - echo "--------------" - echo $MARKETPLACE_CLI_VERSION - echo "${MARKETPLACE_CLI_VERSION}" - echo "--------------" - mkdir -p "${_WORKDIR}" - cd "${_WORKDIR}" -} - -set_download_url(){ - msg_log "Setting _DOWNLOAD_URL" - - msg_log "${MKP_CLI_VERSION}" - - _DOWNLOAD_URL="https://github.com/vmware-labs/marketplace-cli/releases/download/${_MKP_CLI_VERSION}/mkpcli-linux" - - msg_log "_DOWNLOAD_URL = ${_DOWNLOAD_URL}" -} - -download_mkp_cli(){ - msg_log "Downloading ..." - wget "$_DOWNLOAD_URL" && - [[ $_VERBOSE = "true" ]] && ls -lah "$_DOWNLOAD_FILENAME" - chmod +x mkpcli-linux -} - -install_mkp_cli(){ - msg_log "Installing ..." - mv mkpcli-linux /usr/bin/mkpcli - -} - -test_mkp_cli(){ - msg_log "Printing Help" - mkpcli --help -} - -#Main -set_workdir -set_download_url -download_mkp_cli -install_mkp_cli -test_mkp_cli \ No newline at end of file diff --git a/test-scripts/external-test-inputs.json b/test-scripts/external-test-inputs.json deleted file mode 100644 index 47dfb94..0000000 --- a/test-scripts/external-test-inputs.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "tests": { - "downloadChart": { - "slug": "nginx", - "version": "1.21.3_0" - }, - "downloadContainerImage": { - "slug": "vmware-tanzu-rabbitmq1", - "version": "1.0.0" - }, - "downloadISO": { - "slug": "veeam-backup-and-replication-version-111", - "version": "11" - }, - "downloadOVA": { - "slug": "nginxstack", - "version": "1.21.3_1" - } - } -} diff --git a/test-scripts/external-test-runner.sh b/test-scripts/external-test-runner.sh deleted file mode 100755 index 351e0ed..0000000 --- a/test-scripts/external-test-runner.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/env bash - -# Copyright 2022 VMware, Inc. -# SPDX-License-Identifier: BSD-2-Clause - -function TestDownloadChart() { - echo "Download Chart test" - PRODUCT_SLUG=$(jq -r .tests.downloadChart.slug ./external-test-inputs.json) - PRODUCT_VERSION=$(jq -r .tests.downloadChart.version ./external-test-inputs.json) - export PRODUCT_SLUG PRODUCT_VERSION - ./download-chart.sh -} - -function TestDownloadContainerImage() { - echo "Download Container Image test" - PRODUCT_SLUG=$(jq -r .tests.downloadContainerImage.slug ./external-test-inputs.json) - PRODUCT_VERSION=$(jq -r .tests.downloadContainerImage.version ./external-test-inputs.json) - export PRODUCT_SLUG PRODUCT_VERSION - ./download-container-image.sh -} - -function TestDownloadISO() { - echo "Download ISO test" - PRODUCT_SLUG=$(jq -r .tests.downloadISO.slug ./external-test-inputs.json) - PRODUCT_VERSION=$(jq -r .tests.downloadISO.version ./external-test-inputs.json) - export PRODUCT_SLUG PRODUCT_VERSION - ./download-vm.sh -} - -function TestDownloadOVA() { - echo "Download OVA test" - PRODUCT_SLUG=$(jq -r .tests.downloadOVA.slug ./external-test-inputs.json) - PRODUCT_VERSION=$(jq -r .tests.downloadOVA.version ./external-test-inputs.json) - export PRODUCT_SLUG PRODUCT_VERSION - ./download-vm.sh -} - -TestDownloadChart -TestDownloadContainerImage -TestDownloadISO -TestDownloadOVA \ No newline at end of file diff --git a/test/common_steps.go b/test/common_steps.go index 6f8a023..0b22c8f 100644 --- a/test/common_steps.go +++ b/test/common_steps.go @@ -54,8 +54,9 @@ func unsetEnvVars(envVars []string, varsToUnset []string) []string { func DefineCommonSteps(define Definitions) { var ( - envVars []string - unsetVars []string + envVars []string + unsetVars []string + downloadedFile string ) define.Given(`^targeting the (.*) environment$`, func(environment string) { @@ -92,4 +93,15 @@ func DefineCommonSteps(define Definitions) { value := gjson.Get(configOutput, keyPath) Expect(value.String()).To(Equal(expectedValue)) }) + + define.Then(`^(.*) is downloaded$`, func(filename string) { + downloadedFile = filename + _, err := os.Stat(filename) + Expect(err).ToNot(HaveOccurred()) + }, func() { + if downloadedFile != "" { + Expect(os.Remove(downloadedFile)).To(Succeed()) + downloadedFile = "" + } + }) } diff --git a/test/external/debugging_test.go b/test/external/debugging_test.go index af6f9fc..9e8581c 100644 --- a/test/external/debugging_test.go +++ b/test/external/debugging_test.go @@ -19,7 +19,7 @@ var _ = Describe("Debugging", func() { Scenario("Debugging enabled", func() { steps.Given("targeting the production environment") - steps.When("running mkpcli --debug product get --product vmware-tanzu-rabbitmq1") + steps.When("running mkpcli --debug product get --product nginx") steps.Then("the command exits without error") steps.And("the request is printed") }) @@ -27,16 +27,16 @@ var _ = Describe("Debugging", func() { Scenario("Debugging enabled with environment variable", func() { steps.Given("targeting the production environment") steps.And("the environment variable MKPCLI_DEBUG is set to true") - steps.When("running mkpcli product get --product vmware-tanzu-rabbitmq1") + steps.When("running mkpcli product get --product nginx") steps.Then("the command exits without error") steps.And("the request is printed") }) Scenario("Debugging enabled with request payloads", func() { steps.Given("targeting the production environment") - steps.When("running mkpcli --debug --debug-request-payloads download -p vmware-tanzu-rabbitmq1 -v 1.0.0 --accept-eula") + steps.When("running mkpcli --debug --debug-request-payloads download -p nginx -v 1.22.0_150_r04 --filename chart.tgz --accept-eula") steps.Then("the command exits without error") - steps.And("the container image is downloaded") + steps.And("chart.tgz is downloaded") steps.And("the requests are printed with request payloads") }) @@ -44,9 +44,9 @@ var _ = Describe("Debugging", func() { steps.Given("targeting the production environment") steps.And("the environment variable MKPCLI_DEBUG is set to true") steps.And("the environment variable MKPCLI_DEBUG_REQUEST_PAYLOADS is set to true") - steps.When("running mkpcli download -p vmware-tanzu-rabbitmq1 -v 1.0.0 --accept-eula") + steps.When("running mkpcli download -p nginx -v 1.22.0_150_r04 --filename chart.tgz --accept-eula") steps.Then("the command exits without error") - steps.And("the container image is downloaded") + steps.And("chart.tgz is downloaded") steps.And("the requests are printed with request payloads") }) @@ -54,12 +54,12 @@ var _ = Describe("Debugging", func() { DefineCommonSteps(define) define.Then(`^the request is printed$`, func() { - Eventually(CommandSession.Err).Should(Say(regexp.QuoteMeta("Request #0: GET https://gtw.marketplace.cloud.vmware.com/api/v1/products/vmware-tanzu-rabbitmq1?increaseViewCount=false&isSlug=true"))) + Eventually(CommandSession.Err).Should(Say(regexp.QuoteMeta("Request #0: GET https://gtw.marketplace.cloud.vmware.com/api/v1/products/nginx?increaseViewCount=false&isSlug=true"))) Eventually(CommandSession.Err).Should(Say("Request #0 Response: 200 OK")) - Eventually(CommandSession.Out).Should(Say("Name: VMware Tanzu RabbitMQ")) - Eventually(CommandSession.Out).Should(Say("Publisher: VMware Inc")) - Eventually(CommandSession.Out).Should(Say("Assets for 1.0.0:")) - Eventually(CommandSession.Out).Should(Say("registry.pivotal.io/rabbitmq/vmware-tanzu-rabbitmq:2020.12")) + Eventually(CommandSession.Out).Should(Say("Name: NGINX Open Source Helm Chart packaged by Bitnami")) + Eventually(CommandSession.Out).Should(Say("Publisher: Bitnami")) + Eventually(CommandSession.Out).Should(Say("Assets for 1.22.0_150_r04:")) + Eventually(CommandSession.Out).Should(Say("https://charts.bitnami.com/bitnami/nginx-12.0.4.tgz")) }) define.Then(`^the container image is downloaded$`, func() { @@ -68,16 +68,16 @@ var _ = Describe("Debugging", func() { }) define.Then(`^the requests are printed with request payloads$`, func() { - Eventually(CommandSession.Err).Should(Say(regexp.QuoteMeta("Request #0: GET https://gtw.marketplace.cloud.vmware.com/api/v1/products/vmware-tanzu-rabbitmq1?increaseViewCount=false&isSlug=true"))) + Eventually(CommandSession.Err).Should(Say(regexp.QuoteMeta("Request #0: GET https://gtw.marketplace.cloud.vmware.com/api/v1/products/nginx?increaseViewCount=false&isSlug=true"))) Eventually(CommandSession.Err).Should(Say("Request #0 Response: 200 OK")) - Eventually(CommandSession.Err).Should(Say(regexp.QuoteMeta("Request #1: POST https://gtw.marketplace.cloud.vmware.com/api/v1/products/5f99a9d5-dbfd-4cfc-a564-b1a67d092b4f/version-details?versionNumber=1.0.0"))) + Eventually(CommandSession.Err).Should(Say(regexp.QuoteMeta("Request #1: POST https://gtw.marketplace.cloud.vmware.com/api/v1/products/89431c5d-ddb7-45df-a544-2c81a370e17b/version-details?versionNumber=1.22.0_150_r04"))) Eventually(CommandSession.Err).Should(Say("Request #1 Response: 200 OK")) - Eventually(CommandSession.Err).Should(Say(regexp.QuoteMeta("Request #2: POST https://gtw.marketplace.cloud.vmware.com/api/v1/products/5f99a9d5-dbfd-4cfc-a564-b1a67d092b4f/download"))) + Eventually(CommandSession.Err).Should(Say(regexp.QuoteMeta("Request #2: POST https://gtw.marketplace.cloud.vmware.com/api/v1/products/89431c5d-ddb7-45df-a544-2c81a370e17b/download"))) Eventually(CommandSession.Err).Should(Say("--- Start of request #2 body payload ---")) - Eventually(CommandSession.Err).Should(Say(regexp.QuoteMeta("{\"productid\":\"5f99a9d5-dbfd-4cfc-a564-b1a67d092b4f\",\"appVersion\":\"1.0.0\",\"eulaAccepted\":true,\"dockerlinkVersionId\":\"d333021c-6e7d-4a15-b87a-2f66eda9d30c\",\"dockerUrlId\":\"f1702bcd-5634-4983-a652-653b6aedbe1d\",\"imageTagId\":\"83fa36ea-4ebc-4499-b68d-b95bc185dd65\"}"))) + Eventually(CommandSession.Err).Should(Say(regexp.QuoteMeta("{\"productid\":\"89431c5d-ddb7-45df-a544-2c81a370e17b\",\"appVersion\":\"1.22.0_150_r04\",\"eulaAccepted\":true,\"chartVersion\":\"12.0.4\"}"))) Eventually(CommandSession.Err).Should(Say("--- End of request #2 body payload ---")) Eventually(CommandSession.Err).Should(Say("Request #2 Response: 200 OK")) - Eventually(CommandSession.Err).Should(Say(regexp.QuoteMeta("Request #3: GET https://cmpprdcontainersolutions.s3.us-west-2.amazonaws.com/containerImageTars/"))) + Eventually(CommandSession.Err).Should(Say(regexp.QuoteMeta("Request #3: GET https://cmpprdhelmsolutions.s3.us-west-2.amazonaws.com/marketplace-product-files/89431c5d-ddb7-45df-a544-2c81a370e17b/"))) Eventually(CommandSession.Err).Should(Say("Request #3 Response: 200 OK")) }) }) diff --git a/test/external/download_test.go b/test/external/download_test.go index 7480118..38fa8ff 100644 --- a/test/external/download_test.go +++ b/test/external/download_test.go @@ -4,8 +4,6 @@ package external_test import ( - "os" - . "github.com/bunniesandbeatings/goerkin" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" @@ -38,13 +36,6 @@ var _ = Describe("Download", func() { steps.Define(func(define Definitions) { DefineCommonSteps(define) - define.Then(`^yq is downloaded$`, func() { - _, err := os.Stat("yq") - Expect(err).ToNot(HaveOccurred()) - }, func() { - _ = os.Remove("yq") - }) - define.Then(`^a message saying that there are multiple assets available to download$`, func() { Eventually(CommandSession.Err).Should(Say("product " + ProductSlug + " " + ProductVersion + " has multiple downloadable assets, please use the --filter parameter")) })