browserstack / browserstack-gradle-plugin

Gradle plugin for uploading app and running tests on BrowserStack
16 stars 20 forks source link

Reform app request sending; Support 'custom_id' binding; #43

Closed marius-m closed 2 years ago

marius-m commented 2 years ago

Reforming request

! Pull request is part of earlier one, which enables uploading to AppAutomate (https://github.com/browserstack/browserstack-gradle-plugin/pull/42).

Got a bit stuck in forming request with ’custom id’ binding along side with app upload, so it was a bit easier to rewite how multipart message is formed and uploaded from a map of appended data.

Sankalan1987 commented 2 years ago

@marius-m : I have tested the BrowserStack Gradle Plugin with the changes for Custom ID and can confirm that its working fine.

One observation - I have found a non-blocking issue where the custom_id is not displayed in the App Upload API Response while running the Gradle Task : clean uploadDebugToBrowserstackAppLive although I am passing the Custom ID in browserStackConfig in app/build.gradle file. Please refer the AP Response below : -

> Task :app:uploadDebugToBrowserstackAppLive
Most recent DebugApp apk: /Users/sankalan/Documents/github/espresso-browserstack/app/build/outputs/apk/debug/app-debug.apk
Most recent TestApp apk: null
Request method: POST
Request properties: {Content-Type=[multipart/form-data; boundary=3841460873]}
--3841460873
Content-Disposition: form-data; name="file"; filename="app-debug.apk"
Content-Type: Content-Type: application/octet-stream

<---Raw bytes--->
--3841460873
Content-Disposition: form-data; name="custom_id"

Sankalan-Test-App
--3841460873--App upload Response Code : 200
{"app_url":"bs://1e88d9cab7d64689dff8cfbe0fcdc2a58f59c3d0"}

Requesting you to kindly check the same and incorporate the changes accordingly. Also I have identified that current unit tests in test.rb file are broken, and we are working to fix it to confirm 100% backward compatibility.

marius-m commented 2 years ago
  1. Oh okay, I'll take care of the AppLive upload mechanism to support custom_id.
  2. Okay, I didn't the test.rb file and I'm not that familiar. Could you give me some pointers on what do I need to run it?
marius-m commented 2 years ago

1. Fixing custom_id binding

Okay after investigating a bit, you are right. I’ve managed to replicate a problem with app-live server. Seems like app-live server takes in different kind of request (per documentation) and you need to wrap extra properties into internal data map. I’ve fixed this problem, now both servers - app-live and app-automate takes in extra props.

Also, one thing to mention, as app-automate indicates of additional properties sent over 👇 from response

> Task :app:uploadTemplateDevDebugToBrowserstackAppAutomate
Most recent DebugApp apk: /Users/mariusmerkevicius/Projects/<project path>/app/build/outputs/apk/debug/app-debug.apk
Most recent TestApp apk: null
Request method: POST
Request properties: {Content-Type=[multipart/form-data; boundary=10345262802]}
--10345262802
Content-Disposition: form-data; name="file"; filename="app-debug.apk"
Content-Type: application/octet-stream

<---Raw bytes--->
--10345262802
Content-Disposition: form-data; name="custom_id"

<custom id>
--10345262802--App upload Response Code : 200
{"app_url":"bs://<some hidden id>","custom_id":"<hidden custom id>","shareable_id":"<hidden id>"}
Start testing at https://app-automate.browserstack.com/#app_hashed_id=<hidden id>

However sending it to app-live it would not 👇

> Task :app:uploadTemplateDevDebugToBrowserstackAppLive
Most recent DebugApp apk: /Users/mariusmerkevicius/Projects/<project path>/app/build/outputs/apk/debug/app-debug.apk
Most recent TestApp apk: null
Request method: POST
Request properties: {Content-Type=[multipart/form-data; boundary=7010274585]}
--7010274585
Content-Disposition: form-data; name="file"; filename="app-debug.apk"
Content-Type: application/octet-stream

<---Raw bytes--->
--7010274585
Content-Disposition: form-data; name="data"

{"custom_id":"<hidden custom id>"}
--7010274585--App upload Response Code : 200
{"app_url":"bs://<hidden-custom-id>"}
Start testing at https://app-live.browserstack.com/#app_hashed_id=<hidden custom id>

But fetching recently uploaded apps

curl -u "<username>:<api key>" -X GET "https://api-cloud.browserstack.com/app-live/recent_apps"

It would indicated those extra properties abound correctly.

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  2335  100  2335    0     0   3891      0 --:--:-- --:--:-- --:--:--  3891
[
  {
    "app_name": "app-debug.apk",
    "app_version": "<hidden app version>",
    "app_url": "bs://<hidden id>",
    "app_id": "<hidden app id>",
    "uploaded_at": "2022-02-02 10:40:07 UTC",
    "custom_id": "<hidden custom id>"
  },
  <more uploaded apps>
]

2. Fixing test.rb

I’m not entirely sure i’ll be able to fix those. Could you give some pointers how to run it? I assume I’ll need Ruby things.

Sankalan1987 commented 2 years ago

@marius-m - Thanks for checking and fixing the issue. I will review your changes and provide my input. Regarding Point 2 - Fixing test.rb , no action item from your end. We are now analysing the root cause of the script failure and will soon provide a fix to it. I will keep you posted on this.

marius-m commented 2 years ago

👏 amazing! Looking forward to!

Sankalan1987 commented 2 years ago

@marius-m : Now I can see Custom ID in Recent Apps Upload to App Live API Response. This means your recent changes are working fine. Please find below the API RQ/RS:-

curl -u "my_username:my_accesskey" -X GET "https://api-cloud.browserstack.com/app-live/recent_apps"

{"app_name":"app-phone-debug.apk","app_version":"1.0-phone","app_url":"bs://<app_url>","app_id":"<app_id>","uploaded_at":"<timestamp>","custom_id":"AndroidTestAPK"}

I have ran some Unit Tests against your recent commits. Unit Test Result looks good to me. No actions pending from your end and changes looks good. Once we commit our Unit Test changes, I will let you know.

marius-m commented 2 years ago

Thank you! 👏