-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Track secrets in consumer reconciler (#2153)
* Track secrets in consumer reconciler Signed-off-by: Pierangelo Di Pilato <[email protected]> * Add E2E test Signed-off-by: Pierangelo Di Pilato <[email protected]> * Remove unused method Signed-off-by: Pierangelo Di Pilato <[email protected]> * Move generic run utils in top level dir to avoid import errors Signed-off-by: Pierangelo Di Pilato <[email protected]> * Use shared utility function and move tracking before using secrets Signed-off-by: Pierangelo Di Pilato <[email protected]>
- Loading branch information
Showing
32 changed files
with
684 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright 2022 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 featuressteps | ||
|
||
import ( | ||
"context" | ||
|
||
"knative.dev/eventing/pkg/utils" | ||
kubeclient "knative.dev/pkg/client/injection/kube/client" | ||
"knative.dev/reconciler-test/pkg/environment" | ||
"knative.dev/reconciler-test/pkg/feature" | ||
) | ||
|
||
func CopySecretInTestNamespace(namespace, name string) feature.StepFn { | ||
return func(ctx context.Context, t feature.T) { | ||
tgtNs := environment.FromContext(ctx).Namespace() | ||
_, err := utils.CopySecret( | ||
kubeclient.Get(ctx).CoreV1(), | ||
namespace, | ||
name, | ||
tgtNs, | ||
"default", | ||
) | ||
if err != nil { | ||
t.Fatalf("failed to copy secret %s from %s to %s: %v", name, namespace, tgtNs, err) | ||
} | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
test/e2e_new/features/kafka_source_create_secrets_after.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* Copyright 2022 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 features | ||
|
||
import ( | ||
duckv1 "knative.dev/pkg/apis/duck/v1" | ||
"knative.dev/pkg/system" | ||
"knative.dev/reconciler-test/pkg/feature" | ||
"knative.dev/reconciler-test/pkg/k8s" | ||
"knative.dev/reconciler-test/resources/svc" | ||
|
||
"knative.dev/eventing-kafka/test/rekt/resources/kafkasource" | ||
"knative.dev/eventing-kafka/test/rekt/resources/kafkatopic" | ||
|
||
"knative.dev/eventing-kafka-broker/test/e2e_new/features/featuressteps" | ||
testingpkg "knative.dev/eventing-kafka-broker/test/pkg" | ||
) | ||
|
||
func CreateSecretsAfterKafkaSource() *feature.Feature { | ||
f := feature.NewFeatureNamed("Create secrets after KafkaSource") | ||
|
||
topicName := feature.MakeRandomK8sName("topic") // A k8s name is also a valid topic name. | ||
name := feature.MakeRandomK8sName("source") | ||
sink := feature.MakeRandomK8sName("sink") | ||
|
||
tlsSecretName := "strimzi-tls-secret" | ||
saslSecretName := "strimzi-sasl-secret" | ||
|
||
f.Setup("install kafka topic", kafkatopic.Install(topicName)) | ||
f.Setup("install a service", svc.Install(sink, "app", "rekt")) | ||
f.Setup("install a KafkaSource", kafkasource.Install(name, | ||
kafkasource.WithSink(&duckv1.KReference{Kind: "Service", Name: sink, APIVersion: "v1"}, ""), | ||
kafkasource.WithBootstrapServers(testingpkg.BootstrapServersSslSaslScramArr), | ||
kafkasource.WithTopics([]string{topicName}), | ||
kafkasource.WithSASLEnabled(), | ||
kafkasource.WithSASLUser(saslSecretName, "user"), | ||
kafkasource.WithSASLPassword(saslSecretName, "password"), | ||
kafkasource.WithSASLType(saslSecretName, "saslType"), | ||
kafkasource.WithTLSEnabled(), | ||
kafkasource.WithTLSCACert(tlsSecretName, "ca.crt"), | ||
)) | ||
f.Setup("KafkaSource is not ready", k8s.IsNotReady(kafkasource.GVR(), name)) | ||
|
||
f.Requirement("Create TLS secret", featuressteps.CopySecretInTestNamespace(system.Namespace(), tlsSecretName)) | ||
f.Requirement("Create SASL secret", featuressteps.CopySecretInTestNamespace(system.Namespace(), saslSecretName)) | ||
|
||
f.Assert("KafkaSource is ready", kafkasource.IsReady(name)) | ||
|
||
return f | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
//go:build e2e | ||
// +build e2e | ||
|
||
/* | ||
* Copyright 2022 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 e2e_new | ||
|
||
import ( | ||
"testing" | ||
|
||
"knative.dev/pkg/system" | ||
"knative.dev/reconciler-test/pkg/environment" | ||
"knative.dev/reconciler-test/pkg/k8s" | ||
"knative.dev/reconciler-test/pkg/knative" | ||
|
||
"knative.dev/eventing-kafka-broker/test/e2e_new/features" | ||
) | ||
|
||
func TestKafkaSourceCreateSecretsAfterKafkaSource(t *testing.T) { | ||
|
||
t.Parallel() | ||
|
||
ctx, env := global.Environment( | ||
knative.WithKnativeNamespace(system.Namespace()), | ||
knative.WithLoggingConfig, | ||
knative.WithTracingConfig, | ||
k8s.WithEventListener, | ||
environment.Managed(t), | ||
) | ||
|
||
env.Test(ctx, t, features.CreateSecretsAfterKafkaSource()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ | |
* limitations under the License. | ||
*/ | ||
|
||
package testing | ||
package pkg | ||
|
||
import ( | ||
"fmt" | ||
|
Oops, something went wrong.