I have an issue with transaction in Capistrano.
The error I am getting is:
NoMethodError: undefined method `transaction' for #<SSHKit::Backend::Netssh:0x24
08b20>
Capistrano version is: 3.4.0 (Rake Version: 10.4.2).
Code is as below:
namespace :fun do
desc "Sample showing rescue, ensure, and on_rollback inside a transaction"
task :stuff do
on roles :all do
transaction do
on_rollback { logger.debug "my rollback" }
begin
logger.debug "main"
# Either run or run_locally will work the same
# run_locally "false"
run "false"
rescue => e
logger.debug "rescue #{e.class}"
raise e
ensure
logger.debug "ensure"
end
end
end
end
end
Where is the issue?
The transaction keyword was removed in Capistrano 3.
The developers recommend using the new flow control to handle this case: https://github.com/capistrano/capistrano/issues/860
Related
I am writing because I am having troubles running a test using cucumber and capybara. I am using capybara framework with selenium-driver. This is my env.rb
require 'capybara/cucumber'
Capybara.default_driver = :selenium
This is my steps.rb file
Given (/^I am on Youtube$/) do
visit "http://www.youtube.com"
end
When (/^I fill in "([^"]*)" with "([^"]*)"$/) do |field, value|
fill_in(field, :with => value)
end
When (/^I press "([^"]*)"$/) do |button|
click_button(button)
end
Then (/^I should see "([^"]*)"$/) do |text|
page.should have_content(text)
end
And this the output that i obtain. I tried to execute the same file with cucumber in a Mac system and it works. I am using Arch Linux (antergos) with kernel version 4.10.6-1-ARCH #1 SMP PREEMPT
Feature: YouTube has a search function.
Scenario: Search for a term # features/youtube_search.feature:3
Given I am on Youtube # features/step_definitions/youtube_search_steps.rb:1
undefined method `delete' for nil:NilClass (NoMethodError)
./features/step_definitions/youtube_search_steps.rb:2:in `/^I am on Youtube$/'
features/youtube_search.feature:4:in `Given I am on Youtube'
When I fill in "search_query" with "text adventure" # features/step_definitions/youtube_search_steps.rb:5
And I press "search-btn" # features/step_definitions/youtube_search_steps.rb:9
Then I should see "GET LAMP: The Text Adventure Documentary" # features/step_definitions/youtube_search_steps.rb:13
Failing Scenarios:
cucumber features/youtube_search.feature:3 # Scenario: Search for a term
1 scenario (1 failed)
4 steps (1 failed, 3 skipped)
0m1.898s
NOTE: When I run the cucumber command, a new firefox window is opened, but I see the error mentioned in the terminal and test not continue.
Thank you all in advance.
I had this problem. It happens when the selenium-webdriver and Firefox versions don't match. As Firefox gets updated fairly often you will get this error from time to time. If you update your selenium-web it should fix the problem. It did for me.
We have deployed several changes to SSIS packages successfully, but this particular change gives us an error of
The component metedata is out of sync with the compiled script. Recompile the script using the Script Component Editor.
It runs fine in the debugger on my jump host. What do I do to "recompile the script"? Or is there a deeper problem?
UPDATE 1: This particular script component is more like a destination, and asynchronous. It accepts input rows, and all (or most) of them are consumed within the script (it updates external data via a Web Service), and only the error cases continue through to the output.
I have narrowed down the problem to the absolute minimum change that gives this error: adding another input column (or remove an unused input column). To be precise, after opening the package in Visual Studio 2012 on my jump host, double-click the Perform ETL task to open the Data Flow, then double-click the G9 Web Service Script Component.
I switch to Input Columns - there are 16 ticked/listed - and I untick one that is actually not used in the script. Or I tick (add) another column (which I want to use in the script).
Then I swap back to Script, click on Edit Script, and wait for the VstaProjects window to come up.
I either close this VstaProjects window straight away, or I make an extremely minor change to the script (comment only), then Build > Build ScriptComponent_5aa...acb, then press the floppy (Save) symbol, then exit Vsta.
Then I run in the debugger (press green start arrow) and it runs as expected. I build by right-clicking the project (G9) and selecting Build (this might be redundant after running in debugger).
In Windows (File) Explorer, I navigate to the G9/bin/Development folder, double-click G9.ispac (steps through deploy: Project Development file; my-dev-svr; SSISDB > ACME-SSIS (which gives SSISDB/ACME-SSIS/G9); Deploy!
Problem: When I log into my-dev-svr, drill into Integration Services Catalogs, and run the package, then drill into the Overview Report (for this execution) > View Messages, I see several errors. The most important are
Perform ETL:Error: "G9 Web Service Script Component" failed validation and returned validation status "VS_ISBROKEN".
Perform ETL:Error: The component metedata is out of sync with the compiled script. Recompile the script using the Script Component Editor.
Command Line
I'm not entirely convinced this is related, but here it is: I've copied G9.ispac to my-dev-svr, then logged in there and on the command-line, executed dtexec. Bear in mind that this is the same server where SSIS debugging does not work.
D:\ACME\Deploy\SSIS>dtexec /Project G9.ispac /Package ACMEPortal_ProjectProperties_G9.dtsx
Microsoft (R) SQL Server Execute Package Utility
Version 11.0.6020.0 for 64-bit
Copyright (C) Microsoft Corporation. All rights reserved.
Started: 10:51:21 PM
Warning: 2017-04-17 22:51:21.74
Code: 0xC0016016
Source: SSIS:Property
Description: Failed to decrypt an encrypted XML node. Verify that the project was created by the same user. Project load will attempt to continue without the encrypted information.
End Warning
Warning: 2017-04-17 22:51:21.74
Code: 0x800190FF
Source:
Description: Failed to decrypt sensitive data in project with a user key. You may not be the user who encrypted this project, or you are not using the same machine that was used to save the project. If the sensitive data is a parameter value, the value may be required to run the package on the Integration Services server.
End Warning
Progress: 2017-04-17 22:51:25.61
Source: Get ETL Configuration
Executing query "etl_GetGenericETLConfigForACME".: 100% complete
End Progress
Progress: 2017-04-17 22:51:25.64
Source: Get G9 Web Service Connection Config Details
Executing query "etl_GetG9WSConfigSettings".: 100% complete
End Progress
Progress: 2017-04-17 22:51:25.65
Source: Audit ETL Initiation
Executing query "dbo.etl_AuditInitiation".: 100% complete
End Progress
Warning: 2017-04-17 22:51:25.68
Code: 0x80019002
Source: OnError
Description: SSIS Warning Code DTS_W_MAXIMUMERRORCOUNTREACHED. The Execution method succeeded, but the number of errors raised (6) reached the maximum allowed (1); resulting in failure. This occurs when the number of errors reaches the number specified in MaximumErrorCount. Change the MaximumErrorCount or fix the errors.
End Warning
Error: 2017-04-17 22:51:25.68
Code: 0xC0010026
Source: Set Propogate Error to False
Description: The task has failed to load. The contact information for this task is "".
End Error
Error: 2017-04-17 22:51:25.71
Code: 0xC0024107
Source: Set Propogate Error to False
Description: There were errors during task validation.
End Error
Error: 2017-04-17 22:51:25.71
Code: 0xC0010026
Source: Set FilenamePart and Error Variables
Description: The task has failed to load. The contact information for this task is "".
End Error
Warning: 2017-04-17 22:51:25.72
Code: 0x80019002
Source: OnError
Description: SSIS Warning Code DTS_W_MAXIMUMERRORCOUNTREACHED. The Execution method succeeded, but the number of errors raised (10) reached the maximum allowed (1); resulting in failure. This occurs when the number of errors reaches the number specified in MaximumErrorCount. Change the MaximumErrorCount or fix the errors.
End Warning
Error: 2017-04-17 22:51:25.72
Code: 0xC0010026
Source: Set Propogate Error to False
Description: The task has failed to load. The contact information for this task is "".
End Error
Error: 2017-04-17 22:51:25.73
Code: 0xC0024107
Source: Set Propogate Error to False
Description: There were errors during task validation.
End Error
Error: 2017-04-17 22:51:25.73
Code: 0xC0024107
Source: Set FilenamePart and Error Variables
Description: There were errors during task validation.
End Error
Warning: 2017-04-17 22:51:25.74
Code: 0x80019002
Source: ACMEPortal_ProjectProperties_G9
Description: SSIS Warning Code DTS_W_MAXIMUMERRORCOUNTREACHED. The Execution method succeeded, but the number of errors raised (8) reached the maximum allowed (1); resulting in failure. This occurs when the number of errors reaches the number specified in MaximumErrorCount. Change the MaximumErrorCount or fix the errors.
End Warning
DTExec: The package execution returned DTSER_FAILURE (1).
Started: 10:51:21 PM
Finished: 10:51:25 PM
Elapsed: 4.344 seconds
UPDATE 2: An excerpt from the Script Component.
' Microsoft SQL Server Integration Services user script component
' This is your new script component in Microsoft Visual Basic .NET
' ScriptMain is the entrypoint class for script components
Imports System
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Pipeline.Wrapper
Imports Microsoft.SqlServer.Dts.Runtime.Wrapper
Imports ScriptComponentTaskUtility.ACME_ETLDataFlowScriptComponentTasks '-- custom toolkit
Imports ScriptComponentTaskUtility
Imports Microsoft.SqlServer.Dts
Imports System.Windows.Forms
<Microsoft.SqlServer.Dts.Pipeline.SSISScriptComponentEntryPointAttribute> _
<CLSCompliant(False)> _
Public Class ScriptMain
Inherits UserComponent
Private _updateLimit As Integer
Private _rowCount As Integer
Public Overrides Sub PreExecute()
MyBase.PreExecute()
'
' Our application code follows
_updateLimit = 2 '-- Intending to replace this hard-coding
_rowCount = 0
End Sub
Public Overrides Sub G9ProjectInput_ProcessInputRow(ByVal Row As G9ProjectInputBuffer)
Try
' We limit the updated records to X per run (X = 2, but want to make configurable).
' Next ETL run will pick up next X
_rowCount += 1
If (_updateLimit > 0 And _rowCount > _updateLimit) Then Exit Sub
Dim taskComponent As G9Project = New G9Project(Me.UserID, Me.Password, Me.Config, Me.WSURL)
Dim readResponse As Project_DoReadResponse
''MessageBox.Show(Me.WSURL)
readResponse = taskComponent.ReadProject(Row.g9ProjectNumber, Row.Planet)
If (readResponse.Errors.Items.Length > 0) Then
CreateErrorRows(Row, readResponse.Errors.Items(0).ShortDescription)
Exit Sub
End If
Dim g9Project As Project = readResponse.Project
'**********************************
'Change the property values here
Try
' Who's in charge? The Manager or Owner?
If Not (Row.acmeInChargeCode_IsNull) Then
g9Project.SelectionCodes(10).Value = Row.acmeInChargeCode.ToString
End If
' ... other fields
Catch ex As Exception
Row.ErrorColumnName = "Web Service Error"
CreateErrorRows(Row, ex.Message)
Exit Sub
End Try
'End of change of property values
'**********************************
Dim updateResponse As ResponseBase
updateResponse = taskComponent.UpdateProject(g9Project)
If (updateResponse.Errors.Items.Length > 0) Then
CreateErrorRows(Row, updateResponse.Errors.Items(0).ShortDescription)
Exit Sub
End If
Catch ex As Exception
CreateErrorRows(Row, ex.Message)
Exit Sub
End Try
End Sub
' #Region ************************ NOTE: Copy & paste following code block *********************
' contains private member variables, etc, including CreateErrorRows()
End Class
It was necessary to record all the details/configuration/code of the Script Component, then to delete it and recreate it afresh. Then join up the flows again (for the input and output).
In this case, the script is a Transformation script, but in moral terms, it is a destination; only error cases come through to the output.
There was a second Script Component that also had to change as part of the same bug fix. Adding extra columns for input triggered the error there as well, so it was also necessary to do the same delete-and-recreate on this. It was also a Transformation script, but this is fully synchronous (every input row come through to output, with some read-write input columns changed, and some other read-only input columns copied/filtered to additional output columns).
It's important to note (prior to the delete-and-recreate), that I could always run it in the Visual Studio 2012 debugger on my jump host, but the "out of sync" error occurred after I had deployed the G9.ispac file to my-dev-svr (and running either via SSMS > Integration Services Catalog > ... package, or by SQL Server Agent > Job Activity Monitor > job).
An additional observation, that after the delete-and-recreate, I can now freely add and delete input columns to the script - the very activity that caused the error prior. After doing the input column changes, it is enough to press Edit Script..., wait for the VstaProjects window to appear, close it immediately, press OK on the Script Transformation Editor dialog, and verify that a red X does not appear.
I guess it's the SSIS equivalent of "Have you turned it off and turned it on again?"
Since you have already work out the script and make sure the script works fine. Then it has a lot chance it has issues in your destination. It seems that you are using the Script component as data source, try to check the Metadata from the output of the source (right click the precedence constraint), check them whether they are matched with the input of destination, more important, if you have made any changes to the source columns, you'd better to delete and create a new destination, sometimes it might cache the columns that no longer exists.
My test database objects are not viewable by Capybara Selenium WebDriver. Does anyone see an issue with my setup or what I might be missing?
rails_helper.rb
...
RSpec.configure do |config|
config.use_transactional_fixtures = false
...
end
database_clearner.rb
RSpec.configure do |config|
config.use_transactional_fixtures = false
config.before(:suite) do
DatabaseCleaner.clean_with(:truncation)
end
config.before(:each) do
DatabaseCleaner.strategy = :transaction
end
config.before(:all) do
DatabaseCleaner.start
end
config.before(:each, type: :feature) do
# :rack_test driver's Rack app under test shares database connection
# with the specs, so continue to use transaction strategy for speed.
driver_shares_db_connection_with_specs = Capybara.current_driver == :rack_test
if !driver_shares_db_connection_with_specs
# Driver is probably for an external browser with an app
# under test that does *not* share a database connection with the
# specs, so use truncation strategy.
DatabaseCleaner.strategy = :truncation
end
end
config.before(:each, :js => true) do
DatabaseCleaner.strategy = :truncation
end
config.before(:each) do
DatabaseCleaner.start
end
config.append_after(:each) do
DatabaseCleaner.clean
end
config.after(:all) do
DatabaseCleaner.clean
end
end
external_user_viewing_resources_sel_spec.rb
require 'rails_helper'
require 'support/selenium_helper'
RSpec.feature "External user " do
before(:all) do
get_driver
login_user(:external_user)
end
after(:all) do
##driver.find_element(:id, "logout").click()
#quit_driver
end
scenario "can view and click resources (helpful links)", js: true do
#d1_inst_resource = create(:d1_inst_resource)
puts #d1_inst_resource.inspect
#driver.find_element(:id, 'helpful_links_panel')
#driver.find_element(:id, "#{#d1_inst_resource.id}").click();
end
end
selenium_helper.rb
require 'selenium-webdriver'
def get_driver
Capybara.current_driver = Selenium::WebDriver.for :firefox #:chrome
#driver = Capybara.current_driver
end
def quit_driver
#driver.quit
Capybara.use_default_driver
end
def login_user(user)
#user = build_stubbed(user)
#driver.get "http://localhost:3000"
#driver.find_element(:id, "username").send_keys("#{#user.email}")
#driver.find_element(:id, "password").send_keys("#{#user.password}")
#driver.find_element(:css, "button[type='submit']").click()
end
error
..............#<Resource id: 10534, text: "Text1", url: "MyText", position: 1, d1: true, d2: false, d3: false, conference: false, institution: true, start_date: "2016-10-06", end_date: "2020-10-06", created_at: "2016-10-21 13:28:15", updated_at: "2016-10-21 13:28:15">
F...*
Failures:
1) External user can view and click resources (helpful links)
Failure/Error: #driver.find_element(:id, "#{#d1_inst_resource.id}").click();
Selenium::WebDriver::Error::NoSuchElementError:
Unable to locate element: {"method":"id","selector":"10534"}
I've seen other articles but they do not solve my issue. I understand that they run in different threads, but I feel like the configuration above has taken care of that...
Capybara with :js => true causes test to fail
*****UPDATED CODE*****
selenium_helper.rb
def login_user(user)
#user = build_stubbed(user)
page.visit "/"
page.fill_in "username", with: #user.email
page.fill_in "password", with: #user.password
page.find("button[type='submit']").click()
end
external_user_viewing_resources_sel_spec.rb
require 'rails_helper'
require 'support/selenium_helper'
RSpec.feature "External user " do
before(:each) do
Capybara.current_driver = :selenium
#d1_inst_resource = create(:d1_inst_resource)
puts Resource.count
login_user(:external_user)
puts 'test script count'
puts Resource.get_resource_by_member_type_and_division(#user).count
end
scenario "can view and click resources (helpful links)", js: true do
puts page.first('.userName').text
expect(page.first('.userName').text).to eq("#{#user.first_name.upcase} #{#user.last_name.upcase}")
page.find(:id, "#{#d1_inst_resource.id}")
page.find(:id, "#{#d1_inst_resource.id}").click()
end
end
main_controller.rb
def index
#resources = Resource.get_resource_by_member_type_and_division(#user)
puts 'index query count'
puts #resources.count
#resources
end
error
1
index query count
0
test script count
1
REVDIST TUSER1
F
Failures:
1) External user can view and click resources (helpful links)
Failure/Error: page.find(:id, "#{#d1_inst_resource.id}")
Capybara::ElementNotFound:
Unable to find id "11060"
# /Users/meffinger1/.rvm/gems/ruby-2.2.5/gems/capybara-2.9.1/lib/capybara/node/finders.rb:44:in `block in find'
# /Users/meffinger1/.rvm/gems/ruby-2.2.5/gems/capybara-2.9.1/lib/capybara/node/base.rb:85:in `synchronize'
# /Users/meffinger1/.rvm/gems/ruby-2.2.5/gems/capybara-2.9.1/lib/capybara/node/finders.rb:33:in `find'
# /Users/meffinger1/.rvm/gems/ruby-2.2.5/gems/capybara-2.9.1/lib/capybara/session.rb:735:in `block (2 levels) in <class:Session>'
# ./spec/features/selenium/external_user_viewing_resources_sel_spec.rb:28:in `block (2 levels) in <top (required)>'
Finished in 56.01 seconds (files took 6.33 seconds to load)
1 example, 1 failure
You're not seeing the resource because it isn't being created until after the page has already been loaded, however you're also not really using Capybara in your examples since you're bypassing it completely and using selenium instances directly.
In get_driver you're setting Capybara.current_driver to an instance of Selenium::WebDriver when it's expecting a symbol matching one of the drivers registered with Capybara. In `login_user' you're creating a stubbed object (ie. not real/saved to the database) and then using that to login which won't work since theres no user in the database for the app thread to load. I may not be understanding exactly what you're trying to do but I would expect your files to look more like
external_user_viewing_resources_sel_spec.rb
require 'rails_helper'
require 'support/selenium_helper'
RSpec.feature "External user " do
before(:each) do
login_user(:external_user)
end
scenario "can view and click resources (helpful links)", js: true do
#d1_inst_resource = create(:d1_inst_resource)
page.visit("whatever page should should show the record")
page.find(:id, #d1_inst_resource.id").click();
# some check for what should happen based on the click
end
end
selenium_helper.rb
def login_user(user)
#user = create(user)
page.visit "http://localhost:3000" #Is this meant to be a different system than the app under test? if not it should just be page.visit '/'
page.fill_in("username", with: #user.email)
page.fill_in("password", with: #user.password)
page.find(:css, "button[type='submit']").click()
#some check for whatever happens on the page to show the user has logge in
end
Changing my database_cleaner.rb file to this fixed the issue, they are no longer running in two different threads.
RSpec.configure do |config|
config.use_transactional_fixtures = false
config.before :each do
if Capybara.current_driver == :rack_test
DatabaseCleaner.strategy = :transaction
else
DatabaseCleaner.strategy = :truncation
end
DatabaseCleaner.start
end
config.after do
DatabaseCleaner.clean
end
end
Trying to test automatic failover using Mongoid 4.0.2 gem and using MongoDB 2.4.3
To simulate this I'm using this test code:
require 'mongoid'
class TestClass
include Mongoid::Document
store_in collection: "test", database: "test"
field :uuid, type: String
end
Mongoid.load!("config/mongoid.yml", :test)
batch = (1..100).map { |x| TestClass.new({ uuid: x }) }
batch.each_with_index { |x, i|
begin
x.save
sleep(5.seconds)
puts "Saved #{i} records" if i%10 == 0
rescue Exception => e
puts e.message
end
}
In between saves, I jumped on my MongoDB and did rs.stepDown() on the primary node of my Mongo cluster, unfortunately this results in the following errors in my test app:
See https://github.com/mongodb/mongo/blob/master/docs/errors.md
for details about this error.
Moped::Errors::OperationFailure
The operation: #<Moped::Protocol::Command
#length=68
#request_id=192
#response_to=0
#op_code=2004
#flags=[]
#full_collection_name="test.$cmd"
#skip=0
#limit=-1
#selector={:getlasterror=>1, :w=>1}
#fields=nil>
failed with error 10058: "not master"
My Mongoid configuration looks like thus:
test:
sessions:
default:
database: test_db
hosts:
- 192.168.1.10:27017
- 192.168.1.11:27017
options:
max_retries: 10
retry_interval: 1
Any idea what I'm doing wrong here? I thought the Mongoid driver would automatically detect changes in the cluster and automatically retry the request after it updates the cluster state on the client / Ruby side?
I had a problem when i run cap production deploy.
I want to run a command restart unicorn server same as ubuntu service when cap production deploy finished.
But problem was here that it didn't run this command /etc/init.d/unicorn_my_app restart when command cap production deploy finished and the server didn't restart.
And i must ssh to server and start unicorn server /etc/init.d/unicorn_my_app restart manually, so i didn't know the reason.
I research a lot of documents and topics and try a lot, but i was unsuccessful. Hope everybody can help me. Thank you very much.
This is my deploy.rb
lock '3.4.0'
set :application, 'my_app'
set :repo_url, 'git#bitbucket.org:****/my_app.git'
set :branch, 'master'
set :rvm_type, :auto
set :rvm_ruby_version, '2.2.1#my_app'
set :bundle_gemfile, -> { release_path.join('Gemfile') }
set :bundle_dir, -> { shared_path.join('bundle') }
set :bundle_flags, nil
set :bundle_without, %w{development test}.join(' ')
set :bundle_binstubs, nil
set :bundle_roles, :all
set :app_path, '/var/www/my_app/current/'
set :scm, :git
set :pty, true
set :use_sudo, true
set :format, :pretty
set :log_level, :debug
set :keep_releases, 5
set :linked_files, fetch(:linked_files, []).push('config/database.yml', 'config/secrets.yml')
set :linked_dirs, fetch(:linked_dirs, []).push('log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle', 'public/system')
namespace :deploy do
after :restart, :clear_cache do
on roles(:web), in: :groups, limit: 3, wait: 10 do
end
end
task :restart_unicorn do
on roles(:all) do
begin
puts "INFO #{Time.now} starting unicorn"
execute "/etc/init.d/unicorn_my_app restart"
rescue => e
puts "ERROR #{Time.now} error with #{e.inspect}"
end
end
end
after :finishing, "deploy:cleanup", "deploy:restart_unicorn"
end
Update: #Deep: I tried add sudo /etc/init.d/unicorn_my_app restart and it didn't run anyway. Does anybody explain for me why it didn't run ? Thank you.