-
Notifications
You must be signed in to change notification settings - Fork 266
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Integration tests for Tekton * Use knative/client instead of fork * also put back the e2e-tests into its original format where it doesn't run the tekton tests * Run ./hack/build.sh with Go 1.12 * Pull buildah and kn tasks directly from catalog * Revert "Use knative/client instead of fork" This reverts commit 2ab272f. * Revert "Revert "Use knative/client instead of fork"" This reverts commit f14c210. * Update Tekton to 0.8.0 * Revert "Use knative/client instead of fork" This reverts commit 2ab272f. * Use knative/client instead of fork This reverts commit 8eb87ad. * Export variables after calling initialize * Run against arbitrary Docker registry * Conditionally install Tekton * Use knative/client instead of fork This reverts commit 3800adb. * Revert "Use knative/client instead of fork" This reverts commit 71a3d33. * Simplify passing the flag to test * Simplify imports
- Loading branch information
1 parent
556f457
commit 60567a9
Showing
14 changed files
with
454 additions
and
34 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/usr/bin/env bash | ||
|
||
# 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. | ||
|
||
source $(dirname $0)/../vendor/knative.dev/test-infra/scripts/e2e-tests.sh | ||
|
||
function cluster_setup() { | ||
header "Building client" | ||
${REPO_ROOT_DIR}/hack/build.sh -f || return 1 | ||
} | ||
|
||
function knative_setup() { | ||
local version=${KNATIVE_VERSION:-latest} | ||
header "Installing Knative serving (${version})" | ||
|
||
if [ "${version}" = "latest" ]; then | ||
start_latest_knative_serving | ||
else | ||
start_release_knative_serving "${version}" | ||
fi | ||
} |
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
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
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,86 @@ | ||
// 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. | ||
|
||
// +build tekton | ||
|
||
package e2e | ||
|
||
import ( | ||
"strings" | ||
"testing" | ||
"time" | ||
|
||
"gotest.tools/assert" | ||
"k8s.io/apimachinery/pkg/util/wait" | ||
"knative.dev/client/pkg/util" | ||
) | ||
|
||
const ( | ||
// Interval specifies the time between two polls. | ||
Interval = 10 * time.Second | ||
// Timeout specifies the timeout for the function PollImmediate to reach a certain status. | ||
Timeout = 5 * time.Minute | ||
) | ||
|
||
func TestTektonPipeline(t *testing.T) { | ||
test := NewE2eTest(t) | ||
test.Setup(t) | ||
|
||
kubectl := kubectl{t, Logger{}} | ||
basedir := currentDir(t) + "/../resources/tekton" | ||
|
||
// create secret for the kn-deployer-account service account | ||
_, err := kubectl.RunWithOpts([]string{"create", "-n", test.env.Namespace, "secret", | ||
"generic", "container-registry", | ||
"--from-file=.dockerconfigjson=" + Flags.DockerConfigJSON, | ||
"--type=kubernetes.io/dockerconfigjson"}, runOpts{}) | ||
assert.NilError(t, err) | ||
|
||
_, err = kubectl.RunWithOpts([]string{"apply", "-n", test.env.Namespace, "-f", basedir + "/kn-deployer-rbac.yaml"}, runOpts{}) | ||
assert.NilError(t, err) | ||
|
||
_, err = kubectl.RunWithOpts([]string{"apply", "-n", test.env.Namespace, "-f", "https://raw.githubusercontent.com/tektoncd/catalog/master/buildah/buildah.yaml"}, runOpts{}) | ||
assert.NilError(t, err) | ||
|
||
_, err = kubectl.RunWithOpts([]string{"apply", "-n", test.env.Namespace, "-f", "https://raw.githubusercontent.com/tektoncd/catalog/master/kn/kn.yaml"}, runOpts{}) | ||
assert.NilError(t, err) | ||
|
||
_, err = kubectl.RunWithOpts([]string{"apply", "-n", test.env.Namespace, "-f", basedir + "/kn-pipeline.yaml"}, runOpts{}) | ||
assert.NilError(t, err) | ||
|
||
_, err = kubectl.RunWithOpts([]string{"apply", "-n", test.env.Namespace, "-f", basedir + "/kn-pipeline-resource.yaml"}, runOpts{}) | ||
assert.NilError(t, err) | ||
|
||
_, err = kubectl.RunWithOpts([]string{"create", "-n", test.env.Namespace, "-f", basedir + "/kn-pipeline-run.yaml"}, runOpts{}) | ||
assert.NilError(t, err) | ||
|
||
err = waitForPipelineSuccess(t, kubectl, test.env.Namespace) | ||
assert.NilError(t, err) | ||
|
||
const serviceName = "hello" | ||
out, err := test.kn.RunWithOpts([]string{"service", "describe", serviceName}, runOpts{NoNamespace: false}) | ||
assert.NilError(t, err) | ||
assert.Assert(t, util.ContainsAll(out, serviceName, test.kn.namespace)) | ||
assert.Assert(t, util.ContainsAll(out, "Conditions", "ConfigurationsReady", "Ready", "RoutesReady")) | ||
|
||
// tear down only if the test passes, we want to keep the pods otherwise | ||
test.Teardown(t) | ||
} | ||
|
||
func waitForPipelineSuccess(t *testing.T, k kubectl, namespace string) error { | ||
return wait.PollImmediate(Interval, Timeout, func() (bool, error) { | ||
out, err := k.RunWithOpts([]string{"get", "pipelinerun", "-n", namespace, "-o=jsonpath='{.items[0].status.conditions[?(@.type==\"Succeeded\")].status}'"}, runOpts{}) | ||
return strings.Contains(out, "True"), err | ||
}) | ||
} |
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,50 @@ | ||
# 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. | ||
# Define a ServiceAccount named kn-deployer-account that has permission to | ||
# manage Knative services. | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: kn-deployer-account | ||
namespace: ${KN_E2E_NAMESPACE}0 | ||
secrets: | ||
- name: container-registry | ||
imagePullSecrets: | ||
- name: container-registry | ||
|
||
--- | ||
|
||
kind: ClusterRole | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
metadata: | ||
name: kn-deployer | ||
rules: | ||
- apiGroups: ["serving.knative.dev"] | ||
resources: ["services"] | ||
verbs: ["get", "list", "create", "update", "delete", "patch", "watch"] | ||
|
||
--- | ||
|
||
apiVersion: rbac.authorization.k8s.io/v1beta1 | ||
kind: ClusterRoleBinding | ||
metadata: | ||
name: kn-deployer-binding | ||
subjects: | ||
- kind: ServiceAccount | ||
name: kn-deployer-account | ||
namespace: ${KN_E2E_NAMESPACE}0 | ||
roleRef: | ||
kind: ClusterRole | ||
name: kn-deployer | ||
apiGroup: rbac.authorization.k8s.io |
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,32 @@ | ||
# 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. | ||
apiVersion: tekton.dev/v1alpha1 | ||
kind: PipelineResource | ||
metadata: | ||
name: buildah-build-kn-create-source | ||
spec: | ||
type: git | ||
params: | ||
- name: url | ||
value: "https://github.com/knative/client" | ||
--- | ||
apiVersion: tekton.dev/v1alpha1 | ||
kind: PipelineResource | ||
metadata: | ||
name: buildah-build-kn-create-image | ||
spec: | ||
type: image | ||
params: | ||
- name: url | ||
value: "${CONTAINER_REGISTRY}/helloworld:tkn" |
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,38 @@ | ||
# 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. | ||
apiVersion: tekton.dev/v1alpha1 | ||
kind: PipelineRun | ||
metadata: | ||
generateName: buildah-build-kn-create- | ||
spec: | ||
serviceAccount: kn-deployer-account | ||
pipelineRef: | ||
name: buildah-build-kn-create | ||
resources: | ||
- name: source | ||
resourceRef: | ||
name: buildah-build-kn-create-source | ||
- name: image | ||
resourceRef: | ||
name: buildah-build-kn-create-image | ||
params: | ||
- name: ARGS | ||
value: | ||
- "service" | ||
- "create" | ||
- "hello" | ||
- "--force" | ||
- "--service-account=kn-deployer-account" | ||
- "--image=$(inputs.resources.image.url)" | ||
- "--env=TARGET=Tekton" |
Oops, something went wrong.