Skip to content

Commit cb1b58f

Browse files
committed
Revert "Added content for Creating a custom integration test for upstream"
This reverts commit f49b125.
1 parent f49b125 commit cb1b58f

File tree

1 file changed

+1
-180
lines changed

1 file changed

+1
-180
lines changed
Lines changed: 1 addition & 180 deletions
Original file line numberDiff line numberDiff line change
@@ -1,180 +1 @@
1-
= Creating a custom integration test
2-
3-
In {ProductName}, you can create your own integration tests to run on all components of a given application before they are deployed.
4-
5-
.Procedure
6-
7-
To create any custom test, complete the following steps:
8-
9-
. In your preferred IDE, create a Tekton pipeline in a `.yaml` file.
10-
11-
. Within that pipeline, create tasks, which define the actual steps of the test that {ProductName} executes against images before deploying them.
12-
13-
. Commit the `.yaml` file to a GitHub repo and add it as an integration test in {ProductName}.
14-
15-
.Procedure with example
16-
17-
To create a custom test that checks that your app serves the text “Hello world!”, complete the following steps:
18-
19-
. In your preferred IDE, create a new `.yaml` file, with a name of your choosing.
20-
21-
. Define a new Tekton pipeline. The following example is the beginning of a pipeline that uses `curl` to check that the app serves the text “Hello world!”.
22-
23-
+
24-
Example pipeline file:
25-
26-
+
27-
[source]
28-
----
29-
kind: Pipeline
30-
apiVersion: tekton.dev/v1beta1
31-
metadata:
32-
name: example-pipeline
33-
spec:
34-
params:
35-
- description: 'Snapshot of the application'
36-
name: SNAPSHOT
37-
default: '{"components": [{"name":"test-app", "containerImage": "quay.io/example/repo:latest"}]}'
38-
type: string
39-
tasks:
40-
----
41-
42-
. In the `.pipeline.spec` path, declare a new task.
43-
44-
+
45-
Example task declaration:
46-
47-
+
48-
[source]
49-
----
50-
tasks:
51-
- name: task-1
52-
description: Placeholder task that prints the Snapshot and outputs standard TEST_OUTPUT
53-
params:
54-
- name: SNAPSHOT
55-
value: $(params.SNAPSHOT)
56-
taskSpec:
57-
params:
58-
- name: SNAPSHOT
59-
results:
60-
- name: TEST_OUTPUT
61-
description: Test output
62-
steps:
63-
- image: registry.redhat.io/openshift4/ose-cli:latest
64-
env:
65-
- name: SNAPSHOT
66-
value: $(params.SNAPSHOT)
67-
script: |
68-
dnf -y install jq
69-
70-
echo -e "Example test task for the Snapshot:\n ${SNAPSHOT}"
71-
// Run custom tests for the given Snapshot here
72-
// After the tests finish, record the overall result in the RESULT variable
73-
RESULT="SUCCESS"
74-
75-
// Output the standardized TEST_OUTPUT result in JSON form
76-
TEST_OUTPUT=$(jq -rc --arg date $(date +%s) --arg RESULT "${RESULT}" --null-input \
77-
'{result: $RESULT, timestamp: $date, failures: 0, successes: 1, warnings: 0}')
78-
echo -n "${TEST_OUTPUT}" | tee $(results.TEST_OUTPUT.path)
79-
80-
----
81-
82-
. Save the `.yaml` file.
83-
84-
.. If you haven’t already, commit this file to a GitHub repository that {ProductName} can access.
85-
86-
+
87-
Complete example file:
88-
89-
+
90-
[source]
91-
----
92-
kind: Pipeline
93-
apiVersion: tekton.dev/v1beta1
94-
metadata:
95-
name: example-pipeline
96-
spec:
97-
params:
98-
- description: 'Snapshot of the application'
99-
name: SNAPSHOT
100-
default: '{"components": [{"name":"test-app", "containerImage": "quay.io/example/repo:latest"}]}'
101-
type: string
102-
- description: 'Namespace where the application is running'
103-
name: NAMESPACE
104-
default: "default"
105-
type: string
106-
- description: 'Expected output'
107-
name: EXPECTED_OUTPUT
108-
default: "Hello World!"
109-
type: string
110-
workspaces:
111-
- name: cluster-credentials
112-
optional: true
113-
tasks:
114-
- name: task-1
115-
description: Placeholder task that prints the Snapshot and outputs standard TEST_OUTPUT
116-
params:
117-
- name: SNAPSHOT
118-
value: $(params.SNAPSHOT)
119-
taskSpec:
120-
params:
121-
- name: SNAPSHOT
122-
results:
123-
- name: TEST_OUTPUT
124-
description: Test output
125-
steps:
126-
- image: registry.redhat.io/openshift4/ose-cli:latest
127-
env:
128-
- name: SNAPSHOT
129-
value: $(params.SNAPSHOT)
130-
script: |
131-
dnf -y install jq
132-
echo -e "Example test task for the Snapshot:\n ${SNAPSHOT}"
133-
// Run custom tests for the given Snapshot here
134-
// After the tests finish, record the overall result in the RESULT variable
135-
RESULT="SUCCESS"
136-
137-
// Output the standardized TEST_OUTPUT result in JSON form
138-
TEST_OUTPUT=$(jq -rc --arg date $(date +%s) --arg RESULT "${RESULT}" --null-input \
139-
'{result: $RESULT, timestamp: $date, failures: 0, successes: 1, warnings: 0}')
140-
echo -n "${TEST_OUTPUT}" | tee $(results.TEST_OUTPUT.path)
141-
----
142-
143-
. Add your new custom test as an integration test in {ProductName}.
144-
145-
.. For additional instructions on adding an integration test, see this document: xref:how-to-guides/testing_applications/proc_adding_an_integration_test.adoc[Adding an integration test].
146-
147-
.Data injected into the PipelineRun of the integration test
148-
149-
When you create a custom integration test, {ProductName} automatically adds certain parameters, workspaces, and labels to the PipelineRun of the integration test. This section explains what those parameters, workspaces, and labels are, and how they can help you.
150-
151-
Parameters:
152-
153-
* *`SNAPSHOT`*: contains the xref:../../glossary/index.adoc#_snapshot[snapshot] of the whole application as a JSON string. This JSON string provides useful information about the test, such as which components {ProductName} is testing, and what git repository and commit {ProductName} is using to build those components. For information about snapshot JSON string, see link:https://github.com/konflux-ci/integration-examples/blob/main/examples/snapshot_json_string_example[an example snapshot JSON string].
154-
155-
Labels:
156-
157-
* *`appstudio.openshift.io/application`*: contains the name of the application.
158-
159-
* *`appstudio.openshift.io/component`*: contains the name of the component.
160-
161-
* *`appstudio.openshift.io/snapshot`*: contains the name of the snapshot.
162-
163-
* *`test.appstudio.openshift.io/optional`*: contains the optional flag, which specifies whether or not components must pass the integration test before deployment.
164-
165-
* *`test.appstudio.openshift.io/scenario`*: contains the name of the integration test (this label ends with "scenario," because each test is technically a custom resource called an `IntegrationTestScenario`).
166-
167-
168-
.Verification
169-
170-
After adding the integration test to an application, you need to trigger a new build of its components to make {ProductName} run the integration test. Make a commit to the GitHub repositories of your components to trigger a new build.
171-
172-
When the new build is finished, complete the following steps in the {ProductName} console:
173-
174-
. Go to the *Integration tests* tab and select the highlighted name of your test.
175-
176-
. Go to the *Pipeline runs* tab of that test and select the most recent run.
177-
178-
. On the *Details* page, see if the test succeeded for that component. Select the other tabs to view more details.
179-
180-
.. If you used our example script, switch to the *Logs* tab and verify that the test printed “Hello world!”.
1+
= Creating a custom integration test

0 commit comments

Comments
 (0)