[PATCH aeolus 1/3] Fixed RSpec Tests
by Martyn Taylor
From: Martyn Taylor <mtaylor(a)redhat.com>
---
src/spec/controllers/api/builds_controller_spec.rb | 12 ++++++++++--
1 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/src/spec/controllers/api/builds_controller_spec.rb b/src/spec/controllers/api/builds_controller_spec.rb
index 2621e08..aa7ac91 100644
--- a/src/spec/controllers/api/builds_controller_spec.rb
+++ b/src/spec/controllers/api/builds_controller_spec.rb
@@ -43,9 +43,13 @@ describe Api::BuildsController do
:name => 'test',
:description => 'test image')
+ @target_image = mock(Aeolus::Image::Warehouse::TargetImage,
+ :uuid => "1")
+
@build = mock(Aeolus::Image::Warehouse::ImageBuild,
:uuid => '10',
- :image => @image)
+ :image => @image,
+ :target_images => [@target_image])
Aeolus::Image::Warehouse::ImageBuild.stub(:all).and_return([@build])
get :index
@@ -69,9 +73,13 @@ describe Api::BuildsController do
:name => 'test',
:description => 'test image')
+ @target_image = mock(Aeolus::Image::Warehouse::TargetImage,
+ :uuid => "1")
+
@build = mock(Aeolus::Image::Warehouse::ImageBuild,
:uuid => '10',
- :image => @image)
+ :image => @image,
+ :target_images => [@target_image])
Aeolus::Image::Warehouse::ImageBuild.stub(:find).and_return(@build)
get :show, :id => '10'
--
1.7.6.2
12 years, 6 months
[PATCH aeolus 1/3] Fixed issues with API
by Martyn Taylor
From: Martyn Taylor <mtaylor(a)redhat.com>
---
src/app/controllers/api/images_controller.rb | 1 +
src/app/views/api/builds/_build.xml.haml | 3 +++
src/app/views/api/images/_image.xml.haml | 9 ++++-----
src/app/views/api/target_images/_image.xml.haml | 2 +-
src/spec/controllers/api/builds_controller_spec.rb | 12 ++++++++++--
5 files changed, 19 insertions(+), 8 deletions(-)
diff --git a/src/app/controllers/api/images_controller.rb b/src/app/controllers/api/images_controller.rb
index 7987a3e..6c44954 100644
--- a/src/app/controllers/api/images_controller.rb
+++ b/src/app/controllers/api/images_controller.rb
@@ -28,6 +28,7 @@ module Api
def index
@images = Aeolus::Image::Warehouse::Image.all
+ # TODO This should be in aeolus-image-rubygem
@builds = {}
@images.each do |img|
@builds.merge!({img.uuid => Aeolus::Image::Warehouse::ImageBuild.find_all_by_image_uuid(img.uuid)})
diff --git a/src/app/views/api/builds/_build.xml.haml b/src/app/views/api/builds/_build.xml.haml
index c50aa78..7c53344 100644
--- a/src/app/views/api/builds/_build.xml.haml
+++ b/src/app/views/api/builds/_build.xml.haml
@@ -1,3 +1,6 @@
!!! XML
%build{:id => build.uuid, :href => api_build_url(build.uuid) }
%image{:type => 'xs:string', :href => api_image_url(build.image.uuid)}= build.image.uuid
+ %target_images
+ - build.target_images.each do |target_image|
+ %target_image{:id => target_image.uuid, :href => api_target_image_url(target_image.uuid)}
\ No newline at end of file
diff --git a/src/app/views/api/images/_image.xml.haml b/src/app/views/api/images/_image.xml.haml
index 0c0341b..df16d1d 100644
--- a/src/app/views/api/images/_image.xml.haml
+++ b/src/app/views/api/images/_image.xml.haml
@@ -2,10 +2,9 @@
%image{:id => image.uuid, :href => api_image_url(image.uuid) }
%name= image.name
%description= image.description
- - if !image.os.nil?
- %os= image.os.name
- %os_version= image.os.version
- %arch= image.os.arch
+ %os= image.os.name
+ %os_version= image.os.version
+ %arch= image.os.arch
%builds{:type => 'xs:list'}
- @builds[image.uuid].each do |bld|
- %build{:id => bld.uuid, :href => api_build_url(bld.uuid)}
+ %build{:id => bld.uuid, :href => api_build_url(bld.uuid)}
\ No newline at end of file
diff --git a/src/app/views/api/target_images/_image.xml.haml b/src/app/views/api/target_images/_image.xml.haml
index deab843..6616346 100644
--- a/src/app/views/api/target_images/_image.xml.haml
+++ b/src/app/views/api/target_images/_image.xml.haml
@@ -4,6 +4,6 @@
%object_type= image.object_type
%template= image.template
%build{:href=>api_build_url(image.build.uuid), :id=>image.build.uuid}
- %provider_images{:href => api_target_image_provider_images_url(image.uuid)}
+ %provider_images
- image.provider_images.each do |pimg|
%provider_image{:id => pimg.uuid, :href => api_provider_image_url(pimg.uuid)}
diff --git a/src/spec/controllers/api/builds_controller_spec.rb b/src/spec/controllers/api/builds_controller_spec.rb
index 2621e08..aa7ac91 100644
--- a/src/spec/controllers/api/builds_controller_spec.rb
+++ b/src/spec/controllers/api/builds_controller_spec.rb
@@ -43,9 +43,13 @@ describe Api::BuildsController do
:name => 'test',
:description => 'test image')
+ @target_image = mock(Aeolus::Image::Warehouse::TargetImage,
+ :uuid => "1")
+
@build = mock(Aeolus::Image::Warehouse::ImageBuild,
:uuid => '10',
- :image => @image)
+ :image => @image,
+ :target_images => [@target_image])
Aeolus::Image::Warehouse::ImageBuild.stub(:all).and_return([@build])
get :index
@@ -69,9 +73,13 @@ describe Api::BuildsController do
:name => 'test',
:description => 'test image')
+ @target_image = mock(Aeolus::Image::Warehouse::TargetImage,
+ :uuid => "1")
+
@build = mock(Aeolus::Image::Warehouse::ImageBuild,
:uuid => '10',
- :image => @image)
+ :image => @image,
+ :target_images => [@target_image])
Aeolus::Image::Warehouse::ImageBuild.stub(:find).and_return(@build)
get :show, :id => '10'
--
1.7.6.2
12 years, 6 months
[PATCH conductor] deleted unused failing test
by Tomas Hrcka
---
src/spec/controllers/provider_controller_spec.rb | 10 ----------
1 files changed, 0 insertions(+), 10 deletions(-)
diff --git a/src/spec/controllers/provider_controller_spec.rb b/src/spec/controllers/provider_controller_spec.rb
index 4285e0b..bcb930e 100644
--- a/src/spec/controllers/provider_controller_spec.rb
+++ b/src/spec/controllers/provider_controller_spec.rb
@@ -28,16 +28,6 @@ describe ProvidersController do
mock_warden(@admin)
end
- describe "provide ui to view hardware profiles" do
- before do
- get :edit, :id => @provider.id, :details_tab => 'hardware_profiles', :format => :js
- end
-
- it { response.should render_template(:partial => 'hardware_profiles/_list') }
- it { response.should be_success }
- it { assigns[:hardware_profiles].size.should == @provider.hardware_profiles.size }
- end
-
describe "provide ui to view realms" do
before do
get :show, :id => @provider.id, :details_tab => 'realms', :format => :js
--
1.7.6.4
12 years, 6 months
[PATCH conductor 3/5] replaced uuid with id in controllers and views
by Maros Zatko
From: Maros Zatko <mzatko(a)redhat.com>
---
src/app/controllers/api/images_controller.rb | 6 ++--
src/app/views/api/builds/_build.xml.haml | 7 +----
src/app/views/api/images/_image.xml.haml | 6 ++--
src/app/views/api/provider_images/_image.xml.haml | 4 +-
src/app/views/api/target_images/_image.xml.haml | 8 +++---
src/spec/controllers/api/builds_controller_spec.rb | 16 ++++++------
src/spec/controllers/api/images_controller_spec.rb | 10 ++++----
.../api/provider_images_controller_spec.rb | 16 ++++++------
.../api/target_images_controller_spec.rb | 24 ++++++++++----------
9 files changed, 47 insertions(+), 50 deletions(-)
diff --git a/src/app/controllers/api/images_controller.rb b/src/app/controllers/api/images_controller.rb
index 6c44954..0d7a9dc 100644
--- a/src/app/controllers/api/images_controller.rb
+++ b/src/app/controllers/api/images_controller.rb
@@ -31,7 +31,7 @@ module Api
# TODO This should be in aeolus-image-rubygem
@builds = {}
@images.each do |img|
- @builds.merge!({img.uuid => Aeolus::Image::Warehouse::ImageBuild.find_all_by_image_uuid(img.uuid)})
+ @builds.merge!({img.id => Aeolus::Image::Warehouse::ImageBuild.find_all_by_image_uuid(img.id)})
end
respond_with(@images)
end
@@ -40,7 +40,7 @@ module Api
id = params[:id]
@image = Aeolus::Image::Warehouse::Image.find(id)
if @image
- @builds = {(a)image.uuid => Aeolus::Image::Warehouse::ImageBuild.find_all_by_image_uuid(@image.uuid)}
+ @builds = {(a)image.id => Aeolus::Image::Warehouse::ImageBuild.find_all_by_image_uuid(@image.id)}
respond_with(@image)
else
render :nothing => true, :status => 404
@@ -84,4 +84,4 @@ module Api
end
end
end
-end
\ No newline at end of file
+end
diff --git a/src/app/views/api/builds/_build.xml.haml b/src/app/views/api/builds/_build.xml.haml
index 7c53344..3d68707 100644
--- a/src/app/views/api/builds/_build.xml.haml
+++ b/src/app/views/api/builds/_build.xml.haml
@@ -1,6 +1,3 @@
!!! XML
-%build{:id => build.uuid, :href => api_build_url(build.uuid) }
- %image{:type => 'xs:string', :href => api_image_url(build.image.uuid)}= build.image.uuid
- %target_images
- - build.target_images.each do |target_image|
- %target_image{:id => target_image.uuid, :href => api_target_image_url(target_image.uuid)}
\ No newline at end of file
+build{:id => build.id, :href => api_build_url(build.id) }
+ %image{:type => 'xs:string', :href => api_image_url(build.image.id)}= build.image.id
diff --git a/src/app/views/api/images/_image.xml.haml b/src/app/views/api/images/_image.xml.haml
index df16d1d..971a7b4 100644
--- a/src/app/views/api/images/_image.xml.haml
+++ b/src/app/views/api/images/_image.xml.haml
@@ -1,10 +1,10 @@
!!!XML
-%image{:id => image.uuid, :href => api_image_url(image.uuid) }
+%image{:id => image.id, :href => api_image_url(image.id) }
%name= image.name
%description= image.description
%os= image.os.name
%os_version= image.os.version
%arch= image.os.arch
%builds{:type => 'xs:list'}
- - @builds[image.uuid].each do |bld|
- %build{:id => bld.uuid, :href => api_build_url(bld.uuid)}
\ No newline at end of file
+ - @builds[image.id].each do |bld|
+ %build{:id => bld.id, :href => api_build_url(bld.id)}
diff --git a/src/app/views/api/provider_images/_image.xml.haml b/src/app/views/api/provider_images/_image.xml.haml
index ee49143..284c5fa 100644
--- a/src/app/views/api/provider_images/_image.xml.haml
+++ b/src/app/views/api/provider_images/_image.xml.haml
@@ -1,6 +1,6 @@
!!!XML
-%provider_image{:id => image.uuid, :href => api_provider_image_url(image.uuid) }
+%provider_image{:id => image.id, :href => api_provider_image_url(image.id) }
%icicle= image.icicle
%object_type= image.object_type
%target_identifier= image.target_identifier
- %target_image{:id => image.target_image.uuid, :href => api_target_image_url(image.target_image.uuid)}
+ %target_image{:id => image.target_image.id, :href => api_target_image_url(image.target_image.id)}
diff --git a/src/app/views/api/target_images/_image.xml.haml b/src/app/views/api/target_images/_image.xml.haml
index 6616346..0734855 100644
--- a/src/app/views/api/target_images/_image.xml.haml
+++ b/src/app/views/api/target_images/_image.xml.haml
@@ -1,9 +1,9 @@
!!!XML
-%target_image{:id => image.uuid, :href => api_target_image_url(image.uuid) }
+%target_image{:id => image.id, :href => api_target_image_url(image.id) }
%icicle= image.icicle
%object_type= image.object_type
%template= image.template
- %build{:href=>api_build_url(image.build.uuid), :id=>image.build.uuid}
- %provider_images
+ %build{:href=>api_build_url(image.build.id), :id=>image.build.id}
+ %provider_images{:href => api_target_image_provider_images_url(image.id)}
- image.provider_images.each do |pimg|
- %provider_image{:id => pimg.uuid, :href => api_provider_image_url(pimg.uuid)}
+ %provider_image{:id => pimg.id, :href => api_provider_image_url(pimg.id)}
diff --git a/src/spec/controllers/api/builds_controller_spec.rb b/src/spec/controllers/api/builds_controller_spec.rb
index 2621e08..de9e879 100644
--- a/src/spec/controllers/api/builds_controller_spec.rb
+++ b/src/spec/controllers/api/builds_controller_spec.rb
@@ -38,13 +38,13 @@ describe Api::BuildsController do
before do
@os = mock(:OS, :name => 'fedora', :version => '15', :arch => 'x86_64')
@image = mock(Aeolus::Image::Warehouse::Image,
- :uuid => '5',
+ :id => '5',
:os => @os,
:name => 'test',
:description => 'test image')
@build = mock(Aeolus::Image::Warehouse::ImageBuild,
- :uuid => '10',
+ :id => '10',
:image => @image)
Aeolus::Image::Warehouse::ImageBuild.stub(:all).and_return([@build])
@@ -55,8 +55,8 @@ describe Api::BuildsController do
it { response.headers['Content-Type'].should include("application/xml") }
it {
resp = Hash.from_xml(response.body)
- resp['builds']['build']['id'].should == @build.uuid
- resp['builds']['build']['image'].should == @image.uuid
+ resp['builds']['build']['id'].should == @build.id
+ resp['builds']['build']['image'].should == @image.id
}
end
@@ -64,13 +64,13 @@ describe Api::BuildsController do
before do
@os = mock(:OS, :name => 'fedora', :version => '15', :arch => 'x86_64')
@image = mock(Aeolus::Image::Warehouse::Image,
- :uuid => '5',
+ :id => '5',
:os => @os,
:name => 'test',
:description => 'test image')
@build = mock(Aeolus::Image::Warehouse::ImageBuild,
- :uuid => '10',
+ :id => '10',
:image => @image)
Aeolus::Image::Warehouse::ImageBuild.stub(:find).and_return(@build)
@@ -81,8 +81,8 @@ describe Api::BuildsController do
it { response.headers['Content-Type'].should include("application/xml") }
it {
resp = Hash.from_xml(response.body)
- resp['build']['id'].should == @build.uuid
- resp['build']['image'].should == @image.uuid
+ resp['build']['id'].should == @build.id
+ resp['build']['image'].should == @image.id
}
end
end
diff --git a/src/spec/controllers/api/images_controller_spec.rb b/src/spec/controllers/api/images_controller_spec.rb
index 99e08fc..edd5e98 100644
--- a/src/spec/controllers/api/images_controller_spec.rb
+++ b/src/spec/controllers/api/images_controller_spec.rb
@@ -38,7 +38,7 @@ describe Api::ImagesController do
before do
@os = mock(:OS, :name => 'fedora', :version => '15', :arch => 'x86_64')
@image = mock(Aeolus::Image::Warehouse::Image,
- :uuid => '5',
+ :id => '5',
:os => @os,
:name => 'test',
:description => 'test image')
@@ -53,7 +53,7 @@ describe Api::ImagesController do
it {
resp = Hash.from_xml(response.body)
resp['images']['image']['name'].should == @image.name
- resp['images']['image']['id'].should == @image.uuid
+ resp['images']['image']['id'].should == @image.id
resp['images']['image']['os'].should == @image.os.name
resp['images']['image']['arch'].should == @image.os.arch
resp['images']['image']['os_version'].should == @image.os.version
@@ -65,12 +65,12 @@ describe Api::ImagesController do
before do
@os = mock(:OS, :name => 'fedora', :version => '15', :arch => 'x86_64')
@image = mock(Aeolus::Image::Warehouse::Image,
- :uuid => '5',
+ :id => '5',
:os => @os,
:name => 'test',
:description => 'test image')
Aeolus::Image::Warehouse::Image.stub(:find).and_return(@image)
- Aeolus::Image::Warehouse::ImageBuild.stub(:find_all_by_image_uuid).and_return([])
+ Aeolus::Image::Warehouse::ImageBuild.stub(:find_all_by_image_id).and_return([])
get :show, :id => '5'
end
@@ -79,7 +79,7 @@ describe Api::ImagesController do
it {
resp = Hash.from_xml(response.body)
resp['image']['name'].should == @image.name
- resp['image']['id'].should == @image.uuid
+ resp['image']['id'].should == @image.id
resp['image']['os'].should == @image.os.name
resp['image']['arch'].should == @image.os.arch
resp['image']['os_version'].should == @image.os.version
diff --git a/src/spec/controllers/api/provider_images_controller_spec.rb b/src/spec/controllers/api/provider_images_controller_spec.rb
index 75e4f0f..4162d78 100644
--- a/src/spec/controllers/api/provider_images_controller_spec.rb
+++ b/src/spec/controllers/api/provider_images_controller_spec.rb
@@ -37,9 +37,9 @@ describe Api::ProviderImagesController do
describe "#index" do
before do
@timage = mock(Aeolus::Image::Warehouse::TargetImage,
- :uuid => '300')
+ :id => '300')
@pimage = mock(Aeolus::Image::Warehouse::ProviderImage,
- :uuid => '17',
+ :id => '17',
:icicle => '30',
:object_type => 'provider_image',
:target_identifier => '80',
@@ -53,20 +53,20 @@ describe Api::ProviderImagesController do
it { response.headers['Content-Type'].should include("application/xml") }
it {
resp = Hash.from_xml(response.body)
- resp['provider_images']['provider_image']['id'].should == @pimage.uuid
+ resp['provider_images']['provider_image']['id'].should == @pimage.id
resp['provider_images']['provider_image']['icicle'].should == @pimage.icicle
resp['provider_images']['provider_image']['object_type'].should == @pimage.object_type
resp['provider_images']['provider_image']['target_identifier'].should == @pimage.target_identifier
- resp['provider_images']['provider_image']['target_image']['id'].should == @pimage.target_image.uuid
+ resp['provider_images']['provider_image']['target_image']['id'].should == @pimage.target_image.id
}
end
describe "#show" do
before do
@timage = mock(Aeolus::Image::Warehouse::TargetImage,
- :uuid => '300')
+ :id => '300')
@pimage = mock(Aeolus::Image::Warehouse::ProviderImage,
- :uuid => '17',
+ :id => '17',
:icicle => '30',
:object_type => 'provider_image',
:target_identifier => '80',
@@ -80,11 +80,11 @@ describe Api::ProviderImagesController do
it { response.headers['Content-Type'].should include("application/xml") }
it {
resp = Hash.from_xml(response.body)
- resp['provider_image']['id'].should == @pimage.uuid
+ resp['provider_image']['id'].should == @pimage.id
resp['provider_image']['icicle'].should == @pimage.icicle
resp['provider_image']['object_type'].should == @pimage.object_type
resp['provider_image']['target_identifier'].should == @pimage.target_identifier
- resp['provider_image']['target_image']['id'].should == @pimage.target_image.uuid
+ resp['provider_image']['target_image']['id'].should == @pimage.target_image.id
}
end
end
diff --git a/src/spec/controllers/api/target_images_controller_spec.rb b/src/spec/controllers/api/target_images_controller_spec.rb
index 3a98dad..451786f 100644
--- a/src/spec/controllers/api/target_images_controller_spec.rb
+++ b/src/spec/controllers/api/target_images_controller_spec.rb
@@ -37,11 +37,11 @@ describe Api::TargetImagesController do
describe "#index" do
before do
@pimage = mock(Aeolus::Image::Warehouse::ProviderImage,
- :uuid => '42')
+ :id => '42')
@build = mock(Aeolus::Image::Warehouse::ImageBuild,
- :uuid => '543')
+ :id => '543')
@timage = mock(Aeolus::Image::Warehouse::TargetImage,
- :uuid => '100',
+ :id => '100',
:icicle => '321',
:object_type => 'target_image',
:template => '12',
@@ -56,24 +56,24 @@ describe Api::TargetImagesController do
it { response.headers['Content-Type'].should include("application/xml") }
it {
resp = Hash.from_xml(response.body)
- resp['target_images']['target_image']['id'].should == @timage.uuid
+ resp['target_images']['target_image']['id'].should == @timage.id
resp['target_images']['target_image']['icicle'].should == @timage.icicle
resp['target_images']['target_image']['object_type'].should == @timage.object_type
resp['target_images']['target_image']['template'].should == @timage.template
- resp['target_images']['target_image']['build']['id'].should == @timage.build.uuid
+ resp['target_images']['target_image']['build']['id'].should == @timage.build.id
pimgs = resp['target_images']['target_image']['provider_images']
- pimgs['provider_image']['id'].should == @pimage.uuid
+ pimgs['provider_image']['id'].should == @pimage.id
}
end
describe "#show" do
before do
@pimage = mock(Aeolus::Image::Warehouse::ProviderImage,
- :uuid => '42')
+ :id => '42')
@build = mock(Aeolus::Image::Warehouse::ImageBuild,
- :uuid => '543')
+ :id => '543')
@timage = mock(Aeolus::Image::Warehouse::TargetImage,
- :uuid => '100',
+ :id => '100',
:icicle => '321',
:object_type => 'target_image',
:template => '12',
@@ -88,13 +88,13 @@ describe Api::TargetImagesController do
it { response.headers['Content-Type'].should include("application/xml") }
it {
resp = Hash.from_xml(response.body)
- resp['target_image']['id'].should == @timage.uuid
+ resp['target_image']['id'].should == @timage.id
resp['target_image']['icicle'].should == @timage.icicle
resp['target_image']['object_type'].should == @timage.object_type
resp['target_image']['template'].should == @timage.template
- resp['target_image']['build']['id'].should == @timage.build.uuid
+ resp['target_image']['build']['id'].should == @timage.build.id
pimgs = resp['target_image']['provider_images']
- pimgs['provider_image']['id'].should == @pimage.uuid
+ pimgs['provider_image']['id'].should == @pimage.id
}
end
end
--
1.7.6.2
12 years, 7 months
[PATCH conductor] BZ#743695 Run state not listed for Deployment grid summary
by Chris Alfonso
This patch adds a new column to the grid view of the Deployments monitor page.
The new column is 'state', you may be wondering what 'state' references when state
is an instance attribute. The deployment state represents a 'rolled up' state. If
all the instances are of the same state, that state will be shown here. If there is a
difference between the deployment's instances state, the state will show as 'mixed'.
12 years, 7 months
[PATCH conductor] some rspec tests fixed
by Tomas Hrcka
---
.../provider_accounts_controller_spec.rb | 31 ++++++++++------
src/spec/models/deployment_spec.rb | 39 ++++++++++++--------
2 files changed, 43 insertions(+), 27 deletions(-)
diff --git a/src/spec/controllers/provider_accounts_controller_spec.rb b/src/spec/controllers/provider_accounts_controller_spec.rb
index 4406a83..aeaf9ab 100644
--- a/src/spec/controllers/provider_accounts_controller_spec.rb
+++ b/src/spec/controllers/provider_accounts_controller_spec.rb
@@ -60,29 +60,38 @@ describe ProviderAccountsController do
@provider_account.quota = Quota.new
@provider_account.save.should be_true
post :update, :id => @provider_account.id, :provider_account => { :credentials_hash => {:username => 'mockuser', :password => 'mockpassword'} }
- response.should redirect_to provider_account_path(@provider_account)
+ response.should redirect_to edit_provider_path((a)provider_account.provider_id, :details_tab => 'connectivity', :view => 'filter')
ProviderAccount.find((a)provider_account.id).credentials_hash['password'].should == "mockpassword"
end
it "should allow users with account modify permission to delete a cloud account" do
mock_warden(@admin)
lambda do
- post :multi_destroy, :accounts_selected => [@provider_account.id]
+ post :multi_destroy, :provider_id => @provider_account.provider_id, :accounts_selected => [@provider_account.id]
end.should change(ProviderAccount, :count).by(-1)
- response.should redirect_to provider_accounts_url
+ response.should redirect_to edit_provider_path((a)provider_account.provider_id, :details_tab => 'connectivity', :view => 'filter')
ProviderAccount.find_by_id((a)provider_account.id).should be_nil
end
- it "should deny access to users without account modify permission" do
- mock_warden(@tuser)
- get :edit, :id => @provider_account.id
- response.should render_template('layouts/error')
+ describe "should deny access to users without account modify permission" do
+ before do
+ mock_warden(@tuser)
+ end
- post :update, :id => @provider_account.id, :provider_account => { :password => 'foobar' }
- response.should render_template('layouts/error')
+ it "for edit" do
+ get :edit, :provider_id => @provider_account.provider_id, :id => @provider_account.id
+ response.should render_template('layouts/error')
+ end
- post :destroy, :id => @provider_account.id
- response.should render_template('layouts/error')
+ it "for update" do
+ post :update, :id => @provider_account.id, :provider_account => { :password => 'foobar' }
+ response.should render_template('layouts/error')
+ end
+
+ it "for destroy" do
+ post :destroy, :id => @provider_account.id
+ response.should render_template('layouts/error')
+ end
end
it "should provide ui to create new account" do
diff --git a/src/spec/models/deployment_spec.rb b/src/spec/models/deployment_spec.rb
index ee34043..80ca27d 100644
--- a/src/spec/models/deployment_spec.rb
+++ b/src/spec/models/deployment_spec.rb
@@ -82,13 +82,6 @@ describe Deployment do
@deployment.get_action_list.should eql(["start", "stop", "reboot"])
end
- it "should launch instances when launching deployment" do
- @deployment.save!
- @deployment.instances.should be_empty
- @deployment.stub!(:condormatic_instance_create).and_return(true)
- @deployment.launch(FactoryGirl.create(:user))[:errors].should be_empty
- @deployment.instances.count.should == 2
- end
it "should return properties hash" do
@deployment.properties.should be_a_kind_of(Hash)
@@ -112,16 +105,30 @@ describe Deployment do
@deployment.should be_destroyable
expect { @deployment.destroy }.to change(Deployment, :count).by(-1)
end
+ describe "using image from iwhd" do
+ before do
+ image_id = @deployment.deployable_xml.assemblies.first.image_id
+ provider_name = Image.find(image_id).latest_build.provider_images.first.provider_name
+ provider = FactoryGirl.create(:mock_provider, :name => provider_name)
+ @deployment.pool.pool_family.provider_accounts = [FactoryGirl.create(:mock_provider_account, :label => 'testaccount', :provider => provider)]
+ @user_for_launch = FactoryGirl.create(:user)
+ end
+
+ it "should return errors when checking assemblies matches which are not launchable" do
+ @deployment.check_assemblies_matches((a)user_for_launch).should be_empty
+ @deployment.pool.pool_family.provider_accounts.destroy_all
+ @deployment.check_assemblies_matches((a)user_for_launch).should_not be_empty
+ end
+
+ it "should launch instances when launching deployment" do
+ @deployment.save!
+ @deployment.instances.should be_empty
+
+ Taskomatic.stub!(:create_instance).and_return(true)
+ @deployment.launch(@user_for_launch)[:errors].should be_empty
+ @deployment.instances.count.should == 2
+ end
- it "should return errors when checking assemblies matches which are not launchable" do
- user = FactoryGirl.create(:user)
- image_id = @deployment.deployable_xml.assemblies.first.image_id
- provider_name = Image.find(image_id).latest_build.provider_images.first.provider_name
- provider = FactoryGirl.create(:mock_provider, :name => provider_name)
- @deployment.pool.pool_family.provider_accounts = [FactoryGirl.create(:mock_provider_account, :label => 'testaccount', :provider => provider)]
- @deployment.check_assemblies_matches(user).should be_empty
- @deployment.pool.pool_family.provider_accounts.destroy_all
- @deployment.check_assemblies_matches(user).should_not be_empty
end
it "should be able to stop running instances on deletion" do
--
1.7.6.4
12 years, 7 months
[PATCH conductor] Stop instances when a provider is disabled
by Jan Provazník
From: Jan Provaznik <jprovazn(a)redhat.com>
https://www.aeolusproject.org/redmine/issues/2438
---
src/app/controllers/providers_controller.rb | 8 +++++++
src/app/models/instance.rb | 1 +
src/app/models/provider.rb | 24 +++++++++++++++++++++++
src/features/provider.feature | 9 ++++++++
src/features/step_definitions/provider_steps.rb | 7 ++++++
src/spec/models/provider_spec.rb | 10 +++++++++
6 files changed, 59 insertions(+), 0 deletions(-)
diff --git a/src/app/controllers/providers_controller.rb b/src/app/controllers/providers_controller.rb
index 9f8e466..74cc794 100644
--- a/src/app/controllers/providers_controller.rb
+++ b/src/app/controllers/providers_controller.rb
@@ -111,7 +111,15 @@ class ProvidersController < ApplicationController
def update
@provider = Provider.find_by_id(params[:id])
require_privilege(Privilege::MODIFY, @provider)
+ old_enabled = @provider.enabled
@provider.update_attributes(params[:provider])
+ # stop running instances when a provider is disabled
+ # it would be better to have this in provider's observer
+ # but we need to display error message when an error occurs
+ if old_enabled and not @provider.enabled
+ errs = @provider.stop_instances(current_user)
+ flash[:error] = errs unless errs.empty?
+ end
if !(a)provider.connect
flash.now[:warning] = "Failed to connect to Provider"
load_provider_tabs
diff --git a/src/app/models/instance.rb b/src/app/models/instance.rb
index e6bb17a..5f0d49a 100644
--- a/src/app/models/instance.rb
+++ b/src/app/models/instance.rb
@@ -107,6 +107,7 @@ class Instance < ActiveRecord::Base
scope :pending, :conditions => { :state => [STATE_NEW, STATE_PENDING] }
# FIXME: "failed" is misleading too...
scope :failed, :conditions => { :state => [STATE_CREATE_FAILED, STATE_ERROR] }
+ scope :stopable, :conditions => { :state => [STATE_NEW, STATE_PENDING, STATE_RUNNING] }
SEARCHABLE_COLUMNS = %w(name state)
diff --git a/src/app/models/provider.rb b/src/app/models/provider.rb
index bfb838c..30cbee2 100644
--- a/src/app/models/provider.rb
+++ b/src/app/models/provider.rb
@@ -114,6 +114,30 @@ class Provider < ActiveRecord::Base
(frontend_realms + realms.map {|r| r.frontend_realms}.flatten).uniq
end
+ def stop_instances(user)
+ errs = []
+ provider_accounts.each do |pa|
+ pa.instances.stopable.each do |instance|
+ begin
+ unless instance.valid_action?('stop')
+ raise "stop is an invalid action."
+ end
+
+ unless @task = instance.queue_action(user, 'stop')
+ raise "stop cannot be performed on this instance."
+ end
+ Taskomatic.stop_instance(@task)
+ rescue Exception => e
+ err = "Error while stopping an instance #{instance.name}: #{e.message}"
+ errs << err
+ logger.error err
+ logger.error e.backtrace.join("\n ")
+ end
+ end
+ end
+ errs
+ end
+
protected
def validate_provider
if !nil_or_empty(url)
diff --git a/src/features/provider.feature b/src/features/provider.feature
index 5b43e6c..03f835a 100644
--- a/src/features/provider.feature
+++ b/src/features/provider.feature
@@ -83,6 +83,15 @@ Feature: Manage Providers
And there should not be a provider account
And there should not be a realm
+ Scenario: Disable a provider
+ Given there is a provider named "provider1"
+ And this provider has a provider account with 2 running instances
+ When I go to the provider1's edit provider page
+ And I press "provider_submit"
+ Then I should be on the provider1's edit provider page
+ And I should see "Provider is disabled."
+ And I should not see "Error while stopping an instance"
+
# Scenario: Search for hardware profiles
# Given there are these providers:
# | name | url |
diff --git a/src/features/step_definitions/provider_steps.rb b/src/features/step_definitions/provider_steps.rb
index f035997..377e0d4 100644
--- a/src/features/step_definitions/provider_steps.rb
+++ b/src/features/step_definitions/provider_steps.rb
@@ -91,3 +91,10 @@ Then /^there should be these provider:$/ do |table|
p[:provider_type].should == hash[:provider_type]
end
end
+
+Given /^this provider has a provider account with (\d+) running instances$/ do |arg1|
+ pa = FactoryGirl.create(:mock_provider_account, :provider => @provider)
+ arg1.to_i.times do |i|
+ FactoryGirl.create(:instance, :provider_account => pa, :state => 'running')
+ end
+end
diff --git a/src/spec/models/provider_spec.rb b/src/spec/models/provider_spec.rb
index 30e385c..8c593c7 100644
--- a/src/spec/models/provider_spec.rb
+++ b/src/spec/models/provider_spec.rb
@@ -116,6 +116,16 @@ describe Provider do
provider1.frontend_realms.reload
provider1.all_associated_frontend_realms.count.should == 1
end
+
+ it "should stop all associated instances" do
+ provider1 = Factory.create(:mock_provider)
+ pa = FactoryGirl.create(:mock_provider_account, :provider => provider1)
+ inst1 = FactoryGirl.create(:instance, :provider_account => pa)
+ inst2 = FactoryGirl.create(:instance, :provider_account => pa)
+ errs = provider1.stop_instances(nil)
+ errs.should be_empty
+ end
+
end
context "(using original connect method)" do
--
1.7.6
12 years, 7 months
Let's switch to GitHub
by Matt Wagner
Hi all,
I'd like to propose that we move Conductor and aeolus-configure over to
GitHub. (Bear with me for one second, please.)
"But wait," you're thinking. "Didn't we just have that discussion the
other week?" Not like this.
What I'd like to propose is that we keep our workflow exactly the same
as it is today, but move the repository from FedoraHosted to GitHub.
We'll still send patches to the list, have someone test them and send an
ACK to the list, and then push the code. It'll just be to the git repo
on GitHub instead of the repo on FedoraHosted.
Why do this? Two reasons, really:
a.) Most of the other Aeolus projects are already on GitHub. This way,
everything will be in one place.
b.) GitHub is a lot more widely-known than FedoraHosted. If we link
people in the community to the GitHub page for Conductor, most will
instinctively know how to clone the source and how to start
contributing. As it is today, I have to cat .git/config to have any idea
where our repo lives.
I think that we should probably do this at the end of this sprint before
starting the next one, since I imagine moving it mid-sprint would be too
disruptive. Does anyone object to this change?
I think the change will look something like this:
1.) Create the Conductor and aeolus-configure repos on GitHub, and give
existing developers commit rights there
2.) Change our .git/config files to point there
3.) Update the aeolusproject.org site which has documentation pointing
to the FH repos
4.) Update Redmine's repo browser to use the new location
5.) Modify Jenkins to use the GitHub repo
6.) Send out an email explaining the change and telling everyone what
they need to do
7.) Add a logo to the main Aeolus Project organization to replace the
default octocat
Again, I'm happy to take the lead on making this happen, but I want to
make sure there's consensus. (Plus, I don't have rights to the project
right now.)
What do you think?
Best,
Matt
12 years, 7 months