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

A Hub API that can query all running sessions. #6158

Merged
merged 2 commits into from Jul 30, 2018

Conversation

Projects
None yet
3 participants
@krmahadevan
Contributor

krmahadevan commented Jul 14, 2018

Closes #6070

The API can be accessed via
http://IP:Port/grid/api/sessions.

Both GET and POST are supported and result in the
same behavior.

A typical response can look like below (intentionally
trimmed the capabilities to reduce verbosity)

{
  "proxies": [
    {
      "proxyId": "http://192.168.1.6:5555",
      "proxyRemoteHost": "http://192.168.1.6:5555",
      "sessions": {
        "status": 0,
        "value": [
          {
            "id": "df8aa16d-1d52-2e43-b584-2f9df586b0f3",
            "capabilities": {}
          },
          {
            "id": "f85f5641-e6de-3642-913a-a45aafdb85ad",
            "capabilities": {}
          }
        ]
      }
    },
    {
      "proxyId": "http://192.168.1.6:5556",
      "proxyRemoteHost": "http://192.168.1.6:5556",
      "sessions": {
        "status": 0,
        "value": [
          {
            "id": "f4df4fbd-96ee-e042-ab43-40a33698d1e9",
            "capabilities": {}
          }
        ]
      }
    }
  ],
  "success": true
}
@krmahadevan

This comment has been minimized.

Show comment
Hide comment
@krmahadevan

krmahadevan Jul 14, 2018

Contributor

ping @shs96c @barancev - Can one of you please help take a look at this ?

Contributor

krmahadevan commented Jul 14, 2018

ping @shs96c @barancev - Can one of you please help take a look at this ?

@shs96c

This is missing tests, so it'll be easy to introduce accidental regressions.

The approach taken here is very "bare metal": we're basically exposing the internals of the current grid to the world. Is this the approach we want to take, or would we prefer something that explains the domain better? I'm perfectly happy if the answer is "bare metal to get us off the ground", as I think we're allowed to iterate on Grid functionality with greater freedom than anything on the client side.

Show outdated Hide outdated java/server/src/org/openqa/grid/web/servlet/NodeSessionsServlet.java
Show outdated Hide outdated java/server/src/org/openqa/grid/web/servlet/NodeSessionsServlet.java
Show outdated Hide outdated java/server/src/org/openqa/grid/web/servlet/NodeSessionsServlet.java
Show outdated Hide outdated java/server/src/org/openqa/grid/web/servlet/NodeSessionsServlet.java
Show outdated Hide outdated java/server/src/org/openqa/grid/web/servlet/NodeSessionsServlet.java
} catch (IOException e) {
throw new GridException(e.getMessage());
}
return new TreeMap<>();

This comment has been minimized.

@shs96c

shs96c Jul 15, 2018

Member

We don't want to indicate some form of error has occurred?

@shs96c

shs96c Jul 15, 2018

Member

We don't want to indicate some form of error has occurred?

This comment has been minimized.

@krmahadevan

krmahadevan Jul 16, 2018

Contributor

Fixed it. The status gets flipped to false if there was any difficulty in extracting sessions info

@krmahadevan

krmahadevan Jul 16, 2018

Contributor

Fixed it. The status gets flipped to false if there was any difficulty in extracting sessions info

Show outdated Hide outdated java/server/src/org/openqa/grid/web/servlet/NodeSessionsServlet.java
Show outdated Hide outdated java/server/src/org/openqa/grid/web/servlet/NodeSessionsServlet.java
@krmahadevan

This comment has been minimized.

Show comment
Hide comment
@krmahadevan

krmahadevan Jul 16, 2018

Contributor

@shs96c

This is missing tests, so it'll be easy to introduce accidental regressions.

I was initially confused as to what sort of tests I add because this new servlet internally makes a call to WebDriverServlet running in the node. So didn't know how to fake that out. Ended up writing a E2E test which tests the functionality by spinning a grid hub and node.

The approach taken here is very "bare metal": we're basically exposing the internals of the current grid to the world. Is this the approach we want to take, or would we prefer something that explains the domain better? I'm perfectly happy if the answer is "bare metal to get us off the ground", as I think we're allowed to iterate on Grid functionality with greater freedom than anything on the client side.

The ask in #6070 was explicitly to have the capability of listing out all the sessions running in the Hub via an API. Please let me know if there's any other way of giving this capability. I will alter my PR accordingly.

I have addressed the review comments. Please help take a look.

Contributor

krmahadevan commented Jul 16, 2018

@shs96c

This is missing tests, so it'll be easy to introduce accidental regressions.

I was initially confused as to what sort of tests I add because this new servlet internally makes a call to WebDriverServlet running in the node. So didn't know how to fake that out. Ended up writing a E2E test which tests the functionality by spinning a grid hub and node.

The approach taken here is very "bare metal": we're basically exposing the internals of the current grid to the world. Is this the approach we want to take, or would we prefer something that explains the domain better? I'm perfectly happy if the answer is "bare metal to get us off the ground", as I think we're allowed to iterate on Grid functionality with greater freedom than anything on the client side.

The ask in #6070 was explicitly to have the capability of listing out all the sessions running in the Hub via an API. Please let me know if there's any other way of giving this capability. I will alter my PR accordingly.

I have addressed the review comments. Please help take a look.

@krmahadevan

This comment has been minimized.

Show comment
Hide comment
@krmahadevan

krmahadevan Jul 24, 2018

Contributor

@shs96c - thank you so much for merging the other two PRs. Can you please check if this one needs any additional work or if it can be merged as well ?

Contributor

krmahadevan commented Jul 24, 2018

@shs96c - thank you so much for merging the other two PRs. Can you please check if this one needs any additional work or if it can be merged as well ?

@p0deje p0deje added C-java C-grid and removed C-java labels Jul 26, 2018

krmahadevan added some commits Jul 14, 2018

A Hub API that can query all running sessions.
Closes #6070

The API can be accessed via 
http://<IP:Port>/grid/api/sessions.

Both GET and POST are supported and result in the
same behavior.

A typical response can look like below (intentionally
trimmed the capabilities to reduce verbosity)

{
  "proxies": [
    {
      "proxyId": "http://192.168.1.6:5555",
      "proxyRemoteHost": "http://192.168.1.6:5555",
      "sessions": {
        "status": 0,
        "value": [
          {
            "id": "df8aa16d-1d52-2e43-b584-2f9df586b0f3",
            "capabilities": {}
          },
          {
            "id": "f85f5641-e6de-3642-913a-a45aafdb85ad",
            "capabilities": {}
          }
        ]
      }
    },
    {
      "proxyId": "http://192.168.1.6:5556",
      "proxyRemoteHost": "http://192.168.1.6:5556",
      "sessions": {
        "status": 0,
        "value": [
          {
            "id": "f4df4fbd-96ee-e042-ab43-40a33698d1e9",
            "capabilities": {}
          }
        ]
      }
    }
  ],
  "success": true
}
@krmahadevan

This comment has been minimized.

Show comment
Hide comment
@krmahadevan

krmahadevan Jul 26, 2018

Contributor

Rebased off of master and pushed in the updated branch.

Contributor

krmahadevan commented Jul 26, 2018

Rebased off of master and pushed in the updated branch.

@shs96c shs96c merged commit f3197b1 into SeleniumHQ:master Jul 30, 2018

0 of 2 checks passed

continuous-integration/appveyor/pr AppVeyor build failed
Details
continuous-integration/travis-ci/pr The Travis CI build failed
Details

@krmahadevan krmahadevan deleted the krmahadevan:enrich_node_status branch Jul 30, 2018

grigaman pushed a commit to grigaman/selenium that referenced this pull request Sep 20, 2018

A Hub API that can query all running sessions. (#6158)
Closes #6070

The API can be accessed via 
http://<IP:Port>/grid/api/sessions.

Both GET and POST are supported and result in the
same behavior.

A typical response can look like below (intentionally
trimmed the capabilities to reduce verbosity)

{
  "proxies": [
    {
      "proxyId": "http://192.168.1.6:5555",
      "proxyRemoteHost": "http://192.168.1.6:5555",
      "sessions": {
        "status": 0,
        "value": [
          {
            "id": "df8aa16d-1d52-2e43-b584-2f9df586b0f3",
            "capabilities": {}
          },
          {
            "id": "f85f5641-e6de-3642-913a-a45aafdb85ad",
            "capabilities": {}
          }
        ]
      }
    },
    {
      "proxyId": "http://192.168.1.6:5556",
      "proxyRemoteHost": "http://192.168.1.6:5556",
      "sessions": {
        "status": 0,
        "value": [
          {
            "id": "f4df4fbd-96ee-e042-ab43-40a33698d1e9",
            "capabilities": {}
          }
        ]
      }
    }
  ],
  "success": true
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment