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: add webDriverAgentMacUrl #41

Merged
merged 33 commits into from
Jan 6, 2021
Merged

Conversation

KazuCocoa
Copy link
Member

webDriverAgentMacUrl works as same as iOS/webDriverAgentUrl.

This allows us to launch an appium server on a machine and handle mac2 driver on another macOS machine.
(Mainly I want this capability to develop mac2 driver on my environment so far)

README.md Outdated Show resolved Hide resolved
lib/wda-mac.js Outdated Show resolved Hide resolved
lib/wda-mac.js Outdated Show resolved Hide resolved
lib/wda-mac.js Outdated Show resolved Hide resolved
lib/wda-mac.js Outdated Show resolved Hide resolved
lib/wda-mac.js Outdated Show resolved Hide resolved
lib/wda-mac.js Outdated Show resolved Hide resolved
lib/wda-mac.js Outdated Show resolved Hide resolved
@KazuCocoa KazuCocoa changed the title feat: add webDriverAgentMacUrl [wip] feat: add webDriverAgentMacUrl Jan 3, 2021
@KazuCocoa KazuCocoa marked this pull request as draft January 3, 2021 09:14
lib/wda-mac.js Outdated Show resolved Hide resolved
@KazuCocoa KazuCocoa changed the title [wip] feat: add webDriverAgentMacUrl feat: add webDriverAgentMacUrl Jan 4, 2021
@KazuCocoa KazuCocoa marked this pull request as ready for review January 4, 2021 03:12
lib/wda-mac.js Outdated Show resolved Hide resolved
}
return {
scheme,
server: hostname ?? DEFAULT_SYSTEM_HOST,
Copy link
Contributor

Choose a reason for hiding this comment

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

I would say we should throw an exception if hostname cannot be parsed

Copy link
Contributor

Choose a reason for hiding this comment

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

same about protocol

Copy link
Member Author

Choose a reason for hiding this comment

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

Will do this later

Copy link
Member Author

Choose a reason for hiding this comment

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

lib/wda-mac.js Outdated Show resolved Hide resolved
lib/wda-mac.js Outdated Show resolved Hide resolved
@KazuCocoa KazuCocoa changed the title feat: add webDriverAgentMacUrl [wip] feat: add webDriverAgentMacUrl Jan 5, 2021
lib/wda-mac.js Outdated Show resolved Hide resolved
@KazuCocoa KazuCocoa marked this pull request as draft January 5, 2021 20:00
@KazuCocoa KazuCocoa changed the title [wip] feat: add webDriverAgentMacUrl feat: add webDriverAgentMacUrl Jan 6, 2021
@KazuCocoa KazuCocoa marked this pull request as ready for review January 6, 2021 07:13
@KazuCocoa KazuCocoa marked this pull request as draft January 6, 2021 08:24
lib/wda-mac.js Outdated
let wasProcessInitNecessary;
if (this.isProxyingToRemoteServer) {
if (this.process) {
await this.process.stop();
Copy link
Member Author

@KazuCocoa KazuCocoa Jan 6, 2021

Choose a reason for hiding this comment

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

Like below error happened only await cleanupObsoleteProcesses(); case.

[debug] [HTTP] Request idempotency key: 20ac39e4-5f3c-47ae-904a-cc197b645fed
[HTTP] --> POST /wd/hub/session
[HTTP] {"desiredCapabilities":{"platformName":"mac","automationName":"mac2","webDriverAgentMacUrl":"http://localhost:10100"},"capabilities":{"firstMatch":[{"platformName":"mac","appium:automationName":"mac2","appium:webDriverAgentMacUrl":"http://localhost:10100"}]}}
[debug] [W3C] Calling AppiumDriver.createSession() with args: [{"platformName":"mac","automationName":"mac2","webDriverAgentMacUrl":"http://localhost:10100"},null,{"firstMatch":[{"platformName":"mac","appium:automationName":"mac2","appium:webDriverAgentMacUrl":"http://localhost:10100"}]}]
[debug] [BaseDriver] Event 'newSessionRequested' logged at 1609921937694 (00:32:17 GMT-0800 (Pacific Standard Time))
[Appium] Appium v1.20.0-rc.1 creating new Mac2Driver (v0.8.1) session
[debug] [BaseDriver] W3C capabilities and MJSONWP desired capabilities were provided
[debug] [BaseDriver] Creating session with W3C capabilities: {
[debug] [BaseDriver]   "alwaysMatch": {
[debug] [BaseDriver]     "platformName": "mac",
[debug] [BaseDriver]     "appium:automationName": "mac2",
[debug] [BaseDriver]     "appium:webDriverAgentMacUrl": "http://localhost:10100"
[debug] [BaseDriver]   },
[debug] [BaseDriver]   "firstMatch": [
[debug] [BaseDriver]     {}
[debug] [BaseDriver]   ]
[debug] [BaseDriver] }
[BaseDriver] Session created with session id: 7f3ec82f-86fe-47f6-8710-43746bd24077
[debug] [WebDriverAgentMac] Cleaning up 4 obsolete processes
[debug] [WD Proxy] Matched '/status' to command name 'getStatus'
[debug] [WD Proxy] Proxying [GET /status] to [GET http://localhost:10100/status] with no body
[WebDriverAgentMac] Mac2Driver host process has exited with code null, signal SIGKILL
[WD Proxy] connect ECONNREFUSED 127.0.0.1:10100
[debug] [BaseDriver] Event 'newSessionStarted' logged at 1609921937749 (00:32:17 GMT-0800 (Pacific Standard Time))
[debug] [W3C] Encountered internal error running command: Error: An unknown server-side error occurred while processing the command. Original error: Could not proxy command to the remote server. Original error: connect ECONNREFUSED 127.0.0.1:10100
[debug] [W3C]     at WDAMacServer.isProxyReady (/Users/kazuaki/GitHub/appium-mac2-driver/lib/wda-mac.js:301:15)
[debug] [W3C]     at processTicksAndRejections (internal/process/task_queues.js:97:5)
[debug] [W3C]     at waitMs (/Users/kazuaki/GitHub/appium-mac2-driver/lib/wda-mac.js:395:44)
[debug] [W3C]     at spin (/Users/kazuaki/GitHub/appium-mac2-driver/node_modules/asyncbox/lib/asyncbox.js:113:20)
[debug] [W3C]     at waitForCondition (/Users/kazuaki/GitHub/appium-mac2-driver/node_modules/asyncbox/lib/asyncbox.js:129:10)
[debug] [W3C]     at WDAMacServer.startSession (/Users/kazuaki/GitHub/appium-mac2-driver/lib/wda-mac.js:395:9)
[debug] [W3C]     at Mac2Driver.createSession (/Users/kazuaki/GitHub/appium-mac2-driver/lib/driver.js:84:7)
[debug] [W3C]     at AppiumDriver.createSession (/Users/kazuaki/.nodebrew/node/v14.3.0/lib/node_modules/appium/lib/appium.js:371:35)
[HTTP] <-- POST /wd/hub/session 500 171 ms - 915
[HTTP]

But kills/stops processes by await this.process.stop(); like current implementation could wait like below log. So, for now, cleanupObsoleteProcesses is to cleanup RUNNING_PROCESS_IDS.. (.stop worked, then this method only clean RUNNING_PROCESS_IDS)

[debug] [HTTP] Request idempotency key: 07159145-27ac-4d3f-9724-a3ab455e0ca7
[HTTP] --> POST /wd/hub/session
[HTTP] {"desiredCapabilities":{"platformName":"mac","automationName":"mac2","webDriverAgentMacUrl":"http://localhost:10100"},"capabilities":{"firstMatch":[{"platformName":"mac","appium:automationName":"mac2","appium:webDriverAgentMacUrl":"http://localhost:10100"}]}}
[debug] [W3C] Calling AppiumDriver.createSession() with args: [{"platformName":"mac","automationName":"mac2","webDriverAgentMacUrl":"http://localhost:10100"},null,{"firstMatch":[{"platformName":"mac","appium:automationName":"mac2","appium:webDriverAgentMacUrl":"http://localhost:10100"}]}]
[debug] [BaseDriver] Event 'newSessionRequested' logged at 1609922453348 (00:40:53 GMT-0800 (Pacific Standard Time))
[Appium] Appium v1.20.0-rc.1 creating new Mac2Driver (v0.8.1) session
[debug] [BaseDriver] W3C capabilities and MJSONWP desired capabilities were provided
[debug] [BaseDriver] Creating session with W3C capabilities: {
[debug] [BaseDriver]   "alwaysMatch": {
[debug] [BaseDriver]     "platformName": "mac",
[debug] [BaseDriver]     "appium:automationName": "mac2",
[debug] [BaseDriver]     "appium:webDriverAgentMacUrl": "http://localhost:10100"
[debug] [BaseDriver]   },
[debug] [BaseDriver]   "firstMatch": [
[debug] [BaseDriver]     {}
[debug] [BaseDriver]   ]
[debug] [BaseDriver] }
[BaseDriver] Session created with session id: 5103782c-9eb7-49b7-b5d7-9d24cac34ed1
[WebDriverAgentMac] Mac2Driver host process has exited with code null, signal SIGTERM
[debug] [WebDriverAgentMac] Cleaning up 3 obsolete processes
[debug] [WD Proxy] Matched '/status' to command name 'getStatus'
[debug] [WD Proxy] Proxying [GET /status] to [GET http://localhost:10100/status] with no body
[WD Proxy] connect ECONNREFUSED 127.0.0.1:10100
[debug] [WD Proxy] Matched '/status' to command name 'getStatus'
[debug] [WD Proxy] Proxying [GET /status] to [GET http://localhost:10100/status] with no body
[WD Proxy] connect ECONNREFUSED 127.0.0.1:10100
[debug] [WD Proxy] Matched '/status' to command name 'getStatus'
[debug] [WD Proxy] Proxying [GET /status] to [GET http://localhost:10100/status] with no body
[WD Proxy] connect ECONNREFUSED 127.0.0.1:10100
[debug] [WD Proxy] Matched '/status' to command name 'getStatus'
[debug] [WD Proxy] Proxying [GET /status] to [GET http://localhost:10100/status] with no body
[WD Proxy] connect ECONNREFUSED 127.0.0.1:10100
[debug] [WD Proxy] Matched '/status' to command name 'getStatus'
[debug] [WD Proxy] Proxying [GET /status] to [GET

hm..
(I tweaked the order of killing process etc in cleanupObsoleteProcesses, but no luck. So something other things affected?)

Copy link
Contributor

Choose a reason for hiding this comment

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

I think I know what the issue might be. Please call this.process.kill() first and then cleanupObsoleteProcesses. The issue there is that the process gets killed from the outside (by the kill -9 command line utility), so the original process object does not get notified about it is killed, which is ok when we close the server, but not ok when we about to start a new session

@KazuCocoa KazuCocoa marked this pull request as ready for review January 6, 2021 08:54
Copy link
Contributor

@mykola-mokhnach mykola-mokhnach left a comment

Choose a reason for hiding this comment

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

LGTM. Only #41 (comment) is left

@KazuCocoa KazuCocoa merged commit 9e4add0 into appium:master Jan 6, 2021
@KazuCocoa KazuCocoa deleted the add-usewdaurl branch January 6, 2021 17:52
};
}

let parsed_url;
Copy link
Contributor

Choose a reason for hiding this comment

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

parsedUrl

Copy link
Member Author

Choose a reason for hiding this comment

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

oops...

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.

None yet

2 participants