diff --git a/.github/actions/setup-kuttl/action.yml b/.github/actions/setup-kuttl/action.yml new file mode 100644 index 000000000..5817478b2 --- /dev/null +++ b/.github/actions/setup-kuttl/action.yml @@ -0,0 +1,31 @@ +name: Setup Kind +description: Sets up a kind cluster and installs Helm and kubectl +outputs: + krew-path: + description: The path to the Helm binary + value: ${{ steps.krew.outputs.path }} + kuttl-path: + description: The path to the Helm binary + value: ${{ steps.kuttl.outputs.path }} +runs: + using: composite + steps: + - id: krew + name: Install Krew + shell: bash + script: | + set -x; cd "$(mktemp -d)" + OS="$(uname | tr '[:upper:]' '[:lower:]')" + ARCH="$(uname -m | sed -e 's/x86_64/amd64/' -e 's/\(arm\)\(64\)\?.*/\1\2/' -e 's/aarch64$/arm64/')" + KREW="krew-${OS}_${ARCH}" + curl -fsSLO "https://github.com/kubernetes-sigs/krew/releases/latest/download/${KREW}.tar.gz" + tar zxvf "${KREW}.tar.gz" + ./"${KREW}" install krew + echo "path=${KREW_ROOT:-$HOME/.krew}/bin/kubectl-krew" >> "$GITHUB_OUTPUT" + + - id: kuttl + name: Install KUTTL + shell: bash + script: | + kubectl krew install kuttl + echo "path=$(which kubectl-kuttl)" >> "$GITHUB_OUTPUT" diff --git a/.github/workflows/tests-cluster-standalone.yml b/.github/workflows/tests-cluster-standalone.yml index d2b6166f8..8c72427f5 100644 --- a/.github/workflows/tests-cluster-standalone.yml +++ b/.github/workflows/tests-cluster-standalone.yml @@ -20,17 +20,9 @@ jobs: - name: Deploy the operator uses: ./.github/actions/deploy-operator - - name: Deploy a standalone cluster - run: | - helm upgrade --install \ - --values charts/cluster/examples/basic.yaml \ - --namespace database \ - --create-namespace \ - --wait \ - database ./charts/cluster + - name: Install KUTTL + uses: ./.github/actions/setup-kuttl - - name: Verify that the cluster is ready - uses: ./.github/actions/verify-ready-instances - with: - cluster-name: database-cluster - ready-instances: 1 + - name: Run KUTTL tests + run: | + kubectl kuttl test diff --git a/tests/cluster/00-assert.yaml b/tests/cluster/00-assert.yaml index 645556edc..6551705cb 100644 --- a/tests/cluster/00-assert.yaml +++ b/tests/cluster/00-assert.yaml @@ -1,11 +1,24 @@ apiVersion: kuttl.dev/v1beta1 kind: TestAssert -timeout: 60 +timeout: 180 --- apiVersion: postgresql.cnpg.io/v1 kind: Cluster metadata: - name: database-cluster - namespace: database + name: standalone-cluster status: readyInstances: 2 +--- +apiVersion: postgresql.cnpg.io/v1 +kind: Backup +metadata: + labels: + cnpg.io/cluster: standalone-cluster + cnpg.io/immediateBackup: "true" + cnpg.io/scheduled-backup: standalone-cluster-daily-backup +spec: + cluster: + name: standalone-cluster + method: barmanObjectStore +status: + phase: completed diff --git a/tests/cluster/00-cluster.yaml b/tests/cluster/00-cluster.yaml index 807cb254f..e35be41ad 100644 --- a/tests/cluster/00-cluster.yaml +++ b/tests/cluster/00-cluster.yaml @@ -9,4 +9,3 @@ commands: --values ./standalone.yaml --wait standalone ../../charts/cluster -timeout: 180 diff --git a/tests/cluster/standalone.yaml b/tests/cluster/standalone.yaml index d0378a597..ebc8b3ea0 100644 --- a/tests/cluster/standalone.yaml +++ b/tests/cluster/standalone.yaml @@ -3,6 +3,8 @@ cluster: instances: 2 postgresql: archive_timout: "10" + storage: + size: 256Mi backups: enabled: true provider: s3