def pre_execution_check(event, context): dst_bucket = get_dst_bucket(event) bundle_uuid = event[EventConstants.BUNDLE_UUID] bundle_version = event[EventConstants.BUNDLE_VERSION] dss_bucket = event[EventConstants.DSS_BUCKET] replica = Replica[event[EventConstants.REPLICA]] logger.info( "Pre-execution check job_id %s for bundle %s version %s replica %s", event[EventConstants.EXECUTION_ID], bundle_uuid, bundle_version, replica) try: pre_exec_validate(replica, dss_bucket, dst_bucket, bundle_uuid, bundle_version) result = { _InternalEventConstants.VALIDATION_CHECKOUT_STATUS: _InternalEventConstants.VALIDATION_CHECKOUT_STATUS_PASSED, } except PreExecCheckoutError as ex: result = { _InternalEventConstants.VALIDATION_CHECKOUT_STATUS: _InternalEventConstants.VALIDATION_CHECKOUT_STATUS_FAILED, _InternalEventConstants.VALIDATION_CAUSE: str(ex), } return result
def test_validate(self): bundle_uuid = "011c7340-9b3c-4d62-bf49-090d79daf198" version = "2017-06-20T214506.766634Z" for replica in Replica: valid, cause = pre_exec_validate(self.get_test_fixture_bucket(replica), replica.checkout_bucket, replica, bundle_uuid, version) self.assertIs(valid, ValidationEnum.PASSED)
def pre_execution_check(event, context): dst_bucket = get_dst_bucket(event) bundle = event["bundle"] version = event["version"] dss_bucket = event["dss_bucket"] replica = Replica[event["replica"]] logger.info("Pre-execution check job_id %s for bundle %s version %s replica %s", event['execution_name'], bundle, version, replica) checkout_status, cause = pre_exec_validate(dss_bucket, dst_bucket, replica, bundle, version) result = {"checkout_status": checkout_status.name.upper()} if cause: result["cause"] = cause return result
def test_validate_wrong_key(self): bundle_uuid = "WRONG_KEY" version = "WRONG_VERSION" for replica in Replica: valid, cause = pre_exec_validate(replica.bucket, replica.checkout_bucket, replica, bundle_uuid, version) self.assertIs(valid, ValidationEnum.WRONG_BUNDLE_KEY)