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

grid should pass matched node capabilities to node #3220

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 20 additions & 1 deletion java/server/src/org/openqa/grid/internal/TestSession.java
Expand Up @@ -20,6 +20,8 @@
import com.google.common.base.Charsets;
import com.google.common.io.ByteStreams;
import com.google.common.net.MediaType;
import com.google.common.collect.Maps;
import com.google.gson.Gson;

import org.apache.http.Header;
import org.apache.http.HttpEntity;
Expand All @@ -28,6 +30,7 @@
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.entity.StringEntity;
import org.apache.http.entity.InputStreamEntity;
import org.apache.http.message.BasicHttpEntityEnclosingRequest;
import org.apache.http.message.BasicHttpRequest;
Expand Down Expand Up @@ -65,6 +68,8 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;



/**
* Represent a running test for the hub/registry. A test session is created when a TestSlot becomes
* available for a test. <p> The session is destroyed when the test ends ( ended by the client or
Expand Down Expand Up @@ -400,7 +405,21 @@ private HttpRequest prepareProxyRequest(HttpServletRequest request
if (body != null) {
BasicHttpEntityEnclosingRequest r =
new BasicHttpEntityEnclosingRequest(request.getMethod(), uri);
r.setEntity(new InputStreamEntity(body, request.getContentLength()));
final HttpEntity entity;
final WebDriverRequest wdRequest = request instanceof WebDriverRequest
? (WebDriverRequest) request : null ;
if(wdRequest != null && wdRequest.getDesiredCapabilities() != null){
// new Session should pass matched capabilities ( respect nodeConfig,not just client capabilities )
final Map<String, Object> capabilities = slot.getCapabilities();
final Map<String, Object> jsonMap = Maps.newHashMap();
jsonMap.put("desiredCapabilities", capabilities);
jsonMap.put("capabilities", capabilities);
final Gson gson = new Gson();
entity = new StringEntity(gson.toJson(jsonMap));
}else{
entity = new InputStreamEntity(body, request.getContentLength());
}
r.setEntity(entity);
proxyRequest = r;
} else {
proxyRequest = new BasicHttpRequest(request.getMethod(), uri);
Expand Down
1 change: 1 addition & 0 deletions java/server/src/org/openqa/grid/internal/TestSlot.java
Expand Up @@ -109,6 +109,7 @@ public TestSession getNewSession(Map<String, Object> desiredCapabilities) {
}
if (matches(desiredCapabilities)) {
log.info("Trying to create a new session on test slot " + this.capabilities);
desiredCapabilities.putAll(capabilities);
TestSession session = new TestSession(this, desiredCapabilities, new DefaultTimeSource());
currentSession = session;
lastSessionStart = System.currentTimeMillis();
Expand Down