Skip to content

Commit

Permalink
Comment out the certificate rotation test portion
Browse files Browse the repository at this point in the history
  • Loading branch information
Leo6Leo committed Oct 20, 2023
1 parent 10678c9 commit 3280c52
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 51 deletions.
101 changes: 56 additions & 45 deletions test/rekt/features/channel_tls.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,33 +17,44 @@
package features

import (
"context"
cetest "github.com/cloudevents/sdk-go/v2/test"
"github.com/google/uuid"
"k8s.io/apimachinery/pkg/types"
"knative.dev/eventing-kafka-broker/test/rekt/resources/kafkachannel"
"knative.dev/eventing/test/rekt/features/featureflags"
"knative.dev/eventing/test/rekt/resources/addressable"
"knative.dev/eventing/test/rekt/resources/subscription"
"knative.dev/pkg/system"
"knative.dev/reconciler-test/pkg/eventshub"
"knative.dev/reconciler-test/pkg/eventshub/assert"
"knative.dev/reconciler-test/pkg/feature"
"knative.dev/reconciler-test/pkg/resources/service"
"knative.dev/reconciler-test/resources/certificate"
"time"
)

func RotateChannelTLSCertificates() *feature.Feature {
//
//ingressCertificateName := "kafka-channel-ingress-server-tls"
//ingressSecretName := "kafka-channel-ingress-server-tls"
ingressCertificateName := "kafka-channel-ingress-server-tls"
ingressSecretName := "kafka-channel-ingress-server-tls"

channelName := feature.MakeRandomK8sName("channel")
//subscriptionName := feature.MakeRandomK8sName("sub")
subscriptionName := feature.MakeRandomK8sName("subscription")
sink := feature.MakeRandomK8sName("sink")
//source := feature.MakeRandomK8sName("source")
source := feature.MakeRandomK8sName("source")

f := feature.NewFeatureNamed("Rotate Kafka Channel TLS certificate")

f.Prerequisite("transport encryption is strict", featureflags.TransportEncryptionStrict())
f.Prerequisite("should not run when Istio is enabled", featureflags.IstioDisabled())

//f.Setup("Rotate ingress certificate", certificate.Rotate(certificate.RotateCertificate{
// Certificate: types.NamespacedName{
// Namespace: system.Namespace(),
// Name: ingressCertificateName,
// },
//}))
f.Setup("Rotate ingress certificate", certificate.Rotate(certificate.RotateCertificate{
Certificate: types.NamespacedName{
Namespace: system.Namespace(),
Name: ingressCertificateName,
},
}))

f.Setup("install sink", eventshub.Install(sink, eventshub.StartReceiverTLS))
f.Setup("install channel", kafkachannel.Install(channelName,
Expand All @@ -53,41 +64,41 @@ func RotateChannelTLSCertificates() *feature.Feature {
))
f.Setup("channel is ready", kafkachannel.IsReady(channelName))

//f.Setup("install subscription", func(ctx context.Context, t feature.T) {
// d := service.AsDestinationRef(sink)
// d.CACerts = eventshub.GetCaCerts(ctx)
// subscription.Install(subscriptionName,
// subscription.WithChannel(kafkachannel.AsRef(channelName)),
// subscription.WithSubscriberFromDestination(d))(ctx, t)
//})
//
//f.Setup("subscription is ready", subscription.IsReady(subscriptionName))
//
//f.Setup("Channel has HTTPS address", kafkachannel.ValidateAddress(channelName, addressable.AssertHTTPSAddress))
//
//event := cetest.FullEvent()
//event.SetID(uuid.New().String())
//
//f.Requirement("install source", eventshub.Install(source,
// eventshub.StartSenderToResourceTLS(kafkachannel.GVR(), channelName, nil),
// eventshub.InputEvent(event),
// // Send multiple events so that we take into account that the certificate rotation might
// // be detected by the server after some time.
// eventshub.SendMultipleEvents(100, 3*time.Second),
//))
//
//f.Assert("Event sent", assert.OnStore(source).
// MatchSentEvent(cetest.HasId(event.ID())).
// AtLeast(1),
//)
//f.Assert("Event received", assert.OnStore(sink).
// MatchReceivedEvent(cetest.HasId(event.ID())).
// AtLeast(1),
//)
//f.Assert("Source match updated peer certificate", assert.OnStore(source).
// MatchPeerCertificatesReceived(assert.MatchPeerCertificatesFromSecret(system.Namespace(), ingressSecretName, "tls.crt")).
// AtLeast(1),
//)
f.Setup("install subscription", func(ctx context.Context, t feature.T) {
d := service.AsDestinationRef(sink)
d.CACerts = eventshub.GetCaCerts(ctx)
subscription.Install(subscriptionName,
subscription.WithChannel(kafkachannel.AsRef(channelName)),
subscription.WithSubscriberFromDestination(d))(ctx, t)
})

f.Setup("subscription is ready", subscription.IsReady(subscriptionName))

f.Setup("Channel has HTTPS address", kafkachannel.ValidateAddress(channelName, addressable.AssertHTTPSAddress))

event := cetest.FullEvent()
event.SetID(uuid.New().String())

f.Requirement("install source", eventshub.Install(source,
eventshub.StartSenderToResourceTLS(kafkachannel.GVR(), channelName, nil),
eventshub.InputEvent(event),
// Send multiple events so that we take into account that the certificate rotation might
// be detected by the server after some time.
eventshub.SendMultipleEvents(100, 3*time.Second),
))

f.Assert("Event sent", assert.OnStore(source).
MatchSentEvent(cetest.HasId(event.ID())).
AtLeast(1),
)
f.Assert("Event received", assert.OnStore(sink).
MatchReceivedEvent(cetest.HasId(event.ID())).
AtLeast(1),
)
f.Assert("Source match updated peer certificate", assert.OnStore(source).
MatchPeerCertificatesReceived(assert.MatchPeerCertificatesFromSecret(system.Namespace(), ingressSecretName, "tls.crt")).
AtLeast(1),
)

return f
}
10 changes: 4 additions & 6 deletions test/rekt/resources/kafkachannel/kafkachannel.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,21 +100,19 @@ func WithRetentionDuration(retentionDuration string) manifest.CfgFn {

// AsRef returns a KRef for a Channel without namespace.
func AsRef(name string) *duckv1.KReference {
apiVersion, kind := GVK().ToAPIVersionAndKind()
return &duckv1.KReference{
Kind: kind,
APIVersion: apiVersion,
Kind: EnvCfg.ChannelGK,
APIVersion: EnvCfg.ChannelV,
Name: name,
}
}

// AsRef returns a KRef for a Channel without namespace.
func AsDestinationRef(name string) *duckv1.Destination {
apiVersion, kind := GVK().ToAPIVersionAndKind()
return &duckv1.Destination{
Ref: &duckv1.KReference{
Kind: kind,
APIVersion: apiVersion,
Kind: EnvCfg.ChannelGK,
APIVersion: EnvCfg.ChannelV,
Name: name,
},
}
Expand Down

0 comments on commit 3280c52

Please sign in to comment.