Beispiel #1
0
    def test_offer_claim_multiple(self):
        """ Tests that more that one lessee can claim the same offer provided
                that the times specified do not conflict.
            Test steps:
            1) (owner) Create an offer for an owned node.
            2) Check that offer details were returned.
            3) Record what the time will be in five minutes.
            4) (subproj1) Claim the offer from step 1, starting at the time
                recorded in step 3 and ending 30 minutes from then.
            5) Check that lease details were returned.
            6) (subproj2) Claim the offer from step 1, starting five minutes
                after the end time of the lease created in step 4 and ending
                30 minutes from then.
            7) Check that lease details were returned.
            8) (owner) Check that both leases show up when listing leases.
            9) (subproj2) (cleanup) Delete the lease created in step 6.
            10) (subproj1) (cleanup) Delete the lease created in step 4.
            11) (owner) (cleanup) Delete the offer created in step 1. """
        offer = esi.offer_create(self.clients['main-owner'],
                                 self.dummy_node.uuid,
                                 resource_type='dummy_node')
        self.assertNotEqual(offer, {})
        self.addCleanup(esi.offer_delete,
                        self.clients['main-owner'],
                        offer['uuid'])

        time_now = datetime.now()
        lease1_start_time = time_now + timedelta(minutes=5)
        lease1_end_time = lease1_start_time + timedelta(minutes=30)
        lease2_start_time = lease1_end_time + timedelta(minutes=5)
        lease2_end_time = lease2_start_time + timedelta(minutes=30)

        lease1 = esi.offer_claim(self.clients['subproj1-lessee'],
                                 offer['uuid'],
                                 start_time=str(lease1_start_time),
                                 end_time=str(lease1_end_time))
        self.assertNotEqual(lease1, {})
        self.addCleanup(esi.lease_delete,
                        self.clients['subproj1-lessee'],
                        lease1['uuid'])

        lease2 = esi.offer_claim(self.clients['subproj2-lessee'],
                                 offer['uuid'],
                                 start_time=str(lease2_start_time),
                                 end_time=str(lease2_end_time))
        self.assertNotEqual(lease2, {})
        self.addCleanup(esi.lease_delete,
                        self.clients['subproj2-lessee'],
                        lease2['uuid'])

        listings = esi.lease_list(self.clients['main-owner'])
        uuid_listings = [x['UUID'] for x in listings]
        self.assertNotEqual(listings, [])
        for lease_id in lease1['uuid'], lease2['uuid']:
            self.assertIn(lease_id, uuid_listings)
Beispiel #2
0
    def test_offer_claim_basic(self):
        """ Tests that a lessee can claim an offer made available to them
                and delete the created lease when finished.
            Test steps:
            1) (owner) Create an offer for an owned node.
            2) Check that offer details were returned.
            3) (lessee) Claim the offer created in step 1.
            4) Check that lease details were returned.
            5) (cleanup) (lessee) Delete the lease created in step 3.
            6) (cleanup) (owner) Delete the offer created in step 1. """
        offer = esi.offer_create(self.clients['parent-owner'],
                                 self.dummy_node.uuid,
                                 resource_type='dummy_node',
                                 lessee=self.projects['child']['name'])
        self.assertNotEqual(offer, {})
        self.addCleanup(esi.offer_delete,
                        self.clients['parent-owner'],
                        offer['uuid'])

        lease = esi.offer_claim(self.clients['child-lessee'],
                                offer['uuid'])
        self.assertNotEqual(lease, {})
        self.addCleanup(esi.lease_delete,
                        self.clients['child-lessee'],
                        lease['uuid'])
Beispiel #3
0
    def test_lease_show_offer_deleted(self):
        """ Tests that leases created thru claiming an offer are deleted after
                the claimed offer has been deleted.
            Test steps:
            1) (owner) Create an offer for an owned node.
            2) Check that offer details were returned.
            3) (lessee) Claim the offer created in step 1.
            4) Check that lease details were returned.
            5) (owner) Delete the offer created in step 1.
            6) View the details of the lease created in step 4 to ensure the
                lease's status is 'deleted'.
            7) (lessee) If not, delete the lease manually. """
        offer = esi.offer_create(self.clients['parent-owner'],
                                 self.dummy_node.uuid,
                                 resource_type='dummy_node',
                                 lessee=self.projects['child']['name'])
        self.assertNotEqual(offer, {})
        self.addCleanup(esi.offer_delete,
                        self.clients['parent-owner'],
                        offer['uuid'],
                        fail_ok=True)

        lease = esi.offer_claim(self.clients['child-lessee'],
                                offer['uuid'])
        self.assertNotEqual(lease, {})
        self.addCleanup(esi.lease_delete,
                        self.clients['child-lessee'],
                        lease['uuid'],
                        fail_ok=True)

        esi.offer_delete(self.clients['parent-owner'], offer['uuid'])
        details = esi.lease_show(self.clients['child-lessee'], lease['uuid'])
        self.assertEqual(details['status'], 'deleted')
Beispiel #4
0
    def test_offer_claim_conflict(self):
        """ Tests that two lessees cannot make overlapping claims on the
                same offer.
            Test steps:
            1) (owner) Create an offer for an owned node.
            2) Check that offer details were returned.
            3) Record the current time.
            4) (subproj1) Claim the offer from step 1, ending 30 minutes
                after the time recorded in step 3.
            5) Check that lease details were returned.
            6) (subproj2) Attempt to claim the offer from step 1, starting
                15 minutes after the time recorded in step 3, and ending 30
                minutes after that.
            7) Check that the command failed. (returned non-zero exit code)
            8) Check that the proper error message was sent to stderr.
            9) (subproj1) (cleanup) Delete the lease created in step 4.
            10) (owner) (cleanup) Delete the offer created in step 1. """
        offer = esi.offer_create(self.clients['main-owner'],
                                 self.dummy_node.uuid,
                                 resource_type='dummy_node')
        self.assertNotEqual(offer, {})
        self.addCleanup(esi.offer_delete,
                        self.clients['main-owner'],
                        offer['uuid'])

        time_now = datetime.now()
        lease1_end_time = time_now + timedelta(minutes=30)
        lease2_start_time = time_now + timedelta(minutes=15)
        lease2_end_time = lease2_start_time + timedelta(minutes=30)

        lease1 = esi.offer_claim(self.clients['subproj1-lessee'],
                                 offer['uuid'],
                                 end_time=str(lease1_end_time))
        self.assertNotEqual(lease1, {})
        self.addCleanup(esi.lease_delete,
                        self.clients['subproj1-lessee'],
                        lease1['uuid'])

        e = self.assertRaises(CommandFailed,
                              esi.offer_claim,
                              self.clients['subproj2-lessee'],
                              offer['uuid'],
                              start_time=str(lease2_start_time),
                              end_time=str(lease2_end_time))
        err = ('Offer %s has no availabilities at given time range %s, %s' %
               (offer['uuid'], str(lease2_start_time), str(lease2_end_time)))
        self.assertIn(err, e.stderr.decode())
Beispiel #5
0
    def test_offer_claim_sublease(self):
        """ Tests that an offer for a subleased node can be claimed.
            Test steps:
            1) (node-owner) Create a lease on an owned node, specifying
                the sublessee project as the lessee.
            2) Check that lease details were returned.
            3) Wait for the esi-leap manager service to move the lease from
                the created state to the active state.
            4) (sublessee-owner) Create an offer for the node leased to the
                sublessee in step 1.
            5) Check that offer details were returned.
            6) (project-lessee) Claim the offer created in step 3.
            7( Check that lease details were returned.
            8) (cleanup) (project-lessee) Delete the lease from step 5.
            9) (cleanup) (sublessee-owner) Delete the offer from step 3.
            10) (cleanup) (node-owner) Delete the lease from step 1. """
        lease = esi.lease_create(self.clients['node-owner'],
                                 self.dummy_node.uuid,
                                 self.projects['sublessee']['name'],
                                 resource_type='dummy_node')
        self.assertNotEqual(lease, {})
        self.addCleanup(esi.lease_delete, self.clients['node-owner'],
                        lease['uuid'])

        time.sleep(65)

        offer = esi.offer_create(self.clients['sublessee-owner'],
                                 self.dummy_node.uuid,
                                 resource_type='dummy_node')
        self.assertNotEqual(offer, {})
        self.addCleanup(esi.offer_delete, self.clients['sublessee-owner'],
                        offer['uuid'])

        sublease = esi.offer_claim(self.clients['project-lessee'],
                                   offer['uuid'])
        self.assertNotEqual(sublease, {})
        self.addCleanup(esi.lease_delete, self.clients['project-lessee'],
                        sublease['uuid'])