Skip to content
This repository has been archived by the owner on Mar 14, 2024. It is now read-only.

Commit

Permalink
[KOGITO-3979] - Switch to current testing suite by OLM
Browse files Browse the repository at this point in the history
See: https://issues.redhat.com/browse/KOGITO-3979

Signed-off-by: Tarun Khandelwal <tarkhand@redhat.com>
  • Loading branch information
Tarun Khandelwal committed Jan 27, 2021
1 parent 617f387 commit fada938
Show file tree
Hide file tree
Showing 11 changed files with 119 additions and 168 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/Kogito-Operator-OLM-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Kogito Operator OLM Checks
on:
pull_request:
paths:
- 'deploy/**'
- 'pkg/**'
- 'cmd/**'
- 'hack/ci/**'
env:
OP_TEST_CONTAINER_TOOL: docker
GO_VERSION: 1.14
OP_TEST_DEBUG: 1
OP_TEST_CONTAINER_OPT: "-t"
jobs:
olm_integration:
name: OLM Integration Test
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Setup Go ${{ env.GO_VERSION }}
uses: actions/setup-go@v2
with:
go-version: ${{ env.GO_VERSION }}
id: go
- name: Cache dependencies
uses: actions/cache@v1
with:
path: ~/go/pkg/mod/cache
key: ${{ runner.os }}-go-cache-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-cache-
- name: Cache the binaries
uses: actions/cache@v1
with:
path: ~/go/bin/
key: ${{ runner.os }}-go-${{ env.GO_VERSION }}
restore-keys: |
${{ runner.os }}-go-${{ env.GO_VERSION }}
- name: Cache Go mod
uses: actions/cache@v1
with:
path: go.mod
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.mod') }}
restore-keys: |
${{ runner.os }}-go-mod-
- run: go mod tidy
- name: Build Operator Image
env:
BUILDER: docker
run: make docker-build
- name: Run Operator OLM Integration Test
run: ./hack/ci/run-olm-tests.sh
- name: Upload
if: always()
uses: actions/upload-artifact@v2
with:
name: log
path: /tmp/op-test/log.out
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ require (
github.com/stretchr/testify v1.6.1
go.uber.org/zap v1.15.0
golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897 // indirect
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a // indirect
golang.org/x/tools v0.0.0-20200916195026-c9a70fc28ce3 // indirect
gopkg.in/src-d/go-git.v4 v4.13.1
gopkg.in/yaml.v2 v2.3.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1970,6 +1970,8 @@ golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208 h1:qwRHBd0NqMbJxfbotnDhm2ByMI1Shq4Y6oRJo21SGJA=
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a h1:DcqTD9SDLc+1P/r1EmRBwnVsrOwW+kk2vWf9n+1sGhs=
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20170830134202-bb24a47a89ea/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180117170059-2c42eef0765b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
Expand Down
20 changes: 8 additions & 12 deletions hack/ci/load-operator-image.sh → hack/ci/ensure-image.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# Copyright 2020 Red Hat, Inc. and/or its affiliates
# Copyright 2021 Red Hat, Inc. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -13,19 +13,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.


set -e

default_cluster_name="operator-test"
source ./hack/env.sh

if [[ -z ${CLUSTER_NAME} ]]; then
CLUSTER_NAME=$default_cluster_name
fi
version=$(getOperatorVersion)

source ./hack/env.sh
docker images
echo "---> Loading Operator Image into Kind"
kind load docker-image quay.io/kiegroup/kogito-cloud-operator:"$(getOperatorVersion)" --name ${CLUSTER_NAME}
echo "=====> tagging image"
docker tag quay.io/kiegroup/kogito-cloud-operator:${version} kind-registry:5000/kiegroup/kogito-cloud-operator

node_name=$(kubectl get nodes -o jsonpath="{.items[0].metadata.name}")
echo "---> Checking internal loaded images on node ${node_name}"
docker exec "${node_name}" crictl images
echo "======> verifying image exists"
docker images kind-registry:5000/kiegroup/kogito-cloud-operator
18 changes: 18 additions & 0 deletions hack/ci/olm-pretest.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash
# Copyright 2021 Red Hat, Inc. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.



docker push kind-registry:5000/kiegroup/kogito-cloud-operator
43 changes: 23 additions & 20 deletions hack/ci/operator-ensure-manifests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,33 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# Script responsible for ensuring and correcting manifests as needed.
set -e

source ./hack/env.sh
source ./hack/ci/ensure-image.sh

OUTPUT="${PWD}/build/_output/operatorhub"
tempfolder=$(mktemp -d)
echo "$tempfolder"

echo "---> Output dir is set to ${OUTPUT}"
# clean up
rm -rf "${OUTPUT}"
version=$(getOperatorVersion)
latest_released_version=$(getLatestOlmReleaseVersion)

mkdir -p "${OUTPUT}"
git clone https://github.com/operator-framework/community-operators.git ${tempfolder}
mkdir "${tempfolder}/community-operators/kogito-operator/${version}/"
cp -r bundle/manifests/*.yaml "${tempfolder}/community-operators/kogito-operator/${version}/"

# copying all the kogito dependent operator to be added at manifests root.
rm -rf ~/operators/
git clone https://github.com/operator-framework/community-operators.git ~/operators/
cp -r ~/operators/community-operators/strimzi-kafka-operator "${OUTPUT}"
cp -r ~/operators/community-operators/keycloak-operator "${OUTPUT}"
cp -r ~/operators/community-operators/infinispan/ "${OUTPUT}"
cp -r ~/operators/community-operators/kogito-operator/ "${OUTPUT}"
rm -rf ~/operators/

cp -r "deploy/olm-catalog/kogito-operator/$(getOperatorVersion)/" "${OUTPUT}/kogito-operator/"
cp "deploy/olm-catalog/kogito-operator/kogito-operator.package.yaml" "${OUTPUT}/kogito-operator/"
#replace image in target CSV
sed -i "s|quay.io/kiegroup/kogito-cloud-operator.*|kind-registry:5000/kiegroup/kogito-cloud-operator|g" "${tempfolder}/community-operators/kogito-operator/${version}/kogito-operator.clusterserviceversion.yaml"
#
##ensure correct replace field is there
sed -i "s|replace.*|replaces: kogito-operator.v${latest_released_version}|g" "${tempfolder}/community-operators/kogito-operator/${version}/kogito-operator.clusterserviceversion.yaml"
#
sed -i "s|${latest_released_version}|${version}|g" "${tempfolder}/community-operators/kogito-operator/kogito-operator.package.yaml"
#
echo "---> verify CSV updates"
cat "${tempfolder}/community-operators/kogito-operator/${version}/kogito-operator.clusterserviceversion.yaml" | grep kind-registry:5000/kiegroup/kogito-cloud-operator
cat "${tempfolder}/community-operators/kogito-operator/${version}/kogito-operator.clusterserviceversion.yaml" | grep replaces

echo "---> Manifest files in the output directory for OLM verification"
ls -l "${OUTPUT}"
echo "---> Manifest files in kogito-operator directory for OLM verification"
ls -l "${OUTPUT}/kogito-operator/"
echo "---> Verify package.yaml updates"
cat "${tempfolder}/community-operators/kogito-operator/kogito-operator.package.yaml"
52 changes: 0 additions & 52 deletions hack/ci/operator-olm-test.sh

This file was deleted.

29 changes: 0 additions & 29 deletions hack/ci/operatorhubio-catalog.Dockerfile

This file was deleted.

22 changes: 7 additions & 15 deletions hack/ci/install-kind.sh → hack/ci/run-olm-tests.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# Copyright 2020 Red Hat, Inc. and/or its affiliates
# Copyright 2021 Red Hat, Inc. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -14,21 +14,13 @@
# limitations under the License.


default_kind_version=v0.8.1
set -e
source ./hack/ci/operator-ensure-manifests.sh

if [[ -z ${KIND_VERSION} ]]; then
KIND_VERSION=$default_kind_version
fi
export OP_TEST_PRETEST_CUSTOM_SCRIPT=${PWD}/hack/ci/olm-pretest.sh

GOPATH=$(go env GOPATH)
echo "\n=======> Pretest script path set to ${OP_TEST_PRETEST_CUSTOM_SCRIPT}"

if [[ $(which kind) ]]; then
echo "---> kind is already installed. Please make sure it is the required ${KIND_VERSION} version before proceeding"
else
echo "---> kind not found, installing it in \$GOPATH/bin/"
curl -L https://kind.sigs.k8s.io/dl/$KIND_VERSION/kind-$(uname)-amd64 -o "$GOPATH"/bin/kind
chmod +x "$GOPATH"/bin/kind
fi
cd "${tempfolder}"

#for verification
kind version
bash <(curl -sL https://cutt.ly/WhkV76k) all community-operators/kogito-operator/"${version}"
39 changes: 0 additions & 39 deletions hack/ci/start-kind.sh

This file was deleted.

2 changes: 1 addition & 1 deletion hack/env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ CSV_DIR="config/manifests/bases"
TEST_CONFIG_FILE="test/.default_config"

getOperatorVersion() {
local version=$(grep -m 1 'Version =' pkg/version/version.go) && version=$(echo ${version#*=} | tr -d '"')
local version=$(grep -m 1 'Version =' pkg/version/version.go) && version=$(echo ${version#*=} | tr -d '"' | tr -d ' ')
echo "${version}"
}

Expand Down

0 comments on commit fada938

Please sign in to comment.