Skip to content

Commit 09cac33

Browse files
eddycharlyswiatekm
andauthored
chore: chainsaw improvements (#2642)
Signed-off-by: Charles-Edouard Brétéché <[email protected]> Co-authored-by: Mikołaj Świątek <[email protected]>
1 parent a62a081 commit 09cac33

File tree

26 files changed

+189
-293
lines changed

26 files changed

+189
-293
lines changed

CONTRIBUTING.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,11 @@ KUBEBUILDER_ASSETS=$(./bin/setup-envtest use -p path 1.23) go test ./pkg...
120120

121121
To run the end-to-end tests, you'll need [`kind`](https://kind.sigs.k8s.io) and [`chainsaw`](https://kyverno.github.io/chainsaw). Refer to their documentation for installation instructions.
122122

123-
Once they are installed, the tests can be executed with `make prepare-e2e`, which will build an image to use with the tests, followed by `make e2e`. Each call to the `e2e` target will setup a fresh `kind` cluster, making it safe to be executed multiple times with a single `prepare-e2e` step.
123+
Once they are installed, the tests can be executed with `make prepare-e2e`, which will build an image to use with the tests, followed by `make e2e`. Each call to the `e2e` target will set up a fresh `kind` cluster, making it safe to be executed multiple times with a single `prepare-e2e` step.
124124

125125
The tests are located under `tests/e2e` and are written to be used with `chainsaw`. Refer to their documentation to understand how tests are written.
126126

127-
To evert the changes made by the `make prepare-e2e` run `make reset`.
127+
To revert the changes made by the `make prepare-e2e` run `make reset`.
128128

129129
### OpenShift End to End tests
130130
To run the end-to-end tests written for OpenShift, you'll need a OpenShift cluster.

Makefile

+3-16
Original file line numberDiff line numberDiff line change
@@ -361,18 +361,13 @@ CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
361361
ENVTEST ?= $(LOCALBIN)/setup-envtest
362362
CHLOGGEN ?= $(LOCALBIN)/chloggen
363363
GOLANGCI_LINT ?= $(LOCALBIN)/golangci-lint
364+
CHAINSAW ?= $(LOCALBIN)/chainsaw
364365

365366
KUSTOMIZE_VERSION ?= v5.0.3
366367
CONTROLLER_TOOLS_VERSION ?= v0.12.0
367368
GOLANGCI_LINT_VERSION ?= v1.54.0
368369
KIND_VERSION ?= v0.20.0
369-
370-
# Checks if chainsaw is in your PATH
371-
ifneq ($(shell which chainsaw),)
372-
CHAINSAW ?= $(shell which chainsaw)
373-
else
374-
CHAINSAW ?= $(LOCALBIN)/chainsaw
375-
endif
370+
CHAINSAW_VERSION ?= v0.1.4
376371

377372
.PHONY: install-tools
378373
install-tools: kustomize golangci-lint kind controller-gen envtest crdoc kind operator-sdk chainsaw
@@ -406,15 +401,7 @@ crdoc: ## Download crdoc locally if necessary.
406401

407402
.PHONY: chainsaw
408403
chainsaw: ## Find or download chainsaw
409-
ifeq (, $(shell which chainsaw))
410-
@{ \
411-
set -e ;\
412-
go install github.com/kyverno/[email protected] ;\
413-
}
414-
CHAINSAW ?= $(GOBIN)/chainsaw
415-
else
416-
CHAINSAW ?= $(shell which chainsaw)
417-
endif
404+
$(call go-get-tool,$(CHAINSAW), github.com/kyverno/chainsaw,$(CHAINSAW_VERSION))
418405

419406
# go-get-tool will 'go get' any package $2 and install it to $1.
420407
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))

tests/e2e-instrumentation/instrumentation-apache-httpd/chainsaw-test.yaml

+5-17
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,16 @@
22
apiVersion: chainsaw.kyverno.io/v1alpha1
33
kind: Test
44
metadata:
5-
creationTimestamp: null
65
name: instrumentation-apache-httpd
76
spec:
7+
namespaceTemplate:
8+
metadata:
9+
annotations:
10+
openshift.io/sa.scc.uid-range: 1000/1000
11+
openshift.io/sa.scc.supplemental-groups: 3000/1000
812
steps:
913
- name: step-00
1014
try:
11-
- command:
12-
args:
13-
- annotate
14-
- namespace
15-
- ${NAMESPACE}
16-
- openshift.io/sa.scc.uid-range=1000/1000
17-
- --overwrite
18-
entrypoint: kubectl
19-
- command:
20-
args:
21-
- annotate
22-
- namespace
23-
- ${NAMESPACE}
24-
- openshift.io/sa.scc.supplemental-groups=3000/1000
25-
- --overwrite
26-
entrypoint: kubectl
2715
- apply:
2816
file: 00-install-collector.yaml
2917
- apply:

tests/e2e-instrumentation/instrumentation-dotnet-musl/chainsaw-test.yaml

+5-16
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,14 @@ metadata:
55
creationTimestamp: null
66
name: instrumentation-dotnet-musl
77
spec:
8+
namespaceTemplate:
9+
metadata:
10+
annotations:
11+
openshift.io/sa.scc.uid-range: 1000/1000
12+
openshift.io/sa.scc.supplemental-groups: 2000/1000
813
steps:
914
- name: step-00
1015
try:
11-
- command:
12-
args:
13-
- annotate
14-
- namespace
15-
- ${NAMESPACE}
16-
- openshift.io/sa.scc.uid-range=1000/1000
17-
- --overwrite
18-
entrypoint: kubectl
19-
- command:
20-
args:
21-
- annotate
22-
- namespace
23-
- ${NAMESPACE}
24-
- openshift.io/sa.scc.supplemental-groups=2000/1000
25-
- --overwrite
26-
entrypoint: kubectl
2716
- apply:
2817
file: 00-install-collector.yaml
2918
- apply:

tests/e2e-instrumentation/instrumentation-dotnet/chainsaw-test.yaml

+5-16
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,14 @@ metadata:
55
creationTimestamp: null
66
name: instrumentation-dotnet
77
spec:
8+
namespaceTemplate:
9+
metadata:
10+
annotations:
11+
openshift.io/sa.scc.uid-range: 1000/1000
12+
openshift.io/sa.scc.supplemental-groups: 2000/1000
813
steps:
914
- name: step-00
1015
try:
11-
- command:
12-
args:
13-
- annotate
14-
- namespace
15-
- ${NAMESPACE}
16-
- openshift.io/sa.scc.uid-range=1000/1000
17-
- --overwrite
18-
entrypoint: kubectl
19-
- command:
20-
args:
21-
- annotate
22-
- namespace
23-
- ${NAMESPACE}
24-
- openshift.io/sa.scc.supplemental-groups=2000/1000
25-
- --overwrite
26-
entrypoint: kubectl
2716
- apply:
2817
file: 00-install-collector.yaml
2918
- apply:

tests/e2e-instrumentation/instrumentation-go/chainsaw-test.yaml

+5-6
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ metadata:
55
creationTimestamp: null
66
name: instrumentation-go
77
spec:
8+
namespaceTemplate:
9+
metadata:
10+
annotations:
11+
openshift.io/sa.scc.uid-range: 0/0
12+
openshift.io/sa.scc.supplemental-groups: 2000/1000
813
steps:
914
- name: step-00
1015
try:
@@ -14,12 +19,6 @@ spec:
1419
file: 00-install-instrumentation.yaml
1520
- name: step-01
1621
try:
17-
- script:
18-
content: kubectl annotate namespace ${NAMESPACE} openshift.io/sa.scc.uid-range=0/0
19-
--overwrite
20-
- script:
21-
content: kubectl annotate namespace ${NAMESPACE} openshift.io/sa.scc.supplemental-groups=2000/1000
22-
--overwrite
2322
- script:
2423
content: ./add-scc.sh
2524
- apply:

tests/e2e-instrumentation/instrumentation-java-other-ns/chainsaw-test.yaml

+5-16
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ metadata:
55
creationTimestamp: null
66
name: instrumentation-java-other-ns
77
spec:
8+
namespaceTemplate:
9+
metadata:
10+
annotations:
11+
openshift.io/sa.scc.uid-range: 1000/1000
12+
openshift.io/sa.scc.supplemental-groups: 2000/1000
813
steps:
914
- name: step-01
1015
try:
@@ -15,22 +20,6 @@ spec:
1520
name: my-other-ns
1621
- name: step-02
1722
try:
18-
- command:
19-
args:
20-
- annotate
21-
- namespace
22-
- ${NAMESPACE}
23-
- openshift.io/sa.scc.uid-range=1000/1000
24-
- --overwrite
25-
entrypoint: kubectl
26-
- command:
27-
args:
28-
- annotate
29-
- namespace
30-
- ${NAMESPACE}
31-
- openshift.io/sa.scc.supplemental-groups=2000/1000
32-
- --overwrite
33-
entrypoint: kubectl
3423
- apply:
3524
file: 02-install-collector.yaml
3625
- apply:

tests/e2e-instrumentation/instrumentation-java/chainsaw-test.yaml

+5-16
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,14 @@ metadata:
55
creationTimestamp: null
66
name: instrumentation-java
77
spec:
8+
namespaceTemplate:
9+
metadata:
10+
annotations:
11+
openshift.io/sa.scc.uid-range: 1000/1000
12+
openshift.io/sa.scc.supplemental-groups: 2000/1000
813
steps:
914
- name: step-00
1015
try:
11-
- command:
12-
args:
13-
- annotate
14-
- namespace
15-
- ${NAMESPACE}
16-
- openshift.io/sa.scc.uid-range=1000/1000
17-
- --overwrite
18-
entrypoint: kubectl
19-
- command:
20-
args:
21-
- annotate
22-
- namespace
23-
- ${NAMESPACE}
24-
- openshift.io/sa.scc.supplemental-groups=2000/1000
25-
- --overwrite
26-
entrypoint: kubectl
2716
- apply:
2817
file: 00-install-collector.yaml
2918
- apply:

tests/e2e-instrumentation/instrumentation-nginx-contnr-secctx/chainsaw-test.yaml

+5-16
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,14 @@ metadata:
55
creationTimestamp: null
66
name: instrumentation-nginx-contnr-secctx
77
spec:
8+
namespaceTemplate:
9+
metadata:
10+
annotations:
11+
openshift.io/sa.scc.uid-range: 1000/1000
12+
openshift.io/sa.scc.supplemental-groups: 3000/1000
813
steps:
914
- name: step-00
1015
try:
11-
- command:
12-
args:
13-
- annotate
14-
- namespace
15-
- ${NAMESPACE}
16-
- openshift.io/sa.scc.uid-range=1000/1000
17-
- --overwrite
18-
entrypoint: kubectl
19-
- command:
20-
args:
21-
- annotate
22-
- namespace
23-
- ${NAMESPACE}
24-
- openshift.io/sa.scc.supplemental-groups=3000/1000
25-
- --overwrite
26-
entrypoint: kubectl
2716
- apply:
2817
file: 00-install-collector.yaml
2918
- apply:

tests/e2e-instrumentation/instrumentation-nginx-multicontainer/chainsaw-test.yaml

+5-16
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,14 @@ metadata:
55
creationTimestamp: null
66
name: instrumentation-nginx-multicontainer
77
spec:
8+
namespaceTemplate:
9+
metadata:
10+
annotations:
11+
openshift.io/sa.scc.uid-range: 1000/1000
12+
openshift.io/sa.scc.supplemental-groups: 3000/1000
813
steps:
914
- name: step-00
1015
try:
11-
- command:
12-
args:
13-
- annotate
14-
- namespace
15-
- ${NAMESPACE}
16-
- openshift.io/sa.scc.uid-range=1000/1000
17-
- --overwrite
18-
entrypoint: kubectl
19-
- command:
20-
args:
21-
- annotate
22-
- namespace
23-
- ${NAMESPACE}
24-
- openshift.io/sa.scc.supplemental-groups=3000/1000
25-
- --overwrite
26-
entrypoint: kubectl
2716
- apply:
2817
file: 00-install-collector.yaml
2918
- apply:

tests/e2e-instrumentation/instrumentation-nginx/chainsaw-test.yaml

+5-16
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,14 @@ metadata:
55
creationTimestamp: null
66
name: instrumentation-nginx
77
spec:
8+
namespaceTemplate:
9+
metadata:
10+
annotations:
11+
openshift.io/sa.scc.uid-range: 1000/1000
12+
openshift.io/sa.scc.supplemental-groups: 3000/1000
813
steps:
914
- name: step-00
1015
try:
11-
- command:
12-
args:
13-
- annotate
14-
- namespace
15-
- ${NAMESPACE}
16-
- openshift.io/sa.scc.uid-range=1000/1000
17-
- --overwrite
18-
entrypoint: kubectl
19-
- command:
20-
args:
21-
- annotate
22-
- namespace
23-
- ${NAMESPACE}
24-
- openshift.io/sa.scc.supplemental-groups=3000/1000
25-
- --overwrite
26-
entrypoint: kubectl
2716
- apply:
2817
file: 00-install-collector.yaml
2918
- apply:

tests/e2e-instrumentation/instrumentation-nodejs/chainsaw-test.yaml

+5-16
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,14 @@ metadata:
55
creationTimestamp: null
66
name: instrumentation-nodejs
77
spec:
8+
namespaceTemplate:
9+
metadata:
10+
annotations:
11+
openshift.io/sa.scc.uid-range: 1000/1000
12+
openshift.io/sa.scc.supplemental-groups: 2000/1000
813
steps:
914
- name: step-00
1015
try:
11-
- command:
12-
args:
13-
- annotate
14-
- namespace
15-
- ${NAMESPACE}
16-
- openshift.io/sa.scc.uid-range=1000/1000
17-
- --overwrite
18-
entrypoint: kubectl
19-
- command:
20-
args:
21-
- annotate
22-
- namespace
23-
- ${NAMESPACE}
24-
- openshift.io/sa.scc.supplemental-groups=2000/1000
25-
- --overwrite
26-
entrypoint: kubectl
2716
- apply:
2817
file: 00-install-collector.yaml
2918
- apply:

tests/e2e-instrumentation/instrumentation-python/chainsaw-test.yaml

+5-16
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,14 @@ metadata:
55
creationTimestamp: null
66
name: instrumentation-python
77
spec:
8+
namespaceTemplate:
9+
metadata:
10+
annotations:
11+
openshift.io/sa.scc.uid-range: 1000/1000
12+
openshift.io/sa.scc.supplemental-groups: 2000/1000
813
steps:
914
- name: step-00
1015
try:
11-
- command:
12-
args:
13-
- annotate
14-
- namespace
15-
- ${NAMESPACE}
16-
- openshift.io/sa.scc.uid-range=1000/1000
17-
- --overwrite
18-
entrypoint: kubectl
19-
- command:
20-
args:
21-
- annotate
22-
- namespace
23-
- ${NAMESPACE}
24-
- openshift.io/sa.scc.supplemental-groups=2000/1000
25-
- --overwrite
26-
entrypoint: kubectl
2716
- apply:
2817
file: 00-install-collector.yaml
2918
- apply:

0 commit comments

Comments
 (0)