-
Notifications
You must be signed in to change notification settings - Fork 630
set trigger status appropriately if they do not have broker #3144
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
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,74 @@ | ||
| /* | ||
| 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 helpers | ||
|
|
||
| import ( | ||
| "strings" | ||
| "testing" | ||
| "time" | ||
|
|
||
| corev1 "k8s.io/api/core/v1" | ||
| metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
| "k8s.io/apimachinery/pkg/util/wait" | ||
| "knative.dev/eventing/test/lib" | ||
| "knative.dev/eventing/test/lib/resources" | ||
| ) | ||
|
|
||
| const ( | ||
| brokerName = "notdefaultbroker" | ||
| ) | ||
|
|
||
| // TestTriggerNoBroker will create a Trigger with a non-existent broker, then it will ensure | ||
| // the Status is correctly reflected as failed with BrokerDoesNotExist. Then it will create | ||
| // the broker and ensure that Trigger / Broker will get to Ready state. | ||
| func TestTriggerNoBroker(t *testing.T, channel string, brokerCreator BrokerCreator) { | ||
| client := lib.Setup(t, true) | ||
| defer lib.TearDown(client) | ||
| brokerName := strings.ToLower(channel) | ||
| subscriberName := name("dumper", "", "", map[string]interface{}{}) | ||
| pod := resources.EventLoggerPod(subscriberName) | ||
| client.CreatePodOrFail(pod, lib.WithService(subscriberName)) | ||
| client.CreateTriggerOrFailV1Beta1("testtrigger", | ||
| resources.WithSubscriberServiceRefForTriggerV1Beta1(subscriberName), | ||
| resources.WithBrokerV1Beta1(brokerName), | ||
| ) | ||
|
|
||
| // Then make sure the trigger is marked as not ready since there's no broker. | ||
| err := wait.PollImmediate(1*time.Second, 10*time.Second, func() (bool, error) { | ||
| trigger, err := client.Eventing.EventingV1beta1().Triggers(client.Namespace).Get("testtrigger", metav1.GetOptions{}) | ||
| if err != nil { | ||
| return false, err | ||
| } | ||
| if ready := trigger.Status.GetTopLevelCondition(); ready != nil { | ||
| if ready.Status == corev1.ConditionFalse && ready.Reason == "BrokerDoesNotExist" { | ||
| return true, nil | ||
| } | ||
| } | ||
| return false, nil | ||
| }) | ||
| if err != nil { | ||
| t.Fatalf("Trigger status did not get marked as BrokerDoesNotExist: %s", err) | ||
| } | ||
|
|
||
| // Then create the Broker and just make sure they both come ready. | ||
| if bn := brokerCreator(client); bn != brokerName { | ||
| t.Fatalf("Broker created with unexpected name, wanted %q got %q", brokerName, bn) | ||
| } | ||
|
|
||
| // Wait for all test resources to become ready before sending the events. | ||
| client.WaitForAllTestResourcesReadyOrFail() | ||
| } | ||
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,33 @@ | ||
| // +build e2e | ||
|
|
||
| /* | ||
| 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 e2e | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
| "knative.dev/eventing/test/e2e/helpers" | ||
| "knative.dev/eventing/test/lib" | ||
| ) | ||
|
|
||
| func TestTriggerNoBroker(t *testing.T) { | ||
| channelTestRunner.RunTests(t, lib.FeatureBasic, func(t *testing.T, channel metav1.TypeMeta) { | ||
| helpers.TestTriggerNoBroker(t, channel.Kind, helpers.ChannelBasedBrokerCreator(channel, brokerClass)) | ||
| }) | ||
| } |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the reason is passed as a parameter this test is a valid conformance test for the control-plane conformance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean, we could run multiple tests validations for failures? Yes, good point. I'm down to make that change, but I'd prefer to do that in a followup to make sure we get this error case handled into the release :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean, the broker conformance spec doesn't force using
BrokerDoesNotExistas a reason for the trigger to not become ready if there is no broker;if the test has the reason as param implementors can reuse this test without changing the reason they're using (maybe they're using
BrokerNotFoundrather thanBrokerDoesNotExist).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, that makes sense. As I mentioned above I'm all for it, but would prefer to do that in a followup? Ok with you?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Of course 😄