Selenium failing with EOFile error with chromedriver on linux - ruby-on-rails

I have an automated build machine running cucumber tests on an EC2 instance. I am using:
capybara (1.1.4)
selenium-webdriver (2.31.0)
chromedriver (25.0.1364.172-187217)
The tests are run headless using Xvfb X11 Server (1.7.7-29.10.amzn1) This setup has been working fine for months, but last week stopped working on these machines.
The error I am getting is:
(::) failed steps (::)
end of file reached (EOFError)
/mnt/bamboo-ebs/rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/net/protocol.rb:135:in `read_nonblock'
/mnt/bamboo-ebs/rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/net/protocol.rb:135:in `rbuf_fill'
/mnt/bamboo-ebs/rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/net/protocol.rb:116:in `readuntil'
/mnt/bamboo-ebs/rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/net/protocol.rb:126:in `readline'
/mnt/bamboo-ebs/rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/net/http.rb:2219:in `read_status_line'
/mnt/bamboo-ebs/rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/net/http.rb:2208:in `read_new'
/mnt/bamboo-ebs/rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/net/http.rb:1191:in `transport_request'
/mnt/bamboo-ebs/rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/net/http.rb:1177:in `request'
/mnt/bamboo-ebs/rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/net/http.rb:1170:in `block in request'
/mnt/bamboo-ebs/rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/net/http.rb:627:in `start'
/mnt/bamboo-ebs/rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/net/http.rb:1168:in `request'
./features/step_definitions/web_steps.rb:49:in `/^(?:|I )go to (.+)$/'
My best guess is the problem is due to upgrades to the selenium or chromedriver libraries in the past month as these are updated whenever a build instance is started.
I have checked the chromedriver logs but they do not appear to offer anything helpful:
0.000][INFO]: ChromeDriver 23.0.1240.0 /mnt/bamboo-ebs/bin/chromedriver/chromedriver
[0.259][FINE]: Initializing session with capabilities {
"browserName": "chrome",
"chrome.detach": true,
"chromeOptions": {
"detach": true
},
"cssSelectorsEnabled": true,
"javascriptEnabled": true,
"nativeEvents": false,
"platform": "ANY",
"rotatable": false,
"takesScreenshot": false,
"version": ""
}
[0.259][INFO]: Using named testing interface
[0.676][INFO]: Connected to Chrome successfully. Version: 25.0.1364.172
[0.693][FINE]: Command received (/session/132be881788b1e7a6c878f4c45935176)
[0.693][FINE]: Command finished (/session/132be881788b1e7a6c878f4c45935176) with response {
"sessionId": "132be881788b1e7a6c878f4c45935176",
"status": 0,
"value": {
"acceptSslCerts": false,
"applicationCacheEnabled": false,
"browserConnectionEnabled": false,
"browserName": "chrome",
"chrome.chromedriverVersion": "23.0.1240.0",
"chrome.nativeEvents": false,
"cssSelectorsEnabled": true,
"databaseEnabled": false,
"handlesAlerts": true,
"javascriptEnabled": true,
"locationContextEnabled": false,
"nativeEvents": true,
"platform": "linux",
"rotatable": false,
"takesScreenshot": true,
"version": "25.0.1364.172",
"webStorageEnabled": true
}
}
[0.695][FINE]: Command received (/session/132be881788b1e7a6c878f4c45935176/url) with params {
"url": "http://127.0.0.1:31337/"
}
[0.695][FINER]: Waiting for all views to stop loading...
[0.696][FINER]: Done waiting for all views to stop loading
[0.716][FINER]: Waiting for all views to stop loading...
All tests work successfully on my development machine (Mac OSX Mountain Lion) with chromedriver (26.0.1383.0). I have tried to downgrade my chromedriver to match the version on my build machine, but found I could not do this.
I have managed to get the tests to run using firefox, but this is not a long term solution for us.
Any help would be much appreciated.

Related

Configuring vimspector with ruby on rails app running passenger

My question is how do i get vimspector running with a ruby on rails app running passenger (I think)
I'm trying to set up vimspector with some ruby on rails projects I'm working on. Basically the problem is that vimspector doesn't stop at breakpoints in some apps. the apps are using passenger. In a very basic sample app vimspector works fine, but not in the ones where i actually need to debug.
Description:
when i call vimspector#Launch all the splits/windows come up, and a passenger application server gets launched. I don't work alone on some projects so i cannot really change this to another one.
I set some breakpoints and do actions that should stop at them but they run through like without a debugger. Also nothing except for threads running and the console output of the rails server shows up in the splits. In my processes 2 processes show up. Once the Passenger Ruby app and once a node process going to my cust_vscode-ruby directory which is needed for the debugger. The node process has the subprocess rdebug-ide and rdebug-ide has passenger start.
As vimspector works fine with the sample rails app, I don't think its a problem of the install or something like that.
I tried switching to attach but when configuring it for attach i get an endless loading without getting a timeout in the browser. the terminal window where i run rdebug-ide starts of without any repsonse, i launch vimspector and the server is being booted up. It stops at this however and never goes past booting Run rails server -h for more startup options. After which passenger normally starts up. With switching to attach mode only the rdebug controlled rails server shows up in my processes.
I think this should be possible as i'm usind ruby-debug-ide which is being used by RubyMine on which i could debug the apps running passenger just fine. I'm pretty sure that is has to do with passenger as calling it up in launch config leads to it escaping and using attach config leads to it blocking the rails server boot. But I don't know how to fix it.
.vimspector.json
same for both sample app and actual app :
{
"configurations": {
"rails": {
"adapter": "cust_vscode-ruby",
"default": true,
"configuration": {
"name": "Debug Rails server",
"type": "Ruby",
"request": "launch",
"cwd": "${workspaceRoot}",
"pathToBundler": "/Users/username/.rvm/rubies/ruby-version/bin/bundler",
"pathToRDebugIDE": "/Users/username/.rvm/gems/ruby-version/gems/ruby-debug-ide-0.7.3",
"program": "${workspaceRoot}/bin/rails",
"args": [
"server"
]
}
}
}
}
vimspector configuration output
Vimspector Debug Info
--------------------------------------------------------------------------------
ConnectionType: job
Adapter:
--------------------------------------------------------------------------------
{
"command": [
"node",
"/Users/username/.vim/plugged/vimspector/gadgets/macos/cust_vscode-ruby/dist/debugger/main.js"
],
"configuration": {
"cwd": "/Users/username/Folder/app-name",
"showDebugOutput": false,
"trace": false
},
"name": "vscode-ruby-debug",
"env": {},
"cwd": "/Users/username/Folder/app-name"
}
--------------------------------------------------------------------------------
Configuration:
--------------------------------------------------------------------------------
{
"adapter": "cust_vscode-ruby",
"default": true,
"configuration": {
"name": "Debug Rails server",
"type": "Ruby",
"request": "launch",
"cwd": "/Users/username/Folder/app-name",
"pathToBundler": "/Users/username/.rvm/rubies/ruby-version/bin/bundler",
"pathToRDebugIDE": "/Users/username/.rvm/gems/ruby-version/gems/ruby-debug-ide-0.7.3",
"program": "/Users/username/Folder/app-name/bin/rails",
"args": [
"server"
]
}
}
--------------------------------------------------------------------------------
API Prefix:
Launch/Init: True / True
Workspace Root: /Users/username/Folder/app-name
Launch Config:
--------------------------------------------------------------------------------
{
"cwd": "/Users/username/Folder/app-name",
"showDebugOutput": false,
"trace": false,
"name": "Debug Rails server",
"type": "Ruby",
"request": "launch",
"pathToBundler": "/Users/username/.rvm/rubies/ruby-version/bin/bundler",
"pathToRDebugIDE": "/Users/username/.rvm/gems/ruby-version/gems/ruby-debug-ide-0.7.3",
"program": "/Users/username/Folder/app-name/bin/rails",
"args": [
"server"
]
}
--------------------------------------------------------------------------------
Server Capabilities:
--------------------------------------------------------------------------------
{
"supportsConfigurationDoneRequest": true,
"supportsConditionalBreakpoints": true
}
--------------------------------------------------------------------------------
Line Breakpoints:
--------------------------------------------------------------------------------
{
"/Users/username/Folder/app-name/app/controllers/.../somethings_controller.rb": [
{
"state": "ENABLED",
"line": 83,
"options": {},
"sign_id": 1,
"server_bp": {
"verified": true,
"line": 83,
"id": 1
}
}
]
}
--------------------------------------------------------------------------------
Func Breakpoints:
--------------------------------------------------------------------------------
[]
--------------------------------------------------------------------------------
Ex Breakpoints:
None
so i got it to work not with passenger itself.
i changed my vimspector config to the following, switching up some paths to the used binaries by trial and error (i think the one that matters is calling the rails binary in the project root). The important thing is to call in the args server -u puma. Make sure to write each part of the command as a single argument. puma being the default rails server (i found it to be in my sample app), so this gets picked up by rdebug-ide and debase.
{
"configurations": {
"rails": {
"adapter": "cust_vscode-ruby",
"default": true,
"configuration": {
"name": "Debug Rails server",
"type": "Ruby",
"request": "launch",
"cwd": "${workspaceRoot}",
"pathToBundler": "/Users/username/.rvm/rubies/ruby-RUBYVERSION/bin/bundler",
"pathToRDebugIDE": "/Users/username/.rvm/gems/ruby-RUBYVERSION/gems/ruby-debug-ide-RUBYDEBUGIDEVERSION",
"program": "${workspaceRoot}/bin/rails",
"args": [
"server", "-u", "puma"
]
}
}
}
}
There are some options I found for using passenger, it probably has to do something with writing the config as attach.
What seemed closest (but it doesn't work) to the answer seemed to copy the rubymine config that calls:
/bin/bash -c "~/.rvm/bin/rvm _RUBYVERSION_ do ~/.rvm/rubies/ruby-_RUBYVERSION_/bin/ruby ~/.rvm/gems/ruby-_VERSION_/gems/ruby-debug-ide-_RUBYDEBUG-IDEVERSION_/bin/rdebug-ide --key-value --disable-int-handler --evaluation-timeout 10 --evaluation-control --time-limit 100 --memory-limit 0 --rubymine-protocol-extensions --port 42371 --host 0.0.0.0 --dispatcher-port 38403 -- ~/Folder/project/bin/rails server -b 0.0.0.0 -p 3000 -e development"
I think a point where it could be failing, and why it's not working is that passenger needs to be set to allow debugging (PassengerDebugger on), although i might just be confusing everything here. However this passenger option is reserved for the Enterprise version (https://www.phusionpassenger.com/library/admin/apache/debugging_console/ruby/).
Where this left me off was i launched this debug config but couldn't connect to the socket. Maybe this is to some security measure i made to tight for my own good on my system or more likely a fault in the config.
I think it's possible to attach to the passenger server properly somehow some ideas could maybe be found here but i didn't get anywhere with them.
https://mondotondo.com/2012/08/23/how-to-remotely-debug-rails-in-apache-passenger-rubymine/
How can I get ruby-debug-ide to work?
If you are struggeling like me with this, hang in there you will get it some day!

How to get RSpec working with debugger IDE in VSCode

Despite having spent about the last three hours trying to get this working I cannot for the life of my get RSpec to work with the debugger on VSCode. I can get Rspec to run in the terminal on VSCode but that doesn't give me any of the IDE's debugging functionality for inspecting and stepping.
This is what I've got in my launch.json file:
{
"version": "0.2.0",
"configurations": [
{
"name": "Run RSpec - all",
"type": "Ruby",
"request": "launch",
"cwd": "${workspaceRoot}",
"program": "/Users/my-home-dir/.rvm/gems/ruby-2.6.5#project-gemset-name/wrappers/rspec",
"pathToRDebugIDE": "/Users/my-home-dir/.rvm/gems/ruby-2.6.5#project-gemset-name/gems/ruby-debug-ide-0.7.2",
"args": [
"--pattern",
"${workspaceRoot}/spec/**/*_rspec.rb"
]
}
]
}
And my gemfile contains:
gem 'ruby-debug-ide', '~>0.7.2'
gem 'debase', '~>0.2.4.1'
I've got a feeling that the errors may be coming about due to in incompatibility between RVM and VSCode but I've no idea how to unwind that issue.
This was all setup as per the Microsoft recipe here: https://github.com/Microsoft/vscode-recipes/tree/master/debugging-Ruby-on-Rails
Every time I run this setup I get the following error in the debug console:
Debugger terminal error: Process failed: spawn rdebug-ide ENOENT
Is there any way to get this to run? Also is there any way to get it to use guard so that it runs automatically?
I got it working. Unfortunately, I don't use RVM. So, my solution involves rbenv. I'm sharing it here anyway in case it helps you, or someone else.
which rspec pointed me to the shim (shell script) that rbenv uses to execute the version of rspec installed under the current version of Ruby. When I configured launch.json with that path rdebug-ide didn't like the shim. I assume it was expecting the executable.
So, I ran rbenv which rspec and got the actual path to the executable. Once I plugged that into launch.json it worked fine. Of course, if I change the version of Ruby I'm running, I'll have to update the file to point to the version of RSpec installed under the new version of Ruby.
Given the prevalence of Ruby version managers among the community, I would think ruby-debug-ide would have considered this. Perhaps it's worth an issue on their GitHub: https://github.com/ruby-debug/ruby-debug-ide.
I added a preLaunchTask to launch rdebug-ide server then looked for a pattern before attaching the debugger.
I used the focus flag for controlling which tests are run or not. Am able to set breakpoints in main script files as well as *_spec.rb files.
Gemfile:
group :test, :development do
gem "ruby-debug-ide", "~> 0.7.2"
gem "debase", "~> 0.2.4"
end
launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "Listen for rdebug-ide rspec",
"type": "Ruby",
"request": "attach",
"remoteHost": "127.0.0.1",
"remotePort": "1234",
"preLaunchTask": "run-rdebug-for-rspec",
"remoteWorkspaceRoot": "${workspaceRoot}",
"cwd": "${workspaceFolder}"
}
]
}
tasks.json
{
"version": "2.0.0",
"tasks": [{
"label": "run-rdebug-for-rspec",
"command": "bundle",
// could update these are you see fit
// my tests were located in /spec folder
"args": [
"exec","rdebug-ide",
"--host","0.0.0.0",
"--port","1234",
"--dispatcher-port","26162",
// needed to specify the full path of bundle
// can be found by `which bundle`
"--", "/usr/local/bin/bundle", "exec", "rspec", "spec/"
],
"type": "shell",
"isBackground": true,
// this will look for a pattern to attach to rdebug server
// attaching to the server will start running the tests
"problemMatcher": [
{
"pattern": [
{
"regexp": ".",
"file": 1,
"location": 2,
"message": 3
}
],
"background": {
"activeOnStart": true,
// once server is up and running it'll display something like:
// Fast Debugger (ruby-debug-ide 0.7.2, debase 0.2.4.1, file filtering is supported) listens on 0.0.0.0:1234
"beginsPattern": "^Fast Debugger.*1234$",
"endsPattern": ".",
}
}
],
// open up a new task window everytime
// if set to default `shared` then previous task window needs to be closed
// otherwise, was having issues getting patternMatcher to work
// and for rdebug to attach within a shared terminal on successive runs, or restarts.
"presentation": {
"panel": "new"
}
}]
}
While the answer above may work, there will be problems as soon as you upgrade your ruby version because the paths are hard coded.
Here is a less brittle approach that should be able to survive a version upgrade without any problem.
I'm on ruby 3.0.3, managed by rvm on mac osx.
Gemfile includes:
group :development do
gem 'ruby-debug-ide'
gem 'debase', "~> 0.2.5.beta2"
end
(the stable version of debase didn't support ruby v3, hence the beta)
Launch config use the GEM_HOME environment variable to specify the rspec binary (vscode default configuration puts this in workspace root for some reason):
{
"name": "RSpec - all",
"type": "Ruby",
"request": "launch",
"program": "${env:GEM_HOME}/bin/rspec",
"args": [
"-I",
"${workspaceRoot}"
]
}

How to provide a valid crumb in ansible jenkins_script module

I am using Ansible to check the status of several jenkins servers. The playbook that I have created checks the disk space, uptime, and jenkins version perfectly fine. However, I tried to add a task that prints out a list of the installed jenkins plugins for each server by using the jenkins_Script module and keep receiving a '403' error message.
Playbook:
- name: Obtaining a list of Jenkins Plugins
jenkins_script:
script: 'println(Jenkins.instance.pluginManager.plugins)'
url: 'http://server.com:8080/'
user: '*****'
password: '*****'
Output:
fatal: [server]: FAILED! => {
"changed": false,
"failed": true,
"invocation": {
"module_args": {
"args": null,
"force_basic_auth": true,
"password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
"script": "println(Jenkins.instance.pluginManager.plugins)",
"url": "http://server.com:8080/",
"url_password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
"url_username": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
"user": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
"validate_certs": true
}
},
"msg": "HTTP error 403 HTTP Error 403: No valid crumb was included in the request"
}
-- I believe I have narrowed down the issue - It looks like I wasn't providing a crumb. I have since generated the crumb, but there is no 'crumb' arguement for the jenkins_script module. Does anyone know how to successfully provide a crumb?
Will gladly clarify anything stated above if needed, and any assistance is greatly appreciated.
https://github.com/ansible/ansible/pull/20207
-- if you're on ansible 2.3 the changes have already been committed all you have to do is make sure 'cross site request forgery' is enabled on the jenkins servers. (Manage jenkins > Configure Global security)

Nightwatch tests to work on edge

I'm trying to get nightwatch tests to work in Microsoft edge. I'm getting an error saying connection refused. What's the right configuration to get tests to work on edge? Windows 10 edge 13
Could you post your configuration?
Make sure you have installed microsoft edge webdriver (you may download it here https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/).
You have to specify path to your edge driver using webdriver.edge.driver param, ex.
"selenium": {
"start_process": true,
"server_path": "./node_modules/file_dependencies/selenium-server-standalone.jar",
"log_path": "",
"host": "127.0.0.1",
"port": seleniumPort,
"cli_args": {
"webdriver.chrome.driver": "./node_modules/file_dependencies/chromedriver.exe",
"webdriver.ie.driver": "./node_modules/file_dependencies/IEDriverServer.exe",
"webdriver.edge.driver": "C:/Program Files (x86)/Microsoft Web Driver/MicrosoftWebDriver.exe",
"webdriver.gecko.driver": "./node_modules/file_dependencies/geckodriver.exe",
"webdriver.firefox.profile": ""
}
}
and example capabilities
"edge": {
"desiredCapabilities": {
"browserName": "MicrosoftEdge",
"javascriptEnabled": true,
"acceptSslCerts": true,
"pageLoadStrategy": "eager"
}
}

Send iOS Push Notifications with Node.js on Openshift

I'm developing a website , that should send push notifications to iOS devices. I followed this tutorial to send notifications. On my localhost apnagent works fine, but when I git push it to my Openshift cloud I get the following errors in the terminal:
remote: Waiting for application port (8080) become available ...
remote: Application 'apnagent' failed to start (port 8080 not available)
remote: -------------------------
remote: Git Post-Receive Result: failure
remote: Activation status: failure
remote: Activation failed for the following gears:
remote: 55c3344c89f5cf720xxxxxxx (Error activating gear: CLIENT_ERROR: Failed to execute: 'control start' for /var/lib/openshift/55c3344c89f5cf720xxxxxxx/nodejs
remote: #<IO:0x00000000f1c278>
remote: #<IO:0x00000000f1c200>
remote: )
remote: Deployment completed with status: failure
remote: postreceive failed
To ssh://55c3344c89f5cf720xxxxxxx#apnagent-xxxxxxx.rhcloud.com/~/git/apnagent.git/
bbcf2a3..87exxxx master -> master
My package.json looks like this:
{
"private": true,
"name": "apnagent",
"version": "0.0.0",
"dependencies": {
"apnagent": "1.0.x"
},
"engines": {
"node": ">=0.10.22",
"npm": ">=1.3.14"
},
"scripts": {
"start": "node agent/_header.js"
},
"main": "agent/_header.js"
}
I think i should use somehow process.env.OPENSHIFT_NODEJS_PORT as port on the server, or something like this. I'm sure, I've done some configuration mistake since on my local machine everything works fine.
Did you check the logs on the server? SSH into your app and use
less app-root/logs/nodejs.log
and press shift+g to view the recent console outputs for the server. I had a few syntax errors in my scripts and they were causing a similar error.
If that doesn't help, could you post your server script?

Resources