From db18879270ca04f2d89e1b7ebd1dd4ff003b9ed1 Mon Sep 17 00:00:00 2001 From: Pavel Moskovkin <34027831+pavel-moskovkin@users.noreply.github.com> Date: Fri, 2 Oct 2020 11:23:51 +0300 Subject: [PATCH] PENV-630 run gbe-system-tests on pull requests (#188) --- .github/workflows/gbe-system-tests.yaml | 107 ++++++++++++++++++ deploy/autotests/kustomization.yaml | 10 ++ .../block-explorer/block-explorer-patch.yaml | 25 ++++ deploy/block-explorer/external-svc.yaml | 13 +++ deploy/block-explorer/kustomization.yaml | 14 +++ 5 files changed, 169 insertions(+) create mode 100644 .github/workflows/gbe-system-tests.yaml create mode 100644 deploy/autotests/kustomization.yaml create mode 100644 deploy/block-explorer/block-explorer-patch.yaml create mode 100644 deploy/block-explorer/external-svc.yaml create mode 100644 deploy/block-explorer/kustomization.yaml diff --git a/.github/workflows/gbe-system-tests.yaml b/.github/workflows/gbe-system-tests.yaml new file mode 100644 index 00000000..0e756a38 --- /dev/null +++ b/.github/workflows/gbe-system-tests.yaml @@ -0,0 +1,107 @@ +name: system-tests +on: + pull_request: + schedule: + - cron: 0 2 * * * +env: + KUBECONFIG: k3s.yaml + GITOPS_BRANCH: ?ref=REL-57 +jobs: + test: + name: test + runs-on: ubuntu-latest + strategy: + max-parallel: 2 + matrix: + target: [gbe-system-tests] + steps: + - name: Set up go + uses: actions/setup-go@v2 + with: + go-version: '1.14' + - name: checkout code + uses: actions/checkout@master + - name: build block-explorer image + run: docker build -t localhost/block-explorer:local . + - name: spin up k3s + uses: insolar/k3s-gha@v0.1 + with: + kubectl_version: "v1.18.2" + k3s_tag: "v1.17.4-k3s1" + custom_registry: true + registries_yaml_path: "deploy/registries.yaml" + - name: set PAT for github http auth + run: | + git config --global url."https://${{secrets.INS_SERVICE_PAT}}@github.com/".insteadOf "https://github.com/" + kubectl create ns insolar && kubectl -n insolar create secret generic ins-service-pat --from-literal=INS_SERVICE_PAT=${{secrets.INS_SERVICE_PAT}} + - name: set up local registry + run: kubectl apply -k https://github.com/insolar/gitops/k3s-registry + - name: wait for registry to be up and running + run: kubectl -n registry rollout status deploy/registry --timeout=80s + - name: push block-explorer image to local registry + run: docker push localhost/block-explorer:local + - name: deploy insolar-mainnet + run: kubectl apply -k "https://github.com/insolar/gitops/mainnet/overlays/autotests/${{env.GITOPS_BRANCH}}" + - name: wait for bootstrap completion + run: | + echo "waiting for bootstrap completion…" + for attempt in {1..120}; do + STATUS=$(kubectl -n insolar get po bootstrap -o jsonpath='{.status.phase}') + [[ "${STATUS}" == "Succeeded" ]] && exit 0 || sleep 1 + done + exit 1 + - name: wait for insolar network initialization + run: | + echo "waiting for insolar network initialization…" + for try in {0..180}; do + if kubectl -n insolar exec -i deploy/pulsewatcher -- bash -c 'pulsewatcher -c /etc/pulsewatcher/pulsewatcher.yaml -s' | grep 'READY' | grep -v 'NOT'; then + exit 0 + else + sleep 1 + fi + done + exit 1 + - name: deploy block-explorer + run: kubectl -n insolar apply -k deploy/block-explorer + - name: spawn autotests pod + run: | + # create secret + kubectl -n insolar create secret docker-registry ins-registry \ + --docker-server=${{ secrets.REGISTRY_URL }} \ + --docker-username=${{ secrets.REGISTRY_USERNAME }} \ + --docker-password=${{ secrets.REGISTRY_PASSWORD }} + # patch sa + kubectl -n insolar patch sa default -p '{"imagePullSecrets":[{"name":"ins-registry"}]}' + kubectl -n insolar apply -k deploy/autotests + - name: wait for pod initialization + run: | + for attempt in {1..10}; do + STATUS=$(kubectl -n insolar get po go-autotests -o jsonpath='{.status.phase}') + [[ "${STATUS}" == "Running" ]] && exit 0 || sleep $attempt + done + - name: run autotests + run: | + kubectl -n insolar exec go-autotests -- /bin/sh -c 'git config --global url."https://${INS_SERVICE_PAT}@github.com".insteadOf "https://github.com"' + kubectl -n insolar exec go-autotests -- /bin/sh -c 'TEST_COUNT=1 make ${{matrix.target}}' > logs.log + - name: display logs + if: always() + run: cat logs.log + - name: create tests report + if: failure() + run: | + go get github.com/tsovak/go-test-parser/... + go-test-parser logs.log -o report + - name: Upload report to artifacts + if: failure() + uses: actions/upload-artifact@v2 + with: + name: report + path: "report" + - name: Send failure notification to Slack + if: failure() && github.event_name == 'schedule' + uses: 8398a7/action-slack@v3 + with: + status: ${{ job.status }} + fields: repo,message,commit,author,action,eventName,ref,workflow + env: + SLACK_WEBHOOK_URL: ${{ secrets.ACTIONS_NOTIFICATIONS_SLACK_HOOK_URL }} diff --git a/deploy/autotests/kustomization.yaml b/deploy/autotests/kustomization.yaml new file mode 100644 index 00000000..b8831ab1 --- /dev/null +++ b/deploy/autotests/kustomization.yaml @@ -0,0 +1,10 @@ +--- +namespace: insolar +bases: + - https://github.com/insolar/go-autotests/deploy/autotests-pod +images: + - name: localhost/go-autotests + newName: registry.insolar.io/insolar/go-autotests + newTag: latest +generatorOptions: + disableNameSuffixHash: true diff --git a/deploy/block-explorer/block-explorer-patch.yaml b/deploy/block-explorer/block-explorer-patch.yaml new file mode 100644 index 00000000..9451f9e7 --- /dev/null +++ b/deploy/block-explorer/block-explorer-patch.yaml @@ -0,0 +1,25 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: block-explorer +spec: + template: + spec: + initContainers: + - name: check-platform-status + env: + - { name: SLEEP_TIME_BEFORE_START, value: '30' } + image: ellerbrock/alpine-bash-curl-ssl:0.3.0 + command: [ 'bash', '-c' ] + args: + - "for i in {1..60}; do res=$(curl -s 'http://virtual-0.platform-network.insolar.svc.cluster.local:8001/metrics' | grep insolar_network_state | grep -v '#' | awk '{print $2}'); echo $res; if [[ $res = '6' ]];then sleep $SLEEP_TIME_BEFORE_START; exit 0; fi ; sleep 1; done; exit 1" + containers: + - name: block-explorer + env: + - { name: BLOCK_EXPLORER_REPLICATOR_AUTH_INSECURETLS, value: 'true' } + - { name: BLOCK_EXPLORER_REPLICATOR_AUTH_REQUIRED, value: 'true' } + - { name: BLOCK_EXPLORER_REPLICATOR_AUTH_URL, value: 'http://auth-service:8080/auth/token' } + - { name: BLOCK_EXPLORER_REPLICATOR_AUTH_LOGIN, value: 'replicator' } + - { name: BLOCK_EXPLORER_REPLICATOR_AUTH_PASSWORD, value: 'replicator' } + - { name: BLOCK_EXPLORER_REPLICATOR_ADDR, value: heavy-0.platform-network.insolar.svc.cluster.local:5678 } diff --git a/deploy/block-explorer/external-svc.yaml b/deploy/block-explorer/external-svc.yaml new file mode 100644 index 00000000..b3df93d5 --- /dev/null +++ b/deploy/block-explorer/external-svc.yaml @@ -0,0 +1,13 @@ +--- +apiVersion: v1 +kind: Service +metadata: + name: block-explorer-api-external +spec: + type: NodePort + ports: + - name: http + port: 8080 + nodePort: 32199 + selector: + app: block-explorer-api diff --git a/deploy/block-explorer/kustomization.yaml b/deploy/block-explorer/kustomization.yaml new file mode 100644 index 00000000..d83bf76c --- /dev/null +++ b/deploy/block-explorer/kustomization.yaml @@ -0,0 +1,14 @@ +--- +namespace: insolar +bases: + - https://github.com:insolar/adm/kustomize/generic-block-explorer/overlays/docker-for-desktop +patches: + - block-explorer-patch.yaml +resources: + - external-svc.yaml +images: + - name: block-explorer + newName: localhost/block-explorer + newTag: local +generatorOptions: + disableNameSuffixHash: true