Ejemplo n.º 1
0
def test_Loop_customization():
    """Integration tests for Loop Instance."""
    requests.get("{}/reset".format(Clamp._base_url))
    Clamp(cert=('LICENSE', ''))
    svc = Service(name="service01")
    loop_template = Clamp.check_loop_template(service=svc)
    response = requests.post("{}/reset".format(Clamp._base_url))
    response.raise_for_status()
    loop = LoopInstance(template=loop_template, name="instance01", details={})
    loop.create()
    loop.update_microservice_policy()
    #add op policy FrequencyLimiter that already exists in clamp
    loop.add_operational_policy(
        policy_type="onap.policies.controlloop.guard.common.FrequencyLimiter",
        policy_version="1.0.0")
    #only frequency configuration is available in mock clamp
    loop.add_op_policy_config(loop.add_frequency_limiter, limit=1)
    submit = loop.act_on_loop_policy(loop.submit)
    assert submit
    stop = loop.act_on_loop_policy(loop.stop)
    assert stop
    restart = loop.act_on_loop_policy(loop.restart)
    assert restart
    deploy = loop.deploy_microservice_to_dcae()
    assert deploy
    loop.undeploy_microservice_from_dcae()
    new_details = loop._update_loop_details()
    assert new_details["components"]["DCAE"]["componentState"][
        "stateName"] == "MICROSERVICE_UNINSTALLED_SUCCESSFULLY"
Ejemplo n.º 2
0
def test_deploy_microservice_to_dcae(mock_send_message, mock_send_message_json,
                                     mock_timer):
    """Test stop microservice."""
    loop = LoopInstance(template="template", name="test", details=LOOP_DETAILS)
    mock_send_message_json.return_value = SUBMITED
    state = loop.deploy_microservice_to_dcae()
    mock_send_message.assert_called_once_with(
        'PUT', 'Deploy microservice to DCAE',
        (f"{loop.base_url()}/loop/deploy/LOOP_test"))
    assert state
    def deploy(self, loop: LoopInstance) -> None:
        """Deploy closed loop."""
        self._logger.info("******** SUBMIT POLICIES TO PE *******")
        submit = loop.act_on_loop_policy(loop.submit)
        self._logger.info("******** CHECK POLICIES SUBMITION *******")
        if submit:
            self._logger.info("Policies successfully submited to PE")

        else:
            self._logger.error(
                "An error occured while submitting the loop instance")
            raise onap_test_exceptions.PolicyException
        self._logger.info("******** DEPLOY LOOP INSTANCE *******")
        deploy = loop.deploy_microservice_to_dcae()
        if deploy:
            self._logger.info(
                "Loop instance %s successfully deployed on DCAE !!",
                self.loop_name)
        else:
            self._logger.error(
                "An error occured while deploying the loop instance")
            raise onap_test_exceptions.DcaeException