Skip to content

Commit

Permalink
DB2WH Subscription and instance operator based testing (#2)
Browse files Browse the repository at this point in the history
* Updates to README

* updates to readme

* Fixed yaml

* Updated Framework to match with template

* fix bugs

* provider yaml

* added variables

* fixed default value

* fix yaml

* updated module

* fixed module

* sync with latest template changes

* cp key updated

* fixed permission

* added component name

* Updated module name

* commenting the code to test scenario

* fixed values.yaml issues

* Fixed Values.yaml

* Debugging stmt

* Converted create.yaml to HELM charts

* removed operator catalog

* Clean up operator subscription for db2wh

* removed conditional logic

* renamed chart folder

* logic updates

* updates to README

* added debug stmts

* Added Chart Directory path

* fixed chart name

* Values.yaml fix

* Added db2wh operator in the main.tf

* Fixing the string quotes

* updated variable names

* Added operator in the main.tf

* Code Cleanup

* updated namespaces

* Updated namespaces

* updated namespace

* Added sequence for template

* added the path

* updated main.tf

* Format code

* Chart name updated

* Increased sleep

* removed namespace

* Added namespace

* sleep changes

* test

* Added sleep time more to test

* reverted namespace

* debugging validatedeploy.sh

* added cpd-operators

* added sleep time

* testing db2wh catalog source only

* Test

* Added service db2wh with sequence

* Updated Validate deploy to check for Subscription

* clean up db2wh validatedeploy

* Sync main.tf , values.yaml variables

* Added more sleep time

* Updates to support Specialization DB2WH install

* fixed the namespace name

* Removed db2wh service

* Added namespace used for this project

* Updated the DB2wh to support special installation

* Added variables in outputs stage file

* fixed the build error to address the output files

* Fixes for build error

* Fix build error

* Added automation workflow build clean status

* fixed intendent typos

* Format changes

* Added db2wh instance

* removed the CP Catalog file which causes Catalog source removal

* Checking instance module

* Removed job approach and validating if instance creates

* removed annotation

* added annotations

* added sync wave

* Sync wave

* Trying Syncwave

* annotation variations

* Added instance condition

* added pull secret for each namespace and verify if solves

* added dependency block

* removed the depends on condition

* added newline to trigger build

* commented out entitlement/pull secret from test case

* removed the namespace and updated variables for instance chart

* added sleep 10min to verify the db2 instance

* Reverted changes back instance yaml

* update instance variables from values.yaml

* Added delete operator and csv for db2wh

* added delete CSV for DB2wsh

* code cleanup

* Trying with default values

* added CSV delete

* removed variables and trying with default values

* added variable namespace

* Added verify resources related to db2wh

* fixed CSV variable

* commented db2whservice which causes hang sometimes

* Updated Readme to include finalizer and added db2wh service before CSV

* updated readme

* updated readme with instructions

* format readme

* added Operandregistry capability

* added operand registry support

* fixed cm

* updates to chart name

* updated db2u operator catalog

Co-authored-by: bala sivasubramanian <bala@us.ibm.com>
  • Loading branch information
triceam and balasgit authored May 20, 2022
1 parent f2980fc commit ee09fba
Show file tree
Hide file tree
Showing 40 changed files with 1,000 additions and 303 deletions.
77 changes: 56 additions & 21 deletions .github/scripts/validate-deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ GIT_TOKEN=$(cat git_token)

export KUBECONFIG=$(cat .kubeconfig)
NAMESPACE=$(cat .namespace)
BRANCH="main"
SERVER_NAME="default"
TYPE="base"
LAYER="2-services"

COMPONENT_NAME="my-module"
COMPONENT_NAME=$(jq -r '.name // "my-module"' gitops-output.json)
SUBSCRIPTION_NAME=$(jq -r '.sub_name // "sub_name"' gitops-output.json)
OPERATOR_NAMESPACE=$(jq -r '.operator_namespace // "operator_namespace"' gitops-output.json)
CPD_NAMESPACE=$(jq -r '.cpd_namespace // "cpd_namespace"' gitops-output.json)
BRANCH=$(jq -r '.branch // "main"' gitops-output.json)
SERVER_NAME=$(jq -r '.server_name // "default"' gitops-output.json)
LAYER=$(jq -r '.layer_dir // "2-services"' gitops-output.json)
TYPE=$(jq -r '.type // "base"' gitops-output.json)

mkdir -p .testrepo

Expand All @@ -29,15 +31,15 @@ echo "Printing argocd/${LAYER}/cluster/${SERVER_NAME}/${TYPE}/${NAMESPACE}-${COM
cat "argocd/${LAYER}/cluster/${SERVER_NAME}/${TYPE}/${NAMESPACE}-${COMPONENT_NAME}.yaml"

if [[ ! -f "payload/${LAYER}/namespace/${NAMESPACE}/${COMPONENT_NAME}/values.yaml" ]]; then
echo "Application values not found - payload/2-services/namespace/${NAMESPACE}/${COMPONENT_NAME}/values.yaml"
echo "Application values not found - payload/${LAYER}/namespace/${NAMESPACE}/${COMPONENT_NAME}/values.yaml"
exit 1
fi

echo "Printing payload/${LAYER}/namespace/${NAMESPACE}/${COMPONENT_NAME}/values.yaml"
cat "payload/${LAYER}namespace/${NAMESPACE}/${COMPONENT_NAME}/values.yaml"
cat "payload/${LAYER}/namespace/${NAMESPACE}/${COMPONENT_NAME}/values.yaml"

count=0
until kubectl get namespace "${NAMESPACE}" 1> /dev/null 2> /dev/null || [[ $count -eq 20 ]]; do
until kubectl get namespace "${NAMESPACE}" 1>/dev/null 2>/dev/null || [[ $count -eq 20 ]]; do
echo "Waiting for namespace: ${NAMESPACE}"
count=$((count + 1))
sleep 15
Expand All @@ -51,21 +53,54 @@ else
sleep 30
fi

DEPLOYMENT="${COMPONENT_NAME}-${BRANCH}"
count=0
until kubectl get deployment "${DEPLOYMENT}" -n "${NAMESPACE}" || [[ $count -eq 20 ]]; do
echo "Waiting for deployment/${DEPLOYMENT} in ${NAMESPACE}"
count=$((count + 1))
sleep 15
echo "OPERATOR_NAMESPACE ***** "${OPERATOR_NAMESPACE}""
echo "SUBSCRIPTION_NAME *****"${SUBSCRIPTION_NAME}""
sleep 30

CSV=$(kubectl get sub -n "${OPERATOR_NAMESPACE}" "${SUBSCRIPTION_NAME}" -o jsonpath='{.status.installedCSV} {"\n"}')
echo "CSV ***** "${CSV}""
SUB_STATUS=0
while [[ $SUB_STATUS -ne 1 ]]; do
sleep 10
SUB_STATUS=$(kubectl get deployments -n "${OPERATOR_NAMESPACE}" -l olm.owner="${CSV}" -o jsonpath="{.items[0].status.availableReplicas} {'\n'}")
echo "SUB_STATUS ${SUB_STATUS} **** Waiting for subscription/${SUBSCRIPTION_NAME} in ${OPERATOR_NAMESPACE}"
done

if [[ $count -eq 20 ]]; then
echo "Timed out waiting for deployment/${DEPLOYMENT} in ${NAMESPACE}"
kubectl get all -n "${NAMESPACE}"
exit 1
fi
echo "DB2WH Operator is READY"

echo "CPD_NAMESPACE *****"${CPD_NAMESPACE}""
sleep 60
INSTANCE_STATUS=""

while [ true ]; do
INSTANCE_STATUS=$(kubectl get Db2whService db2wh-cr -n "${CPD_NAMESPACE}" -o jsonpath='{.status.db2whStatus} {"\n"}')
echo "Waiting for instance "${INSTANCE_NAME}" to be ready. Current status : "${INSTANCE_STATUS}""
if [ $INSTANCE_STATUS == "Completed" ]; then
break
elif [ $INSTANCE_STATUS == "" ]; then
break
fi
sleep 30
done

echo "DB2 Db2whService/db2wh-cr is ${INSTANCE_STATUS}"

kubectl rollout status "deployment/${DEPLOYMENT}" -n "${NAMESPACE}" || exit 1
echo "DB2 Operator uninstall"

#oc get Db2whService -n project-name

#oc delete csv ${CSV} -n ${OPERATOR_NAMESPACE}

oc delete Db2whService db2wh-cr -n ${CPD_NAMESPACE}

oc delete csv ${CSV} -n ${OPERATOR_NAMESPACE}

# Need to revisit and remove the finalizer from db2whservice


#oc get all -l "app.kubernetes.io/name in (preinstall, rbac, shared-components, zen-integration, zenhelper)" -n ${CPD_NAMESPACE}

cd ..
rm -rf .testrepo


15 changes: 15 additions & 0 deletions .github/workflows/manual-test-repo-delete.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Delete test gitops repo manually
on:
workflow_dispatch:
inputs:
confirm:
description: 'Type "Delete" to confirm'
required: true

jobs:
delete_repo:
if: ${{ github.event.inputs.confirm == 'Delete' }}
uses: cloud-native-toolkit/action-workflows/.github/workflows/manual-test-repo-delete.yaml@v1
secrets:
GIT_ORG: ${{ secrets.GIT_ORG }}
GIT_ADMIN_TOKEN: ${{ secrets.GIT_ADMIN_TOKEN }}
21 changes: 5 additions & 16 deletions .github/workflows/notify.yaml
Original file line number Diff line number Diff line change
@@ -1,22 +1,11 @@
name: Notify

on:
release:
types: [published]

jobs:
notify:
runs-on: ubuntu-latest

strategy:
matrix:
repo:
- cloud-native-toolkit/ibm-garage-iteration-zero
- cloud-native-toolkit/garage-terraform-modules

steps:
- name: Repository dispatch ${{ matrix.repo }}
uses: cloud-native-toolkit/action-repository-dispatch@main
with:
notifyRepo: ${{ matrix.repo }}
eventType: released
env:
GITHUB_TOKEN: ${{ secrets.TOKEN }}
uses: cloud-native-toolkit/action-workflows/.github/workflows/notify.yaml@v1
secrets:
TOKEN: ${{ secrets.TOKEN }}
44 changes: 0 additions & 44 deletions .github/workflows/publish-assets.yaml

This file was deleted.

12 changes: 12 additions & 0 deletions .github/workflows/publish-metadata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Publish metadata

on:
release:
types:
- published

jobs:
publish-assets:
uses: cloud-native-toolkit/action-workflows/.github/workflows/publish-metadata.yaml@v1
secrets:
TOKEN: ${{ secrets.GITHUB_TOKEN }}
26 changes: 26 additions & 0 deletions .github/workflows/verify-pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Verify PR

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the main branch
on:
pull_request:
branches: [ main ]

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
verify:
if: ${{ !contains( github.event.pull_request.labels.*.name, 'skip ci' ) }}
uses: cloud-native-toolkit/action-workflows/.github/workflows/verify-gitops-module.yaml@v1
with:
testcase: ocp4_latest_gitops_cp4d
secrets:
GIT_ORG: ${{ secrets.GIT_ORG }}
AWS_CLUSTER_USERNAME: ${{ secrets.AWS_CLUSTER_USERNAME }}
AWS_CLUSTER_PASSWORD: ${{ secrets.AWS_CLUSTER_PASSWORD }}
IBMCLOUD_API_KEY: ${{ secrets.IBMCLOUD_API_KEY }}
GIT_ADMIN_USERNAME: ${{ secrets.GIT_ADMIN_USERNAME }}
GIT_ADMIN_TOKEN: ${{ secrets.GIT_ADMIN_TOKEN }}
CP_ENTITLEMENT_KEY: ${{ secrets.CP_ENTITLEMENT_KEY }}

verifyMetadata:
uses: cloud-native-toolkit/action-workflows/.github/workflows/verify-module-metadata.yaml@v1
114 changes: 16 additions & 98 deletions .github/workflows/verify.yaml
Original file line number Diff line number Diff line change
@@ -1,114 +1,32 @@
name: Verify and release module
name: Verify

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the main branch
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
verify:
if: ${{ !contains( github.event.pull_request.labels.*.name, 'skip ci' ) }}
runs-on: ubuntu-latest
container: quay.io/ibmgaragecloud/cli-tools:v0.15

strategy:
matrix:
testcase: [ocp4_latest]
# max-parallel: 1
fail-fast: false

env:
HOME: /home/devops

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Checkout
uses: actions/checkout@v1

- id: variables
name: Set up variables
env:
GIT_ORG: ${{ secrets.GIT_ORG }}
shell: bash
run: |
repo=$(echo ${GITHUB_REPOSITORY} | sed -E "s~.*/[^-]+-(.*)~\1~g")
echo "Repo: $repo"
echo "::set-output name=repo::$repo"
org="${GIT_ORG:-cloud-native-toolkit-test}"
echo "Org: $org"
echo "::set-output name=org::$org"
- name: Verify deploy on ${{ matrix.testcase }}
uses: cloud-native-toolkit/action-module-verify-deploy@main
with:
clusterId: ${{ matrix.testcase }}
validateDeployScript: .github/scripts/validate-deploy.sh
env:
TF_VAR_git_username: ${{ secrets.GIT_ADMIN_USERNAME }}
TF_VAR_git_token: ${{ secrets.GIT_ADMIN_TOKEN }}
TF_VAR_git_org: ${{ steps.variables.outputs.org }}
TF_VAR_git_repo: ${{ steps.variables.outputs.repo }}
TF_VAR_ibmcloud_api_key: ${{ secrets.IBMCLOUD_API_KEY }}
IBMCLOUD_API_KEY: ${{ secrets.IBMCLOUD_API_KEY }}

- name: Verify destroy on ${{ matrix.testcase }}
uses: cloud-native-toolkit/action-module-verify-destroy@main
if: ${{ always() }}
with:
clusterId: ${{ matrix.testcase }}
env:
TF_VAR_git_username: ${{ secrets.GIT_ADMIN_USERNAME }}
TF_VAR_git_token: ${{ secrets.GIT_ADMIN_TOKEN }}
TF_VAR_git_org: ${{ steps.variables.outputs.org }}
TF_VAR_git_repo: ${{ steps.variables.outputs.repo }}
TF_VAR_ibmcloud_api_key: ${{ secrets.IBMCLOUD_API_KEY }}
IBMCLOUD_API_KEY: ${{ secrets.IBMCLOUD_API_KEY }}
uses: cloud-native-toolkit/action-workflows/.github/workflows/verify-gitops-module.yaml@v1
with:
testcase: ocp4_latest_gitops_cp4d
secrets:
GIT_ORG: ${{ secrets.GIT_ORG }}
AWS_CLUSTER_USERNAME: ${{ secrets.AWS_CLUSTER_USERNAME }}
AWS_CLUSTER_PASSWORD: ${{ secrets.AWS_CLUSTER_PASSWORD }}
IBMCLOUD_API_KEY: ${{ secrets.IBMCLOUD_API_KEY }}
GIT_ADMIN_USERNAME: ${{ secrets.GIT_ADMIN_USERNAME }}
GIT_ADMIN_TOKEN: ${{ secrets.GIT_ADMIN_TOKEN }}
CP_ENTITLEMENT_KEY: ${{ secrets.CP_ENTITLEMENT_KEY }}

verifyMetadata:
runs-on: ubuntu-latest

env:
DIST_DIR: ./dist
PUBLISH_BRANCH: gh-pages

steps:
- name: Checkout
uses: actions/checkout@v2

- uses: actions/setup-node@v2-beta
with:
node-version: '14'

- name: Build catalog
uses: cloud-native-toolkit/action-module-catalog@v1
with:
tagName: ${{ github.event.release.tag_name }}
distDir: ${{ env.DIST_DIR }}
publishBranch: ${{ env.PUBLISH_BRANCH }}

- name: Verify module schema
run: |
npm i -g ajv-cli
curl -LsO https://modules.cloudnativetoolkit.dev/schemas/module.json
ajv test -s module.json -d ${{ env.DIST_DIR }}/index.yaml --valid
uses: cloud-native-toolkit/action-workflows/.github/workflows/verify-module-metadata.yaml@v1

release:
needs: [verify, verifyMetadata]
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' }}

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Drafts your next Release notes as Pull Requests are merged into "main"
- uses: release-drafter/release-drafter@v5
with:
# (Optional) specify config name to use, relative to .github/. Default: release-drafter.yml
config-name: release-drafter.yaml
publish: true
env:
GITHUB_TOKEN: ${{ secrets.TOKEN }}
uses: cloud-native-toolkit/action-workflows/.github/workflows/release-module.yaml@v1
secrets:
TOKEN: ${{ secrets.TOKEN }}
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,14 @@
.idea/
*.iml

.DS_store


.terraform
*.tfstate*
/test/stages/module

.tmp
.kube
bin2
test/stages/gitops
Loading

0 comments on commit ee09fba

Please sign in to comment.