From 5665144ec4e12644633c45ccc61054e996d7fdb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Serdar=20=C3=96zer?= Date: Mon, 17 Nov 2025 15:59:43 +0100 Subject: [PATCH 01/10] feat: workflow for azurebs created. - scripts to setup, run and teardown created. - only runs against one environment. add others once get the credentials etc. --- .github/scripts/azurebs/run-int.sh | 26 ++++++++++++++ .github/scripts/azurebs/setup.sh | 21 +++++++++++ .github/scripts/azurebs/teardown.sh | 21 +++++++++++ .github/scripts/azurebs/utils.sh | 44 +++++++++++++++++++++++ .github/workflows/azurebs-integration.yml | 36 +++++++++++++++++++ 5 files changed, 148 insertions(+) create mode 100755 .github/scripts/azurebs/run-int.sh create mode 100755 .github/scripts/azurebs/setup.sh create mode 100755 .github/scripts/azurebs/teardown.sh create mode 100755 .github/scripts/azurebs/utils.sh create mode 100644 .github/workflows/azurebs-integration.yml diff --git a/.github/scripts/azurebs/run-int.sh b/.github/scripts/azurebs/run-int.sh new file mode 100755 index 0000000..7d6bb1e --- /dev/null +++ b/.github/scripts/azurebs/run-int.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash +set -euo pipefail + +script_dir="$( cd "$(dirname "${0}")" && pwd )" +repo_root="$(cd "${script_dir}/../../.." && pwd)" + +: "${azure_storage_account:?}" +: "${azure_storage_key:?}" +: "${environment:=AzureCloud}" + +export ACCOUNT_NAME="${azure_storage_account}" +export ACCOUNT_KEY="${azure_storage_key}" +export ENVIRONMENT="${environment}" + +pushd "${script_dir}" > /dev/null + source utils.sh + container_name="$(read_container_name_from_file "${environment}")" + : "${container_name:?}" + export CONTAINER_NAME="${container_name}" +popd > /dev/null + +pushd "${repo_root}" > /dev/null + echo -e "\n running tests with $(go version)..." + ginkgo -r azurebs/integration/ +popd > /dev/null + diff --git a/.github/scripts/azurebs/setup.sh b/.github/scripts/azurebs/setup.sh new file mode 100755 index 0000000..1130763 --- /dev/null +++ b/.github/scripts/azurebs/setup.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash +set -euo pipefail + +script_dir="$( cd "$(dirname "${0}")" && pwd )" +repo_root="$(cd "${script_dir}/../../.." && pwd)" + + +: "${azure_storage_account:?}" +: "${azure_storage_key:?}" +: "${environment:=AzureCloud}" + +export AZURE_STORAGE_ACCOUNT="${azure_storage_account}" +export AZURE_STORAGE_KEY="${azure_storage_key}" + + + +pushd "${script_dir}" + source utils.sh + generate_container_name "${environment}" + create_container "${environment}" +popd diff --git a/.github/scripts/azurebs/teardown.sh b/.github/scripts/azurebs/teardown.sh new file mode 100755 index 0000000..e75d56e --- /dev/null +++ b/.github/scripts/azurebs/teardown.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash +set -euo pipefail + +script_dir="$( cd "$(dirname "${0}")" && pwd )" +repo_root="$(cd "${script_dir}/../../.." && pwd)" + + +: "${azure_storage_account:?}" +: "${azure_storage_key:?}" +: "${environment:=AzureCloud}" + +export AZURE_STORAGE_ACCOUNT="${azure_storage_account}" +export AZURE_STORAGE_KEY="${azure_storage_key}" + + + +pushd "${script_dir}" + source utils.sh + delete_container "${environment}" + delete_container_name_file "${environment}" +popd diff --git a/.github/scripts/azurebs/utils.sh b/.github/scripts/azurebs/utils.sh new file mode 100755 index 0000000..ec7a0e6 --- /dev/null +++ b/.github/scripts/azurebs/utils.sh @@ -0,0 +1,44 @@ +TMP_DIR="/tmp/storage-cli-azurebs-${GITHUB_RUN_ID:-${USER}}" + +# generate a random container name with "azurebs-" prefix +function random_name { + echo "azurebs-$(openssl rand -hex 20)" +} + + +# create a file with .lock suffix and store the container name inside it +function generate_container_name { + local file_name="${1}.lock" + local container_name="$(random_name)" + mkdir -p "${TMP_DIR}" + echo "${container_name}" > "${TMP_DIR}/${file_name}" +} + + +# retrieve the container name from the .lock file +function read_container_name_from_file { + local file_name="$1" + cat "${TMP_DIR}/${file_name}.lock" +} + +# delete the .lock file +function delete_container_name_file { + local file_name="$1" + rm -f "${TMP_DIR}/${file_name}.lock" +} + + +function create_container { + local container_name="$(read_container_name_from_file "$1")" + + az storage container create --account-name "${AZURE_STORAGE_ACCOUNT}" --account-key "${AZURE_STORAGE_KEY}" --name "${container_name}" + +} + + +function delete_container { + local container_name="$(read_container_name_from_file "$1")" + + az storage container delete --account-name "${AZURE_STORAGE_ACCOUNT}" --account-key "${AZURE_STORAGE_KEY}" --name "${container_name}" + +} \ No newline at end of file diff --git a/.github/workflows/azurebs-integration.yml b/.github/workflows/azurebs-integration.yml new file mode 100644 index 0000000..6484d26 --- /dev/null +++ b/.github/workflows/azurebs-integration.yml @@ -0,0 +1,36 @@ + +on: + pull_request: + push: + +jobs: + azurecloud-environment-integration-tests: + name: AzureCloud Environment Integration Tests + runs-on: ubuntu-latest + environment: azurebs-integration + steps: + - name: Checkout code + uses: actions/checkout@v5 + - name: Set up Go + uses: actions/setup-go@v6 + with: + go-version-file: go.mod + - name: Install Ginkgo + run: go install github.com/onsi/ginkgo/v2/ginkgo@latest + - name: Setup Azurebs Test Environment + run: | + export azure_storage_account="${{ secrets.AZURE_STORAGE_ACCOUNT }}" + export azure_storage_key="${{ secrets.AZURE_STORAGE_KEY }}" + ./.github/scripts/azurebs/setup.sh + - name: Run Tests + run: | + export azure_storage_account="${{ secrets.AZURE_STORAGE_ACCOUNT }}" + export azure_storage_key="${{ secrets.AZURE_STORAGE_KEY }}" + ./.github/scripts/azurebs/run-int.sh + - name: Teardown Azurebs Test Environment + if: always() + run: | + export azure_storage_account="${{ secrets.AZURE_STORAGE_ACCOUNT }}" + export azure_storage_key="${{ secrets.AZURE_STORAGE_KEY }}" + ./.github/scripts/azurebs/teardown.sh + \ No newline at end of file From 3709aecc92de714583d08d891a1c8b575963fa89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Serdar=20=C3=96zer?= Date: Mon, 17 Nov 2025 16:16:49 +0100 Subject: [PATCH 02/10] fix: possible fix for timeout error - in worfklow uploading is not failing, might be too fast, so size increased to 2.5 gb --- azurebs/integration/assertions.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azurebs/integration/assertions.go b/azurebs/integration/assertions.go index 5baba9e..fc3fd3e 100644 --- a/azurebs/integration/assertions.go +++ b/azurebs/integration/assertions.go @@ -57,7 +57,7 @@ func AssertPutTimesOut(cliPath string, cfg *config.AZStorageConfig) { defer os.Remove(configPath) //nolint:errcheck const mb = 1024 * 1024 - big := bytes.Repeat([]byte("x"), 25*mb) + big := bytes.Repeat([]byte("x"), 2500*mb) content := MakeContentFile(string(big)) defer os.Remove(content) //nolint:errcheck blob := GenerateRandomString() From 0af4301db5644d51288bedd40e275c6cd34b7cd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Serdar=20=C3=96zer?= Date: Mon, 17 Nov 2025 16:48:10 +0100 Subject: [PATCH 03/10] docs: readme updated --- azurebs/README.md | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/azurebs/README.md b/azurebs/README.md index 4b94514..79d07fb 100644 --- a/azurebs/README.md +++ b/azurebs/README.md @@ -57,27 +57,21 @@ Using ginkgo: ``` bash go install github.com/onsi/ginkgo/v2/ginkgo -ginkgo --skip-package=integration --randomize-all --cover -v -r +ginkgo --skip-package=integration --randomize-all --cover -v -r ./azurebs/... ``` Using go test: ``` bash -go test $(go list ./... | grep -v integration) +go test $(go list ./azurebs/... | grep -v integration) ``` ### Integration tests - -1. Export the following variables into your environment: - - ``` bash - export ACCOUNT_NAME= - export ACCOUNT_KEY= - export CONTAINER_NAME= - ``` - -2. Run integration tests - - ```bash - go test ./integration/... - ``` +1. Create a storage account in your azure subscription. +1. Get `account name` and `access key` from you storage account. +1. Export `account name` with command `export azure_storage_account=`. +1. Export `access key` with command `export azure_storage_key=`. +1. Navigate to project's root folder. +1. Run environment setup script to create container `/.github/scripts/azurebs/setup.sh`. +1. Run tests `/.github/scripts/azurebs/run-int.sh`. +1. Run environment teardown script to delete test resources `/.github/scripts/azurebs/teardown.sh`. From 04c34856f559707f2a000ff3cc053db5640c3d0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Serdar=20=C3=96zer?= Date: Tue, 18 Nov 2025 08:23:46 +0100 Subject: [PATCH 04/10] fix: size of bytes decreased --- azurebs/integration/assertions.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azurebs/integration/assertions.go b/azurebs/integration/assertions.go index fc3fd3e..7fb90bb 100644 --- a/azurebs/integration/assertions.go +++ b/azurebs/integration/assertions.go @@ -57,7 +57,7 @@ func AssertPutTimesOut(cliPath string, cfg *config.AZStorageConfig) { defer os.Remove(configPath) //nolint:errcheck const mb = 1024 * 1024 - big := bytes.Repeat([]byte("x"), 2500*mb) + big := bytes.Repeat([]byte("x"), 250*mb) content := MakeContentFile(string(big)) defer os.Remove(content) //nolint:errcheck blob := GenerateRandomString() From 8afc6b05d3ff5024a22a948b3e6da598ffc8e658 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Serdar=20=C3=96zer?= Date: Tue, 18 Nov 2025 08:37:56 +0100 Subject: [PATCH 05/10] feat: paths are added for pr --- .github/workflows/azurebs-integration.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/azurebs-integration.yml b/.github/workflows/azurebs-integration.yml index 6484d26..49c8461 100644 --- a/.github/workflows/azurebs-integration.yml +++ b/.github/workflows/azurebs-integration.yml @@ -1,7 +1,9 @@ on: pull_request: - push: + paths: + - ".github/workflows/azurebs-integration.yml" + - "azurebs/**" jobs: azurecloud-environment-integration-tests: From d083098bddfaccaa38510c0326826e89e0b28644 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Serdar=20=C3=96zer?= Date: Tue, 18 Nov 2025 08:57:17 +0100 Subject: [PATCH 06/10] fix: shebang added for utils.sh --- .github/scripts/azurebs/utils.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/scripts/azurebs/utils.sh b/.github/scripts/azurebs/utils.sh index ec7a0e6..f7823c8 100755 --- a/.github/scripts/azurebs/utils.sh +++ b/.github/scripts/azurebs/utils.sh @@ -1,3 +1,5 @@ +#!/usr/bin/env bash + TMP_DIR="/tmp/storage-cli-azurebs-${GITHUB_RUN_ID:-${USER}}" # generate a random container name with "azurebs-" prefix From 4c4d47078aefdfb223641a8bc6a0f42af102fed7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Serdar=20=C3=96zer?= Date: Tue, 18 Nov 2025 13:13:27 +0100 Subject: [PATCH 07/10] fix: missing name in worfklow added. Readme updated --- .github/workflows/azurebs-integration.yml | 1 + azurebs/README.md | 67 ++++++++++++++--------- 2 files changed, 41 insertions(+), 27 deletions(-) diff --git a/.github/workflows/azurebs-integration.yml b/.github/workflows/azurebs-integration.yml index 49c8461..91c7fe6 100644 --- a/.github/workflows/azurebs-integration.yml +++ b/.github/workflows/azurebs-integration.yml @@ -1,3 +1,4 @@ +name: Azurebs Integration Tests on: pull_request: diff --git a/azurebs/README.md b/azurebs/README.md index 79d07fb..e6db981 100644 --- a/azurebs/README.md +++ b/azurebs/README.md @@ -1,7 +1,7 @@ # Azure Storage CLI The Azure Storage CLI is for uploading, fetching and deleting content to and from an Azure blobstore. -It is highly inspired by the https://github.com/cloudfoundry/bosh-s3cli. +It is highly inspired by the [storage-cli/s3](https://github.com/cloudfoundry/storage-cli/blob/6058f516e9b81471b64a50b01e228158a05731f0/s3) ## Usage @@ -49,29 +49,42 @@ curl -X PUT -H "x-ms-blob-type: blockblob" -F 'fileX=' ``` -## Running tests - -### Unit tests - -Using ginkgo: - -``` bash -go install github.com/onsi/ginkgo/v2/ginkgo -ginkgo --skip-package=integration --randomize-all --cover -v -r ./azurebs/... -``` - -Using go test: - -``` bash -go test $(go list ./azurebs/... | grep -v integration) -``` - -### Integration tests -1. Create a storage account in your azure subscription. -1. Get `account name` and `access key` from you storage account. -1. Export `account name` with command `export azure_storage_account=`. -1. Export `access key` with command `export azure_storage_key=`. -1. Navigate to project's root folder. -1. Run environment setup script to create container `/.github/scripts/azurebs/setup.sh`. -1. Run tests `/.github/scripts/azurebs/run-int.sh`. -1. Run environment teardown script to delete test resources `/.github/scripts/azurebs/teardown.sh`. +## Running Tests + +### Unit Tests + +- Using ginkgo: + + ``` bash + go install github.com/onsi/ginkgo/v2/ginkgo + ginkgo --skip-package=integration --randomize-all --cover -v -r ./azurebs/... + ``` + +- Using go test: + + ``` bash + go test $(go list ./azurebs/... | grep -v integration) + ``` + +### Integration Tests +- To run the integration tests with your existing container + 1. Export the following variables into your environment. + ```bash + export ACCOUNT_NAME= + export ACCOUNT_KEY= + export CONTAINER_NAME= + ``` + 1. Run the command + ```bash + go test ./azurebs/integration/... + ``` + +- To run it from scratch; create a new container, run tests, delete the container + 1. Create a storage account in your azure subscription. + 1. Get `account name` and `access key` from you storage account. + 1. Export `account name` with command `export azure_storage_account=`. + 1. Export `access key` with command `export azure_storage_key=`. + 1. Navigate to project's root folder. + 1. Run environment setup script to create container `/.github/scripts/azurebs/setup.sh`. + 1. Run tests `/.github/scripts/azurebs/run-int.sh`. + 1. Run environment teardown script to delete test resources `/.github/scripts/azurebs/teardown.sh`. From 9f29ef8b3038c0a3c5c61c0a9d1b66b1cd3434f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Serdar=20=C3=96zer?= Date: Thu, 20 Nov 2025 09:17:31 +0100 Subject: [PATCH 08/10] fix: environment tag in workflow is removed --- .github/workflows/azurebs-integration.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/azurebs-integration.yml b/.github/workflows/azurebs-integration.yml index 91c7fe6..49dd56b 100644 --- a/.github/workflows/azurebs-integration.yml +++ b/.github/workflows/azurebs-integration.yml @@ -10,7 +10,6 @@ jobs: azurecloud-environment-integration-tests: name: AzureCloud Environment Integration Tests runs-on: ubuntu-latest - environment: azurebs-integration steps: - name: Checkout code uses: actions/checkout@v5 From 4d19caa8bc3c2f4d77c71da5befee44f6f454e9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Serdar=20=C3=96zer?= Date: Fri, 21 Nov 2025 10:25:46 +0100 Subject: [PATCH 09/10] docs: run path clarified --- azurebs/README.md | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/azurebs/README.md b/azurebs/README.md index e6db981..7977ba0 100644 --- a/azurebs/README.md +++ b/azurebs/README.md @@ -52,11 +52,13 @@ curl -X GET ## Running Tests ### Unit Tests +**Note:** Run the following commands from the repository root directory - Using ginkgo: ``` bash go install github.com/onsi/ginkgo/v2/ginkgo + ginkgo --skip-package=integration --randomize-all --cover -v -r ./azurebs/... ``` @@ -69,15 +71,18 @@ curl -X GET ### Integration Tests - To run the integration tests with your existing container 1. Export the following variables into your environment. - ```bash - export ACCOUNT_NAME= - export ACCOUNT_KEY= - export CONTAINER_NAME= - ``` - 1. Run the command - ```bash - go test ./azurebs/integration/... - ``` + + ```bash + export ACCOUNT_NAME= + export ACCOUNT_KEY= + export CONTAINER_NAME= + ``` + + 1. Navigate to project's root folder and run the command below: + + ```bash + go test ./azurebs/integration/... + ``` - To run it from scratch; create a new container, run tests, delete the container 1. Create a storage account in your azure subscription. @@ -85,6 +90,6 @@ curl -X GET 1. Export `account name` with command `export azure_storage_account=`. 1. Export `access key` with command `export azure_storage_key=`. 1. Navigate to project's root folder. - 1. Run environment setup script to create container `/.github/scripts/azurebs/setup.sh`. - 1. Run tests `/.github/scripts/azurebs/run-int.sh`. - 1. Run environment teardown script to delete test resources `/.github/scripts/azurebs/teardown.sh`. + 1. Run environment setup script to create container `./.github/scripts/azurebs/setup.sh`. + 1. Run tests `./.github/scripts/azurebs/run-int.sh`. + 1. Run environment teardown script to delete test resources `./.github/scripts/azurebs/teardown.sh`. From 7c28122aedf7ed9bc5e69fe3040799a16aa74cf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Serdar=20=C3=96zer?= Date: Fri, 21 Nov 2025 13:36:43 +0100 Subject: [PATCH 10/10] feat: push main and manual trigger are added --- .github/workflows/azurebs-integration.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/azurebs-integration.yml b/.github/workflows/azurebs-integration.yml index 49dd56b..eb77473 100644 --- a/.github/workflows/azurebs-integration.yml +++ b/.github/workflows/azurebs-integration.yml @@ -1,10 +1,14 @@ name: Azurebs Integration Tests on: + workflow_dispatch: pull_request: paths: - ".github/workflows/azurebs-integration.yml" - "azurebs/**" + push: + branches: + - main jobs: azurecloud-environment-integration-tests: