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

test: mitmproxy + low bandwidth + automated QA using detox #8202

Merged
merged 186 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
186 commits
Select commit Hold shift + click to select a range
0b6a33b
experimental github action
rahimrahman Aug 26, 2024
5ee27a2
start mtmproxy then kill it
rahimrahman Aug 26, 2024
ee97cd1
suspend test for now
rahimrahman Aug 26, 2024
90c1c7f
dont need to be in a PR to trigger
rahimrahman Aug 26, 2024
a445539
trying again with mitmdump
rahimrahman Aug 26, 2024
457e925
where is .mitmproxy folder?
rahimrahman Aug 26, 2024
44195de
run with +e
rahimrahman Aug 26, 2024
abe009d
not sure why exit code 1
rahimrahman Aug 26, 2024
cb47ae7
if this is a better path
rahimrahman Aug 26, 2024
669abf0
let's try killing using trap?
rahimrahman Aug 26, 2024
cc5802f
trying a different path
rahimrahman Aug 26, 2024
2f476f6
maybe using ~ would work?
rahimrahman Aug 26, 2024
425a95a
looking at output to networksetup command
rahimrahman Aug 26, 2024
be18526
minor mistake
rahimrahman Aug 26, 2024
56d9d9d
throttling bandwidth
rahimrahman Aug 26, 2024
e24e217
lets try with sudo
rahimrahman Aug 26, 2024
98a9506
missing sudo
rahimrahman Aug 26, 2024
9a83347
using mitmdump
rahimrahman Aug 27, 2024
49e932a
remove spaces
rahimrahman Aug 27, 2024
0b14463
tried diff path
rahimrahman Aug 27, 2024
b610b07
change to the proper file
rahimrahman Aug 27, 2024
3f1f258
upload artifacts
rahimrahman Aug 27, 2024
c766e8f
install cert
rahimrahman Aug 27, 2024
436ad6f
added cert to simulator
rahimrahman Aug 27, 2024
6971609
getting simulator UDID
rahimrahman Aug 27, 2024
6b7d8e8
proper scoped var
rahimrahman Aug 27, 2024
e94330e
using github outputs
rahimrahman Aug 27, 2024
d531e3e
getenv doesn't have IOS_SIMULATOR_UDID
rahimrahman Aug 27, 2024
84ddd05
using echo command
rahimrahman Aug 27, 2024
9cf7f5d
maybe forgot to scope outputs
rahimrahman Aug 27, 2024
0d06ae2
lets run the command directly
rahimrahman Aug 27, 2024
09ed31f
changed to iPhone 14
rahimrahman Aug 27, 2024
b34fa92
let me see all the devices
rahimrahman Aug 27, 2024
cebb686
try something new
rahimrahman Aug 27, 2024
4d7c1de
rearrange my steps to get cert
rahimrahman Aug 27, 2024
767d611
getenv booted
rahimrahman Aug 27, 2024
9f07353
remove too many outputs
rahimrahman Aug 27, 2024
1f8343c
using mm mobile test server
rahimrahman Aug 27, 2024
1731c78
tie it all together with detox test
rahimrahman Aug 27, 2024
d0bffc8
removed dependency for another job
rahimrahman Aug 27, 2024
58e3bc7
put dependency on a job
rahimrahman Aug 27, 2024
f52fae8
simplify process even more
rahimrahman Aug 27, 2024
19498c3
add github-token on download artifact
rahimrahman Aug 28, 2024
69c6b9b
add run-id, hopefully that's what needed to download
rahimrahman Aug 28, 2024
a251bba
incorrect speed for download
rahimrahman Aug 28, 2024
e7b346b
update to the correct dummynet syntax
rahimrahman Aug 28, 2024
897f7ee
proper mitmdump flow report
rahimrahman Aug 28, 2024
deb57ce
update allow-hosts
rahimrahman Aug 28, 2024
b5805bb
commenting out mitmdump for now
rahimrahman Aug 28, 2024
ff731ba
back to rahim-experiments
rahimrahman Aug 28, 2024
b1b5d22
overly commented out
rahimrahman Aug 28, 2024
92c406c
cacert not --ca-cert
rahimrahman Aug 28, 2024
35c6879
maybe i allow the wrong host?
rahimrahman Aug 28, 2024
3f14dfd
maybe i just forgotr to kill mitmdump after I'm done?
rahimrahman Aug 28, 2024
b839149
using pm2
rahimrahman Aug 28, 2024
16c05da
reinstate jobs. and longer timeout for detox
rahimrahman Aug 29, 2024
3b1e6a9
need sudo
rahimrahman Aug 29, 2024
fe7c84c
recording videos and limiting to 1 test
rahimrahman Aug 29, 2024
9594bfa
just want to run 1 test.
rahimrahman Aug 29, 2024
1c7ddaa
back to experimenting
rahimrahman Aug 29, 2024
7890ee4
using wget
rahimrahman Aug 29, 2024
07364ae
test using chrome
rahimrahman Aug 29, 2024
e2fc2ce
using chrome and add delay
rahimrahman Aug 29, 2024
00ed348
ok test again with detox
rahimrahman Aug 29, 2024
2832298
go back to testing all server_login
rahimrahman Aug 29, 2024
1303943
compare booted simulators
rahimrahman Aug 29, 2024
d4b5954
few more experiments
rahimrahman Aug 30, 2024
fe9a041
no \
rahimrahman Aug 30, 2024
6c62176
using github_outputs
rahimrahman Aug 30, 2024
0db28d5
using fromJSON
rahimrahman Aug 30, 2024
d7bfa93
too many $
rahimrahman Aug 30, 2024
2fec694
can i do this another way?
rahimrahman Aug 30, 2024
8149c24
two runs to get the it assigned
rahimrahman Aug 30, 2024
4e3a516
try again
rahimrahman Aug 30, 2024
ebadf61
.
rahimrahman Aug 30, 2024
1f4c0ec
trying to access devices array
rahimrahman Aug 30, 2024
bacdd2f
try again
rahimrahman Aug 30, 2024
b1d29ff
using jq
rahimrahman Aug 30, 2024
c9d2e64
keep it simple
rahimrahman Aug 30, 2024
db1d312
might not need outputs
rahimrahman Aug 30, 2024
404eaad
forgot pipe
rahimrahman Aug 30, 2024
b550f79
will this work?
rahimrahman Aug 30, 2024
6b042c2
will first element of an array works
rahimrahman Aug 30, 2024
7202eab
see if we got the udid
rahimrahman Aug 30, 2024
c2557a1
did we get it wrong?
rahimrahman Aug 30, 2024
b172593
will this work?
rahimrahman Aug 30, 2024
090f440
let's assign?
rahimrahman Aug 30, 2024
88f5490
we have to put into string
rahimrahman Aug 30, 2024
470535d
ok 1 more
rahimrahman Aug 30, 2024
bac2bc1
will it have quotes?
rahimrahman Aug 30, 2024
0f9b547
echo in an echo
rahimrahman Aug 30, 2024
9987699
is this working?
rahimrahman Aug 30, 2024
57afe94
let's hope this works.
rahimrahman Aug 30, 2024
8b45554
it's actually using 17.4 iPhone 14 not 17.0
rahimrahman Aug 30, 2024
8c5cc4e
broke because i add &
rahimrahman Aug 30, 2024
c61a59c
removed failed step
rahimrahman Aug 30, 2024
10263ba
lowering ping and going back to 10 parallel test
rahimrahman Aug 30, 2024
e665b07
double-up ONE_SEC to see if tests will pass
rahimrahman Aug 30, 2024
6593d22
why curl failed after?
rahimrahman Aug 30, 2024
95430d3
getting more data from failures
rahimrahman Aug 30, 2024
b41d3c3
let's get more logs with pm and mitmdump
rahimrahman Aug 30, 2024
8b5c8b6
more logging and improvement
rahimrahman Aug 30, 2024
5cd1e08
silly error!
rahimrahman Aug 30, 2024
1d5cfea
problem with throttling, let's figure out where we can improve
rahimrahman Aug 30, 2024
17edd24
increase timeout for low-bandwidth
rahimrahman Aug 30, 2024
6d03c9d
increased delay + run all tests
rahimrahman Aug 30, 2024
e3b9e5d
lets see if this will be better for throttling
rahimrahman Aug 30, 2024
8f1b615
try set +e to see if it will return failure
rahimrahman Sep 13, 2024
c8544d4
check disk space.
rahimrahman Sep 13, 2024
d17b214
deleting zip and trash to free up space.
rahimrahman Sep 13, 2024
956b99c
try to do pfctl twice to see if that would help
rahimrahman Sep 13, 2024
f940d67
making bandwidth-throttling a composite action
rahimrahman Sep 13, 2024
f1d5442
would 5 seconds make a diff?
rahimrahman Sep 13, 2024
efb59c6
add shell
rahimrahman Sep 13, 2024
fda0449
throttle bandwidth experiment
rahimrahman Sep 13, 2024
6f6b4d5
fix quick problem
rahimrahman Sep 13, 2024
bfb20e2
5s sleep, and throttling at the right time
rahimrahman Sep 13, 2024
43fa337
the throttling was working better earlier.
rahimrahman Sep 13, 2024
2095766
add a flush in between
rahimrahman Sep 13, 2024
67f4d43
no exit, see if it works well
rahimrahman Sep 13, 2024
5bd4e53
trying continue-on-error
rahimrahman Sep 14, 2024
cc7367a
resetting with continue-on-error vs checking for if steps before worked
rahimrahman Sep 14, 2024
ed17b24
adding flush before throttling to see if it makes a diff
rahimrahman Sep 15, 2024
ca47485
put it back where we think is the best spot
rahimrahman Sep 15, 2024
be93adc
change timeout to 60 and some cleanup
rahimrahman Sep 15, 2024
592d022
forgot a simple $
rahimrahman Sep 15, 2024
228fed7
move network throttling again to see if this is better?
rahimrahman Sep 15, 2024
f1d3a5f
rearranging
rahimrahman Sep 16, 2024
b4c46ab
move throttling back to where it used to work well
rahimrahman Sep 16, 2024
9ca0434
forgot shell
rahimrahman Sep 16, 2024
f29ef9e
inputs not input, and continue-on-error
rahimrahman Sep 16, 2024
1015dc7
getting host from site_1_url
rahimrahman Sep 16, 2024
82b6a88
update the sed script
rahimrahman Sep 16, 2024
f1307ca
move more steps into composite action file
rahimrahman Sep 16, 2024
cef16eb
add shell
rahimrahman Sep 16, 2024
51ef3ee
add more shell
rahimrahman Sep 16, 2024
1199501
action cleanup
rahimrahman Sep 16, 2024
204f158
see if our reset network setting works
rahimrahman Sep 16, 2024
6da1a5e
delete unused files
rahimrahman Sep 16, 2024
9f95a97
more clean up
rahimrahman Sep 16, 2024
c0b1790
wrong indentation
rahimrahman Sep 16, 2024
0a373ec
wrong context
rahimrahman Sep 16, 2024
e1c2a88
see if not having low bandwidth enabled would cause stuff to break
rahimrahman Sep 16, 2024
3719ccf
will it fail on non-existent step name?
rahimrahman Sep 17, 2024
d6c192e
things are failing after proxy started
rahimrahman Sep 17, 2024
2a4aa2a
start using low_bandwidth_mode input
rahimrahman Sep 18, 2024
d23a8bc
incorrect use of curly bracket
rahimrahman Sep 18, 2024
423d9c8
low_bandwidth_mode vs low_bandwidth
rahimrahman Sep 18, 2024
710d44b
correcting the use of curly bracket in if check
rahimrahman Sep 18, 2024
1e2124f
low_bandwidth_mode correction
rahimrahman Sep 18, 2024
79b76cf
why would https:// makes a diff?
rahimrahman Sep 18, 2024
2c84473
just going to start pm2 after stopping
rahimrahman Sep 18, 2024
616cc88
move things around again
rahimrahman Sep 18, 2024
8f20c7b
some more re-arranging
rahimrahman Sep 18, 2024
2e8c49a
exit 1
rahimrahman Sep 18, 2024
f97f3b4
rearranged too much
rahimrahman Sep 18, 2024
00b11e8
clean up
rahimrahman Sep 18, 2024
095182b
start-proxy action
rahimrahman Sep 18, 2024
540677e
incorrect variable name
rahimrahman Sep 18, 2024
3a9f209
use test_server_url instead
rahimrahman Sep 18, 2024
0172826
reverting back to original
rahimrahman Sep 18, 2024
b732a8a
use pull_request
rahimrahman Sep 18, 2024
72af4c1
using env var prepend
rahimrahman Sep 19, 2024
5983178
using existing artifact
rahimrahman Sep 19, 2024
9d5d9e0
not in ""
rahimrahman Sep 19, 2024
318ca22
not going to prepend anymore
rahimrahman Sep 19, 2024
386ea35
incorrectly removed input instead of env
rahimrahman Sep 19, 2024
d40d7ed
close to final
rahimrahman Sep 19, 2024
30da6ef
using original e2e-detox-template
rahimrahman Sep 19, 2024
2fb4db5
timeout-minutes need to be higher for low_bandwidth.
rahimrahman Sep 19, 2024
6f6a138
using label instead of push to branch
rahimrahman Sep 19, 2024
c01dc4f
add check-label
rahimrahman Sep 19, 2024
93c1fe6
remove unneeded test
rahimrahman Sep 20, 2024
55ba281
renamed ci.yml back to original
rahimrahman Sep 20, 2024
876566b
different way to remove label
rahimrahman Sep 20, 2024
7155e7f
Merge branch 'main' into test-random-github-action-experiments
mattermost-build Sep 20, 2024
0a35877
remove experiment file
rahimrahman Sep 20, 2024
891ea49
see label again
rahimrahman Sep 20, 2024
3016d86
output labels
rahimrahman Sep 20, 2024
4689796
another experiment
rahimrahman Sep 20, 2024
d3511f3
test again
rahimrahman Sep 20, 2024
6bf7c25
fix issue when checking for low bandwidth
rahimrahman Sep 20, 2024
0d6e3d5
revert changes to package.json in detox/
rahimrahman Sep 20, 2024
10184b4
changed download to upload in the description
rahimrahman Sep 25, 2024
6e96e13
changes based on review
rahimrahman Oct 5, 2024
9aae8fd
add github.event.label.name to the group "id" per @mvitale1989 sugges…
rahimrahman Oct 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions .github/actions/bandwidth-throttling/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: bandwidth-throttling
description: Action to throttle the bandwidth on MacOS runner

inputs:
test_server_host:
description: The host of the test server, no protocol
required: true
download_speed:
description: The download speed limit (in Kbit/s)
required: false
default: "3300"
upload_speed:
description: The upload speed limit (in Kbit/s)
required: false
default: "3300"
latency:
description: The latency (in ms) each way
required: false
default: "500"
disable:
description: Disable throttling
required: false
default: "false"

runs:
using: composite
steps:
- name: disable first
if: ${{ inputs.disable == 'true' }}
shell: bash
continue-on-error: true
run: |
sudo pfctl -d

sleep 2;

- name: throttle bandwidth down
shell: bash
run: |
# reset pf and dnctl
sudo dnctl -q flush
sudo dnctl -q pipe flush
sudo pfctl -f /etc/pf.conf
sudo pfctl -E

sleep 2;

sudo pfctl -d
sudo dnctl -q flush
sudo dnctl -q pipe flush


echo "dummynet in from ${{ inputs.test_server_host }} to ! 127.0.0.1 pipe 1
dummynet out from ! 127.0.0.1 to ${{ inputs.test_server_host }} pipe 2" | sudo pfctl -f -

# pipe 1 is download
sudo dnctl pipe 1 config bw ${{ inputs.download_speed }}Kbit/s delay ${{ inputs.latency }}ms

# pipe 2 is upload
sudo dnctl pipe 2 config bw ${{ inputs.upload_speed }}Kbit/s delay ${{ inputs.latency }}ms

sleep 5;

sudo pfctl -E

sleep 5;

- name: test curl after throttling
shell: bash
run: |
curl -o /dev/null -m 20 --retry 2 -s -w 'Total: %{time_total}s\n' 'https://${{ inputs.test_server_host }}/api/v4/system/ping?get_server_status=true'
106 changes: 106 additions & 0 deletions .github/actions/prepare-low-bandwidth/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
name: Prepare Low Bandwidth Environment (MacOS & iOS Simulators only)
description: prepare any workflow for low bandwidth testing

inputs:
test_server_url:
description: The URL of the test server
required: true
device_name:
description: The iOS simulator name
required: true
download_speed:
description: The download speed limit (in Kbit/s)
required: false
default: "3300"
upload_speed:
description: The upload speed limit (in Kbit/s)
required: false
default: "3300"
latency:
description: The latency (in ms) each way
required: false
default: "500"


runs:
using: composite
steps:
- name: delete the zip file and trash (to free up space)
shell: bash
run: |
rm -rf mobile-artifacts/*.zip
sudo rm -rf ~/.Trash/*
mvitale1989 marked this conversation as resolved.
Show resolved Hide resolved

- name: check disk space
shell: bash
run: df -h

- name: remove protocol from SITE_1_URL
id: remove-protocol
shell: bash
run: |
echo "SITE_1_HOST=${{ inputs.test_server_url }}" | sed -e 's/http:\/\///g' -e 's/https:\/\///g' >> ${GITHUB_OUTPUT}

- name: Throttle Bandwidth 1
id: throttle-bandwidth-1
continue-on-error: true
uses: ./.github/actions/bandwidth-throttling
with:
test_server_host: ${{ steps.remove-protocol.outputs.SITE_1_HOST }}
download_speed: ${{ inputs.download_speed }}
upload_speed: ${{ inputs.upload_speed }}
latency: ${{ inputs.latency }}

- name: Throttle Bandwidth 2
if: steps.throttle-bandwidth-1.outcome != 'success'
mvitale1989 marked this conversation as resolved.
Show resolved Hide resolved
id: throttle-bandwidth-2
uses: ./.github/actions/bandwidth-throttling
with:
test_server_host: ${{ steps.remove-protocol.outputs.SITE_1_HOST }}
download_speed: ${{ inputs.download_speed}}
upload_speed: ${{ inputs.upload_speed }}
latency: ${{ inputs.latency }}
disable: "true"

- name: Install mitmproxy & pm2 (process manager)
id: install-mitmproxy-pm2
shell: bash
run: |
brew install mitmproxy

npm i -g pm2

- name: Start mitmproxy via mitmdump and stop it (to get .mitmproxy folder)
shell: bash
run: |
pm2 start mitmdump --log /Users/runner/work/mattermost-mobile/mattermost-mobile/mitmdump.log -- --allow-hosts '${{ steps.remove-protocol.outputs.SITE_1_HOST }}' --ignore-hosts 'localhost' -s /Users/runner/work/mattermost-mobile/mattermost-mobile/scripts/mitmdump-flow-parsing.py

sleep 5;

pm2 stop mitmdump

# we need to wait for mitmdump to stop so it'll produce the .mitmproxy folder
sleep 5;

- name: Get simulator UDID
id: get-simulator-udid
shell: bash
run: |
simulator_udid=$(xcrun simctl list devices "${{ inputs.device_name }}" -j | jq '.devices' | jq '."com.apple.CoreSimulator.SimRuntime.iOS-17-4"[0]["udid"]')
saturninoabril marked this conversation as resolved.
Show resolved Hide resolved
echo "simulator_udid="$(echo $simulator_udid) >> ${GITHUB_OUTPUT}

- name: install certificate
shell: bash
run: |
sudo security add-trusted-cert -d -p ssl -p basic -k /Library/Keychains/System.keychain ~/.mitmproxy/mitmproxy-ca-cert.pem

# must boot first before adding root cert
xcrun simctl boot ${{ steps.get-simulator-udid.outputs.simulator_udid }}

xcrun simctl keychain booted add-root-cert ~/.mitmproxy/mitmproxy-ca-cert.pem

sleep 5;

- name: show me booted simulators
shell: bash
run: xcrun simctl list devices booted | grep Booted
36 changes: 36 additions & 0 deletions .github/actions/start-proxy/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Start Proxy
description: Action to throttle the bandwidth on MacOS runner

inputs:
test_server_url:
description: The host of the test server, no protocol
required: true

runs:
using: composite
steps:

- name: restart mitmdump
shell: bash
run: |
pm2 restart mitmdump

sleep 5;

- name: start proxy
shell: bash
run: |
networksetup -setwebproxy Ethernet "127.0.0.1" "8080"
networksetup -setsecurewebproxy Ethernet "127.0.0.1" "8080"

sleep 5;

networksetup -getwebproxy Ethernet
networksetup -getsecurewebproxy Ethernet

- name: test curl and direct it into proxy
shell: bash
run: |
curl -o /dev/null -m 20 -s -w 'Total: %{time_total}s\n' '${{ inputs.test_server_url }}/api/v4/system/ping?get_server_status=true'

curl --proxy "127.0.0.1:8080" -o /dev/null -m 20 -s -w 'Total: %{time_total}s\n' '${{ inputs.test_server_url }}/api/v4/system/ping?get_server_status=true'
rahimrahman marked this conversation as resolved.
Show resolved Hide resolved
30 changes: 18 additions & 12 deletions .github/workflows/e2e-detox-pr.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Can be used to run Detox E2E tests on pull requests for the Mattermost mobile app with low bandwidth
# by using 'E2E iOS tests for PR (LBW 1)' instead.
name: Detox E2E Tests PR

on:
Expand All @@ -7,10 +9,14 @@ on:
types:
- labeled

concurrency:
group: "${{ github.workflow }}-${{ github.event.pull_request.number }}-${{ github.event.label.name }}"
cancel-in-progress: true

jobs:
mvitale1989 marked this conversation as resolved.
Show resolved Hide resolved
update-initial-status:
runs-on: ubuntu-22.04
if: contains(github.event.pull_request.labels.*.name, 'E2E iOS tests for PR')
if: contains(github.event.label.name, 'E2E iOS tests for PR')
steps:
- uses: mattermost/actions/delivery/update-commit-status@main
env:
Expand Down Expand Up @@ -57,6 +63,7 @@ jobs:
run-ios-tests: true
run-type: "PR"
MOBILE_VERSION: ${{ github.event.pull_request.head.sha }}
low_bandwidth_mode: ${{ contains(github.event.label.name,'LBW') && true || false }}
secrets: inherit

update-final-status:
Expand Down Expand Up @@ -87,14 +94,13 @@ jobs:
script: |
const iosLabel = 'E2E iOS tests for PR';
const androidLabel = 'E2E Android tests for PR';
const labels = context.payload.pull_request.labels.map(label => label.name);

if (labels.includes(iosLabel)) {
github.rest.issues.removeLabel({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
name: iosLabel,
});
}

context.payload.pull_request.labels.forEach(label => {
if (label.name.includes(iosLabel)) {
github.rest.issues.removeLabel({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
name: label.name,
});
}
});
48 changes: 47 additions & 1 deletion .github/workflows/e2e-detox-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ on:
required: false
type: string
default: "iOS 17.0"
low_bandwidth_mode:
description: "Enable low bandwidth mode"
required: false
type: boolean
default: false
outputs:
STATUS:
value: ${{ jobs.generate-report.outputs.STATUS }}
Expand Down Expand Up @@ -123,7 +128,7 @@ jobs:
if: ${{ inputs.run-ios-tests }}
runs-on: macos-14
continue-on-error: true
timeout-minutes: 40
timeout-minutes: ${{ inputs.low_bandwidth_mode && 80 || 40 }}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since the network connectivity is slower with defaulted of 1s round trip time, I opted to add 40 more minutes to allow the tests to complete.

env:
IOS: true
needs:
Expand Down Expand Up @@ -154,12 +159,31 @@ jobs:
- name: Unzip iOS Simulator Build
run: unzip -o mobile-artifacts/*.zip -d mobile-artifacts/

- name: Prepare Low Bandwidth Environment
id: prepare-low-bandwidth
uses: ./.github/actions/prepare-low-bandwidth
if: ${{ inputs.low_bandwidth_mode }}
with:
test_server_url: ${{ env.SITE_1_URL }}
device_name: ${{ env.DEVICE_NAME }}
# all these value should be configurable
download_speed: "3300"
upload_speed: "3300"
latency: "500"

- name: Start React Native Metro Server
run: npm run start &

- name: Install Detox Dependencies
run: cd detox && npm i

- name: Start Proxy
if: ${{ inputs.low_bandwidth_mode }}
id: start-proxy
uses: ./.github/actions/start-proxy
with:
test_server_url: ${{ env.SITE_1_URL }}

- name: Run Detox E2E Tests
continue-on-error: true # Label might have been removed manually
run: |
Expand All @@ -169,6 +193,28 @@ jobs:
env:
DETOX_DEVICE_TYPE: ${{ env.DEVICE_NAME }}
DETOX_OS_VERSION: ${{ env.DEVICE_OS_VERSION }}
LOW_BANDWIDTH_MODE: ${{ inputs.low_bandwidth_mode }}


- name: reset network settings
if: ${{ inputs.low_bandwidth_mode || failure() }}
run: |
networksetup -setwebproxystate Ethernet "off"
networksetup -setsecurewebproxystate Ethernet "off"

if (sudo pfctl -q -sa | grep 'Status: Enabled') then sudo pfctl -d; fi
if (command -v pm2 &> /dev/null) then pm2 stop mitmdump; fi

sleep 5;

- name: Upload mitmdump Flow Output
if: ${{ inputs.low_bandwidth_mode }}
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
with:
name: ios-mitmdump-flow-output-${{ needs.generate-specs.outputs.workflow_hash }}-${{ matrix.runId }}
path: |
/Users/runner/work/mattermost-mobile/mattermost-mobile/flow-output.csv
/Users/runner/work/mattermost-mobile/mattermost-mobile/mitmdump.log

- name: Upload iOS Test Report
if: always()
Expand Down
3 changes: 2 additions & 1 deletion detox/e2e/support/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export const getAdminAccount = () => {
};
};

const SECOND = 1000;
const SECOND = 1000 * (process.env.LOW_BANDWIDTH_MODE === 'true' ? 5 : 1);
const MINUTE = 60 * 1000;

export const timeouts = {
Expand All @@ -76,3 +76,4 @@ export const timeouts = {
TWO_MIN: MINUTE * 2,
FOUR_MIN: MINUTE * 4,
};

Loading