def subtest_CreateSliver_nagios(self, slicename=None, doProvision=True, doPOA=False): # Check to see if 'rspeclint' can be found before doing the hard (and # slow) work of calling ListResources at the aggregate if self.options_copy.rspeclint: rspec_util.rspeclint_exists() rspec_namespace = self.manifest_namespace rspec_schema = self.manifest_schema else: rspec_namespace = None rspec_schema = None if slicename == None: slicename = self.create_slice_name() # if reusing a slice name, don't create (or delete) the slice if not self.options_copy.reuse_slice_name: self.subtest_createslice(slicename) time.sleep(self.options_copy.sleep_time) # cleanup up any previous failed runs try: self.subtest_generic_Delete(slicename) time.sleep(self.options_copy.sleep_time) except: pass numslivers, manifest, slivers = self.subtest_generic_CreateSliver( slicename, doProvision, doPOA) with open(self.options_copy.rspec_file) as f: req = f.readlines() request = "".join(req) try: self.assertRspec("CreateSliver", manifest, rspec_namespace, rspec_schema, self.options_copy.rspeclint) self.assertRspecType(request, 'request') self.assertRspecType(manifest, 'manifest') # Make sure the Manifest returned the nodes identified in # the Request self.assertManifestMatchesRequest(request, manifest, self.RSpecVersion(), self.options_copy.bound, "Created sliver") if self.options_copy.api_version >= 3: self.subtest_PerformOperationalAction(slicename, 'geni_start') except: raise finally: time.sleep(self.options_copy.sleep_time)
def subtest_CreateSliver_nagios(self, slicename=None, doProvision=True, doPOA=False): # Check to see if 'rspeclint' can be found before doing the hard (and # slow) work of calling ListResources at the aggregate if self.options_copy.rspeclint: rspec_util.rspeclint_exists() rspec_namespace = self.manifest_namespace rspec_schema = self.manifest_schema else: rspec_namespace = None rspec_schema = None if slicename==None: slicename = self.create_slice_name() # if reusing a slice name, don't create (or delete) the slice if not self.options_copy.reuse_slice_name: self.subtest_createslice( slicename ) time.sleep(self.options_copy.sleep_time) # cleanup up any previous failed runs try: self.subtest_generic_Delete( slicename ) time.sleep(self.options_copy.sleep_time) except: pass numslivers, manifest, slivers = self.subtest_generic_CreateSliver( slicename, doProvision, doPOA ) with open(self.options_copy.rspec_file) as f: req = f.readlines() request = "".join(req) try: self.assertRspec( "CreateSliver", manifest, rspec_namespace, rspec_schema, self.options_copy.rspeclint ) self.assertRspecType( request, 'request') self.assertRspecType( manifest, 'manifest') # Make sure the Manifest returned the nodes identified in # the Request self.assertManifestMatchesRequest( request, manifest, self.RSpecVersion(), self.options_copy.bound, "Created sliver") if self.options_copy.api_version >= 3: self.subtest_PerformOperationalAction( slicename, 'geni_start') except: raise finally: time.sleep(self.options_copy.sleep_time)
def test_CreateSliverWorkflow_with_Shutdown(self, slicename=None): if self.options_copy.rspeclint: rspec_util.rspeclint_exists() rspec_namespace = self.manifest_namespace rspec_schema = self.manifest_schema else: rspec_namespace = None rspec_schema = None with open(self.options_copy.rspec_file) as f: req = f.readlines() request = "".join(req) if slicename==None: slicename = self.create_slice_name(prefix='down') # if reusing a slice name, don't create (or delete) the slice if not self.options_copy.reuse_slice_name: self.subtest_createslice( slicename ) time.sleep(self.options_copy.sleep_time) numslivers, manifest, slivers = self.subtest_generic_CreateSliver( slicename ) time.sleep(self.options_copy.sleep_time) self.assertRspec( "CreateSliver", manifest, rspec_namespace, rspec_schema, self.options_copy.rspeclint ) self.assertRspecType( request, 'request') self.assertRspecType( manifest, 'manifest') try: self.subtest_Shutdown( slicename ) except: # If Shutdown fails, then DeleteSliver to clean up for next run time.sleep(self.options_copy.sleep_time) self.subtest_generic_DeleteSliver( slicename ) if not self.options_copy.reuse_slice_name: self.subtest_deleteslice( slicename )
def test_CreateSliverWorkflow_with_Shutdown(self, slicename=None): if self.options_copy.rspeclint: rspec_util.rspeclint_exists() rspec_namespace = self.manifest_namespace rspec_schema = self.manifest_schema else: rspec_namespace = None rspec_schema = None with open(self.options_copy.rspec_file) as f: req = f.readlines() request = "".join(req) if slicename == None: slicename = self.create_slice_name(prefix='down') # if reusing a slice name, don't create (or delete) the slice if not self.options_copy.reuse_slice_name: self.subtest_createslice(slicename) time.sleep(self.options_copy.sleep_time) numslivers, manifest, slivers = self.subtest_generic_CreateSliver( slicename) time.sleep(self.options_copy.sleep_time) self.assertRspec("CreateSliver", manifest, rspec_namespace, rspec_schema, self.options_copy.rspeclint) self.assertRspecType(request, 'request') self.assertRspecType(manifest, 'manifest') try: self.subtest_Shutdown(slicename) except: # If Shutdown fails, then DeleteSliver to clean up for next run time.sleep(self.options_copy.sleep_time) self.subtest_generic_DeleteSliver(slicename) if not self.options_copy.reuse_slice_name: self.subtest_deleteslice(slicename)
def test_CreateSliverWorkflow_scalingTest(self): """test_CreateSliverWorkflow_ScalingTest: Do CreateSliver workflow with multiple slices""" self.logger.info("\n=== Test.test_CreateSliverWorkflow_scalingTest ===") if self.options_copy.rspeclint: rspec_util.rspeclint_exists() rspec_namespace = self.manifest_namespace rspec_schema = self.manifest_schema request = [] numslivers = [] manifest = [] slivers = [] manifest2 = [] slicenames = [] num_slices = self.options_copy.num_slices # make always --un-bound (since this test assumes that you can # offer the same rspec to an aggregate multiple times) self.options_copy.bound = False for i in xrange(num_slices): slicenames.append("") # slicenames[i] = self.create_slice_name()+str(i) slicenames[i] = self.options_copy.slice_name+str(i) for i in xrange(num_slices): # if reusing a slice name, don't create (or delete) the slice self.subtest_createslice( slicenames[i] ) print "%d: CreateSlice [%s] completed..."%(i, slicenames[i]) time.sleep(self.options_copy.sleep_time) # in case some slivers were left laying around from last # time, try to delete them now for i in xrange(num_slices): try: self.subtest_generic_DeleteSliver( slicenames[i] ) time.sleep(self.options_copy.sleep_time) except: pass try: for i in xrange(num_slices): # Check for the existance of the Request RSpec file # self.assertTrue( os.path.exists(self.options_copy.rspec_file_list[i]), self.assertTrue( os.path.exists(self.options_copy.rspec_file), "Request RSpec file, '%s' for 'CreateSliver' call " \ "expected to exist " \ "but does not." # % self.options_copy.rspec_file_list[i] ) % self.options_copy.rspec_file ) # with open(self.options_copy.rspec_file_list[i]) as f: with open(self.options_copy.rspec_file) as f: request.append("") request[i] = "".join(f.readlines()) numslivers.append(-1) manifest.append("") slivers.append("") # self.options_copy.rspec_file = self.options_copy.rspec_file_list[i] time.sleep(self.options_copy.sleep_time) # # False args mean in v3+, don't do Provision or POA # createReturn = self.subtest_generic_CreateSliver( slicenames[i], False, False ) sliceExpiration = self.getSliceExpiration( slicenames[i] ) createReturn = self.subtest_generic_CreateSliver( slicenames[i], expectedExpiration=sliceExpiration ) print "%d: CreateSliver on slice [%s] completed..."%(i, slicenames[i]) numslivers[i], tmpManifest, slivers[i] = createReturn manifest[i] = "".join(tmpManifest) self.assertRspecType( "".join(request[i]), 'request') self.assertRspecType( "".join(manifest[i]), 'manifest') # manifest should be valid XML self.assertIsXML( manifest[i], "Manifest RSpec returned by 'CreateSliver' on slice '%s' " \ "expected to be wellformed XML file " \ "but was not. Return was: " \ "\n%s\n" \ "... edited for length ..." % (slicenames[i], manifest[i][:100])) if self.options_copy.rspeclint: self.assertTrue(rspec_util.validate_rspec( manifest[i], namespace=rspec_namespace, schema=rspec_schema ), "Return from 'CreateSliver' " \ "expected to pass rspeclint " \ "but did not. Return was: " \ "\n%s\n" \ "... edited for length ..." % (manifest[i][:100])) # Make sure the Manifest returned the nodes identified # in the Request if rspec_util.has_child_node( manifest[i], self.RSpecVersion()): if self.options_copy.bound: self.assertCompIDsEqual( "".join(request[i]), "".join(manifest[i]), self.RSpecVersion(), "Request RSpec and Manifest RSpec " \ "returned by 'ListResources' on slice '%s' " \ "expected to have same component_ids " \ "but did not." % slicenames[i]) self.assertClientIDsEqual( "".join(request[i]), "".join(manifest[i]), self.RSpecVersion(), "Request RSpec and Manifest RSpec " \ "returned by 'ListResources' on slice '%s' " \ "expected to have same client_ids " \ "but did not." % slicenames[i]) else: # the top level node should have a child self.assertResourcesExist( "".join(manifest[i]), "Manifest RSpec returned by 'CreateSliver' on slice '%s' " \ "expected to NOT be empty " \ "but was. Return was: " \ "\n%s\n" % (slicenames[i], "".join(manifest[i]))) # Separate for loop here guarantees time has passed on each AM since createsliver call self.subtest_SliverStatus_scaling(slicenames) except: raise finally: time.sleep(self.options_copy.sleep_time) for i in xrange(num_slices): try: self.subtest_generic_DeleteSliver( slicenames[i] ) print "%d: DeleteSliver on slice [%s] completed..."%(i, slicenames[i]) except: pass self.success = True
def test_CreateSliverWorkflow_scalingTest(self): """test_CreateSliverWorkflow_ScalingTest: Do CreateSliver workflow with multiple slices""" self.logger.info( "\n=== Test.test_CreateSliverWorkflow_scalingTest ===") if self.options_copy.rspeclint: rspec_util.rspeclint_exists() rspec_namespace = self.manifest_namespace rspec_schema = self.manifest_schema request = [] numslivers = [] manifest = [] slivers = [] manifest2 = [] slicenames = [] num_slices = self.options_copy.num_slices # make always --un-bound (since this test assumes that you can # offer the same rspec to an aggregate multiple times) self.options_copy.bound = False for i in xrange(num_slices): slicenames.append("") # slicenames[i] = self.create_slice_name()+str(i) slicenames[i] = self.options_copy.slice_name + str(i) for i in xrange(num_slices): # if reusing a slice name, don't create (or delete) the slice self.subtest_createslice(slicenames[i]) print "%d: CreateSlice [%s] completed..." % (i, slicenames[i]) time.sleep(self.options_copy.sleep_time) # in case some slivers were left laying around from last # time, try to delete them now for i in xrange(num_slices): try: self.subtest_generic_DeleteSliver(slicenames[i]) time.sleep(self.options_copy.sleep_time) except: pass try: for i in xrange(num_slices): # Check for the existance of the Request RSpec file # self.assertTrue( os.path.exists(self.options_copy.rspec_file_list[i]), self.assertTrue( os.path.exists(self.options_copy.rspec_file), "Request RSpec file, '%s' for 'CreateSliver' call " \ "expected to exist " \ "but does not." # % self.options_copy.rspec_file_list[i] ) % self.options_copy.rspec_file ) # with open(self.options_copy.rspec_file_list[i]) as f: with open(self.options_copy.rspec_file) as f: request.append("") request[i] = "".join(f.readlines()) numslivers.append(-1) manifest.append("") slivers.append("") # self.options_copy.rspec_file = self.options_copy.rspec_file_list[i] time.sleep(self.options_copy.sleep_time) # # False args mean in v3+, don't do Provision or POA # createReturn = self.subtest_generic_CreateSliver( slicenames[i], False, False ) sliceExpiration = self.getSliceExpiration(slicenames[i]) createReturn = self.subtest_generic_CreateSliver( slicenames[i], expectedExpiration=sliceExpiration) print "%d: CreateSliver on slice [%s] completed..." % ( i, slicenames[i]) numslivers[i], tmpManifest, slivers[i] = createReturn manifest[i] = "".join(tmpManifest) self.assertRspecType("".join(request[i]), 'request') self.assertRspecType("".join(manifest[i]), 'manifest') # manifest should be valid XML self.assertIsXML( manifest[i], "Manifest RSpec returned by 'CreateSliver' on slice '%s' " \ "expected to be wellformed XML file " \ "but was not. Return was: " \ "\n%s\n" \ "... edited for length ..." % (slicenames[i], manifest[i][:100])) if self.options_copy.rspeclint: self.assertTrue(rspec_util.validate_rspec( manifest[i], namespace=rspec_namespace, schema=rspec_schema ), "Return from 'CreateSliver' " \ "expected to pass rspeclint " \ "but did not. Return was: " \ "\n%s\n" \ "... edited for length ..." % (manifest[i][:100])) # Make sure the Manifest returned the nodes identified # in the Request if rspec_util.has_child_node(manifest[i], self.RSpecVersion()): if self.options_copy.bound: self.assertCompIDsEqual( "".join(request[i]), "".join(manifest[i]), self.RSpecVersion(), "Request RSpec and Manifest RSpec " \ "returned by 'ListResources' on slice '%s' " \ "expected to have same component_ids " \ "but did not." % slicenames[i]) self.assertClientIDsEqual( "".join(request[i]), "".join(manifest[i]), self.RSpecVersion(), "Request RSpec and Manifest RSpec " \ "returned by 'ListResources' on slice '%s' " \ "expected to have same client_ids " \ "but did not." % slicenames[i]) else: # the top level node should have a child self.assertResourcesExist( "".join(manifest[i]), "Manifest RSpec returned by 'CreateSliver' on slice '%s' " \ "expected to NOT be empty " \ "but was. Return was: " \ "\n%s\n" % (slicenames[i], "".join(manifest[i]))) # Separate for loop here guarantees time has passed on each AM since createsliver call self.subtest_SliverStatus_scaling(slicenames) except: raise finally: time.sleep(self.options_copy.sleep_time) for i in xrange(num_slices): try: self.subtest_generic_DeleteSliver(slicenames[i]) print "%d: DeleteSliver on slice [%s] completed..." % ( i, slicenames[i]) except: pass self.success = True