Skip to content

Commit feffc5b

Browse files
authored
Modify RC tests for iOS simulators (#1042)
* Increase one of the RC test timeouts * Try disabling the tests * Try an even bigger timeout * Update UIHandlerAutomated.cs * Update print_matrix_configuration.py * Update print_matrix_configuration.py * Set up a keychain for iOS simulator on tests * Update print_matrix_configuration.py * Update print_matrix_configuration.py * Update UIHandlerAutomated.cs * Update print_matrix_configuration.py
1 parent 6c26a59 commit feffc5b

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

.github/workflows/integration_tests.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,25 @@ jobs:
555555
if: ${{ matrix.device_type == 'virtual' && !cancelled() }}
556556
run: |
557557
xcrun xctrace list devices
558+
- name: Create keychain (macOS Simulator)
559+
if: ${{ contains('iOS,tvOS', matrix.platform) && matrix.device_type == 'virtual'}}
560+
shell: bash
561+
run: |
562+
echo "Creating temporary keychain"
563+
# Create a local keychain on Mac:
564+
# Clean up previous temp keychain, if any.
565+
security delete-keychain tmp-keychain 2> /dev/null || true
566+
# Create temp keychain file and unlock it.
567+
# (Avoid passing in -p on command line by using interactive mode.)
568+
# Also set it to default settings so there is no unlock timeout.
569+
security -i <<EOF
570+
create-keychain -p ${{ secrets.TEST_SECRET }} tmp-keychain
571+
set-keychain-settings tmp-keychain
572+
unlock-keychain -p ${{ secrets.TEST_SECRET }} tmp-keychain
573+
EOF
574+
# Change the keychain list and default keychain to the temp keychain.
575+
security list-keychains -d user -s tmp-keychain
576+
security default-keychain -s tmp-keychain
558577
- name: Run Mobile integration tests on virtual device locally
559578
timeout-minutes: 120
560579
if: ${{ matrix.device_type == 'virtual' && !cancelled() }}
@@ -565,6 +584,15 @@ jobs:
565584
--android_device "${{ matrix.test_device }}" \
566585
--logfile_name ""${{ steps.matrix_info.outputs.info }}"" \
567586
--ci
587+
- name: Delete keychain (macOS Simulator)
588+
if: ${{ always() && contains('iOS,tvOS', matrix.platform) && matrix.device_type == 'virtual' }}
589+
shell: bash
590+
run: |
591+
# Remove the local keychain on Mac:
592+
# Set back to the default login keychain.
593+
security list-keychains -d user -s login.keychain
594+
# Delete the temp keychain, if it exists.
595+
security delete-keychain tmp-keychain || true
568596
- name: Prepare results summary artifact
569597
if: ${{ !cancelled() }}
570598
shell: bash

remote_config/testapp/Assets/Firebase/Sample/RemoteConfig/UIHandlerAutomated.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ namespace Firebase.Sample.RemoteConfig {
44
using System;
55
using System.Linq;
66
using System.Threading.Tasks;
7+
using UnityEngine;
78

89
// An automated version of the UIHandler that runs tests on Firebase Remote Config.
910
public class UIHandlerAutomated : UIHandler {
@@ -13,6 +14,7 @@ protected override void Start() {
1314
// Set the list of tests to run, note this is done at Start since they are
1415
// non-static.
1516
Func<Task>[] tests = {
17+
TestSetConfigSettings,
1618
TestDisplayData,
1719
TestDisplayAllKeys,
1820
// Skip the Realtime RC test on desktop as it is not yet supported.
@@ -48,6 +50,13 @@ private void AssertEq<T>(string message, T value1, T value2) {
4850
}
4951
}
5052

53+
Task TestSetConfigSettings() {
54+
var configSettings = new Firebase.RemoteConfig.ConfigSettings();
55+
configSettings.FetchTimeoutInMilliseconds = 30 * 1000;
56+
configSettings.MinimumFetchIntervalInMilliseconds = 0;
57+
return FirebaseRemoteConfig.DefaultInstance.SetConfigSettingsAsync(configSettings);
58+
}
59+
5160
Task TestDisplayData() {
5261
DisplayData();
5362
return Task.FromResult(true);
@@ -87,6 +96,13 @@ Task TestAddOnConfigUpdateListener() {
8796
return Task.FromResult(true);
8897
}
8998

99+
if (SystemInfo.graphicsDeviceName.ToLower().Contains("simulator")) {
100+
DebugLog("WARNING: iOS simulator can frequently take a significant amount "
101+
+ "of time to do the fetch, so this is disabled by default. To test, "
102+
+ "modify the scripts.");
103+
return Task.FromResult(true);
104+
}
105+
90106
TaskCompletionSource<bool> test_success = new TaskCompletionSource<bool>();
91107
EventHandler<ConfigUpdateEventArgs> myHandler =
92108
(object sender, ConfigUpdateEventArgs args) => {
@@ -124,6 +140,13 @@ Task TestAddAndRemoveConfigUpdateListener() {
124140
}
125141

126142
Task TestFetchData() {
143+
if (SystemInfo.graphicsDeviceName.ToLower().Contains("simulator")) {
144+
DebugLog("WARNING: iOS simulator can frequently take a significant amount "
145+
+ "of time to do the fetch, so this is disabled by default. To test, "
146+
+ "modify the scripts.");
147+
return Task.FromResult(true);
148+
}
149+
127150
// Note: FetchDataAsync calls both Fetch and Activate.
128151
return FetchDataAsync().ContinueWithOnMainThread((_) => {
129152
// Verify that RemoteConfig now has the expected values.

0 commit comments

Comments
 (0)