From 0122e7ff1ab70d8805e208c06ab6a9e2bf92f403 Mon Sep 17 00:00:00 2001 From: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com> Date: Tue, 31 Oct 2023 16:43:25 +0000 Subject: [PATCH] Update cert tests for v2 Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com> --- .../azure/blobstorage/blobstorage_test.go | 39 +++++++++++++++---- .../components/basictest-v1/azureblob.yaml | 22 +++++++++++ .../localsecrets.yaml | 0 .../azureblob.yaml | 0 .../components/basictest-v2/localsecrets.yaml | 9 +++++ 5 files changed, 62 insertions(+), 8 deletions(-) create mode 100644 tests/certification/state/azure/blobstorage/components/basictest-v1/azureblob.yaml rename tests/certification/state/azure/blobstorage/components/{basictest => basictest-v1}/localsecrets.yaml (100%) rename tests/certification/state/azure/blobstorage/components/{basictest => basictest-v2}/azureblob.yaml (100%) create mode 100644 tests/certification/state/azure/blobstorage/components/basictest-v2/localsecrets.yaml diff --git a/tests/certification/state/azure/blobstorage/blobstorage_test.go b/tests/certification/state/azure/blobstorage/blobstorage_test.go index 1a0f93bf58..2b3cc72b96 100644 --- a/tests/certification/state/azure/blobstorage/blobstorage_test.go +++ b/tests/certification/state/azure/blobstorage/blobstorage_test.go @@ -20,9 +20,11 @@ import ( "strconv" "testing" - blob "github.com/dapr/components-contrib/state/azure/blobstorage" + component_v1 "github.com/dapr/components-contrib/state/azure/blobstorage/v1" + component_v2 "github.com/dapr/components-contrib/state/azure/blobstorage/v2" "github.com/dapr/components-contrib/tests/certification/embedded" "github.com/dapr/components-contrib/tests/certification/flow" + "github.com/dapr/dapr/pkg/components" "github.com/dapr/go-sdk/client" "github.com/dapr/kit/logger" @@ -78,14 +80,27 @@ func TestAzureBlobStorage(t *testing.T) { return nil } - flow.New(t, "Test basic operations, save/get/delete using existing container"). + flow.New(t, "v1 - Test basic operations, save/get/delete using existing container"). // Run the Dapr sidecar with azure blob storage. Step(sidecar.Run(sidecarNamePrefix, append(componentRuntimeOptions(), embedded.WithoutApp(), embedded.WithDaprGRPCPort(strconv.Itoa(currentGrpcPort)), embedded.WithDaprHTTPPort(strconv.Itoa(currentHTTPPort)), - embedded.WithComponentsPath("./components/basictest"), + embedded.WithResourcesPath("./components/basictest-v1"), + )..., + )). + Step("Run basic test with existing container", basicTest("statestore-basic")). + Run() + + flow.New(t, "v2 - Test basic operations, save/get/delete using existing container"). + // Run the Dapr sidecar with azure blob storage. + Step(sidecar.Run(sidecarNamePrefix, + append(componentRuntimeOptions(), + embedded.WithoutApp(), + embedded.WithDaprGRPCPort(strconv.Itoa(currentGrpcPort)), + embedded.WithDaprHTTPPort(strconv.Itoa(currentHTTPPort)), + embedded.WithResourcesPath("./components/basictest-v2"), )..., )). Step("Run basic test with existing container", basicTest("statestore-basic")). @@ -98,11 +113,11 @@ func TestAzureBlobStorage(t *testing.T) { embedded.WithoutApp(), embedded.WithDaprGRPCPort(strconv.Itoa(currentGrpcPort)), embedded.WithDaprHTTPPort(strconv.Itoa(currentHTTPPort)), - embedded.WithComponentsPath("./components/nonexistingcontainertest"), + embedded.WithResourcesPath("./components/nonexistingcontainertest"), )..., )). - Step("Run basic test with new table", basicTest("statestore-newcontainer")). - Step("Delete the New Table", deleteContainer). + Step("Run basic test with new container", basicTest("statestore-newcontainer")). + Step("Delete the new container", deleteContainer). Run() flow.New(t, "Test for authentication using Azure Auth layer"). @@ -112,7 +127,7 @@ func TestAzureBlobStorage(t *testing.T) { embedded.WithoutApp(), embedded.WithDaprGRPCPort(strconv.Itoa(currentGrpcPort)), embedded.WithDaprHTTPPort(strconv.Itoa(currentHTTPPort)), - embedded.WithComponentsPath("./components/aadtest"), + embedded.WithResourcesPath("./components/aadtest"), )..., )). Step("Run AAD test", basicTest("statestore-aad")). @@ -124,7 +139,15 @@ func componentRuntimeOptions() []embedded.Option { stateRegistry := state_loader.NewRegistry() stateRegistry.Logger = log - stateRegistry.RegisterComponent(blob.NewAzureBlobStorageStore, "azure.blobstorage") + stateRegistry.RegisterComponentWithVersions("azure.blobstorage", components.Versioning{ + Preferred: components.VersionConstructor{ + Version: "v2", Constructor: component_v1.NewAzureBlobStorageStore, + }, + Deprecated: []components.VersionConstructor{ + {Version: "v1", Constructor: component_v2.NewAzureBlobStorageStore}, + }, + Default: "v1", + }) secretstoreRegistry := secretstores_loader.NewRegistry() secretstoreRegistry.Logger = log diff --git a/tests/certification/state/azure/blobstorage/components/basictest-v1/azureblob.yaml b/tests/certification/state/azure/blobstorage/components/basictest-v1/azureblob.yaml new file mode 100644 index 0000000000..ff77661c3c --- /dev/null +++ b/tests/certification/state/azure/blobstorage/components/basictest-v1/azureblob.yaml @@ -0,0 +1,22 @@ +apiVersion: dapr.io/v1alpha1 +kind: Component +metadata: + name: statestore-basic +spec: + type: state.azure.blobstorage + version: v1 + metadata: + - name: accountName + secretKeyRef: + name: AzureBlobStorageAccount + key: AzureBlobStorageAccount + - name: accountKey + secretKeyRef: + name: AzureBlobStorageAccessKey + key: AzureBlobStorageAccessKey + - name: containerName + secretKeyRef: + name: AzureBlobStorageContainer + key: AzureBlobStorageContainer +auth: + secretstore: envvar-secret-store \ No newline at end of file diff --git a/tests/certification/state/azure/blobstorage/components/basictest/localsecrets.yaml b/tests/certification/state/azure/blobstorage/components/basictest-v1/localsecrets.yaml similarity index 100% rename from tests/certification/state/azure/blobstorage/components/basictest/localsecrets.yaml rename to tests/certification/state/azure/blobstorage/components/basictest-v1/localsecrets.yaml diff --git a/tests/certification/state/azure/blobstorage/components/basictest/azureblob.yaml b/tests/certification/state/azure/blobstorage/components/basictest-v2/azureblob.yaml similarity index 100% rename from tests/certification/state/azure/blobstorage/components/basictest/azureblob.yaml rename to tests/certification/state/azure/blobstorage/components/basictest-v2/azureblob.yaml diff --git a/tests/certification/state/azure/blobstorage/components/basictest-v2/localsecrets.yaml b/tests/certification/state/azure/blobstorage/components/basictest-v2/localsecrets.yaml new file mode 100644 index 0000000000..94bb7a2643 --- /dev/null +++ b/tests/certification/state/azure/blobstorage/components/basictest-v2/localsecrets.yaml @@ -0,0 +1,9 @@ +apiVersion: dapr.io/v1alpha1 +kind: Component +metadata: + name: envvar-secret-store + namespace: default +spec: + type: secretstores.local.env + version: v1 + metadata: