Skip to content

Commit

Permalink
PENV-630 run gbe-system-tests on pull requests (#188)
Browse files Browse the repository at this point in the history
  • Loading branch information
pavel-moskovkin authored Oct 2, 2020
1 parent 2c3f594 commit db18879
Show file tree
Hide file tree
Showing 5 changed files with 169 additions and 0 deletions.
107 changes: 107 additions & 0 deletions .github/workflows/gbe-system-tests.yaml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
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 }}
10 changes: 10 additions & 0 deletions deploy/autotests/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -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
25 changes: 25 additions & 0 deletions deploy/block-explorer/block-explorer-patch.yaml
Original file line number Diff line number Diff line change
@@ -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 }
13 changes: 13 additions & 0 deletions deploy/block-explorer/external-svc.yaml
Original file line number Diff line number Diff line change
@@ -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
14 changes: 14 additions & 0 deletions deploy/block-explorer/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit db18879

Please sign in to comment.