Skip to content

Commit

Permalink
Add a smoke test that is run as part of the scorecard tests
Browse files Browse the repository at this point in the history
Signed-off-by: Kevin Earls <[email protected]>
Co-authored-by: Kevin Earls <[email protected]>

Setup service account and e2e env for kuttl scorecard tests

Signed-off-by: Andreas Gerstmayr <[email protected]>
  • Loading branch information
andreasgerstmayr committed Jan 10, 2023
1 parent 0bdaa9e commit 9385461
Show file tree
Hide file tree
Showing 10 changed files with 141 additions and 10 deletions.
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-scorecard-tests 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
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,13 @@ e2e-log-operator:
prepare-e2e: kuttl set-image-controller container container-target-allocator start-kind cert-manager install-metrics-server install-openshift-routes load-image-all deploy
TARGETALLOCATOR_IMG=$(TARGETALLOCATOR_IMG) ./hack/modify-test-images.sh

.PHONY: prepare-scorecard-tests
prepare-scorecard-tests: prepare-e2e
kubectl apply -f tests/scorecard/rbac.yaml

.PHONY: scorecard-tests
scorecard-tests: operator-sdk
$(OPERATOR_SDK) scorecard -w=5m bundle || (echo "scorecard test failed" && exit 1)
$(OPERATOR_SDK) scorecard --wait-time=5m --service-account=scorecard-admin bundle || (echo "scorecard test failed" && exit 1)


# Build the container image, used only for local dev purposes
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 @@ -45,6 +45,13 @@ stages:
storage:
spec:
mountPath: {}
- image: quay.io/operator-framework/scorecard-test-kuttl:v2.0.0
labels:
suite: kuttlsuite
test: kuttltest1
storage:
spec:
mountPath: {}
storage:
spec:
mountPath: {}
4 changes: 4 additions & 0 deletions bundle/tests/scorecard/kuttl/kuttl-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: kuttl.dev/v1beta1
kind: TestSuite
timeout: 150
startControlPlane: false
64 changes: 64 additions & 0 deletions bundle/tests/scorecard/kuttl/smoketest/00-assert.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: simplest-collector
status:
readyReplicas: 1

---

apiVersion: v1
kind: Service
metadata:
name: simplest-collector-headless
spec:
ports:
- appProtocol: grpc
name: jaeger-grpc
port: 14250
protocol: TCP
targetPort: 14250
- appProtocol: grpc
name: otlp-grpc
port: 4317
protocol: TCP
targetPort: 4317
- appProtocol: http
name: otlp-http
port: 4318
protocol: TCP
targetPort: 4318
- appProtocol: http
name: otlp-http-legacy
port: 55681
protocol: TCP
targetPort: 4318

---

apiVersion: v1
kind: Service
metadata:
name: simplest-collector
spec:
ports:
- appProtocol: grpc
name: jaeger-grpc
port: 14250
protocol: TCP
targetPort: 14250
- appProtocol: grpc
name: otlp-grpc
port: 4317
protocol: TCP
targetPort: 4317
- appProtocol: http
name: otlp-http
port: 4318
protocol: TCP
targetPort: 4318
- appProtocol: http
name: otlp-http-legacy
port: 55681
protocol: TCP
targetPort: 4318
25 changes: 25 additions & 0 deletions bundle/tests/scorecard/kuttl/smoketest/00-install.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
apiVersion: opentelemetry.io/v1alpha1
kind: OpenTelemetryCollector
metadata:
name: simplest
spec:
config: |
receivers:
jaeger:
protocols:
grpc:
otlp:
protocols:
grpc:
http:
processors:
exporters:
logging:
service:
pipelines:
traces:
receivers: [jaeger,otlp]
processors: []
exporters: [logging]
4 changes: 2 additions & 2 deletions config/scorecard/bases/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ kind: Configuration
metadata:
name: config
stages:
- parallel: true
tests: []
- 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/smoke.config.yaml
target:
group: scorecard.operatorframework.io
version: v1alpha3
kind: Configuration
name: config
#+kubebuilder:scaffold:patchesJson6902
7 changes: 7 additions & 0 deletions config/scorecard/patches/smoke.config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
- op: add
path: /stages/0/tests/-
value:
image: quay.io/operator-framework/scorecard-test-kuttl:v2.0.0
labels:
suite: kuttlsuite
test: kuttltest1
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

0 comments on commit 9385461

Please sign in to comment.