On Thu, 2010-02-25 at 14:48 -0500, Chris Lalancette wrote:
On 02/18/2010 02:17 PM, David Lutterkort wrote:
> On Wed, 2010-02-17 at 15:35 -0500, Chris Lalancette wrote:
>> While using the mock driver for a while I noticed that my
>> instances started having weird names. I eventually figured
>> out that the mock driver is auto-assigning instance names
>> based on the instances that already exist. However, it does
>> this using the string "succ" method, which means that after
>> you get to inst9, the next instance is actually insu0. Fix
>> it so that we only increment the number part of the name.
>>
>> Signed-off-by: Chris Lalancette <clalance(a)redhat.com>
>> ---
>> .../lib/deltacloud/drivers/mock/mock_driver.rb | 10 +++++++++-
>> 1 files changed, 9 insertions(+), 1 deletions(-)
>
> ACK.
Thanks, I've pushed this now.
I just noticed that that causes the client tests to fail (since they
expect a fixed instance name). Pushing this patch to fix that:
From 0517bc3032124757769e1d5712931539faa725fd Mon Sep 17 00:00:00 2001
From: David Lutterkort <lutter(a)redhat.com>
Date: Fri, 26 Feb 2010 14:54:13 -0800
Subject: [PATCH core] * client/specs/instances_spec.rb: account for changing instance
names
Fixes test breakage from 399ef311
---
client/specs/instances_spec.rb | 16 ++++++++--------
1 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/client/specs/instances_spec.rb b/client/specs/instances_spec.rb
index b088f74..d5a7816 100644
--- a/client/specs/instances_spec.rb
+++ b/client/specs/instances_spec.rb
@@ -81,8 +81,8 @@ describe "instances" do
DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
instance = client.create_instance( 'img1', :name=>'TestInstance'
)
instance.should_not be_nil
- instance.uri.should eql( API_URL + '/instances/inst3' )
- instance.id.should eql( 'inst3' )
+ instance.uri.should match( %r{#{API_URL}/instances/inst[0-9]+} )
+ instance.id.should match( /inst[0-9]+/ )
instance.name.should eql( 'TestInstance' )
instance.image.id.should eql( 'img1' )
instance.flavor.id.should eql( 'm1-large' )
@@ -94,8 +94,8 @@ describe "instances" do
DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
instance = client.create_instance( 'img1', :realm=>'eu' )
instance.should_not be_nil
- instance.uri.should eql( API_URL + '/instances/inst3' )
- instance.id.should eql( 'inst3' )
+ instance.uri.should match( %r{#{API_URL}/instances/inst[0-9]+} )
+ instance.id.should match( /inst[0-9]+/ )
instance.image.id.should eql( 'img1' )
instance.flavor.id.should eql( 'm1-large' )
instance.realm.id.should eql( 'eu' )
@@ -106,8 +106,8 @@ describe "instances" do
DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
instance = client.create_instance( 'img1', :flavor=>'m1-xlarge'
)
instance.should_not be_nil
- instance.uri.should eql( API_URL + '/instances/inst3' )
- instance.id.should eql( 'inst3' )
+ instance.uri.should match( %r{#{API_URL}/instances/inst[0-9]+} )
+ instance.id.should match( /inst[0-9]+/ )
instance.image.id.should eql( 'img1' )
instance.flavor.id.should eql( 'm1-xlarge' )
instance.realm.id.should eql( 'us' )
@@ -118,8 +118,8 @@ describe "instances" do
DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
instance = client.create_instance( 'img1', :realm=>'eu',
:flavor=>'m1-xlarge' )
instance.should_not be_nil
- instance.uri.should eql( API_URL + '/instances/inst3' )
- instance.id.should eql( 'inst3' )
+ instance.uri.should match( %r{#{API_URL}/instances/inst[0-9]+} )
+ instance.id.should match( /inst[0-9]+/ )
instance.image.id.should eql( 'img1' )
instance.flavor.id.should eql( 'm1-xlarge' )
instance.realm.id.should eql( 'eu' )
--
1.6.6.1