Beispiel #1
0
def test_onboard_service_several_resources(mock_create, mock_add_resource,
                                           mock_checkin, mock_submit,
                                           mock_start_certification,
                                           mock_certify, mock_approve,
                                           mock_distribute):
    getter_mock = mock.Mock(wraps=Service.status.fget)
    mock_status = Service.status.getter(getter_mock)
    with mock.patch.object(Service, 'status', mock_status):
        getter_mock.side_effect = [
            const.DRAFT, const.DRAFT, const.DISTRIBUTED, const.DISTRIBUTED,
            const.DISTRIBUTED, const.DISTRIBUTED, const.DISTRIBUTED,
            const.DISTRIBUTED, const.DISTRIBUTED, None
        ]
        resource1 = SdcResource()
        resource2 = SdcResource()
        service = Service(resources=[resource1, resource2])
        service._time_wait = 0
        service.onboard()
        mock_create.assert_not_called()
        calls = [mock.call(resource1), mock.call(resource2)]
        mock_add_resource.assert_has_calls(calls, any_order=True)
        assert mock_add_resource.call_count == 2
        mock_checkin.assert_called_once()
        mock_submit.assert_not_called()
        mock_start_certification.assert_not_called()
        mock_certify.assert_not_called()
        mock_approve.assert_not_called()
        mock_distribute.assert_not_called()
Beispiel #2
0
def test_service_properties():
    """Integration test to check properties assignment for Service."""
    response = requests.post("{}/reset".format(SDC.base_front_url))
    response.raise_for_status()
    vendor = Vendor(name="test")
    vendor.onboard()
    vsp = Vsp(name="test",
              package=open(
                  "{}/ubuntu16.zip".format(
                      os.path.dirname(os.path.abspath(__file__))), 'rb'))
    vsp.vendor = vendor
    vsp.onboard()
    vf = Vf(name='test', vsp=vsp)
    vf.onboard()
    properties = [
        Property(name="test1", property_type="string", value="123"),
        Property(name="test2", property_type="integer")
    ]
    svc = Service(name='test',
                  resources=[vf],
                  properties=properties,
                  inputs=[properties[1]])
    svc.onboard()
    service_properties = list(svc.properties)
    service_inputs = list(svc.inputs)
    assert len(service_properties) == 2
    assert len(service_inputs) == 1
Beispiel #3
0
def test_service_onboard_unknown():
    """Integration tests for Service."""
    response = requests.post("{}/reset".format(SDC.base_front_url))
    response.raise_for_status()
    vendor = Vendor(name="test")
    vendor.onboard()
    vsp = Vsp(name="test",
              package=open(
                  "{}/ubuntu16.zip".format(
                      os.path.dirname(os.path.abspath(__file__))), 'rb'))
    vsp.vendor = vendor
    vsp.onboard()
    vf = Vf(name='test', vsp=vsp)
    vf.onboard()
    svc = Service(name='test', resources=[vf])
    svc.onboard()
    assert svc.distributed
Beispiel #4
0
def test_onboard_service_distribute(mock_create, mock_add_resource,
                                    mock_checkin, mock_certify,
                                    mock_distribute):
    getter_mock = mock.Mock(wraps=Service.status.fget)
    mock_status = Service.status.getter(getter_mock)
    with mock.patch.object(Service, 'status', mock_status):
        getter_mock.side_effect = [
            const.CERTIFIED, const.CERTIFIED, const.CERTIFIED, const.CERTIFIED,
            const.CERTIFIED, const.CERTIFIED, const.CERTIFIED,
            const.DISTRIBUTED, const.DISTRIBUTED, const.DISTRIBUTED,
            const.DISTRIBUTED, const.DISTRIBUTED, const.DISTRIBUTED,
            const.DISTRIBUTED, None
        ]
        service = Service()
        service._time_wait = 0
        service.onboard()
        mock_create.assert_not_called()
        mock_add_resource.assert_not_called()
        mock_checkin.assert_not_called()
        mock_certify.assert_not_called()
        mock_distribute.assert_called_once()
Beispiel #5
0
def test_onboard_whole_service(mock_create, mock_add_resource, mock_checkin,
                               mock_certify, mock_distribute):
    getter_mock = mock.Mock(wraps=Service.status.fget)
    mock_status = Service.status.getter(getter_mock)
    with mock.patch.object(Service, 'status', mock_status):
        getter_mock.side_effect = [
            None, const.DRAFT, const.DRAFT, const.CHECKED_IN, const.CHECKED_IN,
            const.CHECKED_IN, const.CERTIFIED, const.CERTIFIED,
            const.CERTIFIED, const.CERTIFIED, const.CERTIFIED, const.CERTIFIED,
            const.DISTRIBUTED, const.DISTRIBUTED, const.DISTRIBUTED,
            const.DISTRIBUTED, const.DISTRIBUTED, const.DISTRIBUTED,
            const.DISTRIBUTED, None
        ]
        resource = SdcResource()
        service = Service(resources=[resource])
        service._time_wait = 0
        service.onboard()
        mock_create.assert_called_once()
        mock_add_resource.assert_called_once_with(resource)
        mock_checkin.assert_called_once()
        mock_certify.assert_called_once()
        mock_distribute.assert_called_once()
Beispiel #6
0
def test_onboard_service_resources(mock_create, mock_add_resource,
                                   mock_checkin, mock_submit,
                                   mock_start_certification, mock_certify,
                                   mock_approve, mock_distribute):
    getter_mock = mock.Mock(wraps=Service.status.fget)
    mock_status = Service.status.getter(getter_mock)
    with mock.patch.object(Service, 'status', mock_status):
        getter_mock.side_effect = [
            const.DRAFT, const.DRAFT, const.DISTRIBUTED, const.DISTRIBUTED,
            const.DISTRIBUTED, const.DISTRIBUTED, const.DISTRIBUTED,
            const.DISTRIBUTED, const.DISTRIBUTED, None
        ]
        resource = SdcResource()
        service = Service(resources=[resource])
        service._time_wait = 0
        service.onboard()
        mock_create.assert_not_called()
        mock_add_resource.assert_called_once_with(resource)
        mock_checkin.assert_called_once()
        mock_submit.assert_not_called()
        mock_start_certification.assert_not_called()
        mock_certify.assert_not_called()
        mock_approve.assert_not_called()
        mock_distribute.assert_not_called()
Beispiel #7
0
    logger.info("******** Set SDNC properties for VF ********")
    component = svc.get_component(vf)
    prop = component.get_property("sdnc_model_version")
    prop.value = SDNC_MODEL_VERSION
    prop = component.get_property("sdnc_artifact_name")
    prop.value = Config.SDNC_ARTIFACT_NAME
    prop = component.get_property("sdnc_model_name")
    prop.value = SDNC_MODEL_NAME
    prop = component.get_property("controller_actor")
    prop.value = "CDS"
    prop = component.get_property("skip_post_instantiation_configuration")
    prop.value = Config.SKIP_POST_INSTANTIATION

    logger.info("******** Onboard Service *******")
    svc.checkin()
    svc.onboard()

logger.info("******** Check Service Distribution *******")
distribution_completed = False
nb_try = 0
nb_try_max = 10
while distribution_completed is False and nb_try < nb_try_max:
    distribution_completed = svc.distributed
    if distribution_completed is True:
        logger.info("Service Distribution for %s is successfully finished",
                    svc.name)
        break
    logger.info("Service Distribution for %s ongoing, Wait for 60 s", svc.name)
    time.sleep(60)
    nb_try += 1