Skip to content

Conversation

@dcalhoun
Copy link
Member

@dcalhoun dcalhoun commented Nov 6, 2023

What?

Expand the E2E test setup script to ensure the required iOS simulators are
available.

Why?

Relates to #55251. Simplify setting
up the E2E test environment by automating the process for creating the required
Android emulators.

How?

Update the E2E test setup script to leverage avdmanager to create the required
Android emulators. Remove now unneeded documentation of manual steps.

Testing Instructions

With required emulator unavailable

  1. Delete the Pixel 3 XL via avdmanager delete avd -n <device-id>.
  2. Run npm run native test:e2e:setup
  3. Verify the correct Android emulators are created.

With required emulator available

  1. Verify the Pixel 3XL emulator is available via emulator -list-avds.
  2. Run npm run native test:e2e:setup
  3. Verify duplicative emulators are not created.

Testing Instructions for Keyboard

n/a

Screenshots or screencast

n/a

Simplify E2E test environment setup by creating the required Android
emualtors if they are not present.
The setup script now manages these previously documented steps.
@dcalhoun dcalhoun added [Type] Automated Testing Testing infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests. Mobile App - i.e. Android or iOS Native mobile impl of the block editor. (Note: used in scripts, ping mobile folks to change) labels Nov 6, 2023
@dcalhoun dcalhoun marked this pull request as ready for review November 6, 2023 15:38
@dcalhoun dcalhoun requested a review from geriux November 6, 2023 15:38
The `avdmanager` command is unavailable, also the CI server generally
provides its own emulator.
This CLI is required for creating emulators.
@dcalhoun
Copy link
Member Author

dcalhoun commented Nov 6, 2023

👋🏻 @geriux. I believe we once discussed the following error when running avdmanager commands.

Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema
        at com.android.repository.api.SchemaModule$SchemaModuleVersion.<init>(SchemaModule.java:156)
        at com.android.repository.api.SchemaModule.<init>(SchemaModule.java:75)
        at com.android.sdklib.repository.AndroidSdkHandler.<clinit>(AndroidSdkHandler.java:81)
        at com.android.sdklib.tool.AvdManagerCli.run(AvdManagerCli.java:213)
        at com.android.sdklib.tool.AvdManagerCli.main(AvdManagerCli.java:200)
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.annotation.XmlSchema
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(Unknown Source)
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(Unknown Source)
        at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
        ... 5 more

I was able to resolve this error on my local machine by adding the following to my path before my existing /tools addition, sourced from SO.

diff --git a/zshrc b/zshrc
index be83a92..d1ebb77 100644
--- a/zshrc.local
+++ b/zshrc.local
@@ -36,6 +36,7 @@ export TERM="xterm-256color-italic"
 # Set Android SDK for React Native development
 export ANDROID_HOME=$HOME/Library/Android/sdk
 export PATH=$PATH:$ANDROID_HOME/emulator
+export PATH=$PATH:$ANDROID_HOME/cmdline-tools/latest/bin
 export PATH=$PATH:$ANDROID_HOME/tools
 export PATH=$PATH:$ANDROID_HOME/tools/bin
 export PATH=$PATH:$ANDROID_HOME/platform-tools

@github-actions
Copy link

github-actions bot commented Nov 6, 2023

Flaky tests detected in 6fae855.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/6773444501
📝 Reported issues:

These values need to update if the `device-config.json` updates.
@dcalhoun
Copy link
Member Author

dcalhoun commented Nov 6, 2023

Sorry for the late commits. This should actually be ready for review now. 😅

@geriux
Copy link
Member

geriux commented Nov 7, 2023

I was able to resolve this error on my local machine by adding the following to my path before my existing /tools addition, sourced from SO.

Thank you! Now I'm able to run avdmanager 🚀

Copy link
Member

@geriux geriux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Nice work with the script updates! ⭐

  • ✅ Created the simulator correctly when it didn't exist.
  • ✅ Skipped creating the simulator correctly when it existed.
  • ✅ Android tests ran as expected after creating the simulator using the script.

@dcalhoun dcalhoun merged commit 7b89a5e into trunk Nov 7, 2023
@dcalhoun dcalhoun deleted the test/setup-installs-android-emulators branch November 7, 2023 15:14
@github-actions github-actions bot added this to the Gutenberg 17.1 milestone Nov 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Mobile App - i.e. Android or iOS Native mobile impl of the block editor. (Note: used in scripts, ping mobile folks to change) [Type] Automated Testing Testing infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants