Ejemplo n.º 1
0
def send_cp3(submission_model: Optional[SubmissionModel] = None):
    if submission_model is None:
        body = None
    else:
        body = submission_model.to_dict(include_metadata=False,
                                        strip_nulls=True)
        submission_model.to_file_pretty(os.path.join(
            get_configuration().globals.immortalsRoot,
            'DAS_DEPLOYMENT/input.json'),
                                        include_metadata=False)
    tpr.start_thread(thread_method=post,
                     thread_args=[TestAdapterEndpoint.CP3, body])
Ejemplo n.º 2
0
    def sent_post_ack_listener(self, endpoint: TestAdapterEndpoint, response_code: int, body_str: str):
        immortals_assert_isinstance(endpoint, TestAdapterEndpoint)
        validator = self._pending_acks.pop(0)
        immortals_assert_isinstance(validator.endpoint, TestAdapterEndpoint)
        self._log_expected_and_actual(validator=validator, endpoint=endpoint,
                                      body_val=body_str, status_code=response_code)
        validator.validate_ack(endpoint=endpoint, body_str=body_str, status_code=response_code)

        if endpoint == TestAdapterEndpoint.ENABLED:
            submission = self._submissions.pop(0)
            tpr.start_thread(thread_method=submission.execute)

        if len(self._expected_activity) == 0 and len(self._pending_acks) == 0:
            self.finished = True
Ejemplo n.º 3
0
    def received_post_ack_listener(self, endpoint: TestHarnessEndpoint, response_code: int, body_str: str):
        immortals_assert_isinstance(endpoint, TestHarnessEndpoint)
        validator = self._pending_acks.pop(0)
        immortals_assert_isinstance(validator.endpoint, TestHarnessEndpoint)

        # validator = self._expected_activity.pop(0)
        self._log_expected_and_actual(validator=validator, endpoint=endpoint,
                                      body_val=body_str, status_code=response_code)
        validator.validate_ack(endpoint=endpoint, body_str=body_str, status_code=response_code)

        if endpoint == TestHarnessEndpoint.READY:
            submission = self._submissions.pop(0)
            tpr.start_thread(thread_method=submission.execute)

        # elif endpoint == TestHarnessEndpoint.ACTION_DONE:
        #     if len(self._submissions) > 0:
        #         submission = self._submissions.pop(0)
        #         t = Thread(target=submission.execute)
        #         t.setDaemon(True)
        #         t.start()

        if len(self._expected_activity) == 0 and len(self._pending_acks) == 0:
            self.finished = True
Ejemplo n.º 4
0
    def initialize_execution(self, initialization_data: str, perform_adaptation: bool,
                             scenario_template_tag: str) -> Tuple[str, None] or Tuple[None, str]:

        with self._lock:
            if not self.ready_for_submission():
                return ('A scenario with the identifier "' +
                        self._deployment_model.sessionIdentifier + ' is already running!')

            err_msg, dm, llp1input = _parse_deployment_model(initialization_data, True)

            if err_msg is not None:
                return err_msg, None

            self._das_not_finished = True
            self._scenario_runner_not_finished = True

            self._deployment_model = dm
            self._ll_p1_input = llp1input

            self._test_adapter_state: TestAdapterState = TestAdapterState(
                identifier=self._deployment_model.sessionIdentifier,
                adaptation=AdaptationState(
                    adaptationStatus=Status.PENDING if perform_adaptation else Status.NOT_APPLICABLE,
                    details=None
                ),
                validation=ValidationState(
                    executedTests=None,
                    overallIntentStatus=Status.PENDING
                ),
                rawLogData=[]
            )

            self._scenario_template_tag = scenario_template_tag

        ig.get_event_router().submit(EventTags.DeploymentModelLoaded, data=self._deployment_model)

        ig.get_event_router().submit(event_tag=EventTags.THStatusDasInfo,
                                     data=self._test_adapter_state)

        return_val = LLTestActionResult(RESULT=self._test_adapter_state)

        if perform_adaptation:
            ig.get_event_router().submit(event_tag=EventTags.THStatusPerturbationDetected,
                                         data=self._test_adapter_state)

            tpr.start_thread(
                thread_method=LLRestEndpoint.perform_adaptation_and_validation,
                thread_args=[self]
            )

        else:
            self._das_not_finished = False

            caid = CreateApplicationInstanceData(
                sessionIdentifier=self._ll_p1_input.sessionIdentifier,
                applicationType=ApplicationType.Client_ATAKLite
            )
            websocket.get_das_bridge().createApplicationInstance(caid)

            # copy the existing app to where it belongs!

            tpr.start_thread(
                thread_method=LLRestEndpoint.perform_validation,
                thread_args=[self]
            )

        return None, return_val.to_json_str(include_metadata=False)
Ejemplo n.º 5
0
 def submit_asynchronously(self, event_tag: EventTag, data: object):
     tpr.start_thread(
         thread_method=self._submit,
         thread_args=[event_tag, data, True])
Ejemplo n.º 6
0
 def start_in_thread(self):
     tpr.start_thread(thread_method=self._websocket.start,
                      shutdown_method=self._websocket.stop)
Ejemplo n.º 7
0
def send_disable_das():
    disable = EnableDas(dasEnabled=False)
    body = disable.to_dict(include_metadata=False, strip_nulls=True)
    tpr.start_thread(thread_method=post,
                     thread_args=[TestAdapterEndpoint.ENABLED, body])