Skip to content

Commit f1e3d89

Browse files
committed
feat: Add support tests
1 parent 7f771f8 commit f1e3d89

File tree

3 files changed

+127
-74
lines changed

3 files changed

+127
-74
lines changed
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: 'Contract Tests Action'
2+
description: 'Reusable contract tests action with specified Android SDK version'
3+
inputs:
4+
sdk-version:
5+
description: 'Android SDK version to use (e.g., 35)'
6+
required: true
7+
8+
runs:
9+
using: "composite"
10+
steps:
11+
- name: Set up Docker Compose
12+
shell: bash
13+
run: docker compose version
14+
15+
- name: Prepare directory
16+
shell: bash
17+
run: |
18+
sudo mkdir -p /tmp/otel-android-collector
19+
sudo chmod 777 /tmp/otel-android-collector
20+
21+
- name: Start Docker Compose services
22+
shell: bash
23+
working-directory: ./tests/contract-tests
24+
run: |
25+
docker compose up -d
26+
sleep 40 # Give more time for initialization
27+
ls -la /tmp/otel-android-collector
28+
29+
- name: Enable KVM
30+
shell: bash
31+
run: |
32+
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
33+
sudo udevadm control --reload-rules
34+
sudo udevadm trigger --name-match=kvm
35+
36+
- name: AVD cache
37+
uses: actions/cache@v4
38+
with:
39+
path: |
40+
~/.android/avd/*
41+
~/.android/adb*
42+
key: avd-${{ inputs.sdk-version }}-${{ runner.os }}-${{ github.sha }}
43+
44+
- name: Running Telemetry data generator
45+
uses: reactivecircus/android-emulator-runner@v2
46+
with:
47+
api-level: ${{ inputs.sdk-version }}
48+
target: 'aosp_atd'
49+
arch: x86_64
50+
force-avd-creation: false
51+
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
52+
disable-animations: true
53+
script: ./gradlew connectedCheck
54+
55+
- name: Running Crash App
56+
uses: reactivecircus/android-emulator-runner@v2
57+
with:
58+
api-level: ${{ inputs.sdk-version }}
59+
target: 'aosp_atd'
60+
arch: x86_64
61+
force-avd-creation: false
62+
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
63+
disable-animations: true
64+
script: |
65+
gradle :demo-apps:crash-demo:assembleDebug :demo-apps:crash-demo:installDebug && adb wait-for-device && echo "First launch..." && adb shell am start -n software.amazon.opentelemetry.android.demo.crash/.MainActivity && sleep 40 && echo "Restarting after crash..." && adb shell am start -n software.amazon.opentelemetry.android.demo.crash/.MainActivity && sleep 40
66+
67+
- name: Running ANR App
68+
uses: reactivecircus/android-emulator-runner@v2
69+
with:
70+
api-level: ${{ inputs.sdk-version }}
71+
target: 'aosp_atd'
72+
arch: x86_64
73+
force-avd-creation: false
74+
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
75+
disable-animations: true
76+
script: |
77+
gradle :demo-apps:anr-demo:assembleDebug :demo-apps:anr-demo:installDebug && adb wait-for-device && echo "First launch..." && adb shell am start -n software.amazon.opentelemetry.android.demo.anr/.MainActivity && sleep 60
78+
79+
- name: Run tests on the generated data
80+
shell: bash
81+
run: |
82+
./gradlew tests:contract-tests:testDebugUnitTest -PrunContractTests

.github/workflows/contract_tests.yml

Lines changed: 3 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -18,81 +18,10 @@ jobs:
1818
- name: Checkout repository
1919
uses: actions/checkout@v4
2020

21-
- name: Set up Docker Compose
22-
run: |
23-
docker compose version
24-
2521
- name: Initialize
2622
uses: ./.github/actions/initialization
2723

28-
- name: Prepare directory
29-
run: |
30-
sudo mkdir -p /tmp/otel-android-collector
31-
sudo chmod 777 /tmp/otel-android-collector
32-
33-
- name: Start Docker Compose services
34-
working-directory: ./tests/contract-tests
35-
run: |
36-
docker compose up -d
37-
sleep 40 # Give more time for initialization
38-
ls -la /tmp/otel-android-collector
39-
40-
41-
- name: Enable KVM
42-
run: |
43-
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
44-
sudo udevadm control --reload-rules
45-
sudo udevadm trigger --name-match=kvm
46-
47-
48-
- name: AVD cache
49-
uses: actions/cache@v4
50-
id: avd-cache
51-
with:
52-
path: |
53-
~/.android/avd/*
54-
~/.android/adb*
55-
key: avd-35-${{ runner.os }}-${{ github.sha }}
56-
57-
- name: Running Telemetry data generator
58-
uses: reactivecircus/android-emulator-runner@v2
59-
with:
60-
api-level: 35
61-
target: 'aosp_atd'
62-
arch: x86_64
63-
force-avd-creation: false
64-
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
65-
disable-animations: true
66-
script: ./gradlew connectedCheck
67-
68-
69-
- name: Running Crash App
70-
uses: reactivecircus/android-emulator-runner@v2
71-
with:
72-
api-level: 35
73-
target: 'aosp_atd'
74-
arch: x86_64
75-
force-avd-creation: false
76-
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
77-
disable-animations: true
78-
script: |
79-
gradle :demo-apps:crash-demo:assembleDebug :demo-apps:crash-demo:installDebug && adb wait-for-device && echo "First launch..." && adb shell am start -n software.amazon.opentelemetry.android.demo.crash/.MainActivity && sleep 40 && echo "Restarting after crash..." && adb shell am start -n software.amazon.opentelemetry.android.demo.crash/.MainActivity && sleep 40
80-
81-
- name: Running ANR App
82-
uses: reactivecircus/android-emulator-runner@v2
24+
- name: Run contract tests
25+
uses: ./.github/actions/contract_tests
8326
with:
84-
api-level: 35
85-
target: 'aosp_atd'
86-
arch: x86_64
87-
force-avd-creation: false
88-
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
89-
disable-animations: true
90-
script: |
91-
gradle :demo-apps:anr-demo:assembleDebug :demo-apps:anr-demo:installDebug && adb wait-for-device && echo "First launch..." && adb shell am start -n software.amazon.opentelemetry.android.demo.anr/.MainActivity && sleep 60
92-
93-
- name: Run tests on the generated data
94-
run: |
95-
./gradlew tests:contract-tests:testDebugUnitTest -PrunContractTests
96-
97-
98-
27+
sdk-version: 35
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Contract Tests Matrix
2+
3+
on:
4+
push:
5+
branches:
6+
- support_tests
7+
8+
pull_request:
9+
branches:
10+
- release/*
11+
12+
jobs:
13+
contract-tests:
14+
runs-on: ubuntu-latest
15+
strategy:
16+
matrix:
17+
api-level: [21, 26, 31, 34, 35]
18+
fail-fast: false # This allows all matrix jobs to complete even if one fails
19+
20+
steps:
21+
- name: Checkout repository
22+
uses: actions/checkout@v4
23+
24+
- name: Initialize
25+
uses: ./.github/actions/initialization
26+
27+
- name: Run Contract Tests
28+
uses: ./.github/actions/contract_tests
29+
with:
30+
sdk-version: ${{ matrix.api-level }}
31+
32+
summary:
33+
needs: contract-tests
34+
runs-on: ubuntu-latest
35+
if: always()
36+
steps:
37+
- name: Summary
38+
run: |
39+
echo "Contract Tests Summary:"
40+
echo "Completed tests for API levels: ${{ join(needs.contract-tests.matrix.api-level, ', ') }}"
41+
echo "Overall status: ${{ needs.contract-tests.result }}"
42+

0 commit comments

Comments
 (0)