-
Notifications
You must be signed in to change notification settings - Fork 630
Add e2e test cases for Channel-Subscription model #976
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
0408940
add two e2e test case for Channel and Subscription in Eventing
chizhg 239d792
Merge branch 'master' into AddE2ETestCases
chizhg 4546739
change comment
chizhg 13475d2
add default encoding and some comments
chizhg 3542880
fix comment error
chizhg ad91d20
rename the test case
chizhg 53283c7
set up in the first fine
chizhg 15ee257
try to find presubmit tests fail reason
chizhg 3b1acb2
add back the e2e test cases
chizhg 94ff59c
add +build e2e for the test cases
chizhg dc3aaef
change timeout to 2mins
chizhg 5c5475d
fix code review problems
chizhg 7d059a0
refactor common functions like CreatePodAndServiceReady and SendFakeE…
chizhg 7a7ad80
modify the initialization sequence a little bit
chizhg 9439803
resolve build failure
chizhg 5c157a4
solve code review issues
chizhg 24a4146
move provisioner check ahead
chizhg bef2c43
remove duplicate import
chizhg deb6b65
minor comment change
chizhg 52db472
fix the code review issues
chizhg 4f2e04f
Merge branch 'master' into AddE2ETestCases
chizhg 36264fc
change the timeout to 20 mins, by default it is 10 mins
chizhg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,115 @@ | ||
| // +build e2e | ||
|
|
||
| /* | ||
| Copyright 2019 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 | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "testing" | ||
|
|
||
| "github.com/knative/eventing/pkg/apis/eventing/v1alpha1" | ||
| "github.com/knative/eventing/test" | ||
| "k8s.io/apimachinery/pkg/util/uuid" | ||
| ) | ||
|
|
||
| /* | ||
| TestChannelChain tests the following scenario: | ||
|
|
||
| EventSource ---> Channel ---> Subscriptions ---> Channel ---> Subscriptions ---> Service(Logger) | ||
|
|
||
| */ | ||
| func TestChannelChain(t *testing.T) { | ||
| if test.EventingFlags.Provisioner == "" { | ||
| t.Fatal("ClusterChannelProvisioner must be set to a non-empty string. Either do not specify --clusterChannelProvisioner or set to something other than the empty string") | ||
| } | ||
|
|
||
| const ( | ||
| senderName = "e2e-channelchain-sender" | ||
| loggerPodName = "e2e-channelchain-logger-pod" | ||
| ) | ||
| channelNames := [2]string{"e2e-channelchain1", "e2e-channelchain2"} | ||
| // subscriptionNames1 corresponds to Subscriptions on channelNames[0] | ||
| subscriptionNames1 := [2]string{"e2e-complexscen-subs11", "e2e-complexscen-subs12"} | ||
| // subscriptionNames2 corresponds to Subscriptions on channelNames[1] | ||
| subscriptionNames2 := [1]string{"e2e-complexscen-subs21"} | ||
|
|
||
| clients, cleaner := Setup(t, t.Logf) | ||
| // verify namespace | ||
| ns, cleanupNS := CreateNamespaceIfNeeded(t, clients, t.Logf) | ||
| defer cleanupNS() | ||
|
|
||
| // TearDown() needs to be deferred after cleanupNS(). Otherwise the namespace is deleted and all | ||
| // resources in it. So when TearDown() runs, it spews a lot of not found errors. | ||
| defer TearDown(clients, cleaner, t.Logf) | ||
|
|
||
| // create loggerPod and expose it as a service | ||
| t.Logf("creating logger pod") | ||
| selector := map[string]string{"e2etest": string(uuid.NewUUID())} | ||
| loggerPod := test.EventLoggerPod(loggerPodName, ns, selector) | ||
| loggerSvc := test.Service(loggerPodName, ns, selector) | ||
| loggerPod, err := CreatePodAndServiceReady(clients, loggerPod, loggerSvc, ns, t.Logf, cleaner) | ||
| if err != nil { | ||
| t.Fatalf("Failed to create logger pod and service, and get them ready: %v", err) | ||
| } | ||
|
|
||
| // create channels | ||
| t.Logf("Creating Channel and Subscription") | ||
| channels := make([]*v1alpha1.Channel, 0) | ||
| for _, channelName := range channelNames { | ||
| channel := test.Channel(channelName, ns, test.ClusterChannelProvisioner(test.EventingFlags.Provisioner)) | ||
| t.Logf("channel: %#v", channel) | ||
| channels = append(channels, channel) | ||
| } | ||
|
|
||
| // create subscriptions | ||
| subs := make([]*v1alpha1.Subscription, 0) | ||
| // create subscriptions that subscribe the first channel, and reply events directly to the second channel | ||
| for _, subscriptionName := range subscriptionNames1 { | ||
| sub := test.Subscription(subscriptionName, ns, test.ChannelRef(channelNames[0]), nil, test.ReplyStrategyForChannel(channelNames[1])) | ||
| t.Logf("sub: %#v", sub) | ||
| subs = append(subs, sub) | ||
| } | ||
| // create subscriptions that subscribe the second channel, and call the logging service | ||
| for _, subscriptionName := range subscriptionNames2 { | ||
| sub := test.Subscription(subscriptionName, ns, test.ChannelRef(channelNames[1]), test.SubscriberSpecForService(loggerPodName), nil) | ||
| t.Logf("sub: %#v", sub) | ||
| subs = append(subs, sub) | ||
| } | ||
|
|
||
| // wait for all channels and subscriptions to become ready | ||
| if err := WithChannelsAndSubscriptionsReady(clients, &channels, &subs, t.Logf, cleaner); err != nil { | ||
| t.Fatalf("The Channel or Subscription were not marked as Ready: %v", err) | ||
| } | ||
|
|
||
| // send fake CloudEvent to the first channel | ||
| body := fmt.Sprintf("TestChannelChainEvent %s", uuid.NewUUID()) | ||
| event := &test.CloudEvent{ | ||
| Source: senderName, | ||
| Type: test.CloudEventDefaultType, | ||
| Data: fmt.Sprintf(`{"msg":%q}`, body), | ||
| Encoding: test.CloudEventDefaultEncoding, | ||
| } | ||
| if err := SendFakeEventToChannel(clients, event, channels[0], ns, t.Logf, cleaner); err != nil { | ||
| t.Fatalf("Failed to send fake CloudEvent to the channel %q", channels[0].Name) | ||
| } | ||
|
|
||
| // check if the logging service receives the correct number of event messages | ||
| expectedContentCount := len(subscriptionNames1) * len(subscriptionNames2) | ||
| if err := WaitForLogContentCount(clients, loggerPodName, loggerPod.Spec.Containers[0].Name, body, expectedContentCount); err != nil { | ||
| t.Fatalf("String %q does not appear %d times in logs of logger pod %q: %v", body, expectedContentCount, loggerPodName, err) | ||
| } | ||
| } |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.