forked from SeleniumHQ/selenium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Query Selenium Server to retrieve actual running port.
Fixes SeleniumHQ#1299 Altered the registration logic as below : If port given was 0, then query server to find running port and update registration request with correct values for remoteHost. Signed-off-by: Luke Inman-Semerau <luke.semerau@gmail.com>
- Loading branch information
1 parent
c33471b
commit 31a9914
Showing
7 changed files
with
120 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,4 +20,5 @@ | |
public interface GridNodeServer { | ||
void boot() throws Exception; | ||
void stop(); | ||
int getRealPort(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
java/server/test/org/openqa/grid/internal/utils/SelfRegisteringRemoteTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package org.openqa.grid.internal.utils; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import org.junit.Test; | ||
import org.openqa.grid.common.GridRole; | ||
import org.openqa.grid.common.RegistrationRequest; | ||
import org.openqa.grid.shared.GridNodeServer; | ||
|
||
import java.net.MalformedURLException; | ||
|
||
public class SelfRegisteringRemoteTest { | ||
|
||
@Test | ||
public void testHubRegistrationWhenPortExplicitlyZeroedOut() throws MalformedURLException { | ||
GridNodeServer server = new GridNodeServer() { | ||
@Override | ||
public void boot() throws Exception {} | ||
|
||
@Override | ||
public void stop() {} | ||
|
||
@Override | ||
public int getRealPort() { | ||
return 1234; | ||
} | ||
}; | ||
RegistrationRequest config = new RegistrationRequest(); | ||
config.setRole(GridRole.NODE); | ||
config.getConfiguration().put(RegistrationRequest.HUB_HOST, "localhost"); | ||
config.getConfiguration().put(RegistrationRequest.HUB_PORT, 4444); | ||
config.getConfiguration().put(RegistrationRequest.PORT, 0); | ||
config.getConfiguration().put(RegistrationRequest.REMOTE_HOST, "http://localhost:0/"); | ||
SelfRegisteringRemote remote = new SelfRegisteringRemote(config); | ||
remote.setRemoteServer(server); | ||
remote.updateConfigWithRealPort(); | ||
String host = (String) remote.getConfiguration().get(RegistrationRequest.REMOTE_HOST); | ||
assertEquals("Ensure that the remote host is updated properly", | ||
"http://localhost:" + server.getRealPort(), host); | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters