Skip to content
This repository was archived by the owner on Jun 26, 2024. It is now read-only.
Merged
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
46 changes: 1 addition & 45 deletions .github/actions/collect-kube-resources/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,49 +23,5 @@ runs:
steps:
- id: collect-kube-resources
run: |
kubectl api-resources --verbs=list --namespaced -o name > resources.namespaced.list
kubectl api-resources --verbs=list --namespaced=false -o name > resources.cluster-wide.list

for ns in ${{inputs.operator-namespace}} ${{inputs.olm-namespace}}; do
OUTPUT=${{inputs.output-path}}/${ns}
mkdir -p ${OUTPUT}
for res in $(cat resources.namespaced.list | grep -v secrets); do
kubectl get ${res} --ignore-not-found -n ${ns} -o yaml > ${OUTPUT}/${res}.yaml;
done
mkdir -p $OUTPUT/pod;
for p in $(kubectl get pods -n ${ns} -o name); do
for c in $(kubectl get $p -n ${ns} -o jsonpath='{.spec.containers[].name}'); do
kubectl logs -n ${ns} $p -c $c > $OUTPUT/$p.$c.log;
done;
done;
find ${OUTPUT} -size 0 -delete
done

if [ -f ${{ inputs.test-namespace-file }} ]; then
ns=$(cat ${{ inputs.test-namespace-file }})
OUTPUT=${{inputs.output-path}}/${ns}
mkdir -p ${OUTPUT}
for res in $(cat resources.namespaced.list); do
kubectl get ${res} --ignore-not-found -n ${ns} -o yaml > ${OUTPUT}/${res}.yaml;
done
mkdir -p $OUTPUT/pod;
for p in $(kubectl get pods -n ${ns} -o name); do
for c in $(kubectl get $p -n ${ns} -o jsonpath='{.spec.containers[].name}'); do
kubectl logs -n ${ns} $p -c $c > $OUTPUT/$p.$c.log;
done;
done;
find ${OUTPUT} -size 0 -delete
fi

OUTPUT=${{inputs.output-path}}
for res in $(cat resources.cluster-wide.list); do
kubectl get ${res} --ignore-not-found -o yaml > ${OUTPUT}/${res}.yaml;
done
shell: bash

- id: collect-operator-logs
run: |
mkdir -p ${{inputs.output-path}}
operator_pod=$(kubectl get pods --no-headers -o custom-columns=":metadata.name" -n ${{inputs.operator-namespace}} | tail -1)
kubectl logs ${operator_pod} -n ${{inputs.operator-namespace}} > ${{inputs.output-path}}/${operator_pod}.log
make collect-kube-resources OPERATOR_NAMESPACE=${{inputs.operator-namespace}} OLM_NAMESPACE=${{inputs.olm-namespace}} TEST_NAMESPACE_FILE=${{inputs.test-namespace-file}} TEST_ACCEPTANCE_RESOURCES_DIR=${{inputs.output-path}}
shell: bash
55 changes: 55 additions & 0 deletions hack/collect-kube-resources.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/bin/bash

set -x
OPNS="$(kubectl get namespaces -o name | grep -E '.*/(.+-)?operators$' || test $? = 1)"
OPERATOR_NAMESPACE=${OPERATOR_NAMESPACE:-${OPNS#"namespace/"}}
OLM_NAMESPACE="${OLM_NAMESPACE:-$(kubectl get catalogsources.operators.coreos.com --all-namespaces -o jsonpath='{.items[0].metadata.namespace}' --ignore-not-found=true)}"
OUTPUT_PATH=${OUTPUT_PATH:-out/acceptance-tests/resources}
TEST_NAMESPACE_FILE=${TEST_NAMESPACE_FILE:-$OUTPUT_DIR/test-namespace}
set +x

echo "Collecting Kubernetes resources..."

kubectl api-resources --verbs=list --namespaced -o name >resources.namespaced.list
kubectl api-resources --verbs=list --namespaced=false -o name >resources.cluster-wide.list

for ns in ${OPERATOR_NAMESPACE} ${OLM_NAMESPACE}; do
OUTPUT=${OUTPUT_PATH}/${ns}
mkdir -p ${OUTPUT}
for res in $(cat resources.namespaced.list | grep -v secrets); do
kubectl get ${res} --ignore-not-found -n ${ns} -o yaml >${OUTPUT}/${res}.yaml
done
mkdir -p $OUTPUT/pod
for p in $(kubectl get pods -n ${ns} -o name); do
for c in $(kubectl get $p -n ${ns} -o jsonpath='{.spec.containers[].name}'); do
kubectl logs -n ${ns} $p -c $c >$OUTPUT/$p.$c.log
done
done
find ${OUTPUT} -size 0 -delete
done

if [ -f ${TEST_NAMESPACE_FILE} ]; then
ns=$(cat ${TEST_NAMESPACE_FILE})
OUTPUT=${OUTPUT_PATH}/${ns}
mkdir -p ${OUTPUT}
for res in $(cat resources.namespaced.list); do
kubectl get ${res} --ignore-not-found -n ${ns} -o yaml >${OUTPUT}/${res}.yaml
done
mkdir -p $OUTPUT/pod
for p in $(kubectl get pods -n ${ns} -o name); do
for c in $(kubectl get $p -n ${ns} -o jsonpath='{.spec.containers[].name}'); do
kubectl logs -n ${ns} $p -c $c >$OUTPUT/$p.$c.log
done
done
find ${OUTPUT} -size 0 -delete
fi

OUTPUT=${OUTPUT_PATH}
for res in $(cat resources.cluster-wide.list); do
kubectl get ${res} --ignore-not-found -o yaml >${OUTPUT}/${res}.yaml
done

echo "Collecting operator logs..."
mkdir -p ${OUTPUT_PATH}
operator_pod=$(kubectl get pods --no-headers -o custom-columns=":metadata.name" -n ${OPERATOR_NAMESPACE} | tail -1)
kubectl logs ${operator_pod} -n ${OPERATOR_NAMESPACE} >${OUTPUT_PATH}/${operator_pod}.log
4 changes: 2 additions & 2 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash -e

OLM_VERSION=0.18.1
OLM_VERSION=0.21.2
OPERATOR_CHANNEL=${OPERATOR_CHANNEL:-beta}
OPERATOR_PACKAGE=${OPERATOR_PACKAGE:-service-binding-operator}
DOCKER_CFG=${DOCKER_CFG:-$HOME/.docker/config.json}
Expand Down Expand Up @@ -97,4 +97,4 @@ until [[ $retries == 0 ]]; do
sleep 5
retries=$(($retries - 1))
done
kubectl rollout status -w deployment/service-binding-operator -n $OPERATOR_NAMESPACE
kubectl rollout status -w deployment/service-binding-operator -n $OPERATOR_NAMESPACE
16 changes: 14 additions & 2 deletions make/acceptance.mk
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ SHELLFLAGS = -ec
TEST_ACCEPTANCE_START_SBO ?= local
TEST_ACCEPTANCE_OUTPUT_DIR ?= $(OUTPUT_DIR)/acceptance-tests
TEST_ACCEPTANCE_REPORT_DIR ?= $(OUTPUT_DIR)/acceptance-tests-report
TEST_ACCEPTANCE_RESOURCES_DIR ?= $(TEST_ACCEPTANCE_OUTPUT_DIR)/resources
TEST_ACCEPTANCE_ARTIFACTS ?= $(ARTIFACT_DIR)
TEST_NAMESPACE = $(shell $(HACK_DIR)/get-test-namespace $(OUTPUT_DIR))
TEST_ACCEPTANCE_CLI ?= oc
Expand All @@ -17,6 +18,9 @@ else
TEST_ACCEPTANCE_TAGS_ARG ?= --tags="~@disabled" --tags="~@examples"
endif

OPERATOR_NAMESPACE ?=
OLM_NAMESPACE ?=

# Testing setup
.PHONY: deploy-test-3rd-party-crds
deploy-test-3rd-party-crds:
Expand Down Expand Up @@ -70,7 +74,7 @@ test-acceptance-with-bundle: deploy-from-index-image

.PHONY: test-acceptance-artifacts
# Collect artifacts from acceptance tests to be archived in CI
test-acceptance-artifacts:
test-acceptance-artifacts: collect-kube-resources
$(Q)echo "Gathering acceptance tests artifacts"
$(Q)mkdir -p $(TEST_ACCEPTANCE_ARTIFACTS) \
&& cp -rvf $(TEST_ACCEPTANCE_OUTPUT_DIR) $(TEST_ACCEPTANCE_ARTIFACTS)/
Expand All @@ -88,4 +92,12 @@ test-acceptance-generate-report:
.PHONY: test-acceptance-serve-report
## Serves acceptance tests report at http://localhost:8088
test-acceptance-serve-report:
$(Q)CONTAINER_RUNTIME=$(CONTAINER_RUNTIME) $(HACK_DIR)/allure-report.sh serve
$(Q)CONTAINER_RUNTIME=$(CONTAINER_RUNTIME) $(HACK_DIR)/allure-report.sh serve

.PHONY: collect-kube-resources
# Collect Kubernetes resources
collect-kube-resources:
-$(Q)OUTPUT_PATH=$(TEST_ACCEPTANCE_RESOURCES_DIR) \
OPERATOR_NAMESPACE=$(OPERATOR_NAMESPACE) \
OLM_NAMESPACE=$(OLM_NAMESPACE) \
$(HACK_DIR)/collect-kube-resources.sh
Original file line number Diff line number Diff line change
Expand Up @@ -173,25 +173,27 @@ Feature: Support a number of existing operator-backed services out of the box
And Application can connect to the projected Postgres database

@disable-github-actions
@disable-openshift-4.11
@disable-openshift-4.12
Scenario: Bind test application to Mysql provisioned by Percona Mysql operator and connect
Given Percona Mysql operator is running
* Generic test application is running
* The Custom Resource is present
"""
apiVersion: pxc.percona.com/v1-10-0
apiVersion: pxc.percona.com/v1
kind: PerconaXtraDBCluster
metadata:
name: minimal-cluster
spec:
crVersion: 1.10.0
crVersion: 1.11.0
secretsName: minimal-cluster-secrets
allowUnsafeConfigurations: true
upgradeOptions:
apply: 8.0-recommended
schedule: "0 4 * * *"
pxc:
size: 1
image: percona/percona-xtradb-cluster:8.0.23-14.1
image: percona/percona-xtradb-cluster:8.0.27-18.1
volumeSpec:
persistentVolumeClaim:
resources:
Expand All @@ -200,10 +202,10 @@ Feature: Support a number of existing operator-backed services out of the box
haproxy:
enabled: true
size: 1
image: perconalab/percona-xtradb-cluster-operator:main-haproxy
image: percona/percona-xtradb-cluster-operator:1.11.0-haproxy
logcollector:
enabled: true
image: perconalab/percona-xtradb-cluster-operator:main-logcollector
image: percona/percona-xtradb-cluster-operator:1.11.0-logcollector
"""
* Condition ready=True for PerconaXtraDBCluster/minimal-cluster resource is met
When Service Binding is applied
Expand All @@ -215,7 +217,7 @@ Feature: Support a number of existing operator-backed services out of the box
spec:
services:
- group: pxc.percona.com
version: v1-10-0
version: v1
kind: PerconaXtraDBCluster
name: minimal-cluster
application:
Expand All @@ -225,7 +227,7 @@ Feature: Support a number of existing operator-backed services out of the box
resource: deployments
"""
Then Service Binding is ready
And Kind PerconaXtraDBCluster with apiVersion pxc.percona.com/v1-10-0 is listed in bindable kinds
And Kind PerconaXtraDBCluster with apiVersion pxc.percona.com/v1 is listed in bindable kinds
And Content of file "/bindings/$scenario_id/type" in application pod is
"""
mysql
Expand Down Expand Up @@ -254,20 +256,20 @@ Feature: Support a number of existing operator-backed services out of the box
* Generic test application is running
* The Custom Resource is present
"""
apiVersion: pxc.percona.com/v1-10-0
apiVersion: pxc.percona.com/v1
kind: PerconaXtraDBCluster
metadata:
name: minimal-cluster
spec:
crVersion: 1.10.0
crVersion: 1.11.0
secretsName: minimal-cluster-secrets
allowUnsafeConfigurations: true
upgradeOptions:
apply: 8.0-recommended
schedule: "0 4 * * *"
pxc:
size: 1
image: percona/percona-xtradb-cluster:8.0.23-14.1
image: percona/percona-xtradb-cluster:8.0.27-18.1
volumeSpec:
persistentVolumeClaim:
resources:
Expand All @@ -276,10 +278,10 @@ Feature: Support a number of existing operator-backed services out of the box
haproxy:
enabled: true
size: 1
image: perconalab/percona-xtradb-cluster-operator:main-haproxy
image: percona/percona-xtradb-cluster-operator:1.11.0-haproxy
logcollector:
enabled: true
image: perconalab/percona-xtradb-cluster-operator:main-logcollector
image: percona/percona-xtradb-cluster-operator:1.11.0-logcollector
"""
When Service Binding is applied
"""
Expand All @@ -290,7 +292,7 @@ Feature: Support a number of existing operator-backed services out of the box
spec:
services:
- group: pxc.percona.com
version: v1-10-0
version: v1
kind: PerconaXtraDBCluster
name: minimal-cluster
application:
Expand All @@ -300,7 +302,7 @@ Feature: Support a number of existing operator-backed services out of the box
resource: deployments
"""
Then Service Binding is ready
And Kind PerconaXtraDBCluster with apiVersion pxc.percona.com/v1-10-0 is listed in bindable kinds
And Kind PerconaXtraDBCluster with apiVersion pxc.percona.com/v1 is listed in bindable kinds
And Content of file "/bindings/$scenario_id/type" in application pod is
"""
mysql
Expand Down Expand Up @@ -503,4 +505,4 @@ Feature: Support a number of existing operator-backed services out of the box
And Content of file "/bindings/$scenario_id/host" in application pod is
"""
mongo-cluster-rs0.$NAMESPACE.svc.cluster.local
"""
"""