Skip to content
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

Add Regression test for large number of Triggers #449

Merged
merged 1 commit into from
Feb 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,13 @@ be used to run only [the unit tests](#unit-tests), i.e.:
// +build e2e
```

#### Cleaning up cluster-scoped resources

Each integration test runs in its own Namespace; each Namespace is torn down
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

after its integration test completes. However, cluster-scoped resources will not
be deleted when the Namespace is deleted. So, each test must delete all the
cluster-scoped resources that it creates.

#### Setup tests

The `setup` function in [init_tests.go](./init_test.go) will initialize client
Expand Down
62 changes: 62 additions & 0 deletions test/eventlistener_scale_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// +build e2e

/*
Copyright 2019 The Tekton 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 test

import (
"fmt"
"testing"

bldr "github.com/tektoncd/triggers/test/builder"
knativetest "knative.dev/pkg/test"
)

/*
* Test creating an EventListener with a large number of Triggers.
* This is a regression test for issue #356.
*/
func TestEventListenerScale(t *testing.T) {
c, namespace := setup(t)
t.Parallel()

defer tearDown(t, c, namespace)
knativetest.CleanupOnInterrupt(func() { tearDown(t, c, namespace) }, t.Logf)

t.Log("Start EventListener Scale e2e test")

// Create an EventListener with 1000 Triggers
var err error
el := bldr.EventListener("my-eventlistener", namespace)
for i := 0; i < 1000; i++ {
trigger := bldr.Trigger("my-triggertemplate", "v1alpha1",
bldr.EventListenerTriggerBinding("my-triggerbinding", "", "v1alpha1"),
)
trigger.Name = fmt.Sprintf("%d", i)
el.Spec.Triggers = append(el.Spec.Triggers, trigger)
}
el, err = c.TriggersClient.TektonV1alpha1().EventListeners(namespace).Create(el)
if err != nil {
t.Fatalf("Error creating EventListener: %s", err)
}

// Verify that the EventListener was created properly
if err := WaitFor(eventListenerReady(t, c, namespace, el.Name)); err != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to verify that the EL actually contains the 1000 triggers?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or perhaps that the sink got created?

Copy link
Member Author

@ncskier ncskier Feb 20, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should verify that the sink got created, right? Because it waits for the sink Pod to be ready.

As for verifying that the EventListener actually contains the 1000 Triggers... I guess we could trigger an event to fire all of the Triggers (maybe create a TaskRun or something?). I don't know if this would stress out our test cluster though 😅

Or do you mean just checking the length of the Triggers array in the EventListener returned after creation?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahh you are right...I did not notice that it actually waits for the sink to be created

Copy link
Member Author

@ncskier ncskier Feb 20, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about verifying the 1000 Triggers? Do you think it's alright without that? (I assume yes, since you merged the PR 😄)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we have other tests that verify that we support multiple triggers

t.Fatalf("EventListener is not ready: %s", err)
}
t.Log("EventListener is ready")
}
12 changes: 12 additions & 0 deletions test/eventlistener_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,18 @@ func TestEventListenerCreate(t *testing.T) {
t.Fatalf("Failed to delete EventListener Service: %s", err)
}
t.Log("EventListener's Service was deleted")

// Cleanup cluster-scoped resources
t.Logf("Deleting cluster-scoped resources")
if err := c.KubeClient.RbacV1().ClusterRoles().Delete("my-role", &metav1.DeleteOptions{}); err != nil {
t.Errorf("Failed to delete clusterrole my-role: %s", err)
}
if err := c.KubeClient.RbacV1().ClusterRoleBindings().Delete("my-rolebinding", &metav1.DeleteOptions{}); err != nil {
t.Errorf("Failed to delete clusterrolebinding my-rolebinding: %s", err)
}
if err := c.TriggersClient.TektonV1alpha1().ClusterTriggerBindings().Delete("my-clustertriggerbinding", &metav1.DeleteOptions{}); err != nil {
t.Errorf("Failed to delete clustertriggerbinding my-clustertriggerbinding: %s", err)
}
}

// The structure of this field corresponds to values for the `license` key in
Expand Down
13 changes: 0 additions & 13 deletions test/init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,19 +104,6 @@ func tearDown(t *testing.T, cs *clients, namespace string) {
t.Errorf("Failed to delete namespace %s: %s", namespace, err)
}
}

t.Logf("Deleting Clusterscoped resource")
if err := cs.KubeClient.RbacV1().ClusterRoles().Delete("my-role", &metav1.DeleteOptions{}); err != nil {
t.Errorf("Failed to delete clusterrole my-role: %s", err)
}

if err := cs.KubeClient.RbacV1().ClusterRoleBindings().Delete("my-rolebinding", &metav1.DeleteOptions{}); err != nil {
t.Errorf("Failed to delete clusterrolebinding my-rolebinding: %s", err)
}

if err := cs.TriggersClient.TektonV1alpha1().ClusterTriggerBindings().Delete("my-clustertriggerbinding", &metav1.DeleteOptions{}); err != nil {
t.Errorf("Failed to delete clustertriggerbinding my-clustertriggerbinding: %s", err)
}
}

func header(logf logging.FormatLogger, text string) {
Expand Down