From b4aa865e3087dc7f248346d0cc2b795f37ba52d1 Mon Sep 17 00:00:00 2001 From: Santiago Carmuega Date: Thu, 24 Mar 2022 12:18:03 -0300 Subject: [PATCH] ci: Add more e2e tests (#219) --- .../e2e/assert-n2n-mainnet-origin-blocks.yaml | 13 +++-- .../e2e/assert-n2n-mainnet-tip-blocks.yaml | 58 +++++++++++++++++++ .../e2e/assert-n2n-testnet-origin-blocks.yaml | 58 +++++++++++++++++++ .../e2e/assert-n2n-testnet-tip-blocks.yaml | 58 +++++++++++++++++++ .github/workflows/e2e.yaml | 52 ++++++++++++++--- 5 files changed, 226 insertions(+), 13 deletions(-) create mode 100644 .github/e2e/assert-n2n-mainnet-tip-blocks.yaml create mode 100644 .github/e2e/assert-n2n-testnet-origin-blocks.yaml create mode 100644 .github/e2e/assert-n2n-testnet-tip-blocks.yaml diff --git a/.github/e2e/assert-n2n-mainnet-origin-blocks.yaml b/.github/e2e/assert-n2n-mainnet-origin-blocks.yaml index 3287879b..340be990 100644 --- a/.github/e2e/assert-n2n-mainnet-origin-blocks.yaml +++ b/.github/e2e/assert-n2n-mainnet-origin-blocks.yaml @@ -2,7 +2,7 @@ apiVersion: v1 kind: ConfigMap metadata: - name: assert-n2n-mainnet-origin-blocks + name: ${TEST_NAME} data: daemon.toml: |- [source] @@ -11,7 +11,7 @@ data: magic = "mainnet" [source.finalize] - max_block_quantity: 5000 + max_block_quantity = 2000 [source.intersect] type = "Origin" @@ -23,14 +23,15 @@ data: apiVersion: batch/v1 kind: Job metadata: - name: assert-n2n-mainnet-origin-blocks + name: ${TEST_NAME} labels: - app: assert-n2n-mainnet-origin-blocks + app: ${TEST_NAME} spec: + backoffLimit: 1 template: metadata: labels: - app: assert-n2n-mainnet-origin-blocks + app: ${TEST_NAME} spec: restartPolicy: "Never" containers: @@ -54,4 +55,4 @@ spec: volumes: - name: oura-config configMap: - name: oura + name: ${TEST_NAME} diff --git a/.github/e2e/assert-n2n-mainnet-tip-blocks.yaml b/.github/e2e/assert-n2n-mainnet-tip-blocks.yaml new file mode 100644 index 00000000..d1b9c90e --- /dev/null +++ b/.github/e2e/assert-n2n-mainnet-tip-blocks.yaml @@ -0,0 +1,58 @@ +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: ${TEST_NAME} +data: + daemon.toml: |- + [source] + type = "N2N" + address = ["Tcp", "relays-new.cardano-mainnet.iohk.io:3001"] + magic = "mainnet" + + [source.finalize] + max_block_quantity = 50 + + [source.intersect] + type = "Tip" + + [sink] + type = "Assert" + break_on_failure = true +--- +apiVersion: batch/v1 +kind: Job +metadata: + name: ${TEST_NAME} + labels: + app: ${TEST_NAME} +spec: + backoffLimit: 1 + template: + metadata: + labels: + app: ${TEST_NAME} + spec: + restartPolicy: "Never" + containers: + - name: main + image: ${TARGET_IMAGE} + env: + - name: "RUST_LOG" + value: "warn" + resources: + requests: + memory: 100Mi + cpu: 50m + limits: + memory: 500Mi + cpu: 200m + args: + - "daemon" + volumeMounts: + - mountPath: /etc/oura + name: oura-config + volumes: + - name: oura-config + configMap: + name: ${TEST_NAME} diff --git a/.github/e2e/assert-n2n-testnet-origin-blocks.yaml b/.github/e2e/assert-n2n-testnet-origin-blocks.yaml new file mode 100644 index 00000000..838e5298 --- /dev/null +++ b/.github/e2e/assert-n2n-testnet-origin-blocks.yaml @@ -0,0 +1,58 @@ +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: ${TEST_NAME} +data: + daemon.toml: |- + [source] + type = "N2N" + address = ["Tcp", "relays-new.cardano-testnet.iohkdev.io:3001"] + magic = "testnet" + + [source.finalize] + max_block_quantity = 2000 + + [source.intersect] + type = "Origin" + + [sink] + type = "Assert" + break_on_failure = true +--- +apiVersion: batch/v1 +kind: Job +metadata: + name: ${TEST_NAME} + labels: + app: ${TEST_NAME} +spec: + backoffLimit: 1 + template: + metadata: + labels: + app: ${TEST_NAME} + spec: + restartPolicy: "Never" + containers: + - name: main + image: ${TARGET_IMAGE} + env: + - name: "RUST_LOG" + value: "warn" + resources: + requests: + memory: 100Mi + cpu: 50m + limits: + memory: 500Mi + cpu: 200m + args: + - "daemon" + volumeMounts: + - mountPath: /etc/oura + name: oura-config + volumes: + - name: oura-config + configMap: + name: ${TEST_NAME} diff --git a/.github/e2e/assert-n2n-testnet-tip-blocks.yaml b/.github/e2e/assert-n2n-testnet-tip-blocks.yaml new file mode 100644 index 00000000..ba29cf6a --- /dev/null +++ b/.github/e2e/assert-n2n-testnet-tip-blocks.yaml @@ -0,0 +1,58 @@ +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: ${TEST_NAME} +data: + daemon.toml: |- + [source] + type = "N2N" + address = ["Tcp", "relays-new.cardano-testnet.iohkdev.io:3001"] + magic = "testnet" + + [source.finalize] + max_block_quantity = 20 + + [source.intersect] + type = "Tip" + + [sink] + type = "Assert" + break_on_failure = true +--- +apiVersion: batch/v1 +kind: Job +metadata: + name: ${TEST_NAME} + labels: + app: ${TEST_NAME} +spec: + backoffLimit: 1 + template: + metadata: + labels: + app: ${TEST_NAME} + spec: + restartPolicy: "Never" + containers: + - name: main + image: ${TARGET_IMAGE} + env: + - name: "RUST_LOG" + value: "warn" + resources: + requests: + memory: 100Mi + cpu: 50m + limits: + memory: 500Mi + cpu: 200m + args: + - "daemon" + volumeMounts: + - mountPath: /etc/oura + name: oura-config + volumes: + - name: oura-config + configMap: + name: ${TEST_NAME} diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index d1e807b1..1c01f29e 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -9,8 +9,7 @@ env: CLUSTER: m1-prod-6x3kk4 jobs: - test: - name: End to End tests + build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -33,12 +32,17 @@ jobs: push: true tags: ${{ env.TARGET_IMAGE }} + prepare: + needs: ["build"] + runs-on: ubuntu-latest + + steps: - uses: aws-actions/configure-aws-credentials@v1 with: aws-region: us-west-2 aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/ClusterAdmin + role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/ClusterAdminRole role-session-name: Github-e2e-Rollout role-duration-seconds: 1200 @@ -46,11 +50,45 @@ jobs: run: aws eks update-kubeconfig --name ${CLUSTER} - name: Create Namespace + run: kubectl create namespace e2e-${GITHUB_RUN_NUMBER} + + test: + needs: ["prepare"] + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + include: + - name: assert-n2n-mainnet-origin-blocks + - name: assert-n2n-mainnet-tip-blocks + - name: assert-n2n-testnet-origin-blocks + - name: assert-n2n-testnet-tip-blocks + + steps: + - uses: actions/checkout@v2 + + - uses: aws-actions/configure-aws-credentials@v1 + with: + aws-region: us-west-2 + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/ClusterAdminRole + role-session-name: Github-e2e-Rollout + role-duration-seconds: 3600 + + - name: Login to EKS + run: aws eks update-kubeconfig --name ${CLUSTER} + + - name: Rollout Job working-directory: .github/e2e + env: + TEST_NAME: ${{ matrix.name }} run: |+ - kubectl create namespace e2e-${{ env.GITHUB_RUN_NUMBER }} + envsubst < ${TEST_NAME}.yaml | kubectl apply -n e2e-${GITHUB_RUN_NUMBER} -f - - - name: Rollout Jobs - working-directory: .github/e2e + - name: Wait for Completion + env: + TEST_NAME: ${{ matrix.name }} run: |+ - envsubst < assert-n2n-mainnet-origin-blocks.yaml | kubectl apply -n e2e-${{ env.GITHUB_RUN_NUMBER }} -f - + kubectl wait --for=condition=complete --timeout=1800s job ${TEST_NAME} -n e2e-${GITHUB_RUN_NUMBER} + kubectl get job ${TEST_NAME} -o jsonpath={.status.succeeded} -n e2e-${GITHUB_RUN_NUMBER}