From 10ceb2fdebd3485374143e89c73a0286d3ec96d8 Mon Sep 17 00:00:00 2001 From: Gabriel Freites Date: Wed, 9 Jun 2021 21:48:55 -0500 Subject: [PATCH 01/15] increased test coverage and created validation base for rabbitmq adapter --- pkg/adapter/adapter.go | 4 +- pkg/adapter/adapter_test.go | 124 +++++++++++++++++++++++++++++- pkg/adapter/adapter_validation.go | 45 +++++++++++ 3 files changed, 170 insertions(+), 3 deletions(-) create mode 100644 pkg/adapter/adapter_validation.go diff --git a/pkg/adapter/adapter.go b/pkg/adapter/adapter.go index d348a33e36..bac8f5c487 100644 --- a/pkg/adapter/adapter.go +++ b/pkg/adapter/adapter.go @@ -114,8 +114,8 @@ func vhostHandler(brokers string, vhost string) string { return fmt.Sprintf("%s%s", brokers, vhost) } -func (a *Adapter) CreateConn(User string, Password string, logger *zap.Logger) (*amqp.Conn, error) { - if User != "" && Password != "" { +func (a *Adapter) CreateConn(user string, password string, logger *zap.Logger) (*amqp.Conn, error) { + if user != "" && password != "" { a.config.Brokers = fmt.Sprintf( "amqp://%s:%s@%s", a.config.User, diff --git a/pkg/adapter/adapter_test.go b/pkg/adapter/adapter_test.go index 8d68c3fe60..915903978e 100644 --- a/pkg/adapter/adapter_test.go +++ b/pkg/adapter/adapter_test.go @@ -22,13 +22,17 @@ import ( "io/ioutil" "net/http" "net/http/httptest" + "reflect" "testing" + "time" + "github.com/NeowayLabs/wabbit" "github.com/NeowayLabs/wabbit/amqp" "github.com/NeowayLabs/wabbit/amqptest" "github.com/NeowayLabs/wabbit/amqptest/server" origamqp "github.com/streadway/amqp" "go.uber.org/zap" + "knative.dev/eventing/pkg/adapter/v2" "knative.dev/eventing/pkg/kncloudevents" "knative.dev/pkg/logging" "knative.dev/pkg/source" @@ -477,6 +481,11 @@ func TestAdapterVhostHandler(t *testing.T) { brokers: "amqp://localhost:5672", vhost: "test-vhost", want: "amqp://localhost:5672/test-vhost", + }, { + name: "brokers and vhost without separating slash but vhost with ending slash", + brokers: "amqp://localhost:5672", + vhost: "test-vhost/", + want: "amqp://localhost:5672/test-vhost/", }, { name: "brokers with trailing slash and vhost without the slash", brokers: "amqp://localhost:5672/", @@ -494,7 +503,6 @@ func TestAdapterVhostHandler(t *testing.T) { want: "amqp://localhost:5672//test-vhost", }} { t.Run(tt.name, func(t *testing.T) { - t.Parallel() got := vhostHandler(tt.brokers, tt.vhost) if got != tt.want { t.Errorf("Unexpected URI for %s/%s want:\n%+s\ngot:\n%+s", tt.brokers, tt.vhost, tt.want, got) @@ -502,3 +510,117 @@ func TestAdapterVhostHandler(t *testing.T) { }) } } + +func TestAdapter_PollForMessages(t *testing.T) { + fakeServer := server.NewServer("amqp://localhost:5672/%2f") + err := fakeServer.Start() + if err != nil { + t.Errorf("%s: %s", "Failed to connect to RabbitMQ", err) + } + + conn, err := amqptest.Dial("amqp://localhost:5672/%2f") + if err != nil { + t.Errorf("%s: %s", "Failed to connect to RabbitMQ", err) + } + + channel, err := conn.Channel() + if err != nil { + t.Errorf("Failed to open a channel") + } + + statsReporter, _ := source.NewStatsReporter() + + a := &Adapter{ + config: &adapterConfig{ + Topic: "topic", + Brokers: "amqp://guest:guest@localhost:5672/", + ExchangeConfig: ExchangeConfig{ + Name: "Test-exchange", + TypeOf: "topic", + Durable: true, + AutoDeleted: false, + Internal: false, + NoWait: false, + }, + QueueConfig: QueueConfig{ + Name: "", + Durable: false, + DeleteWhenUnused: false, + Exclusive: true, + NoWait: false, + }, + }, + context: context.TODO(), + logger: zap.NewNop(), + reporter: statsReporter, + } + + err = channel.ExchangeDeclare(a.config.ExchangeConfig.Name, a.config.ExchangeConfig.TypeOf, nil) + + if err != nil { + t.Errorf("Failed to declare an exchange") + } + + queue, err := channel.QueueDeclare("", wabbit.Option{ + "durable": a.config.QueueConfig.Durable, + "delete": a.config.QueueConfig.DeleteWhenUnused, + "exclusive": a.config.QueueConfig.Exclusive, + "noWait": a.config.QueueConfig.NoWait, + }) + if err != nil { + t.Errorf(err.Error()) + } + + if err := channel.Confirm(false); err != nil { + t.Fatalf("[x] Channel could not be put into confirm mode: %s", err) + } + + ctx, _ := context.WithDeadline(context.TODO(), time.Now().Add(100*time.Millisecond)) + + err = a.PollForMessages(&channel, &queue, ctx.Done()) + + if err != nil { + t.Errorf("testing err %s", err) + } + + channel.Close() + fakeServer.Stop() +} + +func TestAdapter_NewEnvConfig(t *testing.T) { + env := NewEnvConfig() + var envPlaceholder adapter.EnvConfigAccessor + if reflect.TypeOf(env) == reflect.TypeOf(envPlaceholder) { + t.Errorf("Error in NewnvConfig return Type") + } +} + +func TestAdapter_NewAdapter(t *testing.T) { + ctx := context.TODO() + env := NewEnvConfig() + h := &fakeHandler{ + handler: sinkAccepted, + } + + sinkServer := httptest.NewServer(h) + defer sinkServer.Close() + + s, err := kncloudevents.NewHTTPMessageSenderWithTarget(sinkServer.URL) + if err != nil { + t.Fatal(err) + } + + statsReporter, _ := source.NewStatsReporter() + a := NewAdapter(ctx, env, s, statsReporter) + cmpA := &Adapter{ + config: env.(*adapterConfig), + httpMessageSender: s, + reporter: statsReporter, + logger: logging.FromContext(ctx).Desugar(), + context: ctx, + } + + if a == cmpA { + t.Errorf("Error in NewnvConfig return Type") + } +} diff --git a/pkg/adapter/adapter_validation.go b/pkg/adapter/adapter_validation.go new file mode 100644 index 0000000000..d6906f5e64 --- /dev/null +++ b/pkg/adapter/adapter_validation.go @@ -0,0 +1,45 @@ +/* +Copyright 2020 The Knative 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 rabbitmq + +import ( + "context" + + "knative.dev/pkg/apis" + "knative.dev/pkg/kmp" +) + +func (current *Adapter) Validate(ctx context.Context) *apis.FieldError { + if apis.IsInUpdate(ctx) { + original := apis.GetBaseline(ctx).(*Adapter) + if diff, err := kmp.ShortDiff(original.config, current.config); err != nil { + return &apis.FieldError{ + Message: "Failed to diff RabbitmqSource", + Paths: []string{"spec"}, + Details: err.Error(), + } + } else if diff != "" { + return &apis.FieldError{ + Message: "Immutable fields changed (-old +new)", + Paths: []string{"spec"}, + Details: diff, + } + } + } + + return nil +} From 77adb93a28749fc419b7c4b87709c53a13a0f2c3 Mon Sep 17 00:00:00 2001 From: Gabriel Freites Date: Mon, 21 Jun 2021 14:37:55 -0500 Subject: [PATCH 02/15] added basic files to the source vhost e2e test and parelization to vsource vhost adapter tests --- pkg/adapter/adapter_test.go | 2 ++ test/e2e/main_test.go | 15 +++++++++++++++ test/e2e/source_test.go | 19 +++++++++++++++++++ 3 files changed, 36 insertions(+) diff --git a/pkg/adapter/adapter_test.go b/pkg/adapter/adapter_test.go index 915903978e..fa4cbc73cf 100644 --- a/pkg/adapter/adapter_test.go +++ b/pkg/adapter/adapter_test.go @@ -503,6 +503,8 @@ func TestAdapterVhostHandler(t *testing.T) { want: "amqp://localhost:5672//test-vhost", }} { t.Run(tt.name, func(t *testing.T) { + tt := tt + t.Parallel() got := vhostHandler(tt.brokers, tt.vhost) if got != tt.want { t.Errorf("Unexpected URI for %s/%s want:\n%+s\ngot:\n%+s", tt.brokers, tt.vhost, tt.want, got) diff --git a/test/e2e/main_test.go b/test/e2e/main_test.go index c6a51d6022..bb41990cca 100644 --- a/test/e2e/main_test.go +++ b/test/e2e/main_test.go @@ -147,3 +147,18 @@ func TestSourceDirect(t *testing.T) { env.Test(ctx, t, DirectSourceTest()) env.Finish() } + +func TestSourceVhostSetup(t *testing.T) { + t.Parallel() + + ctx, env := global.Environment( + knative.WithKnativeNamespace(system.Namespace()), + knative.WithLoggingConfig, + knative.WithTracingConfig, + k8s.WithEventListener, + ) + env.Test(ctx, t, RabbitMQCluster()) + env.Test(ctx, t, RecorderFeature()) + env.Test(ctx, t, VhostSourceTest()) + env.Finish() +} diff --git a/test/e2e/source_test.go b/test/e2e/source_test.go index 19c1958e26..08709792ac 100644 --- a/test/e2e/source_test.go +++ b/test/e2e/source_test.go @@ -53,3 +53,22 @@ func DirectSourceTest() *feature.Feature { return f } + +// VhostSourceTest makes sure an RabbitMQ Source is created on the desired vhost. +func VhostSourceTest() *feature.Feature { + f := new(feature.Feature) + + f.Setup("install RabbitMQ source", source.Install()) + f.Alpha("RabbitMQ source").Must("goes ready", AllGoReady) + // Note this is a different producer than events hub because it publishes + // directly to RabbitMQ + f.Setup("install producer", sourceproducer.Install()) + f.Alpha("RabbitMQ source"). + Must("the recorder received all sent events within the time", + func(ctx context.Context, t feature.T) { + // TODO: Use constraint matching instead of just counting number of events. + eventshub.StoreFromContext(ctx, "recorder").AssertAtLeast(t, 5) + }) + + return f +} From 9692175b05b7d76f71f6e3913c81a57770b1c149 Mon Sep 17 00:00:00 2001 From: Gabriel Freites Date: Tue, 22 Jun 2021 15:39:29 -0500 Subject: [PATCH 03/15] added yaml to create a source on an specific vhost --- .../config/source/rabbitmq-source-vhost.yaml | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 test/e2e/config/source/rabbitmq-source-vhost.yaml diff --git a/test/e2e/config/source/rabbitmq-source-vhost.yaml b/test/e2e/config/source/rabbitmq-source-vhost.yaml new file mode 100644 index 0000000000..449954b190 --- /dev/null +++ b/test/e2e/config/source/rabbitmq-source-vhost.yaml @@ -0,0 +1,35 @@ +apiVersion: sources.knative.dev/v1alpha1 +kind: RabbitmqSource +metadata: + name: rabbitmq-source + namespace: {{ .namespace }} +spec: + brokers: "rabbitmqc.{{ .namespace }}:5672/" + vhost: "test-vhost" + topic: "" + user: + secretKeyRef: + name: "rabbitmqc-default-user" + key: "username" + password: + secretKeyRef: + name: "rabbitmqc-default-user" + key: "password" + exchange_config: + type: "fanout" + durable: true + auto_deleted: false + internal: false + nowait: false + queue_config: + name: "" + routing_key: "" + durable: false + delete_when_unused: false + exclusive: false + nowait: false + sink: + ref: + apiVersion: v1 + kind: Service + name: recorder From d58fd7d50d824df4c172c9ff5b7c7351c94cdebb Mon Sep 17 00:00:00 2001 From: Gabriel Freites Date: Tue, 22 Jun 2021 16:17:20 -0500 Subject: [PATCH 04/15] removed unused validation file and created vhostsource e2e test dir to locate config files --- .../rabbitmq-source-vhost.yaml | 0 .../e2e/config/sourcevhost/source.go | 32 +++++++------------ 2 files changed, 12 insertions(+), 20 deletions(-) rename test/e2e/config/{source => sourcevhost}/rabbitmq-source-vhost.yaml (100%) rename pkg/adapter/adapter_validation.go => test/e2e/config/sourcevhost/source.go (50%) diff --git a/test/e2e/config/source/rabbitmq-source-vhost.yaml b/test/e2e/config/sourcevhost/rabbitmq-source-vhost.yaml similarity index 100% rename from test/e2e/config/source/rabbitmq-source-vhost.yaml rename to test/e2e/config/sourcevhost/rabbitmq-source-vhost.yaml diff --git a/pkg/adapter/adapter_validation.go b/test/e2e/config/sourcevhost/source.go similarity index 50% rename from pkg/adapter/adapter_validation.go rename to test/e2e/config/sourcevhost/source.go index d6906f5e64..c29c9dbc95 100644 --- a/pkg/adapter/adapter_validation.go +++ b/test/e2e/config/sourcevhost/source.go @@ -14,32 +14,24 @@ See the License for the specific language governing permissions and limitations under the License. */ -package rabbitmq +package source import ( "context" - "knative.dev/pkg/apis" - "knative.dev/pkg/kmp" + "knative.dev/reconciler-test/pkg/environment" + "knative.dev/reconciler-test/pkg/feature" + "knative.dev/reconciler-test/pkg/manifest" ) -func (current *Adapter) Validate(ctx context.Context) *apis.FieldError { - if apis.IsInUpdate(ctx) { - original := apis.GetBaseline(ctx).(*Adapter) - if diff, err := kmp.ShortDiff(original.config, current.config); err != nil { - return &apis.FieldError{ - Message: "Failed to diff RabbitmqSource", - Paths: []string{"spec"}, - Details: err.Error(), - } - } else if diff != "" { - return &apis.FieldError{ - Message: "Immutable fields changed (-old +new)", - Paths: []string{"spec"}, - Details: diff, - } +func init() { + environment.RegisterPackage(manifest.ImagesLocalYaml()...) +} + +func Install() feature.StepFn { + return func(ctx context.Context, t feature.T) { + if _, err := manifest.InstallLocalYaml(ctx, map[string]interface{}{"producerCount": 5}); err != nil { + t.Fatal(err) } } - - return nil } From bcb9f40ad410e92fc32825ea3c64a6b1fc622ac4 Mon Sep 17 00:00:00 2001 From: Gabriel Freites Date: Tue, 22 Jun 2021 16:20:41 -0500 Subject: [PATCH 05/15] renamed file for new e2e config test --- test/e2e/config/sourcevhost/{source.go => sourcevhost.go} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename test/e2e/config/sourcevhost/{source.go => sourcevhost.go} (100%) diff --git a/test/e2e/config/sourcevhost/source.go b/test/e2e/config/sourcevhost/sourcevhost.go similarity index 100% rename from test/e2e/config/sourcevhost/source.go rename to test/e2e/config/sourcevhost/sourcevhost.go From c68f4f13b23e943a42300c1321f25df32c3f7c48 Mon Sep 17 00:00:00 2001 From: Gabriel Freites Date: Tue, 22 Jun 2021 19:50:10 -0500 Subject: [PATCH 06/15] added basic e2e test for vhost in source --- test/e2e/config/sourcevhost/rabbitmq-source-vhost.yaml | 2 ++ test/e2e/config/sourcevhost/sourcevhost.go | 2 +- test/e2e/source_test.go | 4 +++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/test/e2e/config/sourcevhost/rabbitmq-source-vhost.yaml b/test/e2e/config/sourcevhost/rabbitmq-source-vhost.yaml index 449954b190..af317dfe6c 100644 --- a/test/e2e/config/sourcevhost/rabbitmq-source-vhost.yaml +++ b/test/e2e/config/sourcevhost/rabbitmq-source-vhost.yaml @@ -3,6 +3,8 @@ kind: RabbitmqSource metadata: name: rabbitmq-source namespace: {{ .namespace }} + labels: + app: rabbitmq-source-app spec: brokers: "rabbitmqc.{{ .namespace }}:5672/" vhost: "test-vhost" diff --git a/test/e2e/config/sourcevhost/sourcevhost.go b/test/e2e/config/sourcevhost/sourcevhost.go index c29c9dbc95..5647279957 100644 --- a/test/e2e/config/sourcevhost/sourcevhost.go +++ b/test/e2e/config/sourcevhost/sourcevhost.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package source +package sourcevhost import ( "context" diff --git a/test/e2e/source_test.go b/test/e2e/source_test.go index 08709792ac..0c1fbdaaa3 100644 --- a/test/e2e/source_test.go +++ b/test/e2e/source_test.go @@ -23,6 +23,8 @@ import ( "knative.dev/eventing-rabbitmq/test/e2e/config/source" "knative.dev/eventing-rabbitmq/test/e2e/config/sourceproducer" + "knative.dev/eventing-rabbitmq/test/e2e/config/sourcevhost" + "knative.dev/reconciler-test/pkg/eventshub" "knative.dev/reconciler-test/pkg/feature" @@ -58,7 +60,7 @@ func DirectSourceTest() *feature.Feature { func VhostSourceTest() *feature.Feature { f := new(feature.Feature) - f.Setup("install RabbitMQ source", source.Install()) + f.Setup("install RabbitMQ source on test-vhost", sourcevhost.Install()) f.Alpha("RabbitMQ source").Must("goes ready", AllGoReady) // Note this is a different producer than events hub because it publishes // directly to RabbitMQ From 8cc0de758bb26bf6406e7f4d67ac3874799be8e7 Mon Sep 17 00:00:00 2001 From: Gabriel Freites Date: Tue, 22 Jun 2021 19:50:40 -0500 Subject: [PATCH 07/15] removed unused label from source yamll --- test/e2e/config/sourcevhost/rabbitmq-source-vhost.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/e2e/config/sourcevhost/rabbitmq-source-vhost.yaml b/test/e2e/config/sourcevhost/rabbitmq-source-vhost.yaml index af317dfe6c..449954b190 100644 --- a/test/e2e/config/sourcevhost/rabbitmq-source-vhost.yaml +++ b/test/e2e/config/sourcevhost/rabbitmq-source-vhost.yaml @@ -3,8 +3,6 @@ kind: RabbitmqSource metadata: name: rabbitmq-source namespace: {{ .namespace }} - labels: - app: rabbitmq-source-app spec: brokers: "rabbitmqc.{{ .namespace }}:5672/" vhost: "test-vhost" From 7c23b28339123108c1bb14e9e614aa934dee565c Mon Sep 17 00:00:00 2001 From: Gabriel Freites Date: Thu, 24 Jun 2021 10:03:27 -0500 Subject: [PATCH 08/15] fixed context leak in with deadline --- pkg/adapter/adapter_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/adapter/adapter_test.go b/pkg/adapter/adapter_test.go index fa4cbc73cf..9a347fb63a 100644 --- a/pkg/adapter/adapter_test.go +++ b/pkg/adapter/adapter_test.go @@ -577,7 +577,8 @@ func TestAdapter_PollForMessages(t *testing.T) { t.Fatalf("[x] Channel could not be put into confirm mode: %s", err) } - ctx, _ := context.WithDeadline(context.TODO(), time.Now().Add(100*time.Millisecond)) + ctx, cancelFunc := context.WithDeadline(context.TODO(), time.Now().Add(100*time.Millisecond)) + defer cancelFunc() err = a.PollForMessages(&channel, &queue, ctx.Done()) From c97f1072ff782510566e3fb2b7317661b243a576 Mon Sep 17 00:00:00 2001 From: Gabriel Freites Date: Thu, 24 Jun 2021 10:34:10 -0500 Subject: [PATCH 09/15] added readme to tests docs --- test/README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 test/README.md diff --git a/test/README.md b/test/README.md new file mode 100644 index 0000000000..813fdb21a5 --- /dev/null +++ b/test/README.md @@ -0,0 +1,3 @@ +# Tests + +For more info on the tests see [Eventing Tests](https://github.com/knative/eventing/blob/main/test/README.md) \ No newline at end of file From 5c7e7f57dcc09a53f435b67306c2a3113c82553e Mon Sep 17 00:00:00 2001 From: Gabriel Freites Date: Thu, 24 Jun 2021 14:09:52 -0500 Subject: [PATCH 10/15] fixed testss --- test/e2e/source_test.go | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/test/e2e/source_test.go b/test/e2e/source_test.go index 0c1fbdaaa3..339dace08b 100644 --- a/test/e2e/source_test.go +++ b/test/e2e/source_test.go @@ -62,15 +62,5 @@ func VhostSourceTest() *feature.Feature { f.Setup("install RabbitMQ source on test-vhost", sourcevhost.Install()) f.Alpha("RabbitMQ source").Must("goes ready", AllGoReady) - // Note this is a different producer than events hub because it publishes - // directly to RabbitMQ - f.Setup("install producer", sourceproducer.Install()) - f.Alpha("RabbitMQ source"). - Must("the recorder received all sent events within the time", - func(ctx context.Context, t feature.T) { - // TODO: Use constraint matching instead of just counting number of events. - eventshub.StoreFromContext(ctx, "recorder").AssertAtLeast(t, 5) - }) - return f } From 9243ee856ee0b1de802753263fe26f2c51088a30 Mon Sep 17 00:00:00 2001 From: Gabriel Freites Date: Thu, 24 Jun 2021 14:21:43 -0500 Subject: [PATCH 11/15] added TODO annotation for rabbitmqsource e2e test --- test/e2e/source_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/test/e2e/source_test.go b/test/e2e/source_test.go index 339dace08b..885e8e5274 100644 --- a/test/e2e/source_test.go +++ b/test/e2e/source_test.go @@ -62,5 +62,6 @@ func VhostSourceTest() *feature.Feature { f.Setup("install RabbitMQ source on test-vhost", sourcevhost.Install()) f.Alpha("RabbitMQ source").Must("goes ready", AllGoReady) + // TODO: still needs some more logic to test all of it return f } From ca09b8513bf8bcce321b79dbdd945fbf83ec6d61 Mon Sep 17 00:00:00 2001 From: Gabriel Freites Date: Thu, 24 Jun 2021 16:59:44 -0500 Subject: [PATCH 12/15] fixing lint on new readme --- test/README.md | 2 +- test/e2e/config/sourcevhost/sourcevhost.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/README.md b/test/README.md index 813fdb21a5..85713825fb 100644 --- a/test/README.md +++ b/test/README.md @@ -1,3 +1,3 @@ # Tests -For more info on the tests see [Eventing Tests](https://github.com/knative/eventing/blob/main/test/README.md) \ No newline at end of file +For more info on the tests see [Eventing Tests](https://github.com/knative/eventing/blob/main/test/README.md) diff --git a/test/e2e/config/sourcevhost/sourcevhost.go b/test/e2e/config/sourcevhost/sourcevhost.go index 5647279957..dc113e7986 100644 --- a/test/e2e/config/sourcevhost/sourcevhost.go +++ b/test/e2e/config/sourcevhost/sourcevhost.go @@ -30,7 +30,7 @@ func init() { func Install() feature.StepFn { return func(ctx context.Context, t feature.T) { - if _, err := manifest.InstallLocalYaml(ctx, map[string]interface{}{"producerCount": 5}); err != nil { + if _, err := manifest.InstallLocalYaml(ctx, nil); err != nil { t.Fatal(err) } } From 2bd501c4b318eb40b666fe64efd12e2afe251851 Mon Sep 17 00:00:00 2001 From: Gabriel Freites Date: Mon, 28 Jun 2021 12:03:26 -0500 Subject: [PATCH 13/15] removed unused function calls in tests and added unique name for new test source yaml --- test/e2e/config/sourcevhost/rabbitmq-source-vhost.yaml | 2 +- test/e2e/main_test.go | 8 +------- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/test/e2e/config/sourcevhost/rabbitmq-source-vhost.yaml b/test/e2e/config/sourcevhost/rabbitmq-source-vhost.yaml index 449954b190..b6ea2720d3 100644 --- a/test/e2e/config/sourcevhost/rabbitmq-source-vhost.yaml +++ b/test/e2e/config/sourcevhost/rabbitmq-source-vhost.yaml @@ -1,7 +1,7 @@ apiVersion: sources.knative.dev/v1alpha1 kind: RabbitmqSource metadata: - name: rabbitmq-source + name: rabbitmq-source-vhost namespace: {{ .namespace }} spec: brokers: "rabbitmqc.{{ .namespace }}:5672/" diff --git a/test/e2e/main_test.go b/test/e2e/main_test.go index bb41990cca..e6069ebcb4 100644 --- a/test/e2e/main_test.go +++ b/test/e2e/main_test.go @@ -151,14 +151,8 @@ func TestSourceDirect(t *testing.T) { func TestSourceVhostSetup(t *testing.T) { t.Parallel() - ctx, env := global.Environment( - knative.WithKnativeNamespace(system.Namespace()), - knative.WithLoggingConfig, - knative.WithTracingConfig, - k8s.WithEventListener, - ) + ctx, env := global.Environment() env.Test(ctx, t, RabbitMQCluster()) - env.Test(ctx, t, RecorderFeature()) env.Test(ctx, t, VhostSourceTest()) env.Finish() } From ca457aab490b900d48b03e168d1451de0b1e4529 Mon Sep 17 00:00:00 2001 From: Gabriel Freites Date: Mon, 28 Jun 2021 13:48:56 -0500 Subject: [PATCH 14/15] added CR headders and fixed PR comments --- test/e2e/config/source/rabbitmq-source.yaml | 14 ++++++++++++++ .../config/sourcevhost/rabbitmq-source-vhost.yaml | 14 ++++++++++++++ test/e2e/config/sourcevhost/sourcevhost.go | 2 +- test/e2e/main_test.go | 2 +- test/e2e/source_test.go | 2 +- 5 files changed, 31 insertions(+), 3 deletions(-) diff --git a/test/e2e/config/source/rabbitmq-source.yaml b/test/e2e/config/source/rabbitmq-source.yaml index d5a59397d9..e34d54b380 100644 --- a/test/e2e/config/source/rabbitmq-source.yaml +++ b/test/e2e/config/source/rabbitmq-source.yaml @@ -1,3 +1,17 @@ +# Copyright 2021 The Knative 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 +# +# https://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. + apiVersion: sources.knative.dev/v1alpha1 kind: RabbitmqSource metadata: diff --git a/test/e2e/config/sourcevhost/rabbitmq-source-vhost.yaml b/test/e2e/config/sourcevhost/rabbitmq-source-vhost.yaml index b6ea2720d3..a4c2b97d83 100644 --- a/test/e2e/config/sourcevhost/rabbitmq-source-vhost.yaml +++ b/test/e2e/config/sourcevhost/rabbitmq-source-vhost.yaml @@ -1,3 +1,17 @@ +# Copyright 2021 The Knative 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 +# +# https://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. + apiVersion: sources.knative.dev/v1alpha1 kind: RabbitmqSource metadata: diff --git a/test/e2e/config/sourcevhost/sourcevhost.go b/test/e2e/config/sourcevhost/sourcevhost.go index dc113e7986..205111bb97 100644 --- a/test/e2e/config/sourcevhost/sourcevhost.go +++ b/test/e2e/config/sourcevhost/sourcevhost.go @@ -1,5 +1,5 @@ /* -Copyright 2020 The Knative Authors +Copyright 2021 The Knative Authors Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/test/e2e/main_test.go b/test/e2e/main_test.go index e6069ebcb4..1cfd888a23 100644 --- a/test/e2e/main_test.go +++ b/test/e2e/main_test.go @@ -153,6 +153,6 @@ func TestSourceVhostSetup(t *testing.T) { ctx, env := global.Environment() env.Test(ctx, t, RabbitMQCluster()) - env.Test(ctx, t, VhostSourceTest()) + env.Test(ctx, t, VHostSourceTest()) env.Finish() } diff --git a/test/e2e/source_test.go b/test/e2e/source_test.go index 885e8e5274..91115b4411 100644 --- a/test/e2e/source_test.go +++ b/test/e2e/source_test.go @@ -57,7 +57,7 @@ func DirectSourceTest() *feature.Feature { } // VhostSourceTest makes sure an RabbitMQ Source is created on the desired vhost. -func VhostSourceTest() *feature.Feature { +func VHostSourceTest() *feature.Feature { f := new(feature.Feature) f.Setup("install RabbitMQ source on test-vhost", sourcevhost.Install()) From a055fff58ce28e9dd7575afe1087568701af48d3 Mon Sep 17 00:00:00 2001 From: Gabriel Freites Date: Wed, 30 Jun 2021 09:26:41 -0500 Subject: [PATCH 15/15] fixing e2e tests run --- test/e2e/config/sourcevhost/rabbitmq-source-vhost.yaml | 5 ----- test/e2e/main_test.go | 5 +++-- test/e2e/source_test.go | 2 +- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/test/e2e/config/sourcevhost/rabbitmq-source-vhost.yaml b/test/e2e/config/sourcevhost/rabbitmq-source-vhost.yaml index a4c2b97d83..19840aee57 100644 --- a/test/e2e/config/sourcevhost/rabbitmq-source-vhost.yaml +++ b/test/e2e/config/sourcevhost/rabbitmq-source-vhost.yaml @@ -42,8 +42,3 @@ spec: delete_when_unused: false exclusive: false nowait: false - sink: - ref: - apiVersion: v1 - kind: Service - name: recorder diff --git a/test/e2e/main_test.go b/test/e2e/main_test.go index 1cfd888a23..690ed83ee7 100644 --- a/test/e2e/main_test.go +++ b/test/e2e/main_test.go @@ -151,8 +151,9 @@ func TestSourceDirect(t *testing.T) { func TestSourceVhostSetup(t *testing.T) { t.Parallel() - ctx, env := global.Environment() - env.Test(ctx, t, RabbitMQCluster()) + ctx, env := global.Environment( + knative.WithKnativeNamespace(system.Namespace()), + ) env.Test(ctx, t, VHostSourceTest()) env.Finish() } diff --git a/test/e2e/source_test.go b/test/e2e/source_test.go index 91115b4411..f9f24c221d 100644 --- a/test/e2e/source_test.go +++ b/test/e2e/source_test.go @@ -61,7 +61,7 @@ func VHostSourceTest() *feature.Feature { f := new(feature.Feature) f.Setup("install RabbitMQ source on test-vhost", sourcevhost.Install()) - f.Alpha("RabbitMQ source").Must("goes ready", AllGoReady) // TODO: still needs some more logic to test all of it + return f }