You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltacloud.apache.org by mf...@redhat.com on 2012/07/26 14:21:20 UTC
[PATCH core 1/2] Core: Added tests for instances and hwp collections
From: Michal Fojtik <mf...@redhat.com>
Signed-off-by: Michal fojtik <mf...@redhat.com>
---
.../hardware_profiles_collection_test.rb | 51 +++++++++++++++++
.../deltacloud/collections/keys_collection_test.rb | 60 ++++++++++++++++++++
2 files changed, 111 insertions(+)
create mode 100644 server/tests/deltacloud/collections/hardware_profiles_collection_test.rb
create mode 100644 server/tests/deltacloud/collections/keys_collection_test.rb
diff --git a/server/tests/deltacloud/collections/hardware_profiles_collection_test.rb b/server/tests/deltacloud/collections/hardware_profiles_collection_test.rb
new file mode 100644
index 0000000..6ba449a
--- /dev/null
+++ b/server/tests/deltacloud/collections/hardware_profiles_collection_test.rb
@@ -0,0 +1,51 @@
+require 'minitest/autorun'
+require_relative File.join('..', 'common.rb')
+
+describe Deltacloud::Collections::HardwareProfiles do
+
+ before do
+ def app; Deltacloud::API; end
+ authorize 'mockuser', 'mockpassword'
+ @collection = Deltacloud::Collections.collection(:hardware_profiles)
+ end
+
+ it 'has index operation' do
+ @collection.operation(:index).must_equal Sinatra::Rabbit::HardwareProfilesCollection::IndexOperation
+ end
+
+ it 'has show operation' do
+ @collection.operation(:show).must_equal Sinatra::Rabbit::HardwareProfilesCollection::ShowOperation
+ end
+
+ it 'returns list of hardware profiles in various formats with index operation' do
+ formats.each do |format|
+ header 'Accept', format
+ get root_url + '/hardware_profiles'
+ status.must_equal 200
+ end
+ end
+
+ it 'returns details about hardware profile in various formats with show operation' do
+ formats.each do |format|
+ header 'Accept', format
+ get root_url + '/hardware_profiles/m1-small'
+ status.must_equal 200
+ end
+ end
+
+ it 'returns details for various hardware profile configurations' do
+ get root_url + '/hardware_profiles'
+ status.must_equal 200
+ (xml/'hardware_profiles/hardware_profile').each do |hwp|
+ get root_url + '/hardware_profiles/' + hwp[:id]
+ status.must_equal 200
+ xml.root[:id].must_equal hwp[:id]
+ end
+ end
+
+ it 'reports 404 when querying non-existing hardware profile' do
+ get root_url + '/hardware_profiles/unknown'
+ status.must_equal 404
+ end
+
+end
diff --git a/server/tests/deltacloud/collections/keys_collection_test.rb b/server/tests/deltacloud/collections/keys_collection_test.rb
new file mode 100644
index 0000000..26b58c4
--- /dev/null
+++ b/server/tests/deltacloud/collections/keys_collection_test.rb
@@ -0,0 +1,60 @@
+require 'minitest/autorun'
+require_relative File.join('..', 'common.rb')
+
+describe Deltacloud::Collections::Keys do
+
+ before do
+ def app; Deltacloud::API; end
+ authorize 'mockuser', 'mockpassword'
+ @collection = Deltacloud::Collections.collection(:keys)
+ end
+
+ it 'has index operation' do
+ @collection.operation(:index).must_equal Sinatra::Rabbit::KeysCollection::IndexOperation
+ end
+
+ it 'has show operation' do
+ @collection.operation(:show).must_equal Sinatra::Rabbit::KeysCollection::ShowOperation
+ end
+
+ it 'returns list of keys in various formats with index operation' do
+ formats.each do |format|
+ header 'Accept', format
+ get root_url + '/keys'
+ status.must_equal 200
+ end
+ end
+
+ it 'returns details about key in various formats with show operation' do
+ formats.each do |format|
+ header 'Accept', format
+ get root_url + '/keys/test-key'
+ status.must_equal 200
+ end
+ end
+
+ it 'provides URL to create new key' do
+ header 'Accept', 'text/html'
+ get root_url + '/keys/new'
+ status.must_equal 200
+ response_body.must_include 'Create new SSH key'
+ end
+
+ it 'must support creating and destroying keys' do
+ post root_url + '/keys', { :name => 'unit-test1' }
+ status.must_equal 201
+ xml.root.name.must_equal 'key'
+ xml.root[:id].must_equal 'unit-test1'
+ (xml/'key/pem').wont_be_empty
+ post root_url + '/keys', { :name => 'unit-test1' }
+ status.must_equal 403
+ delete root_url + '/keys/unit-test1'
+ status.must_equal 204
+ end
+
+ it 'reports 404 when querying non-existing key' do
+ get root_url + '/keys/unknown'
+ status.must_equal 404
+ end
+
+end
--
1.7.10.2
Re: [PATCH core 2/2] Core: Fixed typos in collection test names
Posted by David Lutterkort <lu...@redhat.com>.
On Thu, 2012-07-26 at 14:21 +0200, mfojtik@redhat.com wrote:
> From: Michal Fojtik <mf...@redhat.com>
>
>
> Signed-off-by: Michal fojtik <mf...@redhat.com>
> ---
> .../collections/images_collection_test.rb | 4 +--
> .../collections/instances_collection_test.rb | 38 ++++++++++++++++++++
> 2 files changed, 40 insertions(+), 2 deletions(-)
ACK
David
[PATCH core 2/2] Core: Fixed typos in collection test names
Posted by mf...@redhat.com.
From: Michal Fojtik <mf...@redhat.com>
Signed-off-by: Michal fojtik <mf...@redhat.com>
---
.../collections/images_collection_test.rb | 4 +--
.../collections/instances_collection_test.rb | 38 ++++++++++++++++++++
2 files changed, 40 insertions(+), 2 deletions(-)
diff --git a/server/tests/deltacloud/collections/images_collection_test.rb b/server/tests/deltacloud/collections/images_collection_test.rb
index de105c9..b57eba3 100644
--- a/server/tests/deltacloud/collections/images_collection_test.rb
+++ b/server/tests/deltacloud/collections/images_collection_test.rb
@@ -17,7 +17,7 @@ describe Deltacloud::Collections::Images do
@collection.operation(:show).must_equal Sinatra::Rabbit::ImagesCollection::ShowOperation
end
- it 'returns list of drivers in various formats with index operation' do
+ it 'returns list of images in various formats with index operation' do
formats.each do |format|
header 'Accept', format
get root_url + '/images'
@@ -25,7 +25,7 @@ describe Deltacloud::Collections::Images do
end
end
- it 'returns details about driver in various formats with show operation' do
+ it 'returns details about image in various formats with show operation' do
formats.each do |format|
header 'Accept', format
get root_url + '/images/img1'
diff --git a/server/tests/deltacloud/collections/instances_collection_test.rb b/server/tests/deltacloud/collections/instances_collection_test.rb
index abaf571..d4c0c97 100644
--- a/server/tests/deltacloud/collections/instances_collection_test.rb
+++ b/server/tests/deltacloud/collections/instances_collection_test.rb
@@ -19,5 +19,43 @@ describe Deltacloud::Collections::Instances do
status.must_equal 200
end
+ it 'returns list of instances in various formats with index operation' do
+ formats.each do |format|
+ header 'Accept', format
+ get root_url + '/instances'
+ status.must_equal 200
+ end
+ end
+
+ it 'returns details about instance in various formats with show operation' do
+ formats.each do |format|
+ header 'Accept', format
+ get root_url + '/instances/inst1'
+ status.must_equal 200
+ end
+ end
+
+ it 'allow to create and execute actions on created instance' do
+ post root_url + '/instances', { :image_id => 'img1', :name => 'test', }
+ status.must_equal 201
+ instance_id = xml.root[:id]
+ instance_id.wont_be_nil
+ delete root_url + '/instances/' + instance_id
+ status.must_equal 405
+ # You can't remove RUNNING instance
+ (xml/'error/message').first.text.strip.must_equal 'Requested method not allowed'
+ post root_url + '/instances/' + instance_id + '/reboot'
+ status.must_equal 202
+ post root_url + '/instances/' + instance_id + '/stop'
+ status.must_equal 202
+ post root_url + '/instances/' + instance_id + '/start'
+ status.must_equal 202
+ post root_url + '/instances/' + instance_id + '/stop'
+ status.must_equal 202
+ (xml/'instance/state').first.text.strip.must_equal 'STOPPED'
+ delete root_url + '/instances/' + instance_id
+ status.must_equal 204
+ end
+
end
--
1.7.10.2
Re: [PATCH core 1/2] Core: Added tests for instances and hwp
collections
Posted by David Lutterkort <lu...@redhat.com>.
On Thu, 2012-07-26 at 15:44 -0700, David Lutterkort wrote:
> On Thu, 2012-07-26 at 14:21 +0200, mfojtik@redhat.com wrote:
> > From: Michal Fojtik <mf...@redhat.com>
> >
> >
> > Signed-off-by: Michal fojtik <mf...@redhat.com>
> > ---
> > .../hardware_profiles_collection_test.rb | 51 +++++++++++++++++
> > .../deltacloud/collections/keys_collection_test.rb | 60 ++++++++++++++++++++
> > 2 files changed, 111 insertions(+)
> > create mode 100644 server/tests/deltacloud/collections/hardware_profiles_collection_test.rb
> > create mode 100644 server/tests/deltacloud/collections/keys_collection_test.rb
> >
> > diff --git a/server/tests/deltacloud/collections/hardware_profiles_collection_test.rb b/server/tests/deltacloud/collections/hardware_profiles_collection_test.rb
> > new file mode 100644
> > index 0000000..6ba449a
> > --- /dev/null
> > +++ b/server/tests/deltacloud/collections/hardware_profiles_collection_test.rb
> > @@ -0,0 +1,51 @@
> > +require 'minitest/autorun'
> > +require_relative File.join('..', 'common.rb')
>
> This fails on 1.8.7 - after applying my other patch series, put a
> "require 'require_relative'" in there and this gets my ACK.
Forgot to mention: the reason this is important is so that you can run
'bundle exec
ruby ./tests/deltacloud/collections/hardware_profiles_collection_test.rb' and the comment applies to a lot of the other test files.
David
Re: [PATCH core 1/2] Core: Added tests for instances and hwp
collections
Posted by David Lutterkort <lu...@redhat.com>.
On Thu, 2012-07-26 at 14:21 +0200, mfojtik@redhat.com wrote:
> From: Michal Fojtik <mf...@redhat.com>
>
>
> Signed-off-by: Michal fojtik <mf...@redhat.com>
> ---
> .../hardware_profiles_collection_test.rb | 51 +++++++++++++++++
> .../deltacloud/collections/keys_collection_test.rb | 60 ++++++++++++++++++++
> 2 files changed, 111 insertions(+)
> create mode 100644 server/tests/deltacloud/collections/hardware_profiles_collection_test.rb
> create mode 100644 server/tests/deltacloud/collections/keys_collection_test.rb
>
> diff --git a/server/tests/deltacloud/collections/hardware_profiles_collection_test.rb b/server/tests/deltacloud/collections/hardware_profiles_collection_test.rb
> new file mode 100644
> index 0000000..6ba449a
> --- /dev/null
> +++ b/server/tests/deltacloud/collections/hardware_profiles_collection_test.rb
> @@ -0,0 +1,51 @@
> +require 'minitest/autorun'
> +require_relative File.join('..', 'common.rb')
This fails on 1.8.7 - after applying my other patch series, put a
"require 'require_relative'" in there and this gets my ACK.
David