Skip to content

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

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

Merged
merged 11 commits into from
Feb 24, 2022

Conversation

marius-m
Copy link
Contributor

@marius-m marius-m commented Jan 18, 2022

Reforming request

! Pull request is part of earlier one, which enables uploading to AppAutomate (#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.

  • Created separate class which forms multipart request and pushes its bytes into the pipe

  • Appended a builder its easier composition (probably it will be easier to append additional properties as well)

  • Added debugger logger (writes logs how message is formed into System.out) if there are problems forming it

    • To enable debugger, use debug = true in extension (when configuring in the app plugin configuration)
  • Added ’customId’ property binding to request

    • To bind, use customId = 12345 in app plugin configuration
  • Sample configuration

    browserStackConfig {
        username = "$System.env.AT_REPOSITORY_USERNAME"
        accessKey = "$System.env.AT_REPOSITORY_KEY"
        customId = "Cool-App"
        debug = true
        configFilePath = "${rootDir}/config-browserstack.json"
    }
    

@Sankalan1987
Copy link
Contributor

@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
Copy link
Contributor Author

marius-m commented Feb 1, 2022

  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
Copy link
Contributor Author

marius-m commented Feb 2, 2022

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
Copy link
Contributor

Sankalan1987 commented Feb 2, 2022

@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
Copy link
Contributor Author

marius-m commented Feb 2, 2022

👏 amazing! Looking forward to!

@Sankalan1987
Copy link
Contributor

@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
Copy link
Contributor Author

Thank you! 👏

Copy link
Collaborator

@deepwired deepwired left a comment

Choose a reason for hiding this comment

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

LGTM

@deepwired deepwired merged commit 4fff0c6 into browserstack:master Feb 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants