-
Notifications
You must be signed in to change notification settings - Fork 9
140 lines (136 loc) · 5.88 KB
/
e2e-tests-grpc.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
# This file is part of Astarte.
#
# Copyright 2022 SECO Mind Srl
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
name: End to End test gRPC
on: [pull_request]
env:
PB_REL: https://github.com/protocolbuffers/protobuf/releases
jobs:
e2e-test-grpc:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.12"]
msghub-version: ["v0.7.0"]
concurrency:
group: e2e-test-grpc-${{ matrix.python-version }}-${{ github.ref }}
cancel-in-progress: true
steps:
- name: Checkout astarte-device-sdk-python
uses: actions/checkout@v4
with:
path: astarte-device-sdk-python
- name: Checkout astarte-message-hub
uses: actions/checkout@v4
with:
repository: astarte-platform/astarte-message-hub
path: astarte-message-hub
ref: ${{ matrix.msghub-version }}
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install Protoc
run: |
curl -LO $PB_REL/download/v26.1/protoc-26.1-linux-x86_64.zip
unzip protoc-26.1-linux-x86_64.zip -d $HOME/.local
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Create Astarte Cluster
uses: astarte-platform/astarte-cluster-action@v1
with:
astarte_version: "1.2.0"
- name: Install interface
working-directory: ./astarte-device-sdk-python/.github/workflows
timeout-minutes: 3
run: ./install_interfaces.sh $GITHUB_WORKSPACE/astarte-device-sdk-python/e2etest/interfaces
- name: Setup device generic env variables
run: |
echo "E2E_REALM=test" >> $GITHUB_ENV
APPENGINE_TOKEN=$(astartectl utils gen-jwt appengine)
echo "E2E_APPENGINE_TOKEN=$APPENGINE_TOKEN" >> $GITHUB_ENV
echo "E2E_APPENGINE_URL=https://api.autotest.astarte-platform.org/appengine" >> $GITHUB_ENV
echo "E2E_PAIRING_URL=https://api.autotest.astarte-platform.org/pairing" >> $GITHUB_ENV
- name: Setup device specific env variables
run: |
DEVICE_1_ID=$(astartectl utils device-id generate-random)
echo "E2E_DEVICE_1_ID=$DEVICE_1_ID" >> $GITHUB_ENV
CREDENTIALS_SECRET_1=$(astartectl pairing agent register --compact-output -- "$DEVICE_1_ID")
echo "E2E_CREDENTIALS_SECRET_1=$CREDENTIALS_SECRET_1" >> $GITHUB_ENV
- name: Fill in config file
run: |
echo "realm = \"$E2E_REALM\"" > message-hub-config.toml
echo "pairing_url = \"$E2E_PAIRING_URL\"" >> message-hub-config.toml
echo "grpc_socket_port = 50051" >> message-hub-config.toml
echo "device_id = \"$E2E_DEVICE_1_ID\"" >> message-hub-config.toml
echo "credentials_secret = \"$E2E_CREDENTIALS_SECRET_1\"" >> message-hub-config.toml
echo "store_directory = \"./tmp\"" >> message-hub-config.toml
cat message-hub-config.toml
working-directory: ./astarte-message-hub
- name: Setup GRPC node specific env variables
run: |
echo "E2E_GRPC_SOCKET_PORT=50051" >> $GITHUB_ENV
echo "E2E_GRPC_NODE_UUID=98bb9fe5-b4ce-4dea-9b88-8d1f8525e4b4" >> $GITHUB_ENV
working-directory: ./astarte-message-hub
- name: Create folder for binary
run: |
mkdir ./astarte-message-hub/target
mkdir ./astarte-message-hub/target/release
- name: Restore cached astarte-message-hub binary
id: cache-astarte-message-hub-restore
uses: actions/cache/restore@v4
with:
path: ./astarte-message-hub/target/release/astarte-message-hub
key: astarte-message-hub-${{ matrix.msghub-version }}
- name: Build message hub
if: steps.cache-astarte-message-hub-restore.outputs.cache-hit != 'true'
run: cargo build --release
working-directory: ./astarte-message-hub
- name: Save grpc_python_plugin
if: steps.cache-astarte-message-hub-restore.outputs.cache-hit != 'true'
id: cache-astarte-message-hub-save
uses: actions/cache/save@v4
with:
path: ./astarte-message-hub/target/release/astarte-message-hub
key: ${{ steps.cache-astarte-message-hub-restore.outputs.cache-primary-key }}
- name: Install the Astarte device Python module
run: |
python3 -m pip install --upgrade pip
python3 -m pip install -e .[e2e]
working-directory: ./astarte-device-sdk-python
- name: Wait for 5 seconds
run: sleep 5
- name: Run message hub
run: nohup ./target/release/astarte-message-hub > nohup.out 2> nohup.err < /dev/null &
working-directory: ./astarte-message-hub
- name: Wait for 5 seconds
run: sleep 5
- name: Run test base
run: |
export REQUESTS_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt
python3 e2etest/base/main.py --device_n 1 --mock_data_n 1
working-directory: ./astarte-device-sdk-python
- name: Run test for reconnection
run: |
export REQUESTS_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt
python3 ./e2etest/reconnection/main.py --device_n 1
working-directory: ./astarte-device-sdk-python