deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Koper, Dies" <di...@fast.au.fujitsu.com>
Subject RE: [PATCH] CIMI: make cimi system scenario more generic and work on fgcp
Date Tue, 23 Apr 2013 08:53:41 GMT
Hi Marios,

I think I'm close but I'm not there yet.
With the fgcp, when requesting a new system to be created, the resource
transitions from CREATING to STOPPED/MIXED over a few minutes.
But the current test assumes it transitions to the end state instantly.
So I've added calls to poll_state to ensure a system has reached the end
state before it looks for advertised operations and tries to invoke
them.

The current poll_state method seems to be written for machines. I don't
think this code is called with mock for systems because mock's systems
reach their end state instantly, but with fgcp I can't get it to work.

I'm trying to make the poll_state method more generic to cater for any
resource with a state attribute and for the moment only focus on
machines and systems.

> +        stateful_resource = machine(:refetch => true) if
> stateful_resource.is_a? CIMI::Model::Machine
> +        stateful_resource = system(:refetch => true) if
> stateful_resource.is_a? CIMI::Model::System

This is the resource specific part of the method:
When the expected state hasn't been reached yet, wait 10 seconds and
then fetch the machine or system state again from the backend.

I'm not sure how the machine method is implemented and how I can
implement the same for system. Any suggestions?

Cheers,
Dies Koper


> -----Original Message-----
> From: diesk@fast.au.fujitsu.com [mailto:diesk@fast.au.fujitsu.com]
> Sent: Tuesday, 23 April 2013 5:36 PM
> To: dev@deltacloud.apache.org
> Subject: [PATCH] CIMI: make cimi system scenario more generic and work
> on fgcp
> 
> From: Dies Koper <diesk@fast.au.fujitsu.com>
> 
> ---
>  tests/cimi/system1_test.rb |  6 +++++-
>  tests/cimi/test_helper.rb  | 12 +++++++-----
>  2 files changed, 12 insertions(+), 6 deletions(-)
> 
> diff --git a/tests/cimi/system1_test.rb b/tests/cimi/system1_test.rb
> index 6102c37..0acae54 100644
> --- a/tests/cimi/system1_test.rb
> +++ b/tests/cimi/system1_test.rb
> @@ -133,6 +133,8 @@ class SystemTemplate < CIMI::Test::Spec
>    # 1.10 Starting the new System
>    it "should be able to start the system", :only => :json  do
>      test_system_created =
> get(fetch(system_created.headers[:location]).id, :accept => :json)
> +    # ensure the system has reached a stable state (STOPPED, MIXED or
> STARTED)
> +    poll_state(fetch(system_created.headers[:location]), ["STARTED",
> "STOPPED", "MIXED"])
>      unless test_system_created.json["state"].eql?("STARTED")
>        uri = discover_uri_for("start", "",
> test_system_created.json["operations"])
>        response = post( uri,
> @@ -158,7 +160,9 @@ class SystemTemplate < CIMI::Test::Spec
>    # 1.12 Stop the new System
>    it "should be able to stop the system", :only => :json  do
>      test_system_created =
> get(fetch(system_created.headers[:location]).id, :accept => :json)
> -    unless test_system_created.json["state"].eql?("STOPPED")
> +    # ensure the system has reached a stable state (STOPPED, MIXED or
> STARTED)
> +    poll_state(fetch(system_created.headers[:location]), ["STARTED",
> "STOPPED", "MIXED"])
> +    unless test_system_created.json["state"].upcase.eql?("STOPPED")
>        uri = discover_uri_for("stop", "",
> test_system_created.json["operations"])
>        response = post( uri,
>              "<Action xmlns=\"http://schemas.dmtf.org/cimi/1\">" +
> diff --git a/tests/cimi/test_helper.rb b/tests/cimi/test_helper.rb
> index c4bedac..66f32be 100644
> --- a/tests/cimi/test_helper.rb
> +++ b/tests/cimi/test_helper.rb
> @@ -254,12 +254,14 @@ module CIMI::Test::Methods
>        log.debug "/#{method.to_s.upcase} #{absolute_url(path)}"
>      end
> 
> -    def poll_state(machine, state)
> -      while not machine.state.upcase.eql?(state)
> -        puts state
> -        puts 'waiting for machine to be: ' + state.to_s()
> +    def poll_state(stateful_resource, states)
> +      states = [states] unless states.is_a? Array
> +      while not states.include?(stateful_resource.state.upcase)
> +        puts stateful_resource.state
> +        puts 'waiting for resource to be: ' + states.join(' or
').to_s
>          sleep(10)
> -        machine = machine(:refetch => true)
> +        stateful_resource = machine(:refetch => true) if
> stateful_resource.is_a? CIMI::Model::Machine
> +        stateful_resource = system(:refetch => true) if
> stateful_resource.is_a? CIMI::Model::System
>        end
>      end
> 
> --
> 1.8.0.msysgit.0
> 
> 



Mime
View raw message