-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Initialize load testing #3554
Closed
Closed
Initialize load testing #3554
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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 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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// +build conformance e2e examples | ||
// +build conformance e2e examples load | ||
|
||
/* | ||
Copyright 2019 The Tekton Authors | ||
|
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,69 @@ | ||
#!/usr/bin/env bash | ||
|
||
# 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. | ||
|
||
# This script calls out to scripts in tektoncd/plumbing to setup a cluster | ||
# and deploy Tekton Pipelines to it for running integration tests. | ||
|
||
source $(git rev-parse --show-toplevel)/vendor/github.com/tektoncd/plumbing/scripts/library.sh | ||
|
||
function fail_test() { | ||
echo "***************************************" | ||
echo "*** LOAD TESTS FAILED ***" | ||
echo "*** Start of information dump ***" | ||
echo "***************************************" | ||
echo ">>> All resources:" | ||
kubectl get all --all-namespaces | ||
echo ">>> Services:" | ||
kubectl get services --all-namespaces | ||
echo ">>> Events:" | ||
kubectl get events --all-namespaces | ||
function_exists dump_extra_cluster_state && dump_extra_cluster_state | ||
echo "***************************************" | ||
echo "*** LOAD TESTS FAILED ***" | ||
echo "*** End of information dump ***" | ||
echo "***************************************" | ||
exit 1 | ||
} | ||
|
||
function success() { | ||
echo "**************************************" | ||
echo "*** LOAD TESTS PASSED ***" | ||
echo "**************************************" | ||
exit 0 | ||
} | ||
|
||
TIMEOUT="10m" | ||
TASKRUN_NUM=50 | ||
|
||
while [[ $# -ne 0 ]]; do | ||
parameter=$1 | ||
[[ $# -ge 2 ]] || abort "missing parameter after $1" | ||
shift | ||
case ${parameter} in | ||
--timeout) TIMEOUT=$1 ;; | ||
--taskrun-num) TASKRUN_NUM=$1 ;; | ||
*) abort "unknown option ${parameter}" ;; | ||
esac | ||
shift | ||
done | ||
|
||
# Script entry point. | ||
header "Running load tests" | ||
|
||
report_go_test -tags load -timeout ${TIMEOUT} ./test/ -taskrun-num ${TASKRUN_NUM} || failed=1 | ||
|
||
(( failed )) && fail_test | ||
success |
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,80 @@ | ||
// +build load | ||
|
||
/* | ||
Copyright 2020 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 ( | ||
"context" | ||
"flag" | ||
"sync" | ||
"testing" | ||
|
||
"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" | ||
corev1 "k8s.io/api/core/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
knativetest "knative.dev/pkg/test" | ||
"knative.dev/pkg/test/helpers" | ||
) | ||
|
||
var ( | ||
taskrunNum = flag.Int("taskrun-num", 50, "Number of TaskRun") | ||
) | ||
|
||
// TestPerformance creates multiple builds and checks that each of them has only one build pod. | ||
func TestPerformance(t *testing.T) { | ||
t.Parallel() | ||
|
||
ctx, cancel := context.WithCancel(context.Background()) | ||
defer cancel() | ||
c, namespace := setup(ctx, t) | ||
|
||
knativetest.CleanupOnInterrupt(func() { tearDown(ctx, t, c, namespace) }, t.Logf) | ||
defer tearDown(ctx, t, c, namespace) | ||
|
||
var wg sync.WaitGroup | ||
for i := 0; i < *taskrunNum; i++ { | ||
wg.Add(1) | ||
taskrunName := helpers.ObjectNameForTest(t) | ||
t.Logf("Creating taskrun %q.", taskrunName) | ||
|
||
taskrun := &v1beta1.TaskRun{ | ||
ObjectMeta: metav1.ObjectMeta{Name: taskrunName, Namespace: namespace}, | ||
Spec: v1beta1.TaskRunSpec{ | ||
TaskSpec: &v1beta1.TaskSpec{ | ||
Steps: []v1beta1.Step{{Container: corev1.Container{ | ||
Image: "busybox", | ||
Command: []string{"/bin/echo"}, | ||
Args: []string{"simple"}, | ||
}}}, | ||
}, | ||
}, | ||
} | ||
if _, err := c.TaskRunClient.Create(ctx, taskrun, metav1.CreateOptions{}); err != nil { | ||
t.Fatalf("Error creating taskrun: %v", err) | ||
} | ||
go func(t *testing.T) { | ||
defer wg.Done() | ||
|
||
if err := WaitForTaskRunState(ctx, c, taskrunName, TaskRunSucceed(taskrunName), "TaskRunDuplicatePodTaskRunSuccess"); err != nil { | ||
t.Errorf("Error waiting for TaskRun to finish: %s", err) | ||
return | ||
} | ||
}(t) | ||
} | ||
wg.Wait() | ||
} |
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.
Any reason for creating the
TaskRun
synchronously ?