groupon / Selenium-Grid-Extras

Simplify the management of the Selenium Grid Nodes and stabilize said nodes by cleaning up the test environment after the build has been completed
BSD 3-Clause "New" or "Revised" License
536 stars 209 forks source link

need task documentation #268

Open shankarkc opened 8 years ago

shankarkc commented 8 years ago

Grid extra has some excellent tasks...But its not documented how/when they are used by selenium grid. I am running grid extra. I see firefox browser crashing. I do see a task that says killAllFirefox as below in log :- 24 Oct 2016 06:26:55 [main] INFO tasks.ExecuteOSTask - Y KillAllFirefox - /kill_firefox - Executes os level kill command on all instance of Firefox. But the crashed instance is not cleaned up. I am not sure what is missing in my setup. I do have this module enabled. It will be really helpfull if you add some details about these tasks(how user should use it/how and when grid uses it). Grid extra has an excellent capture screenshot as OS level used by video recorder. May be users can use it to capture testcase screenshots instead of webdrivers screenshot (because it wont have addressbar part). But its not documented how to use it.

shankarkc commented 8 years ago

Also http://hubIP:3000/api shows bunch of APIs. If enduser want to use it how can he use it? can you pls provide more information? these API will be useful.

smccarthy commented 8 years ago

@shankarkc I agree that we could use more documentation. For now, you could use the information at http://ip:3000/api (notice it will work with the hub or node ip addresses).

That should give you all of the info you need (description of what the endpoint does, and the required and optional parameters). For instance, if you wanted to take an OS level screenshot of node2, you would call a GET request on : http://node_2_ip_address:3000/screenshot . The response will have this information :

    "response_description": {
      "error": "Error received during execution of command",
      "exit_code": "Exit code for operation",
      "out": "All of the StandardOut received from the system",
      "file_type": "Type of file returned (PNG/JPG/GIF)",
      "file": "Name of the file saved on the NodeConfig\u0027s HD",
      "image": "Base64 URL Encoded (ISO-8859-1) string of the image",
      "hostname": "Human readable machine name",
      "ip": "IP Address of current machine",
      "timestamp": "Timestamp of the screenshot"
    },
shankarkc commented 8 years ago

@smccarthy thank you for the information. can you please let me know how to configure grid extra to cleanup the crashed browser ?

This is my selenium_grid_extra json file for node. Am i missing something here?

{
  "theConfigMap": {
    "auto_start_hub": "0",
    "auto_start_node": "1",
    "default_role": "node",
    "disabled_modules": [
      "com.groupon.seleniumgridextras.tasks.SessionHistory",
      "com.groupon.seleniumgridextras.tasks.RebootNode"
    ],
    "tear_down": [
      "com.groupon.seleniumgridextras.tasks.KillAllFirefox",
      "com.groupon.seleniumgridextras.tasks.KillAllChrome"
    ],
    "node_config_files": [
      "node_5555.json"
    ],
    "hub_config_files": [],
    "hub_config": {},
    "video_recording_options": {
      "videos_to_keep": "40"
    },
    "iedriver": {
      "version": "2.53.1"
    },
    "auto_update_drivers": "1",
    "chromedriver": {
      "version": "2.24"
    },
    "webdriver": {
      "version": "2.53.1"
    }
  }
}

With this setting i dont see any log on node side saying killingBrowser. So I am missing sth. So i was looking for documentation to configure tasks to kill browsers.

shankarkc commented 8 years ago

Thank you.. Can you pls outline how to kill brosers at the end of sessions? Do i have to call killFireFox explicitly? Or extra will take care of it. I have it in enabled modules. But i dont see logs for same. Am i missing something? On Oct 24, 2016 9:40 PM, "Shawn McCarthy" notifications@github.com wrote:

@shankarkc https://github.com/shankarkc I agree that we could use more documentation. For now, you could use the information at http://ip:3000/api (notice it will work with the hub or node ip addresses).

That should give you all of the info you need (description of what the endpoint does, and the required and optional parameters). For instance, if you wanted to take an OS level screenshot of node2, you would call a GET request on : http://node_2_ip_address:3000/screenshot . The response will have this information :

"response_description": {
  "error": "Error received during execution of command",
  "exit_code": "Exit code for operation",
  "out": "All of the StandardOut received from the system",
  "file_type": "Type of file returned (PNG/JPG/GIF)",
  "file": "Name of the file saved on the NodeConfig\u0027s HD",
  "image": "Base64 URL Encoded (ISO-8859-1) string of the image",
  "hostname": "Human readable machine name",
  "ip": "IP Address of current machine",
  "timestamp": "Timestamp of the screenshot"
},

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/groupon/Selenium-Grid-Extras/issues/268#issuecomment-255786640, or mute the thread https://github.com/notifications/unsubscribe-auth/AEb7V7EUtTjfzBlS4LMgNmPb0aCO2OARks5q3Nh-gaJpZM4Kec6x .

shankarkc commented 8 years ago

Hi @smccarthy can you please help me in this? On docker selenium grid extra nodes are going down as crashed browser instances are not cleanedup. I am assuing that selenium grid extra will cleanup all opened/crashed browsers when session ended. Is my assumption right ? Should i call killFirefox endpoint explicitly from my code when my session completes? Please let me know. Thanks a lot.

smccarthy commented 8 years ago

Hi @shankarkc I don't think Grid Extras automatically kills crashed browsers (I could be wrong). I am checking now. However, yes you could call the kill firefox endpoint explicitly to do this.

I did see this in SetupTeardownProxy, which makes it seem like IE is killed after the session, but not firefox or chrome.

        Map<String, Object> cap = session.getRequestedCapabilities();
        String browser = (String) cap.get(CapabilityType.BROWSER_NAME);

        if (browser != null &&
                (browser.equals(BrowserType.IE) ||
                        browser.equals(BrowserType.IEXPLORE) ||
                        browser.equals(BrowserType.IE_HTA) ||
                        browser.equals(BrowserType.IEXPLORE_PROXY))) {
            CommonThreadPool.startCallable(
                    new RemoteGridExtrasAsyncCallable(
                            this.getRemoteHost().getHost(),
                            RuntimeConfig.getGridExtrasPort(),
                            TaskDescriptions.Endpoints.KILL_IE,
                            new HashMap<String, String>()));
        }
automation311 commented 6 years ago

Hi @shankarkc where you able to achieve kill browsers at the end of sessions? I have the latest Selenium Grid Extras. In my selenium_grid_extras_config.json I don't see a tear down section. did you include it yourself? did that work?

shankarkc commented 6 years ago

@automation311 i think by default it is not there. You need to add it. Also you should have kill binary in path. I will post the json i have created so that you can refer to it(tomorrow) . It works for me.

automation311 commented 6 years ago

thanks for quick reply. That would be really helpful.

shankarkc commented 6 years ago

here is my json file...sorry for the delay...

{
  "theConfigMap": {
    "auto_start_hub": "0",
    "auto_start_node": "1",
    "active_modules": [
      "com.groupon.seleniumgridextras.tasks.DeleteOldLogsTask",
      "com.groupon.seleniumgridextras.tasks.Setup",
      "com.groupon.seleniumgridextras.tasks.Teardown",
      "com.groupon.seleniumgridextras.tasks.MoveMouse",
      "com.groupon.seleniumgridextras.tasks.VideoRecorder",
      "com.groupon.seleniumgridextras.tasks.KillAllFirefox",
      "com.groupon.seleniumgridextras.tasks.KillAllChrome",
      "com.groupon.seleniumgridextras.tasks.GetProcesses",
      "com.groupon.seleniumgridextras.tasks.KillPid",
      "com.groupon.seleniumgridextras.tasks.Netstat",
      "com.groupon.seleniumgridextras.tasks.Screenshot",
      "com.groupon.seleniumgridextras.tasks.ExposeDirectory",
      "com.groupon.seleniumgridextras.tasks.StartGrid",
      "com.groupon.seleniumgridextras.tasks.GetInfoForPort",
      "com.groupon.seleniumgridextras.tasks.GridStatus",
      "com.groupon.seleniumgridextras.tasks.KillAllByName",
      "com.groupon.seleniumgridextras.tasks.StopGrid",
      "com.groupon.seleniumgridextras.tasks.GetConfig",
      "com.groupon.seleniumgridextras.tasks.StopGridExtras",
      "com.groupon.seleniumgridextras.tasks.IEProtectedMode",
      "com.groupon.seleniumgridextras.tasks.IEMixedContent",
      "com.groupon.seleniumgridextras.tasks.Resolution",
      "com.groupon.seleniumgridextras.tasks.SystemInfo",
      "com.groupon.seleniumgridextras.tasks.GetNodeConfig",
      "com.groupon.seleniumgridextras.tasks.UpdateNodeConfig"
    ],
    "disabled_modules": [
      "com.groupon.seleniumgridextras.tasks.KillAllSafari",
      "com.groupon.seleniumgridextras.tasks.RebootNode",
      "com.groupon.seleniumgridextras.tasks.SetAutoLogonUser",
      "com.groupon.seleniumgridextras.tasks.UpgradeGridExtrasTask",
      "com.groupon.seleniumgridextras.tasks.AutoUpgradeDrivers",
      "com.groupon.seleniumgridextras.tasks.DownloadWebdriver",
      "com.groupon.seleniumgridextras.tasks.DownloadIEDriver",
      "com.groupon.seleniumgridextras.tasks.DownloadChromeDriver",
      "com.groupon.seleniumgridextras.tasks.DownloadGeckoDriver"
    ],
    "tear_down": [
      "com.groupon.seleniumgridextras.tasks.KillAllFirefox",
      "com.groupon.seleniumgridextras.tasks.KillAllChrome"
    ],
    "node_config_files": [
      "node_5555.json"
    ],
    "node_additional_classpath": [
       "./all-node-extensions-1.0.jar:./extension-proxy-1.0.jar"
    ],
    "reboot_after_sessions": "0",
    "grid_jvm_x_options": "-Xmx1g -XX:ParallelGCThreads=5",
    "auto_update_drivers": "0",
    "hub_config_files": [],
    "hub_config": {},
    "video_recording_options": {
      "videos_to_keep": "40"
    },
    "webdriver": {
      "version": "replce_web_driver_version_here"
    },
    "chromedriver": {
      "version": "replce_chrome_driver_version_here",
      "bit": "64"
    },
    "geckodriver": {
      "version": "replce_gecko_driver_version_here"
    }
  }
}

please pay attention to disabled_modules and active_modules Make sure you have the right ones for your need...OR just take tear_down section...I have sikuli integrated in this JSON...May be you dont need it. I just retained it so that you can refer to it

automation311 commented 6 years ago

@shankarkc Thank you so much i really appreciate it. Let me explain why i am looking for the kill browser option and I have few questions regarding the above JSON too.. I have Selenium Grid Extras installed. once my regression suit ends, In the Grid console I still see couple of the Browser instance is being occupied (grayed out) and that particular nodes have browsers open even after the regression is done. So I believe the kill browser is not happening properly so that was the reason why i was asking for how to achieve kill browsers at the end of sessions. So if i include "tear_down" section will it help? your thoughts?

If you think "tear_down" section will help to fix this issue then should i have to just include "com.groupon.seleniumgridextras.tasks.KillAllFirefox", "com.groupon.seleniumgridextras.tasks.KillAllChrome", In "active_modules" as well or some more

and then in the last post you were mentioning if i include tear_down section then i have to kill binary in path. how to do that ? can you please help?

shankarkc commented 6 years ago

On a node how many tests are running at a time? If maxinstances on that node is one then teardown kill is safe. If not then it could be killing a running test. To check if kill is in path just type kill in shell window... Assuming you are using Linux OS... If it complains command not found you have to install kill... OR put that in path

shankarkc commented 6 years ago

I think all modules are active by default.. You just need to have tear_down section i think

shankarkc commented 6 years ago

I suggest use https://zalando.github.io/zalenium/ then each test will have a new node for the execution.... Give it a try... It might make it easier to manage.

automation311 commented 6 years ago

oh then this tear-down section wont help me. I have 5 max instances in each node. so how do i make all browser instance to get killed once my regression is done?

automation311 commented 6 years ago

Is this something related to timeout? any idea?

shankarkc commented 6 years ago

@automation311 most likely its bcz your tests are not closing the webdriver sessions at the end of the test execution. Our team runs thousands of tests but we have not faced this issue. We use testng and using aftertest annotation we always close the sessions.