From a84ab2d0f6ed042a3abd679071a9877768e3715f Mon Sep 17 00:00:00 2001 From: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com> Date: Mon, 23 Jan 2023 17:39:40 +0000 Subject: [PATCH] Some fixes Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com> --- internal/component/azure/eventhubs/metadata.go | 4 ++-- .../components/binding/consumer1/eventhubs.yaml | 2 -- tests/config/bindings/tests.yml | 2 ++ tests/conformance/bindings/bindings.go | 13 ++++++++----- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/internal/component/azure/eventhubs/metadata.go b/internal/component/azure/eventhubs/metadata.go index aa56df0b5..03dece0a1 100644 --- a/internal/component/azure/eventhubs/metadata.go +++ b/internal/component/azure/eventhubs/metadata.go @@ -78,7 +78,7 @@ func parseEventHubsMetadata(meta map[string]string, isBinding bool, log logger.L if isBinding { if m.ConnectionString == "" { if m.EventHub == "" { - return nil, errors.New("property eventHub is required when connecting with a connection string") + return nil, errors.New("property 'eventHub' is required when connecting with Azure AD") } m.hubName = m.EventHub } else { @@ -88,7 +88,7 @@ func parseEventHubsMetadata(meta map[string]string, isBinding bool, log logger.L } else if m.EventHub != "" { m.hubName = m.EventHub } else { - return nil, errors.New("the provided connection string does not contain a value for 'EntityPath' and no eventHub property was passed") + return nil, errors.New("the provided connection string does not contain a value for 'EntityPath' and no 'eventHub' property was passed") } } diff --git a/tests/certification/bindings/azure/eventhubs/components/binding/consumer1/eventhubs.yaml b/tests/certification/bindings/azure/eventhubs/components/binding/consumer1/eventhubs.yaml index 490d4e92b..53b3016ae 100644 --- a/tests/certification/bindings/azure/eventhubs/components/binding/consumer1/eventhubs.yaml +++ b/tests/certification/bindings/azure/eventhubs/components/binding/consumer1/eventhubs.yaml @@ -27,7 +27,5 @@ spec: secretKeyRef: name: AzureEventHubsBindingsContainer value: AzureEventHubsBindingsContainer - - name: partitionID - value: 0 auth: secretStore: envvar-secret-store \ No newline at end of file diff --git a/tests/config/bindings/tests.yml b/tests/config/bindings/tests.yml index 40791c92d..1163ddd35 100644 --- a/tests/config/bindings/tests.yml +++ b/tests/config/bindings/tests.yml @@ -29,6 +29,8 @@ components: outputData: '{"id": "$((uuid))", "orderid": "abcdef-test", "partitionKey": "partitionValue", "nestedproperty": {"subproperty": "something of value for testing"}, "description": "conformance test item"}' - component: azure.eventhubs operations: ["create", "operations", "read"] + config: + readBindingWait: 15s - component: azure.eventgrid operations: ["create", "operations", "read"] config: diff --git a/tests/conformance/bindings/bindings.go b/tests/conformance/bindings/bindings.go index 0c875d39e..f8c0e1373 100644 --- a/tests/conformance/bindings/bindings.go +++ b/tests/conformance/bindings/bindings.go @@ -19,6 +19,7 @@ import ( "io" "strconv" "strings" + "sync/atomic" "testing" "time" @@ -189,16 +190,17 @@ func ConformanceTests(t *testing.T, props map[string]string, inputBinding bindin }) } - inputBindingCall := 0 - readChan := make(chan int) + inputBindingCall := atomic.Int32{} + readChan := make(chan int, 1) readCtx, readCancel := context.WithCancel(context.Background()) defer readCancel() if config.HasOperation("read") { t.Run("read", func(t *testing.T) { testLogger.Info("Read test running ...") err := inputBinding.Read(readCtx, func(ctx context.Context, r *bindings.ReadResponse) ([]byte, error) { - inputBindingCall++ - readChan <- inputBindingCall + t.Logf("Read message: %s", string(r.Data)) + v := inputBindingCall.Add(1) + readChan <- int(v) return nil, nil }) @@ -208,6 +210,7 @@ func ConformanceTests(t *testing.T, props map[string]string, inputBinding bindin // Need a small wait here because with brokers like MQTT // if you publish before there is a consumer, the message is thrown out // Currently, there is no way to know when Read is successfully subscribed. + t.Logf("Sleeping for %v", config.ReadBindingWait) time.Sleep(config.ReadBindingWait) } @@ -262,7 +265,7 @@ func ConformanceTests(t *testing.T, props map[string]string, inputBinding bindin assert.Greater(t, inputBindingCall, 0) testLogger.Info("Read channel signalled.") case <-time.After(config.ReadBindingTimeout): - assert.Greater(t, inputBindingCall, 0) + assert.Greaterf(t, inputBindingCall, 0, "Timed out after %v while reading", config.ReadBindingTimeout) testLogger.Info("Read timeout.") } testLogger.Info("Verify Read test done.")