Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support instrumentation capabilities #998

Merged
merged 5 commits into from
Jan 15, 2025

Conversation

shahrukhamd
Copy link
Contributor

@shahrukhamd shahrukhamd commented Jan 14, 2025

Description

Added new instrumentation capabilities. saucectl will forwards these arguments in the API call it makes to further internal services.

@shahrukhamd shahrukhamd requested a review from a team as a code owner January 14, 2025 11:51
@diegoperini diegoperini added the enhancement New feature or request label Jan 14, 2025
@alexplischke alexplischke changed the title [RDX-483]: support instrumentation capabilities feat: support instrumentation capabilities Jan 14, 2025
Copy link
Contributor

@alexplischke alexplischke left a comment

Choose a reason for hiding this comment

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

This will also require updates in https://github.com/saucelabs/sauce-docs 🙏

@@ -257,9 +257,14 @@ func (r *EspressoRunner) newStartOptions(
// Overwrite device settings
RealDeviceKind: strings.ToLower(espresso.Android),
AppSettings: job.AppSettings{
AudioCapture: s.AppSettings.AudioCapture,
InstrumentationEnabled: s.AppSettings.ResigningEnabled,
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't that supposed to be InstrumentationEnabled?

Suggested change
InstrumentationEnabled: s.AppSettings.ResigningEnabled,
InstrumentationEnabled: s.AppSettings.InstrumentationEnabled,

Copy link
Contributor

@diegoperini diegoperini Jan 15, 2025

Choose a reason for hiding this comment

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

This AppSettings to job.AppSettings struct mapping maps saucectl yaml values to composer API call json payload. In the yaml, the definition ResigningEnabled is used both for iOS and Android but in the API call, the name is different per platform. I wish I was able to rename it so that it's consistent but that's a breaking change for existing saucectl users, so we do this ugly mapping as the lesser evil.

History:

  • saucectl always used ResigningEnabled for this value
  • all internal APIs always used different names for this and thus, Android instrumentation in saucectl was actually always broken if the instrumentation flag is turned off in app settings. Most people turn it on via app settings anyway so that was fine but now that we're removing app storage flag evaluations for automated tests and will use the saucectl yaml as the source of truth, this bug had to be fixed.

TLDR: The shape of that line is intentional, to avoid breaking all YAML files out there.

Copy link
Contributor

Choose a reason for hiding this comment

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

We're updating the docs today 👍

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks @diegoperini! It'd be good to leave an inline comment in the code explaining that little difference. I won't remember this in 2 weeks (or any new dev that joins) 😂

Copy link
Contributor

Choose a reason for hiding this comment

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

Good idea, added it.

@shahrukhamd
Copy link
Contributor Author

This will also require updates in https://github.com/saucelabs/sauce-docs 🙏

saucelabs/sauce-docs#3060

@diegoperini diegoperini force-pushed the rdx-484-support-instrumentation-capabilities branch from d7caa37 to aef763e Compare January 15, 2025 16:19
@diegoperini diegoperini merged commit fca048e into main Jan 15, 2025
16 checks passed
@diegoperini diegoperini deleted the rdx-484-support-instrumentation-capabilities branch January 15, 2025 16:54
sc.Bool("audioCapture", "suite::appSettings::audioCapture", false, "Overwrite app settings for real device to capture audio.")
sc.Bool("imageInjection", "suite::appSettings::instrumentation::imageInjection", false, "Overwrite app settings for real device to inject provided images in the user app.")
sc.Bool("bypassScreenshotRestriction", "suite::appSettings::instrumentation::bypassScreenshotRestriction", false, "Overwrite app settings for real device to enable screenshot restriction.")
sc.Bool("groupFolderRedirect", "suite::appSettings::instrumentation::groupFolderRedirect", false, "Overwrite app settings for real device to redirect group folder.")
Copy link
Contributor

Choose a reason for hiding this comment

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

Hi @diegoperini ! I noticed that some iOS-specific configuration fields have been added here for Espresso run arguments. Could you clarify why these are necessary? I don't think they’re needed in this context.

Copy link
Contributor

Choose a reason for hiding this comment

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

They are not needed. Addressed here: https://github.com/saucelabs/saucectl/pull/999/files

sc.Bool("audioCapture", "suite::appSettings::audioCapture", false, "Overwrite app settings for real device to capture audio.")
sc.Bool("imageInjection", "suite::appSettings::instrumentation::imageInjection", false, "Overwrite app settings for real device to inject provided images in the user app.")
sc.Bool("bypassScreenshotRestriction", "suite::appSettings::instrumentation::bypassScreenshotRestriction", false, "Overwrite app settings for real device to enable screenshot restriction.")
Copy link
Contributor

Choose a reason for hiding this comment

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

Same applies here. bypassScreenshotRestriction is Android only. I don't think it's necessary as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

"description": "Overwrite app settings for real device to inject provided images in the user app.",
"type": "boolean"
},
"bypassScreenshotRestriction": {
Copy link
Contributor

Choose a reason for hiding this comment

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

Since the configuration fields are newly added and already separated into Android and iOS, I believe it would be better to split them into distinct sections for each platform in the JSON schema.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree but that's a change that will make existing saucectl configurations invalid. We'll have to plan for it with proper communication.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants