Skip to content

Commit

Permalink
Modify RC tests for iOS simulators (#1042)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
a-maurice authored Jun 18, 2024
1 parent 6c26a59 commit feffc5b
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/integration_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,25 @@ jobs:
if: ${{ matrix.device_type == 'virtual' && !cancelled() }}
run: |
xcrun xctrace list devices
- name: Create keychain (macOS Simulator)
if: ${{ contains('iOS,tvOS', matrix.platform) && matrix.device_type == 'virtual'}}
shell: bash
run: |
echo "Creating temporary keychain"
# Create a local keychain on Mac:
# Clean up previous temp keychain, if any.
security delete-keychain tmp-keychain 2> /dev/null || true
# Create temp keychain file and unlock it.
# (Avoid passing in -p on command line by using interactive mode.)
# Also set it to default settings so there is no unlock timeout.
security -i <<EOF
create-keychain -p ${{ secrets.TEST_SECRET }} tmp-keychain
set-keychain-settings tmp-keychain
unlock-keychain -p ${{ secrets.TEST_SECRET }} tmp-keychain
EOF
# Change the keychain list and default keychain to the temp keychain.
security list-keychains -d user -s tmp-keychain
security default-keychain -s tmp-keychain
- name: Run Mobile integration tests on virtual device locally
timeout-minutes: 120
if: ${{ matrix.device_type == 'virtual' && !cancelled() }}
Expand All @@ -565,6 +584,15 @@ jobs:
--android_device "${{ matrix.test_device }}" \
--logfile_name ""${{ steps.matrix_info.outputs.info }}"" \
--ci
- name: Delete keychain (macOS Simulator)
if: ${{ always() && contains('iOS,tvOS', matrix.platform) && matrix.device_type == 'virtual' }}
shell: bash
run: |
# Remove the local keychain on Mac:
# Set back to the default login keychain.
security list-keychains -d user -s login.keychain
# Delete the temp keychain, if it exists.
security delete-keychain tmp-keychain || true
- name: Prepare results summary artifact
if: ${{ !cancelled() }}
shell: bash
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ namespace Firebase.Sample.RemoteConfig {
using System;
using System.Linq;
using System.Threading.Tasks;
using UnityEngine;

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

Task TestSetConfigSettings() {
var configSettings = new Firebase.RemoteConfig.ConfigSettings();
configSettings.FetchTimeoutInMilliseconds = 30 * 1000;
configSettings.MinimumFetchIntervalInMilliseconds = 0;
return FirebaseRemoteConfig.DefaultInstance.SetConfigSettingsAsync(configSettings);
}

Task TestDisplayData() {
DisplayData();
return Task.FromResult(true);
Expand Down Expand Up @@ -87,6 +96,13 @@ Task TestAddOnConfigUpdateListener() {
return Task.FromResult(true);
}

if (SystemInfo.graphicsDeviceName.ToLower().Contains("simulator")) {
DebugLog("WARNING: iOS simulator can frequently take a significant amount "
+ "of time to do the fetch, so this is disabled by default. To test, "
+ "modify the scripts.");
return Task.FromResult(true);
}

TaskCompletionSource<bool> test_success = new TaskCompletionSource<bool>();
EventHandler<ConfigUpdateEventArgs> myHandler =
(object sender, ConfigUpdateEventArgs args) => {
Expand Down Expand Up @@ -124,6 +140,13 @@ Task TestAddAndRemoveConfigUpdateListener() {
}

Task TestFetchData() {
if (SystemInfo.graphicsDeviceName.ToLower().Contains("simulator")) {
DebugLog("WARNING: iOS simulator can frequently take a significant amount "
+ "of time to do the fetch, so this is disabled by default. To test, "
+ "modify the scripts.");
return Task.FromResult(true);
}

// Note: FetchDataAsync calls both Fetch and Activate.
return FetchDataAsync().ContinueWithOnMainThread((_) => {
// Verify that RemoteConfig now has the expected values.
Expand Down

0 comments on commit feffc5b

Please sign in to comment.