Skip to content

Sort dependencies in Cargo.toml #27

Sort dependencies in Cargo.toml

Sort dependencies in Cargo.toml #27

Workflow file for this run

name: Integration Test
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
integration:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: Swatinem/rust-cache@v2
with:
shared-key: integration
- uses: dtolnay/rust-toolchain@stable
- name: Install protoc and musl-tools
run: sudo apt-get update && sudo apt-get install -y protobuf-compiler musl-tools
- name: Clone virtual-lorawan-device
uses: actions/checkout@v4
with:
repository: lthiery/virtual-lorawan-device
ref: lk/smoke-test
path: virtual-lorawan-device
- name: Build virtual-lorawan-device
working-directory: virtual-lorawan-device
run: cargo build --release --target x86_64-unknown-linux-gnu
- name: Configure virtual device
working-directory: virtual-lorawan-device
run: |
cat > settings/settings.toml << 'EOF'
[device.one.credentials]
dev_eui = "${{ secrets.TEST_DEV_EUI }}"
app_eui = "${{ secrets.TEST_APP_EUI }}"
app_key = "${{ secrets.TEST_APP_KEY }}"
EOF
- name: Install cargo-deb
run: cargo install cargo-deb
- name: Build deb package
run: cargo deb --target x86_64-unknown-linux-musl
- name: Install deb package
run: sudo dpkg -i target/debian/helium-multi-gateway_*.deb
- name: Verify service is running
run: |
sleep 2
sudo systemctl is-active helium-multi-gateway
- name: Check logs for startup
run: sudo journalctl -u helium-multi-gateway --no-pager -n 20
- name: Verify API is responding with valid structure
run: |
response=$(curl -sf http://127.0.0.1:4468/gateways)
echo "$response" | jq .
echo "$response" | jq -e '.total >= 0'
echo "$response" | jq -e '.connected >= 0'
echo "$response" | jq -e '.gateways | type == "array"'
- name: Run integration test
working-directory: virtual-lorawan-device
timeout-minutes: 5
run: |
RUST_LOG=info ./target/x86_64-unknown-linux-gnu/release/virtual-lorawan-device \
--settings ./settings \
--smoke-test 30
- name: Verify gateway appeared after integration test
run: |
response=$(curl -sf http://127.0.0.1:4468/gateways)
echo "$response" | jq .
total=$(echo "$response" | jq '.total')
echo "Total gateways: $total"
if [ "$total" -lt 1 ]; then
echo "Expected at least 1 gateway after integration test"
exit 1
fi
# Verify gateway fields are present
echo "$response" | jq -e '.gateways[0].mac'
echo "$response" | jq -e '.gateways[0].public_key'
echo "$response" | jq -e '.gateways[0] | has("connected")'
# Test single gateway endpoint
mac=$(echo "$response" | jq -r '.gateways[0].mac')
gw_response=$(curl -sf "http://127.0.0.1:4468/gateways/$mac")
echo "$gw_response" | jq .
echo "$gw_response" | jq -e '.mac'
echo "$gw_response" | jq -e '.public_key'
- name: Verify Prometheus metrics after integration test
run: |
metrics=$(curl -sf http://127.0.0.1:4468/metrics)
echo "$metrics"
# Verify gateway connection was counted
echo "$metrics" | grep -E '^gateway_connections_total\{mac="[0-9a-f]+"\} [1-9]'
# Verify uplink packets were counted
echo "$metrics" | grep -E '^packets_uplink_total\{mac="[0-9a-f]+"\} [1-9]'
# Verify downlink packets were counted
echo "$metrics" | grep -E '^packets_downlink_total\{mac="[0-9a-f]+"\} [1-9]'
- name: Save pre-reconnect state
run: |
response=$(curl -sf http://127.0.0.1:4468/gateways)
mac=$(echo "$response" | jq -r '.gateways[0].mac')
echo "MAC=$mac" >> "$GITHUB_ENV"
metrics=$(curl -sf http://127.0.0.1:4468/metrics)
uplinks=$(echo "$metrics" | grep -oP "^packets_uplink_total\{mac=\"$mac\"\} \K[0-9]+")
echo "UPLINKS_BEFORE=$uplinks" >> "$GITHUB_ENV"
echo "Gateway $mac had $uplinks uplinks before reconnect test"
- name: Wait for semtech-udp disconnect timeout (65s)
run: |
echo "Waiting 65s for disconnect (30s timeout + 30s cache check interval)..."
sleep 65
- name: Verify gateway disconnected
run: |
response=$(curl -sf "http://127.0.0.1:4468/gateways/$MAC")
echo "$response" | jq .
connected=$(echo "$response" | jq '.connected')
echo "Gateway connected: $connected"
if [ "$connected" != "false" ]; then
echo "Expected gateway to be disconnected after 65s wait"
exit 1
fi
- name: Reconnect virtual device (second smoke test)
working-directory: virtual-lorawan-device
timeout-minutes: 5
run: |
RUST_LOG=info ./target/x86_64-unknown-linux-gnu/release/virtual-lorawan-device \
--settings ./settings \
--smoke-test 30
- name: Verify gateway reconnected and uplinks increased
run: |
response=$(curl -sf "http://127.0.0.1:4468/gateways/$MAC")
echo "$response" | jq .
connected=$(echo "$response" | jq '.connected')
if [ "$connected" != "true" ]; then
echo "Expected gateway to be connected after reconnect"
exit 1
fi
metrics=$(curl -sf http://127.0.0.1:4468/metrics)
uplinks=$(echo "$metrics" | grep -oP "^packets_uplink_total\{mac=\"$MAC\"\} \K[0-9]+")
echo "Uplinks before: $UPLINKS_BEFORE, after: $uplinks"
if [ "$uplinks" -le "$UPLINKS_BEFORE" ]; then
echo "Expected uplink count to increase after reconnect"
exit 1
fi
echo "Reconnect test passed: gateway recovered and forwarded packets"
- name: Show multi-gateway logs
if: always()
run: sudo journalctl -u helium-multi-gateway --no-pager -n 100