Return-Path: X-Original-To: apmail-incubator-deltacloud-dev-archive@minotaur.apache.org Delivered-To: apmail-incubator-deltacloud-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id E42837916 for ; Thu, 17 Nov 2011 18:48:10 +0000 (UTC) Received: (qmail 96330 invoked by uid 500); 17 Nov 2011 18:48:10 -0000 Delivered-To: apmail-incubator-deltacloud-dev-archive@incubator.apache.org Received: (qmail 96317 invoked by uid 500); 17 Nov 2011 18:48:10 -0000 Mailing-List: contact deltacloud-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: deltacloud-dev@incubator.apache.org Delivered-To: mailing list deltacloud-dev@incubator.apache.org Received: (qmail 96308 invoked by uid 99); 17 Nov 2011 18:48:10 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 17 Nov 2011 18:48:10 +0000 X-ASF-Spam-Status: No, hits=-5.0 required=5.0 tests=RCVD_IN_DNSWL_HI,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of mfojtik@redhat.com designates 209.132.183.28 as permitted sender) Received: from [209.132.183.28] (HELO mx1.redhat.com) (209.132.183.28) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 17 Nov 2011 18:48:05 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id pAHIlhoC014610 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 17 Nov 2011 13:47:43 -0500 Received: from [10.36.5.157] (vpn1-5-157.ams2.redhat.com [10.36.5.157]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id pAHIlgii027424 for ; Thu, 17 Nov 2011 13:47:42 -0500 Message-ID: <4EC556CA.9070606@redhat.com> Date: Thu, 17 Nov 2011 19:47:38 +0100 From: Michal Fojtik User-Agent: Postbox 3.0.0 (Macintosh/20111031) MIME-Version: 1.0 To: deltacloud-dev@incubator.apache.org Subject: Re: [PATCH core 4/4] CIMI: Revampled spec files once again to use the helpers for checking sanity of serialization References: <1321475673-14645-1-git-send-email-mfojtik@redhat.com> <1321475673-14645-5-git-send-email-mfojtik@redhat.com> <4EC4E650.30800@redhat.com> In-Reply-To: <4EC4E650.30800@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 Thanks! Fixed MachineConfig data to match with latest WIP and pushed. -- Michal marios@redhat.com wrote: > ACK > > On 16/11/11 22:34, mfojtik@redhat.com wrote: >> From: Michal Fojtik >> >> --- >> .../spec/cimi/model/machine_configuration_spec.rb | 99 ++------------ >> server/spec/cimi/model/machine_image_spec.rb | 82 +---------- >> server/spec/cimi/model/machine_template_spec.rb | 152 +------------------ >> 3 files changed, 25 insertions(+), 308 deletions(-) >> >> diff --git a/server/spec/cimi/model/machine_configuration_spec.rb b/server/spec/cimi/model/machine_configuration_spec.rb >> index d60286e..454e8c4 100644 >> --- a/server/spec/cimi/model/machine_configuration_spec.rb >> +++ b/server/spec/cimi/model/machine_configuration_spec.rb >> @@ -20,97 +20,16 @@ describe "MachineConfiguration model" do >> @json = IO::read(File::join(DATA_DIR, "machine_configuration.json")) >> end >> >> - describe 'XML' do >> - it "can be constructed" do >> - conf = CIMI::Model::MachineConfiguration.from_xml(@xml) >> - conf.should_not be_nil >> - conf.should serialize_to @xml, :fmt => :xml >> - end >> - >> - it "should convert strings in keys to symbols when contructed from XML" do >> - conf = CIMI::Model::MachineConfiguration.from_xml(@xml) >> - conf.should_not be_nil >> - conf.attribute_values.keys.each { |key| key.should be_a(Symbol) } >> - end >> - >> - it "should have default properties" do >> - conf = CIMI::Model::MachineConfiguration.from_xml(@xml) >> - conf.name.should == 'MachineConfiguration1' >> - conf.uri == 'http://cimi.example.org/machine_configurations/1' >> - conf.description == 'Example MachineConfiguration One' >> - conf.created.should == "2011-11-14" >> - end >> - >> - it "should have cpu and memory properties" do >> - conf = CIMI::Model::MachineConfiguration.from_xml(@xml) >> - conf.cpu.should == "2" >> - conf.memory.should be_an_instance_of Hash >> - conf.memory['quantity'].should == '1' >> - conf.memory['units'].should == 'gigabyte' >> - end >> - >> - it "should have disk array property with capacity" do >> - conf = CIMI::Model::MachineConfiguration.from_xml(@xml) >> - conf.disk.size.should == 1 >> - conf.disk[0].respond_to?(:capacity).should be_true >> - conf.disk[0].capacity.size.should == 1 >> - conf.disk[0].capacity[0]['format'] == 'ext4' >> - conf.disk[0].capacity[0]['quantity'] == '1' >> - conf.disk[0].capacity[0]['attachmentPoint'] == '/' >> - conf.disk[0].capacity[0]['units'] == 'terabyte' >> - end >> - >> - it "should have edit and delete operations" do >> - conf = CIMI::Model::MachineConfiguration.from_xml(@xml) >> - conf.operations.size.should == 2 >> - conf.operations.any? { |operation| operation.rel == 'edit' }.should be_true >> - conf.operations.any? { |operation| operation.rel == 'delete' }.should be_true >> - conf.operations.each { |operation| operation.href.should =~ /^http:\/\/.*\/(#{operation.rel})$/ } >> - end >> + it "can be constructed from XML" do >> + conf = CIMI::Model::MachineConfiguration.from_xml(@xml) >> + conf.should_not be_nil >> + should_serialize_from_xml! conf, @xml, @json >> end >> >> - describe "JSON" do >> - it "can be constructed" do >> - conf = CIMI::Model::MachineConfiguration.from_json(@json) >> - conf.should_not be_nil >> - conf.should serialize_to @json, :fmt => :json >> - end >> - >> - it "should have default properties" do >> - conf = CIMI::Model::MachineConfiguration.from_json(@json) >> - conf.name.should == 'MachineConfiguration1' >> - conf.uri == 'http://cimi.example.org/machine_configurations/1' >> - conf.description == 'Example MachineConfiguration One' >> - conf.created.should == "2011-11-14" >> - end >> - >> - it "should have cpu and memory properties" do >> - conf = CIMI::Model::MachineConfiguration.from_json(@json) >> - conf.cpu.should == "2" >> - conf.memory.should be_an_instance_of Hash >> - conf.memory['quantity'].should == '1' >> - conf.memory['units'].should == 'gigabyte' >> - end >> - >> - it "should have disk array property with capacity" do >> - conf = CIMI::Model::MachineConfiguration.from_json(@json) >> - conf.disk.should be_an_instance_of Array >> - conf.disk.size.should > 0 >> - conf.disk[0].should respond_to :capacity >> - conf.disk[0].capacity.size.should == 1 >> - conf.disk[0].capacity[0]['format'] == 'ext4' >> - conf.disk[0].capacity[0]['quantity'] == '1' >> - conf.disk[0].capacity[0]['attachmentPoint'] == '/' >> - conf.disk[0].capacity[0]['units'] == 'terabyte' >> - end >> - >> - it "should have edit and delete operations" do >> - conf = CIMI::Model::MachineConfiguration.from_json(@json) >> - conf.operations.size.should == 2 >> - conf.operations.any? { |operation| operation.rel == 'edit' }.should be_true >> - conf.operations.any? { |operation| operation.rel == 'delete' }.should be_true >> - conf.operations.each { |operation| operation.href.should =~ /^http:\/\/.*\/(#{operation.rel})$/ } >> - end >> - >> + it "can be constructed from JSON" do >> + conf = CIMI::Model::MachineConfiguration.from_json(@json) >> + conf.should_not be_nil >> + should_serialize_from_json! conf, @xml, @json >> end >> + >> end >> diff --git a/server/spec/cimi/model/machine_image_spec.rb b/server/spec/cimi/model/machine_image_spec.rb >> index 517769a..824d032 100644 >> --- a/server/spec/cimi/model/machine_image_spec.rb >> +++ b/server/spec/cimi/model/machine_image_spec.rb >> @@ -21,82 +21,16 @@ describe "MachineImage model" do >> @json = IO::read(File::join(DATA_DIR, "machine_image.json")) >> end >> >> - describe "XML" do >> - it "can be constructed" do >> - img = CIMI::Model::MachineImage.from_xml(@xml) >> - img.should_not be_nil >> - img.should serialize_to @xml, :fmt => :xml >> - end >> - >> - it "should have default properties" do >> - img = CIMI::Model::MachineImage.from_xml(@xml) >> - img.uri.should == "http://cimi.example.org/machine_image/1" >> - img.name.should == "img1" >> - img.description.should == "Machine Image One" >> - img.created.should == "2011-11-14" >> - end >> - >> - it "should have image location property" do >> - img = CIMI::Model::MachineImage.from_xml(@xml) >> - img.image_location.should be_an_instance_of Hash >> - img.image_location['href'].should == 'nfs://cimi.example.com/images/1.img' >> - end >> - >> - it "should have edit and delete operations" do >> - img = CIMI::Model::MachineImage.from_xml(@xml) >> - img.operations.any? { |operation| operation.rel == 'edit' }.should be_true >> - img.operations.any? { |operation| operation.rel == 'delete' }.should be_true >> - img.operations.each { |operation| operation.href.should =~ /^http:\/\/.*\/(#{operation.rel})$/ } >> - end >> - >> - it "should parse properties correctly in XML" do >> - img = CIMI::Model::MachineImage.from_xml(@xml) >> - img.property.any? { |p| p.name == 'status' }.should be_true >> - img.property.any? { |p| p.name == 'locked' }.should be_true >> - img.property.size.should == 2 >> - end >> - >> - it "should convert strings in keys to symbols when contructed from XML" do >> - imgl = CIMI::Model::MachineImage.from_xml(@xml) >> - imgl.should_not be_nil >> - imgl.attribute_values.keys.each { |key| key.should be_a_kind_of(Symbol) } >> - end >> + it "can be constructed from XML" do >> + conf = CIMI::Model::MachineImage.from_xml(@xml) >> + conf.should_not be_nil >> + should_serialize_from_xml! conf, @xml, @json >> end >> >> - describe 'JSON' do >> - it "can be constructed" do >> - img = CIMI::Model::MachineImage.from_json(@json) >> - img.should_not be_nil >> - img.should serialize_to @json, :fmt => :json >> - end >> - >> - it "should have default properties" do >> - img = CIMI::Model::MachineImage.from_json(@json) >> - img.uri.should == "http://cimi.example.org/machine_images/1" >> - img.name.should == "img1" >> - img.description.should == "Machine Image One" >> - img.created.should == "2011-11-14" >> - end >> - >> - it "should have image location property" do >> - img = CIMI::Model::MachineImage.from_json(@json) >> - img.image_location.should be_an_instance_of Hash >> - img.image_location['href'].should == 'nfs://cimi.example.com/images/1.img' >> - end >> - >> - it "should have edit and delete operations" do >> - img = CIMI::Model::MachineImage.from_json(@json) >> - img.operations.any? { |operation| operation.rel == 'edit' }.should be_true >> - img.operations.any? { |operation| operation.rel == 'delete' }.should be_true >> - img.operations.each { |operation| operation.href.should =~ /^http:\/\/.*\/(#{operation.rel})$/ } >> - end >> - >> - it "should parse properties correctly in XML" do >> - img = CIMI::Model::MachineImage.from_json(@json) >> - img.property.any? { |p| p.name == 'status' }.should be_true >> - img.property.any? { |p| p.name == 'locked' }.should be_true >> - img.property.size.should == 2 >> - end >> + it "can be constructed from JSON" do >> + conf = CIMI::Model::MachineImage.from_json(@json) >> + conf.should_not be_nil >> + should_serialize_from_json! conf, @xml, @json >> end >> >> end >> diff --git a/server/spec/cimi/model/machine_template_spec.rb b/server/spec/cimi/model/machine_template_spec.rb >> index 8ccd9ae..0c6f50a 100644 >> --- a/server/spec/cimi/model/machine_template_spec.rb >> +++ b/server/spec/cimi/model/machine_template_spec.rb >> @@ -20,152 +20,16 @@ describe "MachineTemplate model" do >> @json = IO::read(File::join(DATA_DIR, "machine_template.json")) >> end >> >> - describe 'XML' do >> - it "can be constructed" do >> - templ = CIMI::Model::MachineTemplate.from_xml(@xml) >> - templ.should_not be_nil >> - templ.should serialize_to @xml, :fmt => :xml >> - end >> - >> - it "should have default properties" do >> - templ = CIMI::Model::MachineTemplate.from_xml(@xml) >> - templ.created.should == "2011-11-01" >> - templ.name.should == "My First Template" >> - templ.description.should == "A template for testing" >> - templ.uri.should == "http://cimi.example.org/machine_templates/1" >> - end >> - >> - it "should convert strings in keys to symbols when contructed from XML" do >> - templ = CIMI::Model::MachineTemplate.from_xml(@xml) >> - templ.should_not be_nil >> - templ.attribute_values.keys.each { |key| key.should be_a_kind_of(Symbol) } >> - end >> - >> - it "should reference machine_config" do >> - templ = CIMI::Model::MachineTemplate.from_xml(@xml) >> - templ.machine_config.should be_an_instance_of Struct::CIMI_MachineConfig >> - templ.machine_config.href.should == "http://cimi.example.org/machine_configs/1" >> - end >> - >> - it "should reference machine_image" do >> - templ = CIMI::Model::MachineTemplate.from_xml(@xml) >> - templ.machine_image.should be_an_instance_of Struct::CIMI_MachineImage >> - templ.machine_image.href.should == "http://cimi.example.org/machine_images/1" >> - end >> - >> - it "should have list of attached volumes" do >> - templ = CIMI::Model::MachineTemplate.from_xml(@xml) >> - templ.volumes.should be_a_kind_of Array >> - templ.volumes.each do |volume| >> - volume.href.should =~ /^http:\/\/.*\/volumes\/(\w+)$/ >> - volume.protocol.should == 'nfs' >> - volume.attachment_point == '/dev/sda' >> - volume.should be_an_instance_of Struct::CIMI_Volume >> - end >> - end >> - >> - it "should have list of network interfaces" do >> - templ = CIMI::Model::MachineTemplate.from_xml(@xml) >> - templ.network_interfaces.should be_an_instance_of Array >> - templ.network_interfaces.each do |interface| >> - interface.hostname == 'host.cimi.example.org' >> - interface.mac_address == '00:11:22:33:44:55' >> - interface.state == 'UP' >> - interface.protocol == 'TCP' >> - interface.allocation == 'static' >> - interface.address == '192.168.0.17' >> - interface.default_gateway == '192.168.0.1' >> - interface.dns == '192.168.0.1' >> - interface.max_transmission_unit == '1500' >> - interface.vsp.should_not be_nil >> - interface.vsp.should be_an_instance_of Struct::CIMI_Vsp >> - interface.vsp.href.should =~ /^http:\/\/.*\/vsps\/(\w+)$/ >> - interface.should be_an_instance_of Struct::CIMI_NetworkInterface >> - end >> - end >> - >> - it "should have edit and delete operations" do >> - templ = CIMI::Model::MachineTemplate.from_xml(@xml) >> - templ.operations.size.should == 2 >> - templ.operations.any? { |operation| operation.rel == 'edit' }.should be_true >> - templ.operations.any? { |operation| operation.rel == 'delete' }.should be_true >> - templ.operations.each { |operation| operation.href.should =~ /^http:\/\/.*\/(#{operation.rel})$/ } >> - end >> - >> + it "can be constructed from XML" do >> + conf = CIMI::Model::MachineTemplate.from_xml(@xml) >> + conf.should_not be_nil >> + should_serialize_from_xml! conf, @xml, @json >> end >> >> - describe 'JSON' do >> - it "can be constructed" do >> - templ = CIMI::Model::MachineTemplate.from_json(@json) >> - templ.should_not be_nil >> - templ.should serialize_to @xml, :fmt => :xml >> - end >> - >> - it "should have default properties" do >> - templ = CIMI::Model::MachineTemplate.from_json(@json) >> - templ.created.should == "2011-11-01" >> - templ.name.should == "My First Template" >> - templ.description.should == "A template for testing" >> - templ.uri.should == "http://cimi.example.org/machine_templates/1" >> - end >> - >> - it "should convert strings in keys to symbols when contructed from XML" do >> - templ = CIMI::Model::MachineTemplate.from_json(@json) >> - templ.should_not be_nil >> - templ.attribute_values.keys.each { |key| key.should be_a_kind_of(Symbol) } >> - end >> - >> - it "should reference machine_config" do >> - templ = CIMI::Model::MachineTemplate.from_json(@json) >> - templ.machine_config.should be_an_instance_of Struct::CIMI_MachineConfig >> - templ.machine_config.href.should == "http://cimi.example.org/machine_configs/1" >> - end >> - >> - it "should reference machine_image" do >> - templ = CIMI::Model::MachineTemplate.from_json(@json) >> - templ.machine_image.should be_an_instance_of Struct::CIMI_MachineImage >> - templ.machine_image.href.should == "http://cimi.example.org/machine_images/1" >> - end >> - >> - it "should have list of attached volumes" do >> - templ = CIMI::Model::MachineTemplate.from_json(@json) >> - templ.volumes.should be_a_kind_of Array >> - templ.volumes.each do |volume| >> - volume.href.should =~ /^http:\/\/.*\/volumes\/(\w+)$/ >> - volume.protocol.should == 'nfs' >> - volume.attachment_point == '/dev/sda' >> - volume.should be_an_instance_of Struct::CIMI_Volume >> - end >> - end >> - >> - it "should have list of network interfaces" do >> - templ = CIMI::Model::MachineTemplate.from_json(@json) >> - templ.network_interfaces.should be_an_instance_of Array >> - templ.network_interfaces.each do |interface| >> - interface.hostname == 'host.cimi.example.org' >> - interface.mac_address == '00:11:22:33:44:55' >> - interface.state == 'UP' >> - interface.protocol == 'TCP' >> - interface.allocation == 'static' >> - interface.address == '192.168.0.17' >> - interface.default_gateway == '192.168.0.1' >> - interface.dns == '192.168.0.1' >> - interface.max_transmission_unit == '1500' >> - interface.vsp.should_not be_nil >> - interface.vsp.should be_an_instance_of Struct::CIMI_Vsp >> - interface.vsp.href.should =~ /^http:\/\/.*\/vsps\/(\w+)$/ >> - interface.should be_an_instance_of Struct::CIMI_NetworkInterface >> - end >> - end >> - >> - it "should have edit and delete operations" do >> - templ = CIMI::Model::MachineTemplate.from_json(@json) >> - templ.operations.size.should == 2 >> - templ.operations.any? { |operation| operation.rel == 'edit' }.should be_true >> - templ.operations.any? { |operation| operation.rel == 'delete' }.should be_true >> - templ.operations.each { |operation| operation.href.should =~ /^http:\/\/.*\/(#{operation.rel})$/ } >> - end >> - >> + it "can be constructed from JSON" do >> + conf = CIMI::Model::MachineTemplate.from_json(@json) >> + conf.should_not be_nil >> + should_serialize_from_json! conf, @xml, @json >> end >> >> end >