Ejemplo n.º 1
0
    def test_end_session_and_notify_dp_transition(self, mock_get_state):
        """Testing if SM steps in and out of BaicellsQRTBWaitNotifyDPState as per state map"""

        mock_get_state.return_value = MOCK_CBSD_STATE

        acs_state_machine = provision_clean_sm(state='check_wait_get_params', )

        msg = Tr069MessageBuilder.param_values_qrtb_response(
            GET_PARAMS_RESPONSE_PARAMS,
            models.GetParameterValuesResponse,
        )

        # SM should transition from check_wait_get_params to end_session -> notify_dp automatically
        # upon receiving response from the radio
        acs_state_machine.handle_tr069_message(msg)

        self.assertIsInstance(
            acs_state_machine.state,
            BaicellsQRTBNotifyDPState,
        )

        msg = Tr069MessageBuilder.get_inform(event_codes=['1 BOOT'])

        # SM should go into wait_inform state, respond with Inform response and transition to wait_empty
        acs_state_machine.handle_tr069_message(msg)

        self.assertIsInstance(acs_state_machine.state, WaitEmptyMessageState)
Ejemplo n.º 2
0
    def test_transition_depending_on_sas_enabled_flag(
        self,
        dp_mode,
        expected_state,
        mock_get_state,
    ):
        """Testing if SM steps in and out of FreedomFiOneWaitNotifyDPState as per state map depending on whether
        sas_enabled param is set to True or False in the service config

        Args:
            dp_mode: bool flag to enable or disable dp mode
            expected_state (Any): State
            mock_get_state (Any): mocking get_cbsd_state method
        """

        mock_get_state.return_value = MOCK_CBSD_STATE

        acs_state_machine = EnodebAcsStateMachineBuilder.build_acs_state_machine(
            EnodebDeviceName.FREEDOMFI_ONE)
        acs_state_machine._service.config = _get_service_config(
            dp_mode=dp_mode)
        acs_state_machine.desired_cfg = build_desired_config(
            acs_state_machine.mconfig,
            acs_state_machine.service_config,
            acs_state_machine.device_cfg,
            acs_state_machine.data_model,
            acs_state_machine.config_postprocessor,
        )

        # Need to fill these values in the device_cfg if we're going to transition to notify_dp state
        acs_state_machine.device_cfg.set_parameter(SASParameters.SAS_USER_ID,
                                                   'test_user')
        acs_state_machine.device_cfg.set_parameter(SASParameters.SAS_FCC_ID,
                                                   'test_fcc')
        acs_state_machine.device_cfg.set_parameter(ParameterName.SERIAL_NUMBER,
                                                   'test_sn')
        acs_state_machine.transition('check_wait_get_params')

        msg = Tr069MessageBuilder.param_values_qrtb_response(
            [], models.GetParameterValuesResponse)

        # SM should transition from check_wait_get_params to end_session -> notify_dp automatically
        # upon receiving response from the radio
        acs_state_machine.handle_tr069_message(msg)

        self.assertIsInstance(acs_state_machine.state, expected_state)

        msg = Tr069MessageBuilder.get_inform(event_codes=['1 BOOT'])

        # SM should go into wait_inform state, respond with Inform response and transition to FreedomFiOneGetInitState
        acs_state_machine.handle_tr069_message(msg)

        self.assertIsInstance(acs_state_machine.state,
                              FreedomFiOneGetInitState)
Ejemplo n.º 3
0
    def test_notify_dp_sets_values_received_by_dp_in_desired_config(
            self, mock_get_state) -> None:
        expected_final_param_values = {
            ParameterName.UL_BANDWIDTH: '100',
            ParameterName.DL_BANDWIDTH: '100',
            ParameterName.EARFCNUL: 55340,
            ParameterName.EARFCNDL: 55340,
            ParameterName.POWER_SPECTRAL_DENSITY: 34,
        }
        test_user = '******'
        test_fcc_id = 'fcc_id'
        test_serial_number = '123'

        acs_state_machine = EnodebAcsStateMachineBuilder.build_acs_state_machine(
            EnodebDeviceName.BAICELLS_QRTB)

        acs_state_machine.desired_cfg = EnodebConfiguration(
            BaicellsQRTBTrDataModel())

        acs_state_machine.device_cfg.set_parameter(ParameterName.SAS_USER_ID,
                                                   test_user)
        acs_state_machine.device_cfg.set_parameter(ParameterName.SAS_FCC_ID,
                                                   test_fcc_id)
        acs_state_machine.device_cfg.set_parameter(ParameterName.SERIAL_NUMBER,
                                                   test_serial_number)

        for param in expected_final_param_values:
            with self.assertRaises(KeyError):
                acs_state_machine.desired_cfg.get_parameter(param)

        # Skip previous steps not to duplicate the code
        acs_state_machine.transition('check_wait_get_params')
        req = Tr069MessageBuilder.param_values_qrtb_response(
            [],
            models.GetParameterValuesResponse,
        )

        mock_get_state.return_value = MOCK_CBSD_STATE

        resp = acs_state_machine.handle_tr069_message(req)

        mock_get_state.assert_called_with(
            CBSDRequest(serial_number=test_serial_number), )

        self.assertTrue(isinstance(resp, models.DummyInput))

        for param, value in expected_final_param_values.items():
            self.assertEqual(
                value,
                acs_state_machine.desired_cfg.get_parameter(param),
            )
Ejemplo n.º 4
0
    def test_device_and_desired_config_discrepancy_after_initial_configuration(
            self):
        """
        Testing a situation where device_cfg and desired_cfg are already present on the state machine,
        because the initial configuration of the radio has occurred, but then the configs have diverged
        (e.g. as a result of domain-proxy setting different values on the desired config)
        """
        # Skipping previous states
        acs_state_machine = provision_clean_sm('wait_get_transient_params')

        # Need to set this param on the device_cfg first, otherwise we won't be able to generate the desired_cfg
        # using 'build_desired_config' function
        acs_state_machine.device_cfg.set_parameter(ParameterName.IP_SEC_ENABLE,
                                                   'false')

        acs_state_machine.desired_cfg = build_desired_config(
            acs_state_machine.mconfig,
            acs_state_machine.service_config,
            acs_state_machine.device_cfg,
            acs_state_machine.data_model,
            acs_state_machine.config_postprocessor,
        )

        prepare_device_cfg_same_as_desired_cfg(acs_state_machine)

        # Let's say that while in 'wait_for_dp' state, the DP asked us to change this param's value in the desired_cfg
        acs_state_machine.desired_cfg.set_parameter(ParameterName.EARFCNDL, 5)

        req = Tr069MessageBuilder.param_values_qrtb_response(
            GET_TRANSIENT_PARAMS_RESPONSE_PARAMS,
            models.GetParameterValuesResponse,
        )

        # ACS asking for all params from data model
        acs_state_machine.handle_tr069_message(req)

        req = Tr069MessageBuilder.param_values_qrtb_response(
            GET_PARAMS_RESPONSE_PARAMS,
            models.GetParameterValuesResponse,
        )

        # ACS asking for object params
        acs_state_machine.handle_tr069_message(req)
        req = Tr069MessageBuilder.get_object_param_values_response(
            cell_reserved_for_operator_use='true',
            enable='true',
            is_primary='true',
            plmnid='00101',
        )

        # ACS should ask the radio to correct the only parameter that doesn't match the desired config - EARFCNDL
        resp = acs_state_machine.handle_tr069_message(req)

        self.assertIsInstance(resp, models.SetParameterValues)
        self.assertEqual(1, len(resp.ParameterList.ParameterValueStruct))
        self.assertEqual(
            'Device.Services.FAPService.1.CellConfig.LTE.RAN.RF.EARFCNDL',
            resp.ParameterList.ParameterValueStruct[0].Name,
        )
        self.assertEqual('5',
                         resp.ParameterList.ParameterValueStruct[0].Value.Data)
Ejemplo n.º 5
0
    def test_provision(self, mock_get_state) -> None:
        mock_get_state.return_value = MOCK_CBSD_STATE

        acs_state_machine = EnodebAcsStateMachineBuilder.build_acs_state_machine(
            EnodebDeviceName.BAICELLS_QRTB)
        data_model = BaicellsQRTBTrDataModel()

        # Send an Inform message, wait for an InformResponse
        inform_msg = Tr069MessageBuilder.get_qrtb_inform(
            params=DEFAULT_INFORM_PARAMS,
            oui='48BF74',
            enb_serial='1202000181186TB0006',
            event_codes=['2 PERIODIC'],
        )
        resp = acs_state_machine.handle_tr069_message(inform_msg)
        self.assertTrue(
            isinstance(resp, models.InformResponse),
            'Should respond with an InformResponse',
        )

        # Send an empty http request to kick off the rest of provisioning
        req = models.DummyInput()
        resp = acs_state_machine.handle_tr069_message(req)

        # Expect a request for transient params
        self.assertTrue(
            isinstance(resp, models.GetParameterValues),
            'State machine should be requesting param values',
        )

        should_ask_for = [p.name for p in GET_TRANSIENT_PARAMS_RESPONSE_PARAMS]
        self.verify_acs_asking_enb_for_params(should_ask_for, resp)

        # Send back some typical values
        req = Tr069MessageBuilder.param_values_qrtb_response(
            GET_TRANSIENT_PARAMS_RESPONSE_PARAMS,
            models.GetParameterValuesResponse,
        )

        # And then SM should request all parameter values from the data model
        resp = acs_state_machine.handle_tr069_message(req)
        self.assertTrue(
            isinstance(resp, models.GetParameterValues),
            'State machine should be requesting param values',
        )

        should_ask_for = [
            data_model.get_parameter(pn, ).path
            for pn in data_model.get_parameter_names()
        ]
        self.verify_acs_asking_enb_for_params(should_ask_for, resp)

        # Send back typical values
        req = Tr069MessageBuilder.param_values_qrtb_response(
            GET_PARAMS_RESPONSE_PARAMS,
            models.GetParameterValuesResponse,
        )

        # SM will be requesting object parameter values
        resp = acs_state_machine.handle_tr069_message(req)
        self.assertTrue(
            isinstance(resp, models.GetParameterValues),
            'State machine should be requesting object param vals',
        )

        should_ask_for = [
            'Device.Services.FAPService.1.CellConfig.LTE.EPC.PLMNList.1.CellReservedForOperatorUse',
            'Device.Services.FAPService.1.CellConfig.LTE.EPC.PLMNList.1.Enable',
            'Device.Services.FAPService.1.CellConfig.LTE.EPC.PLMNList.1.IsPrimary',
            'Device.Services.FAPService.1.CellConfig.LTE.EPC.PLMNList.1.PLMNID',
        ]

        self.verify_acs_asking_enb_for_params(should_ask_for, resp)

        # Send back some typical values for object parameters
        req = Tr069MessageBuilder.get_object_param_values_response(
            cell_reserved_for_operator_use='true',
            enable='true',
            is_primary='true',
            plmnid='00101',
        )
        resp = acs_state_machine.handle_tr069_message(req)

        # All the radio responses were intentionally crafted so that they match enodebd desired config.
        # Therefore the provisioning ends here. The radio goes directly into end_session -> notify_dp state
        self.assertTrue(
            isinstance(resp, models.DummyInput),
            'State machine should send back an empty message',
        )

        self.assertIsInstance(
            acs_state_machine.state,
            BaicellsQRTBNotifyDPState,
        )