maestro icon indicating copy to clipboard operation
maestro copied to clipboard

feat: network failure simulation using a stub proxy

Open NyCodeGHG opened this issue 1 year ago • 8 comments
trafficstars

Proposed Changes

This PR adds a new command simulateNetworkFailure which starts a stub proxy which closes all received connections to simulate a network failure.

Testing

Ran this flow on an Android API 34 emulator.

appId: org.wikipedia
---
- simulateNetworkFailure: true
- openLink: https://google.com/teapot
- assertVisible: "Webpage not available"
- back
- simulateNetworkFailure: false
- openLink: https://google.com/teapot
- assertNotVisible: "Webpage not available"

Issues Fixed

NyCodeGHG avatar Feb 19 '24 08:02 NyCodeGHG

I'm not sure how this behaves on macOS. I currently don't have access to a mac to test this.

NyCodeGHG avatar Feb 19 '24 09:02 NyCodeGHG

@NyCodeGHG, I have a macOS and I cant test this for you, but could you please help me know how to build maestro locally to execute at least one test?

johnaziz57 avatar Apr 18 '24 12:04 johnaziz57

@johnaziz57 sure, you can run ./gradlew installDist and then execute ./maestro-cli/build/install/maestro/bin/maestro make sure you have a path to a JDK 8 in your JAVA_HOME environment variable

NyCodeGHG avatar Apr 19 '24 07:04 NyCodeGHG

Hey @NyCodeGHG , I ran the gradlew command and it works successfully, I ran another script that I wrote before and it worked; but when I tried to run the same script that you have in the Testing section, I got

Failed to parse file: /Users/john/projects/playground-maestro/samples/android-flow.yaml:3
Unrecognized field "simulateNetworkFailure" (class maestro.orchestra.yaml.YamlFluentCommand), not marked as ignorable

Am I missing something?

johnaziz57 avatar Apr 22 '24 09:04 johnaziz57

@johnaziz57 I can't reproduce your problem. I'm not sure what could cause this problem :thinking:

NyCodeGHG avatar Apr 22 '24 09:04 NyCodeGHG

@NyCodeGHG , I assume that ./installDist is not enough to have a bin that contains your changes. Is there any other gradle command that you run?

johnaziz57 avatar Apr 22 '24 14:04 johnaziz57

@johnaziz57 I only run ./gradlew installDist and then execute ./maestro-cli/build/install/maestro/bin/maestro test my-test-file.yaml

NyCodeGHG avatar Apr 22 '24 16:04 NyCodeGHG

Hey @NyCodeGHG , I have managed to run it. I think the problem was with JAVA 8 and some certificate installation on my machine that was not going correctly hand in had.

I tested the code and it fails but for a different reason. It fails because - assertVisible: "Webpage not available" The error page doesn't show the exact text Screenshot 2024-04-24 at 17 41 16

In the end I can say that running this on MacOs with Android Emulator is working perfectly.

Great work and thanks for your patience

johnaziz57 avatar Apr 24 '24 15:04 johnaziz57

Hi there @NyCodeGHG, thanks for taking the time to work on this and to raise this PR! Unfortunately this is not something we will go ahead and merge at this time, since we're not planning on adding network manipulating features to maestro. We did experiment with this some time back and came to the conclusion that for now we want maestro to be a blackbox UI testing framework only and not include advanced device modification tooling such as network failure simulation. Again, really appreciate your work on this and hopefully this can be useful in another way outside of maestro.

axelniklasson avatar May 21 '24 13:05 axelniklasson

@axelniklasson is there any plans to include plugins/extensions for Maestro.

Maybe this way you can let people add the feature they want without affecting the goal of the main project 🙇

johnaziz57 avatar Jul 31 '24 12:07 johnaziz57