diff --git a/Makefile b/Makefile index 96e2f8c61..369d260f8 100644 --- a/Makefile +++ b/Makefile @@ -71,10 +71,6 @@ unit-test: sanity-test: blob go test -v -timeout=30m ./test/sanity -.PHONY: integration-test -integration-test: blob - go test -v -timeout=30m ./test/integration - .PHONY: e2e-test e2e-test: install-ginkgo if [ ! -z "$(EXTERNAL_E2E_TEST_BLOBFUSE)" ] || [ ! -z "$(EXTERNAL_E2E_TEST_BLOBFUSE_v2)" ] || [ ! -z "$(EXTERNAL_E2E_TEST_NFS)" ]; then \ diff --git a/test/integration/README.md b/test/integration/README.md deleted file mode 100644 index 5ec1db660..000000000 --- a/test/integration/README.md +++ /dev/null @@ -1,37 +0,0 @@ -## Integration Test -Integration test verifies the functionality of CSI driver as a standalone server outside Kubernetes. It exercises the lifecycle of the volume by creating, attaching, staging, mounting volumes and the reverse operations. - -## Run Integration Tests Locally -### Prerequisite - - Make sure `GOPATH` is set and [csc](https://github.com/rexray/gocsi/tree/master/csc) tool is installed under `$GOPATH/bin/csc` -``` -export set GOPATH=$HOME/go -go get github.com/rexray/gocsi/csc -cd $GOPATH/src/github.com/rexray/gocsi/csc -make build -export PATH=$PATH:$GOROOT/bin:$GOPATH/bin -``` - - - Set Azure credentials by environment variables - > You could get these variables from `/etc/kubernetes/azure.json` on a kubernetes cluster node -``` -# Required environment variables: -export set AZURE_TENANT_ID= -export set AZURE_SUBSCRIPTION_ID= -export set AZURE_CLIENT_ID= -export set AZURE_CLIENT_SECRET= - -# Optional environment variables: -# If the the test is not for the public Azure, e.g. Azure China Cloud, then you need to set AZURE_CLOUD_NAME and AZURE_LOCATION. -# For Azure Stack Clound, you need to set AZURE_ENVIRONMENT_FILEPATH for your cloud environment. -# If you have an existing resource group created for the test, then you need to set variable AZURE_RESOURCE_GROUP. -export set AZURE_CLOUD_NAME= -export set AZURE_LOCATION= -export set AZURE_ENVIRONMENT_FILEPATH= -export set AZURE_RESOURCE_GROUP= -``` - -### Run integration tests -``` -make test-integration -``` diff --git a/test/integration/integration_test.go b/test/integration/integration_test.go deleted file mode 100644 index c55d7989c..000000000 --- a/test/integration/integration_test.go +++ /dev/null @@ -1,82 +0,0 @@ -/* -Copyright 2019 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package integration - -import ( - "context" - "log" - "os" - "os/exec" - "strings" - "testing" - - "sigs.k8s.io/blob-csi-driver/test/utils/azure" - "sigs.k8s.io/blob-csi-driver/test/utils/credentials" - - "github.com/stretchr/testify/assert" -) - -func TestIntegration(t *testing.T) { - creds, err := credentials.CreateAzureCredentialFile() - defer func() { - err := credentials.DeleteAzureCredentialFile() - assert.NoError(t, err) - }() - assert.NoError(t, err) - assert.NotNil(t, creds) - - os.Setenv("AZURE_CREDENTIAL_FILE", credentials.TempAzureCredentialFilePath) - - azureClient, err := azure.GetClient(creds.Cloud, creds.SubscriptionID, creds.AADClientID, creds.TenantID, creds.AADClientSecret) - assert.NoError(t, err) - - ctx := context.Background() - // Create an empty resource group for integration test - log.Printf("Creating resource group %s in %s", creds.ResourceGroup, creds.Cloud) - _, err = azureClient.EnsureResourceGroup(ctx, creds.ResourceGroup, creds.Location, nil) - assert.NoError(t, err) - defer func() { - // Only delete resource group the test created - if strings.HasPrefix(creds.ResourceGroup, credentials.ResourceGroupPrefix) { - log.Printf("Deleting resource group %s", creds.ResourceGroup) - err := azureClient.DeleteResourceGroup(ctx, creds.ResourceGroup) - assert.NoError(t, err) - } - }() - - // Execute the script from project root - err = os.Chdir("../..") - assert.NoError(t, err) - // Change directory back to test/integration in preparation for next test - defer func() { - err := os.Chdir("test/integration") - assert.NoError(t, err) - }() - - cwd, err := os.Getwd() - assert.NoError(t, err) - assert.True(t, strings.HasSuffix(cwd, "blob-csi-driver")) - - // Pass in resource group name, storage account name and cloud type - cmd := exec.Command("./test/integration/run-tests-all-clouds.sh", creds.ResourceGroup, creds.Cloud) - cmd.Dir = cwd - cmd.Stdout = os.Stdout - cmd.Stderr = os.Stderr - if err := cmd.Run(); err != nil { - t.Fatalf("Integration test failed %v", err) - } -} diff --git a/test/integration/run-test.sh b/test/integration/run-test.sh deleted file mode 100755 index 76ec62517..000000000 --- a/test/integration/run-test.sh +++ /dev/null @@ -1,100 +0,0 @@ -#!/bin/bash - -# Copyright 2019 The Kubernetes Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -set -euo pipefail - -function cleanup { - echo "pkill -f blobplugin" - pkill -f blobplugin -} - -t=$(date +%s) -readonly volname="citest-$t" -readonly volsize="2147483648" -readonly expanded_vol_size="2147483650" -readonly endpoint="$1" -readonly staging_target_path="$2" -readonly target_path="$3" -readonly resource_group="$4" -readonly cloud="$5" - -echo "Begin to run integration test on $cloud..." - -# Run CSI driver as a background service -_output/amd64/blobplugin --endpoint "$endpoint" --nodeid CSINode --enable-blob-mock-mount -v=5 & -trap cleanup EXIT - -if [[ "$cloud" == "AzureChinaCloud" ]]; then - sleep 25 -else - sleep 5 -fi - -# Begin to run CSI functions one by one -echo "Create volume test:" -value="$(csc controller new --endpoint "$endpoint" --cap MULTI_NODE_MULTI_WRITER,mount,xfs "$volname" --req-bytes "$volsize" --params skuname=Standard_LRS)" -sleep 15 - -volumeid="$(echo "$value" | awk '{print $1}' | sed 's/"//g')" -echo "Got volume id: $volumeid" -storage_account_name="$(echo "$volumeid" | awk -F# '{print $2}')" - -csc controller validate-volume-capabilities --endpoint "$endpoint" --cap MULTI_NODE_MULTI_WRITER,mount,xfs "$volumeid" - -if [[ "$cloud" != "AzureChinaCloud" ]]; then - echo "stage volume test:" - csc node stage --endpoint "$endpoint" --cap MULTI_NODE_MULTI_WRITER,mount,xfs --staging-target-path "$staging_target_path" "$volumeid" - - echo "publish volume test:" - csc node publish --endpoint "$endpoint" --cap MULTI_NODE_MULTI_WRITER,mount,xfs --staging-target-path "$staging_target_path" --target-path "$target_path" "$volumeid" - sleep 2 - - echo "node stats test:" - csc node stats --endpoint "$endpoint" "$volumeid:$target_path:$staging_target_path" - sleep 2 - - echo 'expand volume test' - csc controller expand-volume --endpoint "$endpoint" --req-bytes "$expanded_vol_size" "$volumeid" - - echo "unpublish volume test:" - csc node unpublish --endpoint "$endpoint" --target-path "$target_path" "$volumeid" - sleep 2 - - echo "unstage volume test:" - csc node unstage --endpoint "$endpoint" --staging-target-path "$staging_target_path" "$volumeid" - sleep 2 -fi - -echo "Delete volume test:" -csc controller del --endpoint "$endpoint" "$volumeid" -sleep 15 - -echo "Create volume in storage account($storage_account_name) under resource group($resource_group):" -value="$(csc controller new --endpoint "$endpoint" --cap MULTI_NODE_MULTI_WRITER,mount,xfs "$volname" --req-bytes "$volsize" --params skuname=Standard_LRS,storageAccount=$storage_account_name,resourceGroup=$resource_group)" -sleep 15 - -volumeid="$(echo "$value" | awk '{print $1}' | sed 's/"//g')" -echo "got volume id: $volumeid" - -echo "Delete volume test:" -csc controller del --endpoint "$endpoint" "$volumeid" -sleep 15 - -csc identity plugin-info --endpoint "$endpoint" -csc node get-info --endpoint "$endpoint" - -echo "Integration test on $cloud is completed." diff --git a/test/integration/run-tests-all-clouds.sh b/test/integration/run-tests-all-clouds.sh deleted file mode 100755 index 18d9fb5d4..000000000 --- a/test/integration/run-tests-all-clouds.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/bash - -# Copyright 2019 The Kubernetes Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set -eo pipefail - -GO111MODULE=off go get github.com/rexray/gocsi/csc - -function install_blobfuse_bin { - echo 'Installing blobfuse...' - apt-get update && apt install ca-certificates pkg-config libfuse-dev cmake libcurl4-gnutls-dev libgnutls28-dev uuid-dev libgcrypt20-dev wget -y - wget https://packages.microsoft.com/config/ubuntu/16.04/packages-microsoft-prod.deb - dpkg -i packages-microsoft-prod.deb - apt-get update && apt install blobfuse fuse -y - rm -f packages-microsoft-prod.deb -} - -readonly resource_group="$1" -readonly cloud="$2" - -# copy blobfuse binary -if [[ "$cloud" == "AzureStackCloud" ]]; then - install_blobfuse_bin -else - mkdir -p /usr/blob - cp test/artifacts/blobfuse /usr/bin/blobfuse -fi - -apt update && apt install libfuse2 -y -test/integration/run-test.sh "tcp://127.0.0.1:10000" "/tmp/stagingtargetpath" "/tmp/targetpath" "$resource_group" "$cloud"