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

[chore] Add a smoke test that is run as part of the scorecard tests V2 #1335

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
11 changes: 4 additions & 7 deletions .github/workflows/scorecard.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,13 @@ jobs:
- name: Check out code into the Go module directory
uses: actions/checkout@v3

- name: "install kuttl and kind"
- name: "install kuttl"
run: ./hack/install-kuttl.sh

- name: "start kind"
- name: "prepare cluster"
env:
KUBE_VERSION: ${{ matrix.kube-version }}
run: kind create cluster --config kind-$KUBE_VERSION.yaml
run: make prepare-e2e KUBE_VERSION=$KUBE_VERSION VERSION=e2e

- name: "wait until cluster is ready"
run: kubectl wait --timeout=5m --for=condition=available deployment/coredns -n kube-system

- name: "run scorecard test"
- name: "run scorecard tests"
run: make scorecard-tests
15 changes: 13 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ OPERATOR_SDK_VERSION ?= 1.27.0

CERTMANAGER_VERSION ?= 1.10.0

SCORECARD_KUTTL_TESTS := \
smoke-simplest \
smoke-sidecar \
instrumentation-java

ifndef ignore-not-found
ignore-not-found = false
endif
Expand Down Expand Up @@ -190,8 +195,9 @@ prepare-e2e: kuttl set-image-controller container container-target-allocator con
TARGETALLOCATOR_IMG=$(TARGETALLOCATOR_IMG) SED_BIN="$(SED)" ./hack/modify-test-images.sh

.PHONY: scorecard-tests
scorecard-tests: operator-sdk
$(OPERATOR_SDK) scorecard -w=5m bundle || (echo "scorecard test failed" && exit 1)
scorecard-tests: operator-sdk bundle-scorecard-kuttl-tests
kubectl apply -f tests/scorecard/rbac.yaml
$(OPERATOR_SDK) scorecard -w=15m bundle || (echo "scorecard test failed" && exit 1)


# Build the container image, used only for local dev purposes
Expand Down Expand Up @@ -377,6 +383,11 @@ bundle: kustomize operator-sdk manifests set-image-controller
$(OPERATOR_SDK) bundle validate ./bundle
./hack/ignore-createdAt-bundle.sh

# Copy selected e2e tests to the kuttl scorecard tests of the bundle
.PHONY: bundle-scorecard-kuttl-tests
bundle-scorecard-kuttl-tests:
for t in $(SCORECARD_KUTTL_TESTS); do cp -r tests/e2e/$$t bundle/tests/scorecard/kuttl; done

# Build the bundle image, used only for local dev purposes
.PHONY: bundle-build
bundle-build:
Expand Down
7 changes: 7 additions & 0 deletions bundle/tests/scorecard/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ apiVersion: scorecard.operatorframework.io/v1alpha3
kind: Configuration
metadata:
name: config
serviceaccount: scorecard-admin
stages:
- parallel: true
tests:
Expand Down Expand Up @@ -45,6 +46,12 @@ stages:
storage:
spec:
mountPath: {}
- image: docker.io/andreasgerstmayr/scorecard-test-kuttl:1681909083
Copy link
Member

Choose a reason for hiding this comment

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

Why is it using a custom image? Could we switch to the upstream one?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same as above (this file is auto-generated from the file above).

labels:
suite: kuttl
storage:
spec:
mountPath: {}
storage:
spec:
mountPath: {}
7 changes: 7 additions & 0 deletions bundle/tests/scorecard/kuttl/kuttl-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: kuttl.dev/v1beta1
kind: TestSuite
parallel: 1
startControlPlane: false
timeout: 120
suppress:
- events
1 change: 1 addition & 0 deletions config/scorecard/bases/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ apiVersion: scorecard.operatorframework.io/v1alpha3
kind: Configuration
metadata:
name: config
serviceaccount: scorecard-admin
stages:
- parallel: true
tests: []
6 changes: 6 additions & 0 deletions config/scorecard/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,10 @@ patchesJson6902:
version: v1alpha3
kind: Configuration
name: config
- path: patches/kuttl.config.yaml
target:
group: scorecard.operatorframework.io
version: v1alpha3
kind: Configuration
name: config
#+kubebuilder:scaffold:patchesJson6902
9 changes: 9 additions & 0 deletions config/scorecard/patches/kuttl.config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
- op: add
path: /stages/0/tests/-
value:
# TODO: Switch to quay.io/operator-framework/scorecard-test-kuttl image
# once https://github.com/operator-framework/operator-sdk/pull/6401 is merged.
# https://github.com/open-telemetry/opentelemetry-operator/issues/1721
image: docker.io/andreasgerstmayr/scorecard-test-kuttl:1681909083
Copy link
Member

Choose a reason for hiding this comment

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

Why is it using a custom image?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It needs kuttl 0.15.0 because this kuttl version contains fixes regarding test cleanup, which is especially important if we run the tests in a single namespace.
Once operator-framework/operator-sdk#6401 is merged and released, we can switch to the official one again.

labels:
suite: kuttl
17 changes: 17 additions & 0 deletions tests/scorecard/rbac.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: scorecard-admin
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: scorecard-admin-rolebinding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-admin
subjects:
- kind: ServiceAccount
name: scorecard-admin
namespace: default