Skip to content

Commit 35ae92b

Browse files
authored
iOS tests (signalfx#60)
1 parent 3cfbc50 commit 35ae92b

16 files changed

Lines changed: 860 additions & 17422 deletions

File tree

.github/workflows/ci.yml

Lines changed: 55 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -58,18 +58,62 @@ jobs:
5858
--form 'payload=@"example/android/app/build/outputs/apk/release/app-release.apk"' \
5959
--form 'name="app-release.apk"'
6060
- name: Run tests
61-
run: cd example && npm run wdio.sauce
61+
run: cd example && npm run wdio.android.sauce
6262
build-ios:
6363
needs: version-check
6464
runs-on: macos-latest
65+
permissions: read-all
66+
environment: integration
67+
env:
68+
SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }}
69+
SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }}
70+
SAUCE_TUNNEL_ID: ${{ secrets.SAUCE_TUNNEL_ID }}
6571
steps:
66-
- uses: actions/checkout@v3
67-
- uses: actions/setup-node@v3
68-
with:
69-
node-version: '18'
70-
cache: 'npm'
71-
- run: npm ci
72-
- run: npm run bootstrap
73-
- name: Build ios
74-
run: cd example/ios && xcodebuild -workspace SplunkOtelReactNativeExample.xcworkspace -scheme SplunkOtelReactNativeExample -configuration Debug CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY=""
75-
72+
- uses: actions/checkout@v3
73+
- uses: actions/setup-node@v3
74+
with:
75+
node-version: '18'
76+
cache: 'npm'
77+
- name: Download sc binary for os x
78+
run: |
79+
SC_VERSION="4.9.1"
80+
SC_ARCH="x64"
81+
SC_DIR="$RUNNER_TOOL_CACHE/sc/$SC_VERSION/$SC_ARCH"
82+
mkdir -p $SC_DIR
83+
mkdir -p $SC_DIR.complete
84+
curl -L https://saucelabs.com/downloads/sc-$SC_VERSION-osx.zip -o $SC_DIR/sc-$SC_VERSION-osx.zip
85+
unzip $SC_DIR/sc-$SC_VERSION-osx.zip -d $SC_DIR
86+
mv $SC_DIR/sc-$SC_VERSION-osx $SC_DIR/sc-$SC_VERSION-linux
87+
- name: Setup sauce connect
88+
uses: saucelabs/sauce-connect-action@v2
89+
with:
90+
username: ${{ secrets.SAUCE_USERNAME }}
91+
accessKey: ${{ secrets.SAUCE_ACCESS_KEY }}
92+
tunnelName: ${{ secrets.SAUCE_TUNNEL_ID }}
93+
noSSLBumpDomains: all
94+
scVersion: '4.9.1'
95+
- run: npm ci
96+
- run: npm run bootstrap
97+
- name: Build iOS
98+
run: |
99+
cd example/ios && \
100+
xcodebuild \
101+
-workspace SplunkOtelReactNativeExample.xcworkspace \
102+
-scheme SplunkOtelReactNativeExample \
103+
-derivedDataPath './iosSimBuild' \
104+
-sdk iphonesimulator \
105+
-arch x86_64 \
106+
-configuration Release \
107+
CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=NO
108+
- name: Zip iOS build
109+
run: |
110+
cd example/ios/iosSimBuild/Build/Products/Release-iphonesimulator && \
111+
zip -r SplunkOtelReactNativeExample.zip SplunkOtelReactNativeExample.app
112+
- name: Upload zip to saucelabs
113+
run: |
114+
curl -u "$SAUCE_USERNAME:$SAUCE_ACCESS_KEY" --location \
115+
--request POST 'https://api.us-west-1.saucelabs.com/v1/storage/upload' \
116+
--form 'payload=@"example/ios/iosSimBuild/Build/Products/Release-iphonesimulator/SplunkOtelReactNativeExample.zip"' \
117+
--form 'name="SplunkOtelReactNativeExample.zip"'
118+
- name: Run tests
119+
run: cd example && npm run wdio.ios.sauce

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,4 @@ lib/
7171

7272
*.tgz
7373
.env
74+
iosSimBuild/

android/src/main/java/com/splunkotelreactnative/SplunkOtelReactNativeModule.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,12 @@ private Attributes attributesFromMap(@Nullable ReadableMap attributeMap) {
248248
if (value instanceof String) {
249249
builder.put(entry.getKey(), (String) value);
250250
} else if (value instanceof Number) {
251-
builder.put(entry.getKey(), ((Number) value).doubleValue());
251+
// TODO fix this
252+
if (entry.getKey().equals("http.status_code")) {
253+
builder.put(entry.getKey(), ((Number) value).intValue());
254+
} else {
255+
builder.put(entry.getKey(), ((Number) value).doubleValue());
256+
}
252257
}
253258
}
254259

example/__tests__/e2e/configs/wdio.local.conf.ts renamed to example/__tests__/e2e/configs/wdio.android.local.conf.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export const config: Options.Testrunner = {
2121
...baseConfig,
2222
maxInstances: 1, // unless you have more emulators
2323
hostname: process.env.APPIUM_HOST || '127.0.0.1',
24-
port: parseInt(process.env.APPIUM_PORT, 10) || 4723,
24+
port: parseInt(process.env.APPIUM_PORT || '4723', 10),
2525
capabilities: [
2626
{
2727
'platformName': 'Android',
File renamed without changes.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
Copyright 2023 Splunk Inc.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
import type { Options } from '@wdio/types';
18+
import { config as baseConfig } from './wdio.conf';
19+
20+
export const config: Options.Testrunner = {
21+
...baseConfig,
22+
maxInstances: 1, // unless you have more emulators
23+
hostname: process.env.APPIUM_HOST || '127.0.0.1',
24+
port: parseInt(process.env.APPIUM_PORT || '4723', 10),
25+
capabilities: [
26+
{
27+
'platformName': 'iOS',
28+
'appium:deviceName': 'iPhone 15 Pro',
29+
'appium:platformVersion': '17.0',
30+
'appium:automationName': 'XCUITest',
31+
//TODO find local app file
32+
'appium:app': 'SplunkOtelReactNativeExample.app'
33+
},
34+
],
35+
};
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
Copyright 2023 Splunk Inc.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
import type { Options } from '@wdio/types';
18+
import { config as baseConfig } from './wdio.conf';
19+
20+
export const config: Options.Testrunner = {
21+
...baseConfig,
22+
user: process.env.SAUCE_USERNAME,
23+
key: process.env.SAUCE_ACCESS_KEY,
24+
region: 'us',
25+
// We can't start more than one devServer and not sure how to differentiate between tests spans
26+
// if we have only one server.
27+
maxInstances: 1,
28+
services: ['sauce'],
29+
capabilities: [
30+
{
31+
'platformName': 'iOS',
32+
// 'appium:deviceName': 'iPhone Simulator',
33+
// 'appium:platformVersion': '17.0',
34+
'appium:platformVersion': 'current_major',
35+
'appium:deviceName': 'iPhone Instant Simulator',
36+
'appium:automationName': 'XCUITest',
37+
'appium:app': 'storage:filename=SplunkOtelReactNativeExample.zip',
38+
'sauce:options': {
39+
tunnelIdentifier: process.env.SAUCE_TUNNEL_ID,
40+
},
41+
},
42+
],
43+
};

example/__tests__/e2e/specs/http.e2e.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,12 @@ describe('Http request', () => {
3333
await fetchButton.click();
3434

3535
const fetchSpan = await devServer.findSpan(
36-
(span) => span.tags.component === 'http'
36+
(span: { tags: { component: string; }; }) => span.tags.component === 'http'
3737
);
3838
expect(fetchSpan).toBeDefined();
3939
expect(fetchSpan.tags['http.method']).toBe('GET');
40-
expect(fetchSpan.tags['http.status_code']).toBe('200.0');
40+
// FIXME android status code is 200.0 and ios 200
41+
expect(fetchSpan.tags['http.status_code']).toBe('200');
4142
expect(fetchSpan.tags['http.url']).toBe(
4243
'https://raw.githubusercontent.com/signalfx/splunk-otel-react-native/main/package.json'
4344
);

example/__tests__/e2e/specs/navigation.e2e.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ describe('Navigation', () => {
3232
await navigationButton.waitForDisplayed({ timeout: 10000, interval: 1500 });
3333
// get rid of initial Created span from Home screen
3434
const homeCreateSpan = await devServer.findSpan(
35-
(span) => span.tags.component === 'ui'
35+
(span: { tags: { component: string; }; }) => span.tags.component === 'ui'
3636
);
3737
expect(homeCreateSpan).toBeDefined();
3838
devServer.clearSpans();
@@ -42,7 +42,7 @@ describe('Navigation', () => {
4242
await fetch.waitForDisplayed({ timeout: 10000, interval: 1500 });
4343

4444
const createSpan = await devServer.findSpan(
45-
(span) => span.tags.component === 'ui'
45+
(span: { tags: { component: string; }; }) => span.tags.component === 'ui'
4646
);
4747

4848
expect(createSpan).toBeDefined();

example/android/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
buildscript {
44
ext {
5-
buildToolsVersion = "31.0.0"
5+
buildToolsVersion = "32.0.0"
66
minSdkVersion = 21
7-
compileSdkVersion = 31
8-
targetSdkVersion = 31
7+
compileSdkVersion = 32
8+
targetSdkVersion = 32
99

1010
if (System.properties['os.arch'] == "aarch64") {
1111
// For M1 Users we need to use the NDK 24 which added support for aarch64

0 commit comments

Comments
 (0)