-
Notifications
You must be signed in to change notification settings - Fork 4
153 lines (136 loc) · 5.09 KB
/
astarte-ctl-test.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# SPDX-FileCopyrightText: 2024 SECO Mind Srl
#
# SPDX-License-Identifier: Apache-2.0
name: Test
on:
push:
branches:
- 'main'
pull_request:
jobs:
astarte-ctl-test:
name: Astartectl Test
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
# Utility tool for later
- name: Setup jq
uses: dcarbone/install-jq-action@v2
- name: Check jq
run: |
which jq
jq --version
- name: Create Astarte Cluster
id: astarte
uses: astarte-platform/astarte-cluster-action@v1
with:
astarte_version: "1.1.1"
astartectl_version: "24.5.2"
- name: Checkout sources
uses: actions/checkout@v3
- name: Install interface
run: |
astartectl realm-management interfaces sync $GITHUB_WORKSPACE/interfaces/*.json --non-interactive
astartectl realm-management interfaces ls
# This will handle load balancing
- name: Install MetalLB
run: |
helm repo add bitnami https://charts.bitnami.com/bitnami
helm repo update
helm install metallb bitnami/metallb -n metallb-system --version 4.16.1 --create-namespace
# Give some time to metallb pods to get ready
- name: Sleep it off
run: sleep 60s
id: sleep
# Get a list of IPs from which we will choose the one assigned to Scylla
- name: Get network address list
id: lb-addresses
run: |
echo "LB_ADDRESSES=$(docker network inspect kind | jq --raw-output 'first | .IPAM.Config | .[] | .Subnet' | awk '{match($0,/[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+/); ip = substr($0,RSTART,RLENGTH); print ip}' | tr -d '\n' | sed 's#\(.*\)#\1/27\n#')" >> $GITHUB_OUTPUT
# Configure metallb
- name: Configure MetalLB
if: steps.sleep.outcome == 'success'
id: metallb-conf
env:
LB_ADDRESSES: ${{ steps.lb-addresses.outputs.LB_ADDRESSES }}
run: |
echo "---
apiVersion: metallb.io/v1beta1
kind: IPAddressPool
metadata:
name: demo-pool
namespace: metallb-system
spec:
addresses:
- $LB_ADDRESSES
---
apiVersion: metallb.io/v1beta1
kind: L2Advertisement
metadata:
name: demo-advertisement
namespace: metallb-system
spec:
ipAddressPools:
- demo-pool
" | \
kubectl apply -f -
# Expose Scylla
- name: Expose Scylla with a LoadBalancer
if: steps.metallb-conf.outcome == 'success'
id: scylla-svc
run: kubectl expose svc -n astarte astarte-cassandra --target-port=9042 --name=astarte-cassandra-lb --type=LoadBalancer
- name: Retrieve Scylla connection info
if: steps.scylla-svc.outcome == 'success'
run: echo "Scylla is reachable at $(kubectl get svc -n astarte astarte-cassandra-lb -o=jsonpath='{.status.loadBalancer.ingress[0].ip}'):9042"
- name: Checkout Astarte Import
uses: actions/checkout@v2
with:
repository: astarte-platform/astarte
path: astarte_import
ref: master
- name: Setup Elixir
uses: erlef/setup-beam@v1
with:
elixir-version: '1.15'
otp-version: '25.0'
- name: Install dependencies for Astarte Import
run: |
cd astarte_import/tools/astarte_import
mix deps.get
- name: Build Astarte Import
run: |
cd astarte_import/tools/astarte_import
IP=$(kubectl get svc -n astarte astarte-cassandra-lb -o=jsonpath='{.status.loadBalancer.ingress[0].ip}')
export CASSANDRA_DB_HOST=$IP
export CASSANDRA_DB_PORT=9042
export CASSANDRA_NODES=$IP:9042
echo "CASSANDRA_NODES=$CASSANDRA_NODES" >> $GITHUB_ENV
MIX_ENV=prod mix do compile, release
- name: Run Astarte Import
run: |
cd astarte_import/tools/astarte_import/_build/prod/rel/astarte_import/bin
./astarte_import eval "Mix.Tasks.Astarte.Import.run [\"test\",\"${{ github.workspace }}/import.xml\"]"
- name: Setup ENV
run: |
echo "E2E_REALM=test" >> $GITHUB_ENV
echo "E2E_API_URL=https://api.autotest.astarte-platform.org" >> $GITHUB_ENV
TOKEN=$(astartectl utils gen-jwt all-realm-apis)
echo "E2E_JWT=$TOKEN" >> $GITHUB_ENV
echo "E2E_DEVICE_TEST_1=ogmcilZpRDeDWwuNfJr0yA" >> $GITHUB_ENV
DEVICE_TEST_2=$(astartectl utils device-id generate-random)
echo "E2E_DEVICE_TEST_2=$DEVICE_TEST_2" >> $GITHUB_ENV
astartectl pairing agent register --compact-output -- "$DEVICE_TEST_2"
- name: Setup python
uses: actions/setup-python@v2
with:
python-version: '3.12'
- name: Install dependencies
shell: bash
run: pip install -e ./tests
- name: Format check
shell: bash
run: python -m black -l 100 --diff --check tests/
- name: Run tests
shell: bash
run: ./test.sh