On Thu, 2013-03-07 at 09:14 -0500, jvlcek wrote:
> On 03/06/2013 08:31 PM, David Lutterkort wrote:
> > Am I the only one who runs into errors running 'rake test' ? I've got a
> > bunch of fixes that I'll send out in a minute, but I still get errors
> > from test:drivers:rhevm - seems like the fixtures need to be rerecorded.
> >
> > Can others run rake test successfully ?
> >
> > David
> >
> >
> I had just re-recorded the fixtures for test:drivers:rhevm a few days
> ago. Do you have the latest bits?

Yes. Part of the problem is that VCR matches on the full URL; the first
patch changes it so that it only matches on method, path and query
params (though I think RHEV-M doesn't use the latter)

We also leak a good bit of information with our recordings. The second
(untested) patch tries to scrub user, password, and hostname from the
recordings.

Finally, I also attach the test failures I get with these changes; it's
better than with current HEAD (e884d128). It looks like the failure is
genuinely because we need rerecording.

BTW, this is with the latest rbovirt (rbovirt-0.0.18)

David

>From e90253c4c97b7e76852ac8c6d327dd5ef8299b3d Mon Sep 17 00:00:00 2001
From: David Lutterkort <lut...@redhat.com>
Date: Thu, 7 Mar 2013 09:41:16 -0800
Subject: [PATCH 1/2] RHEVM tests: have VCR match only on path and query, not
 full URI

---
 server/tests/drivers/rhevm/common.rb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/server/tests/drivers/rhevm/common.rb b/server/tests/drivers/rhevm/common.rb
index 14a51f9..b3d3a63 100644
--- a/server/tests/drivers/rhevm/common.rb
+++ b/server/tests/drivers/rhevm/common.rb
@@ -22,5 +22,5 @@ VCR.configure do |c|
   # be sure to clear fixtures/*.yml files which can be done with "git checkout".
   # e.g.:
   # c.default_cassette_options = { :record => :all }
-  c.default_cassette_options = { :record => :none }
+  c.default_cassette_options = { :record => :none, :match_requests_on => [ :method, :path, :query ] }
 end
-- 
1.8.1.4

>From fc34541a2dfe3fc8fbe8d580988cf91d58c3da08 Mon Sep 17 00:00:00 2001
From: David Lutterkort <lut...@redhat.com>
Date: Thu, 7 Mar 2013 09:43:38 -0800
Subject: [PATCH 2/2] RHEVM tests: do not record username/password/hostname
 with VCR

---
 server/tests/drivers/rhevm/common.rb | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/server/tests/drivers/rhevm/common.rb b/server/tests/drivers/rhevm/common.rb
index b3d3a63..88d7d36 100644
--- a/server/tests/drivers/rhevm/common.rb
+++ b/server/tests/drivers/rhevm/common.rb
@@ -18,6 +18,14 @@ VCR.configure do |c|
   # NOTE: Empty this directory before re-recording
   c.cassette_library_dir = File.join(File.dirname(__FILE__), 'fixtures')
   c.hook_into :webmock
+  # Rewrite sensitive information before recording
+  c.before_record do |i|
+    u = URI::parse(i.request.uri)
+    u.host = "rhevm.example.com"
+    u.user = "admin"
+    u.password = "secret"
+    i.request.uri = u.to_s
+  end
   # Set :record to :all, when re-recording and between re-record attemps
   # be sure to clear fixtures/*.yml files which can be done with "git checkout".
   # e.g.:
-- 
1.8.1.4

avon:server (dev/rhevm)>rake test:drivers:rhevm
Run options:

# Running tests:

..........output error : string is not in UTF-8
E...output error : string is not in UTF-8
E....

Finished tests in 13.493763s, 1.4081 tests/s, 5.9287 assertions/s.

  1) Error:
test_0006_must allow to create a new instance and make it running(RhevmDriver 
Instances):
Deltacloud::Exceptions::BackendError:

================================================================================
An HTTP request has been made that VCR does not know how to handle:
  GET 
https://mockuser:mockpassword@10.16.120.71/api/vms/4e5dbb0f-a295-4679-842d-c152ea2eeaa7

VCR is currently using the following cassette:
  - 
/homes/lutter/code/deltacloud/git/server/tests/drivers/rhevm/fixtures/test_0006_must_allow_to_create_a_new_instance_and_make_it_running-10.yml
  - :record => :none
  - :match_requests_on => [:method, :path, :query]

Under the current configuration VCR can not find a suitable HTTP interaction
to replay and is prevented from recording new requests. There are a few ways
you can deal with this:

  * If you're surprised VCR is raising this error
    and want insight about how VCR attempted to handle the request,
    you can use the debug_logger configuration option to log more details [1].
  * You can use the :new_episodes record mode to allow VCR to
    record this new request to the existing cassette [2].
  * If you want VCR to ignore this request (and others like it), you can
    set an `ignore_request` callback [3].
  * The current record mode (:none) does not allow requests to be recorded. You
    can temporarily change the record mode to :once, delete the cassette file
    and re-run your tests to allow the cassette to be recorded with this 
request [4].
  * The cassette contains 14 HTTP interactions that have not been
    played back. If your request is non-deterministic, you may need to
    change your :match_requests_on cassette option to be more lenient
    or use a custom request matcher to allow it to match [5].

[1] https://www.relishapp.com/vcr/vcr/v/2-4-0/docs/configuration/debug-logging
[2] https://www.relishapp.com/vcr/vcr/v/2-4-0/docs/record-modes/new-episodes
[3] https://www.relishapp.com/vcr/vcr/v/2-4-0/docs/configuration/ignore-request
[4] https://www.relishapp.com/vcr/vcr/v/2-4-0/docs/record-modes/none
[5] https://www.relishapp.com/vcr/vcr/v/2-4-0/docs/request-matching
================================================================================


    
/homes/lutter/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/rbovirt-0.0.18/lib/rbovirt.rb:146:in
 `handle_fault'
    
/homes/lutter/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/rbovirt-0.0.18/lib/rbovirt.rb:81:in
 `rescue in http_get'
    
/homes/lutter/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/rbovirt-0.0.18/lib/rbovirt.rb:78:in
 `http_get'
    
/homes/lutter/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/rbovirt-0.0.18/lib/client/vm_api.rb:5:in
 `vm'
    
/homes/lutter/code/deltacloud/git/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb:131:in
 `block in instances'
    
/homes/lutter/code/deltacloud/git/server/lib/deltacloud/drivers/exceptions.rb:220:in
 `call'
    
/homes/lutter/code/deltacloud/git/server/lib/deltacloud/drivers/exceptions.rb:220:in
 `safely'
    
/homes/lutter/code/deltacloud/git/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb:128:in
 `instances'
    
/homes/lutter/code/deltacloud/git/server/lib/deltacloud/drivers/base_driver.rb:229:in
 `instance'
    /homes/lutter/code/deltacloud/git/server/lib/deltacloud/api.rb:118:in 
`method_missing'
    /homes/lutter/code/deltacloud/git/server/lib/deltacloud/api.rb:47:in `block 
(3 levels) in wait_for!'
    
/homes/lutter/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/vcr-2.4.0/lib/vcr/util/variable_args_block_caller.rb:9:in
 `call'
    
/homes/lutter/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/vcr-2.4.0/lib/vcr/util/variable_args_block_caller.rb:9:in
 `call_block'
    
/homes/lutter/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/vcr-2.4.0/lib/vcr.rb:173:in
 `use_cassette'
    /homes/lutter/code/deltacloud/git/server/tests/test_helper.rb:40:in `block 
in record_retries'
    /homes/lutter/code/deltacloud/git/server/lib/deltacloud/api.rb:47:in `call'
    /homes/lutter/code/deltacloud/git/server/lib/deltacloud/api.rb:47:in `block 
(2 levels) in wait_for!'
    /homes/lutter/.rbenv/versions/1.9.3-p392/lib/ruby/1.9.1/timeout.rb:68:in 
`timeout'
    /homes/lutter/code/deltacloud/git/server/lib/deltacloud/api.rb:45:in `block 
in wait_for!'
    /homes/lutter/code/deltacloud/git/server/lib/deltacloud/api.rb:43:in 
`downto'
    /homes/lutter/code/deltacloud/git/server/lib/deltacloud/api.rb:43:in 
`wait_for!'
    
/homes/lutter/code/deltacloud/git/server/tests/drivers/rhevm/instance_test.rb:83:in
 `block (2 levels) in <top (required)>'

  2) Error:
test_0005_must allow to create a new instance and destroy it(RhevmDriver 
Instances):
Deltacloud::Exceptions::BackendError:

================================================================================
An HTTP request has been made that VCR does not know how to handle:
  GET 
https://mockuser:mockpassword@10.16.120.71/api/vms/b48f5594-0788-46c5-b56c-af1c349d280f

VCR is currently using the following cassette:
  - 
/homes/lutter/code/deltacloud/git/server/tests/drivers/rhevm/fixtures/test_0005_must_allow_to_create_a_new_instance_and_destroy_it-10.yml
  - :record => :none
  - :match_requests_on => [:method, :path, :query]

Under the current configuration VCR can not find a suitable HTTP interaction
to replay and is prevented from recording new requests. There are a few ways
you can deal with this:

  * If you're surprised VCR is raising this error
    and want insight about how VCR attempted to handle the request,
    you can use the debug_logger configuration option to log more details [1].
  * You can use the :new_episodes record mode to allow VCR to
    record this new request to the existing cassette [2].
  * If you want VCR to ignore this request (and others like it), you can
    set an `ignore_request` callback [3].
  * The current record mode (:none) does not allow requests to be recorded. You
    can temporarily change the record mode to :once, delete the cassette file
    and re-run your tests to allow the cassette to be recorded with this 
request [4].
  * The cassette contains 14 HTTP interactions that have not been
    played back. If your request is non-deterministic, you may need to
    change your :match_requests_on cassette option to be more lenient
    or use a custom request matcher to allow it to match [5].

[1] https://www.relishapp.com/vcr/vcr/v/2-4-0/docs/configuration/debug-logging
[2] https://www.relishapp.com/vcr/vcr/v/2-4-0/docs/record-modes/new-episodes
[3] https://www.relishapp.com/vcr/vcr/v/2-4-0/docs/configuration/ignore-request
[4] https://www.relishapp.com/vcr/vcr/v/2-4-0/docs/record-modes/none
[5] https://www.relishapp.com/vcr/vcr/v/2-4-0/docs/request-matching
================================================================================


    
/homes/lutter/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/rbovirt-0.0.18/lib/rbovirt.rb:146:in
 `handle_fault'
    
/homes/lutter/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/rbovirt-0.0.18/lib/rbovirt.rb:81:in
 `rescue in http_get'
    
/homes/lutter/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/rbovirt-0.0.18/lib/rbovirt.rb:78:in
 `http_get'
    
/homes/lutter/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/rbovirt-0.0.18/lib/client/vm_api.rb:5:in
 `vm'
    
/homes/lutter/code/deltacloud/git/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb:131:in
 `block in instances'
    
/homes/lutter/code/deltacloud/git/server/lib/deltacloud/drivers/exceptions.rb:220:in
 `call'
    
/homes/lutter/code/deltacloud/git/server/lib/deltacloud/drivers/exceptions.rb:220:in
 `safely'
    
/homes/lutter/code/deltacloud/git/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb:128:in
 `instances'
    
/homes/lutter/code/deltacloud/git/server/lib/deltacloud/drivers/base_driver.rb:229:in
 `instance'
    /homes/lutter/code/deltacloud/git/server/lib/deltacloud/api.rb:118:in 
`method_missing'
    /homes/lutter/code/deltacloud/git/server/lib/deltacloud/api.rb:47:in `block 
(3 levels) in wait_for!'
    
/homes/lutter/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/vcr-2.4.0/lib/vcr/util/variable_args_block_caller.rb:9:in
 `call'
    
/homes/lutter/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/vcr-2.4.0/lib/vcr/util/variable_args_block_caller.rb:9:in
 `call_block'
    
/homes/lutter/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/vcr-2.4.0/lib/vcr.rb:173:in
 `use_cassette'
    /homes/lutter/code/deltacloud/git/server/tests/test_helper.rb:40:in `block 
in record_retries'
    /homes/lutter/code/deltacloud/git/server/lib/deltacloud/api.rb:47:in `call'
    /homes/lutter/code/deltacloud/git/server/lib/deltacloud/api.rb:47:in `block 
(2 levels) in wait_for!'
    /homes/lutter/.rbenv/versions/1.9.3-p392/lib/ruby/1.9.1/timeout.rb:68:in 
`timeout'
    /homes/lutter/code/deltacloud/git/server/lib/deltacloud/api.rb:45:in `block 
in wait_for!'
    /homes/lutter/code/deltacloud/git/server/lib/deltacloud/api.rb:43:in 
`downto'
    /homes/lutter/code/deltacloud/git/server/lib/deltacloud/api.rb:43:in 
`wait_for!'
    
/homes/lutter/code/deltacloud/git/server/tests/drivers/rhevm/instance_test.rb:59:in
 `block (2 levels) in <top (required)>'

19 tests, 80 assertions, 0 failures, 2 errors, 0 skips
rake aborted!
Command failed with status (2): [ruby -I"lib" -S testrb  
"tests/drivers/rhevm/images_test.rb" "tests/drivers/rhevm/instance_test.rb" 
"tests/drivers/rhevm/provider_test.rb" "tests/drivers/rhevm/realms_test.rb" ]

Tasks: TOP => test:drivers:rhevm
(See full trace by running task with --trace)
a

Reply via email to