Example #1
0
    def setUpClass(cls):
        """
        Starts the thread which launches ryu apps

        Create a testing bridge, add a port, setup the port interfaces. Then
        launch the ryu apps for testing pipelined. Gets the references
        to apps launched by using futures.
        """
        super(VlanLearnTest, cls).setUpClass()
        warnings.simplefilter('ignore')
        cls.service_manager = create_service_manager([],
                                                     ['ue_mac', 'vlan_learn'])

        vlan_learn_controller_reference = Future()
        testing_controller_reference = Future()
        test_setup = TestSetup(
            apps=[
                PipelinedController.VlanLearn, PipelinedController.Testing,
                PipelinedController.StartupFlows
            ],
            references={
                PipelinedController.VlanLearn: vlan_learn_controller_reference,
                PipelinedController.Testing: testing_controller_reference,
                PipelinedController.StartupFlows: Future(),
            },
            config={
                'bridge_name': cls.BRIDGE,
                'bridge_ip_address': cls.BRIDGE_IP,
                'internal_ip_subnet': '192.168.0.0/16',
                'ovs_gtp_port_number': 32768,
                'clean_restart': True,
            },
            mconfig=None,
            loop=None,
            service_manager=cls.service_manager,
            integ_test=False,
        )

        BridgeTools.create_bridge(cls.BRIDGE, cls.IFACE)

        cls.thread = start_ryu_app_thread(test_setup)
        cls.vlan_learn_controller = vlan_learn_controller_reference.result()
        cls.testing_controller = testing_controller_reference.result()
Example #2
0
    def setUpClass(cls):
        """
        Starts the thread which launches ryu apps

        Create a testing bridge, add a port, setup the port interfaces. Then
        launch the ryu apps for testing pipelined. Gets the references
        to apps launched by using futures.
        """
        super(InOutTestNonNATBasicFlows, cls).setUpClass()
        warnings.simplefilter('ignore')
        cls.service_manager = create_service_manager([])

        inout_controller_reference = Future()
        testing_controller_reference = Future()
        test_setup = TestSetup(
            apps=[
                PipelinedController.InOut, PipelinedController.Testing,
                PipelinedController.StartupFlows
            ],
            references={
                PipelinedController.InOut: inout_controller_reference,
                PipelinedController.Testing: testing_controller_reference,
                PipelinedController.StartupFlows: Future(),
            },
            config={
                'bridge_name': cls.BRIDGE,
                'bridge_ip_address': cls.BRIDGE_IP,
                'ovs_gtp_port_number': 32768,
                'clean_restart': True,
                'enable_nat': False,
                'uplink_gw_mac': '11:22:33:44:55:66'
            },
            mconfig=None,
            loop=None,
            service_manager=cls.service_manager,
            integ_test=False,
        )

        BridgeTools.create_bridge(cls.BRIDGE, cls.IFACE)

        cls.thread = start_ryu_app_thread(test_setup)
        cls.inout_controller = inout_controller_reference.result()
        cls.testing_controller = testing_controller_reference.result()
Example #3
0
    def __init__(self):
        self.static_rules = PolicyRuleDict()

        # Local sessiond
        self.sessiond = session_manager_pb2_grpc.LocalSessionManagerStub(
            ServiceRegistry.get_rpc_channel("sessiond",
                                            ServiceRegistry.LOCAL), )

        self.proxy_responder = session_manager_pb2_grpc.SessionProxyResponderStub(
            ServiceRegistry.get_rpc_channel("sessiond",
                                            ServiceRegistry.LOCAL), )

        # Mock session controller server
        cloud_port = load_service_config("sessiond")["local_controller_port"]
        self.controller = MockSessionManager()
        self.server = grpc.server(ThreadPoolExecutor(max_workers=10))
        session_manager_pb2_grpc.add_CentralSessionControllerServicer_to_server(
            self.controller, self.server)
        self.server.add_insecure_port('127.0.0.1:{}'.format(cloud_port))
        self.server.start()

        # Add new controller to bridge
        BridgeTools.add_controller_to_bridge(self.BRIDGE, self.CONTROLLER_PORT)

        # Start ryu test controller for adding flows
        testing_controller_reference = Future()
        test_setup = TestSetup(
            apps=[PipelinedController.Testing],
            references={
                PipelinedController.Testing: testing_controller_reference
            },
            config={
                'bridge_name': self.BRIDGE,
                'bridge_ip_address': '192.168.128.1',
                'controller_port': self.CONTROLLER_PORT,
            },
            mconfig=None,
            loop=None,
            integ_test=True,
        )
        self.thread = start_ryu_app_thread(test_setup)
        self.testing_controller = testing_controller_reference.result()
Example #4
0
    def setUpClass(cls):
        """
        Starts the thread which launches ryu apps

        Create a testing bridge, add a port, setup the port interfaces. Then
        launch the ryu apps for testing pipelined. Gets the references
        to apps launched by using futures.
        """
        super(ClassifierTest, cls).setUpClass()
        warnings.simplefilter('ignore')
        cls.service_manager = create_service_manager([], ['classifier'])
        classifier_reference = Future()
        testing_controller_reference = Future()
        test_setup = TestSetup(
            apps=[
                PipelinedController.Classifier, PipelinedController.Testing,
                PipelinedController.StartupFlows
            ],
            references={
                PipelinedController.Classifier: classifier_reference,
                PipelinedController.Testing: testing_controller_reference,
                PipelinedController.StartupFlows: Future(),
            },
            config={
                'bridge_name': cls.BRIDGE,
                'bridge_ip_address': cls.BRIDGE_IP,
                'ovs_gtp_port_number': 32768,
                'ovs_mtr_port_number': 15577,
                'mtr_ip': cls.MTR_IP,
                'ovs_internal_sampling_port_number': 15578,
                'ovs_internal_sampling_fwd_tbl_number': 201,
                'clean_restart': True,
            },
            mconfig=None,
            loop=None,
            service_manager=cls.service_manager,
            integ_test=False,
        )
        BridgeTools.create_bridge(cls.BRIDGE, cls.IFACE)
        cls.thread = start_ryu_app_thread(test_setup)
        cls.classifier_controller = classifier_reference.result()
        cls.testing_controller = testing_controller_reference.result()
Example #5
0
    def setUpClass(cls):
        """
        Starts the thread which launches ryu apps

        Create a testing bridge, add a port, setup the port interfaces. Then
        launch the ryu apps for testing pipelined. Gets the references
        to apps launched by using futures.
        """
        super(UEMacAddressTest, cls).setUpClass()
        warnings.simplefilter('ignore')
        cls.service_manager = create_service_manager([], include_ue_mac=True)
        cls._tbl_num = cls.service_manager.get_table_num(
            UEMacAddressController.APP_NAME)
        ue_mac_controller_reference = Future()
        testing_controller_reference = Future()
        test_setup = TestSetup(
            apps=[PipelinedController.UEMac, PipelinedController.Testing],
            references={
                PipelinedController.UEMac: ue_mac_controller_reference,
                PipelinedController.Testing: testing_controller_reference,
                PipelinedController.Arp: Future(),
            },
            config={
                'setup_type': 'CWF',
                'allow_unknown_arps': False,
                'bridge_name': cls.BRIDGE,
                'bridge_ip_address': cls.BRIDGE_IP,
                'ovs_gtp_port_number': 32768,
            },
            mconfig=None,
            loop=None,
            service_manager=cls.service_manager,
            integ_test=False,
        )

        BridgeTools.create_bridge(cls.BRIDGE, cls.IFACE)

        cls.thread = start_ryu_app_thread(test_setup)
        cls.ue_mac_controller = ue_mac_controller_reference.result()
        cls.testing_controller = testing_controller_reference.result()
Example #6
0
    def setUpClass(cls, *_):
        """
        Starts the thread which launches ryu apps

        Create a testing bridge, add a port, setup the port interfaces. Then
        launch the ryu apps for testing pipelined. Gets the references
        to apps launched by using futures, mocks the redis policy_dictionary
        of gy_controller
        """
        super(GYTableTest, cls).setUpClass()
        warnings.simplefilter('ignore')
        cls.service_manager = create_service_manager(
            [PipelineD.ENFORCEMENT], ['arpd'],
        )
        cls._tbl_num = cls.service_manager.get_table_num(
            GYController.APP_NAME,
        )

        gy_controller_reference = Future()
        testing_controller_reference = Future()
        test_setup = TestSetup(
            apps=[
                PipelinedController.GY,
                PipelinedController.Arp,
                PipelinedController.Testing,
                PipelinedController.StartupFlows,
            ],
            references={
                PipelinedController.GY:
                    gy_controller_reference,
                PipelinedController.Arp:
                    Future(),
                PipelinedController.Testing:
                    testing_controller_reference,
                PipelinedController.StartupFlows:
                    Future(),
            },
            config={
                'setup_type': 'CWF',
                'allow_unknown_arps': False,
                'bridge_name': cls.BRIDGE,
                'bridge_ip_address': '192.168.128.1',
                'internal_ip_subnet': '192.168.0.0/16',
                'nat_iface': 'eth2',
                'enodeb_iface': 'eth1',
                'enable_queue_pgm': False,
                'local_ue_eth_addr': False,
                'qos': {'enable': False},
                'dpi': {'enable': False},
                'clean_restart': True,
            },
            mconfig=PipelineD(
                ue_ip_block='192.168.128.0/24',
            ),
            loop=None,
            service_manager=cls.service_manager,
            integ_test=False,
        )

        BridgeTools.create_bridge(cls.BRIDGE, cls.IFACE)

        cls.thread = start_ryu_app_thread(test_setup)

        cls.gy_controller = gy_controller_reference.result()
        cls.testing_controller = testing_controller_reference.result()

        cls.gy_controller._redirect_manager._save_redirect_entry = MagicMock()
Example #7
0
    def setUpClass(cls):
        """
        Starts the thread which launches ryu apps

        Create a testing bridge, add a port, setup the port interfaces. Then
        launch the ryu apps for testing pipelined. Gets the references
        to apps launched by using futures, mocks the redis policy_dictionary
        of enforcement_controller
        """
        super(EnforcementTableHeTest, cls).setUpClass()
        warnings.simplefilter('ignore')
        cls.service_manager = create_service_manager([PipelineD.ENFORCEMENT],
                                                     ['proxy'])
        cls._tbl_num = cls.service_manager.get_table_num(
            EnforcementController.APP_NAME)
        BridgeTools.create_bridge(cls.BRIDGE, cls.IFACE)

        BridgeTools.create_veth_pair(cls.VETH, cls.VETH_NS)
        BridgeTools.add_ovs_port(cls.BRIDGE, cls.VETH, cls.PROXY_PORT)

        enforcement_controller_reference = Future()
        testing_controller_reference = Future()
        he.activate_he_urls_for_ue = mocked_activate_he_urls_for_ue
        he.deactivate_he_urls_for_ue = mocked_deactivate_he_urls_for_ue

        test_setup = TestSetup(apps=[
            PipelinedController.Enforcement,
            PipelinedController.HeaderEnrichment, PipelinedController.Testing,
            PipelinedController.StartupFlows
        ],
                               references={
                                   PipelinedController.Enforcement:
                                   enforcement_controller_reference,
                                   PipelinedController.HeaderEnrichment:
                                   cls.he_controller_reference,
                                   PipelinedController.Testing:
                                   testing_controller_reference,
                                   PipelinedController.StartupFlows: Future(),
                               },
                               config={
                                   'bridge_name': cls.BRIDGE,
                                   'bridge_ip_address': '192.168.128.1',
                                   'nat_iface': 'eth2',
                                   'enodeb_iface': 'eth1',
                                   'qos': {
                                       'enable': False
                                   },
                                   'clean_restart': True,
                                   'uplink_port': 20,
                                   'proxy_port_name': cls.VETH,
                                   'enable_nat': True,
                                   'ovs_gtp_port_number': 10,
                               },
                               mconfig=PipelineD(),
                               loop=None,
                               service_manager=cls.service_manager,
                               integ_test=False)

        cls.thread = start_ryu_app_thread(test_setup)

        cls.enforcement_controller = enforcement_controller_reference.result()
        cls.testing_controller = testing_controller_reference.result()
Example #8
0
    def setUpClass(cls):
        """
        Starts the thread which launches ryu apps

        Create a testing bridge, add a port, setup the port interfaces. Then
        launch the ryu apps for testing pipelined. Gets the references
        to apps launched by using futures.
        """
        super(UplinkBridgeWithNonNATTest_IP_VLAN, cls).setUpClass()
        warnings.simplefilter('ignore')
        cls.service_manager = create_service_manager([])

        uplink_bridge_controller_reference = Future()
        testing_controller_reference = Future()
        test_setup = TestSetup(
            apps=[
                PipelinedController.UplinkBridge, PipelinedController.Testing,
                PipelinedController.StartupFlows
            ],
            references={
                PipelinedController.UplinkBridge:
                uplink_bridge_controller_reference,
                PipelinedController.Testing: testing_controller_reference,
                PipelinedController.StartupFlows: Future(),
            },
            config={
                'bridge_name': cls.BRIDGE,
                'bridge_ip_address': cls.BRIDGE_IP,
                'ovs_gtp_port_number': 32768,
                'clean_restart': True,
                'enable_nat': False,
                'uplink_bridge': cls.UPLINK_BRIDGE,
                'uplink_eth_port_name': cls.UPLINK_ETH_PORT,
                'virtual_mac': '02:bb:5e:36:06:4b',
                'uplink_patch': cls.UPLINK_PATCH,
                'uplink_dhcp_port': cls.UPLINK_DHCP,
                'sgi_management_iface_vlan': cls.VLAN_TAG,
                'sgi_management_iface_ip_addr': cls.SGi_IP,
                'dev_vlan_in': "test_v_in",
                'dev_vlan_out': "test_v_out",
            },
            mconfig=None,
            loop=None,
            service_manager=cls.service_manager,
            integ_test=False,
        )

        BridgeTools.create_bridge(cls.BRIDGE, cls.BRIDGE)
        # validate vlan id set
        vlan = "10"
        BridgeTools.create_bridge(cls.UPLINK_BRIDGE, cls.UPLINK_BRIDGE)

        set_ip_cmd = [
            "ip", "addr", "replace", "2.33.44.6", "dev", cls.UPLINK_BRIDGE
        ]
        subprocess.check_call(set_ip_cmd)

        BridgeTools.create_internal_iface(cls.UPLINK_BRIDGE, cls.UPLINK_DHCP,
                                          None)
        BridgeTools.create_internal_iface(cls.UPLINK_BRIDGE, cls.UPLINK_PATCH,
                                          None)
        BridgeTools.create_internal_iface(cls.UPLINK_BRIDGE,
                                          cls.UPLINK_ETH_PORT, None)

        cls.thread = start_ryu_app_thread(test_setup)
        cls.uplink_br_controller = uplink_bridge_controller_reference.result()

        cls.testing_controller = testing_controller_reference.result()
Example #9
0
    def setUpClass(cls):
        """
        Starts the thread which launches ryu apps

        Create a testing bridge, add a port, setup the port interfaces. Then
        launch the ryu apps for testing pipelined. Gets the references
        to apps launched by using futures.
        """
        super(UplinkBridgeWithNonNatUplinkConnect_Test, cls).setUpClass()
        warnings.simplefilter('ignore')
        cls.service_manager = create_service_manager([])

        cls._setup_vlan_network("0")

        BridgeTools.create_bridge(cls.UPLINK_BRIDGE, cls.UPLINK_BRIDGE)
        BridgeTools.create_internal_iface(cls.UPLINK_BRIDGE, cls.UPLINK_DHCP,
                                          None)
        BridgeTools.create_internal_iface(cls.UPLINK_BRIDGE, cls.UPLINK_PATCH,
                                          None)

        check_connectivity(cls.ROUTER_IP, cls.UPLINK_ETH_PORT)

        # this is setup after AGW boot up in NATed mode.
        uplink_bridge_controller_reference = Future()
        testing_controller_reference = Future()
        test_setup = TestSetup(
            apps=[
                PipelinedController.UplinkBridge, PipelinedController.Testing,
                PipelinedController.StartupFlows
            ],
            references={
                PipelinedController.UplinkBridge:
                uplink_bridge_controller_reference,
                PipelinedController.Testing: testing_controller_reference,
                PipelinedController.StartupFlows: Future(),
            },
            config={
                'bridge_name': cls.BRIDGE,
                'bridge_ip_address': cls.BRIDGE_IP,
                'ovs_gtp_port_number': 32768,
                'clean_restart': True,
                'enable_nat': False,
                'uplink_bridge': cls.UPLINK_BRIDGE,
                'uplink_eth_port_name': cls.UPLINK_ETH_PORT,
                'virtual_mac': '02:bb:5e:36:06:4b',
                'uplink_patch': cls.UPLINK_PATCH,
                'uplink_dhcp_port': cls.UPLINK_DHCP,
                'sgi_management_iface_vlan': "",
                'ovs_vlan_workaround': True,
                'dev_vlan_in': "testv1_in",
                'dev_vlan_out': "testv1_out",
            },
            mconfig=None,
            loop=None,
            service_manager=cls.service_manager,
            integ_test=False,
        )

        BridgeTools.create_bridge(cls.BRIDGE, cls.BRIDGE)

        cls.thread = start_ryu_app_thread(test_setup)
        cls.uplink_br_controller = uplink_bridge_controller_reference.result()

        cls.testing_controller = testing_controller_reference.result()
Example #10
0
    def setUpClass(cls):
        """
        Starts the thread which launches ryu apps

        Create a testing bridge, add a port, setup the port interfaces. Then
        launch the ryu apps for testing pipelined. Gets the references
        to apps launched by using futures.
        """
        super(AccessControlTestLTE, cls).setUpClass()
        warnings.simplefilter('ignore')
        cls.service_manager = create_service_manager([],
            ['access_control'])
        cls._tbl_num = cls.service_manager.get_table_num(
            AccessControlController.APP_NAME)

        access_control_controller_reference = Future()
        testing_controller_reference = Future()
        test_setup = TestSetup(
            apps=[PipelinedController.AccessControl,
                  PipelinedController.Testing,
                  PipelinedController.StartupFlows],
            references={
                PipelinedController.AccessControl:
                    access_control_controller_reference,
                PipelinedController.Testing:
                    testing_controller_reference,
                PipelinedController.StartupFlows:
                    Future(),
            },
            config={
                'setup_type': 'LTE',
                'allow_unknown_arps': False,
                'bridge_name': cls.BRIDGE,
                'bridge_ip_address': cls.BRIDGE_IP,
                'nat_iface': 'eth2',
                'enodeb_iface': 'eth1',
                'enable_queue_pgm': False,
                'access_control': {
                    'ip_blacklist': [
                        {
                            'ip': cls.INBOUND_TEST_IP,
                            'direction': 'inbound',
                        },
                        {
                            'ip': cls.OUTBOUND_TEST_IP,
                            'direction': 'outbound',
                        },
                        {
                            'ip': cls.BOTH_DIR_TEST_IP,
                        },
                    ]
                },
                'clean_restart': True,
            },
            mconfig=PipelineD(
                allowed_gre_peers=[{'ip': '1.2.3.4/24', 'key': 123}],
            ),
            loop=None,
            service_manager=cls.service_manager,
            integ_test=False,
        )

        BridgeTools.create_bridge(cls.BRIDGE, cls.IFACE)

        cls.thread = start_ryu_app_thread(test_setup)
        cls.access_control_controller = \
            access_control_controller_reference.result()
        cls.testing_controller = testing_controller_reference.result()
Example #11
0
    def setUpClass(cls):
        """
        Starts the thread which launches ryu apps

        Create a testing bridge, add a port, setup the port interfaces. Then
        launch the ryu apps for testing pipelined. Gets the references
        to apps launched by using futures.
        """
        super(UplinkBridgeWithNonNATTest, cls).setUpClass()
        warnings.simplefilter('ignore')
        cls.service_manager = create_service_manager([])

        uplink_bridge_controller_reference = Future()
        testing_controller_reference = Future()
        test_setup = TestSetup(
            apps=[
                PipelinedController.UplinkBridge, PipelinedController.Testing,
                PipelinedController.StartupFlows
            ],
            references={
                PipelinedController.UplinkBridge:
                uplink_bridge_controller_reference,
                PipelinedController.Testing: testing_controller_reference,
                PipelinedController.StartupFlows: Future(),
            },
            config={
                'bridge_name': cls.BRIDGE,
                'bridge_ip_address': cls.BRIDGE_IP,
                'ovs_gtp_port_number': 32768,
                'clean_restart': True,
                'enable_nat': False,
                'uplink_bridge': cls.UPLINK_BRIDGE,
                'uplink_eth_port_name': cls.UPLINK_ETH_PORT,
                'virtual_mac': '02:bb:5e:36:06:4b',
                'uplink_patch': cls.UPLINK_PATCH,
                'uplink_dhcp_port': cls.UPLINK_DHCP,
                'sgi_management_iface_vlan': "",
                'dev_vlan_in': cls.VLAN_DEV_IN,
                'dev_vlan_out': cls.VLAN_DEV_OUT,
                'ovs_vlan_workaround': False,
                'sgi_management_iface_ip_addr': '1.1.11.1',
            },
            mconfig=None,
            loop=None,
            service_manager=cls.service_manager,
            integ_test=False,
        )

        BridgeTools.create_bridge(cls.BRIDGE, cls.BRIDGE)
        BridgeTools.create_bridge(cls.UPLINK_BRIDGE, cls.UPLINK_BRIDGE)

        BridgeTools.create_veth_pair(cls.VLAN_DEV_IN, cls.VLAN_DEV_OUT)
        # Add to OVS,
        BridgeTools.add_ovs_port(cls.UPLINK_BRIDGE, cls.VLAN_DEV_IN, "70")
        BridgeTools.add_ovs_port(cls.UPLINK_BRIDGE, cls.VLAN_DEV_OUT, "71")

        # dummy uplink interface
        vlan = "10"

        BridgeTools.create_internal_iface(cls.UPLINK_BRIDGE, cls.UPLINK_DHCP,
                                          None)
        BridgeTools.create_internal_iface(cls.UPLINK_BRIDGE, cls.UPLINK_PATCH,
                                          None)
        BridgeTools.create_internal_iface(cls.UPLINK_BRIDGE,
                                          cls.UPLINK_ETH_PORT, None)

        cls.thread = start_ryu_app_thread(test_setup)
        cls.uplink_br_controller = uplink_bridge_controller_reference.result()

        cls.testing_controller = testing_controller_reference.result()
Example #12
0
    def setUpClass(cls):
        """
        Starts the thread which launches ryu apps

        Create a testing bridge, add a port, setup the port interfaces. Then
        launch the ryu apps for testing pipelined. Gets the references
        to apps launched by using futures.
        """
        egress.get_mobilityd_gw_info = mocked_get_mobilityd_gw_info
        egress.set_mobilityd_gw_info = mocked_set_mobilityd_gw_info

        super(InOutTestNonNATBasicFlowsIPv6, cls).setUpClass()
        warnings.simplefilter('ignore')
        cls.service_manager = create_service_manager([])

        ingress_controller_reference = Future()
        middle_controller_reference = Future()
        egress_controller_reference = Future()
        testing_controller_reference = Future()
        test_setup = TestSetup(
            apps=[
                PipelinedController.Ingress,
                PipelinedController.Middle,
                PipelinedController.Egress,
                PipelinedController.Testing,
                PipelinedController.StartupFlows,
            ],
            references={
                PipelinedController.Ingress:
                    ingress_controller_reference,
                PipelinedController.Middle:
                    middle_controller_reference,
                PipelinedController.Egress:
                    egress_controller_reference,
                PipelinedController.Testing:
                    testing_controller_reference,
                PipelinedController.StartupFlows:
                    Future(),
            },
            config={
                'setup_type': 'LTE',
                'bridge_name': cls.BRIDGE,
                'bridge_ip_address': cls.BRIDGE_IP,
                'ovs_gtp_port_number': 32768,
                'clean_restart': True,
                'enable_nat': False,
                'uplink_gw_mac': '11:22:33:44:55:11',
                'uplink_port': OFPP_LOCAL,
                'non_nat_gw_probe_frequency': 0.5,
            },
            mconfig=None,
            loop=None,
            service_manager=cls.service_manager,
            integ_test=False,
        )

        BridgeTools.create_bridge(cls.BRIDGE, cls.IFACE)

        cls.thread = start_ryu_app_thread(test_setup)
        cls.ingress_controller = ingress_controller_reference.result()
        cls.middle_controller = middle_controller_reference.result()
        cls.egress_controller = egress_controller_reference.result()
        cls.testing_controller = testing_controller_reference.result()
Example #13
0
    def setUpClass(cls):
        """
        Starts the thread which launches ryu apps

        Create a testing bridge, add a port, setup the port interfaces. Then
        launch the ryu apps for testing pipelined. Gets the references
        to apps launched by using futures.
        """
        super(LIMirrorTest, cls).setUpClass()
        warnings.simplefilter('ignore')
        cls.service_manager = create_service_manager([], ['li_mirror'])

        inout_controller_reference = Future()
        li_mirror_reference = Future()
        testing_controller_reference = Future()
        test_setup = TestSetup(
            apps=[
                PipelinedController.InOut,
                PipelinedController.LIMirror,
                PipelinedController.Testing,
                PipelinedController.StartupFlows,
            ],
            references={
                PipelinedController.InOut: inout_controller_reference,
                PipelinedController.LIMirror: li_mirror_reference,
                PipelinedController.Testing: testing_controller_reference,
                PipelinedController.StartupFlows: Future(),
            },
            config={
                'setup_type': 'CWF',
                'bridge_name': cls.BRIDGE,
                'bridge_ip_address': cls.BRIDGE_IP,
                'internal_ip_subnet': '192.168.0.0/16',
                'ovs_gtp_port_number': 32768,
                'clean_restart': True,
                'li_mirror_all': True,
                'li_local_iface': cls.LI_LOCAL_IFACE,
                'li_dst_iface': cls.LI_DST_IFACE,
                'uplink_port': OFPP_LOCAL,
            },
            mconfig=None,
            loop=None,
            service_manager=cls.service_manager,
            integ_test=False,
        )

        BridgeTools.create_bridge(cls.BRIDGE, cls.IFACE)
        BridgeTools.create_internal_iface(
            cls.BRIDGE,
            cls.LI_LOCAL_IFACE,
            cls.LI_LOCAL_IP,
        )
        BridgeTools.create_internal_iface(
            cls.BRIDGE,
            cls.LI_DST_IFACE,
            cls.LI_DST_IP,
        )

        cls.thread = start_ryu_app_thread(test_setup)
        cls.inout_controller = inout_controller_reference.result()
        cls.li_controller = li_mirror_reference.result()
        cls.testing_controller = testing_controller_reference.result()
Example #14
0
    def setUpClass(cls):
        """
        Starts the thread which launches ryu apps

        Create a testing bridge, add a port, setup the port interfaces. Then
        launch the ryu apps for testing pipelined. Gets the references
        to apps launched by using futures, mocks the redis policy_dictionary
        of enforcement_controller
        """
        super(RestartResilienceTest, cls).setUpClass()
        warnings.simplefilter('ignore')
        cls._static_rule_dict = {}
        cls.service_manager = create_service_manager([PipelineD.ENFORCEMENT])
        cls._enforcement_tbl_num = cls.service_manager.get_table_num(
            EnforcementController.APP_NAME)
        cls._tbl_num = cls.service_manager.get_table_num(
            EnforcementController.APP_NAME)

        enforcement_controller_reference = Future()
        testing_controller_reference = Future()
        enf_stat_ref = Future()
        startup_flows_ref = Future()

        def mock_thread_safe(cmd, body):
            cmd(body)

        loop_mock = MagicMock()
        loop_mock.call_soon_threadsafe = mock_thread_safe

        test_setup = TestSetup(apps=[
            PipelinedController.Enforcement, PipelinedController.Testing,
            PipelinedController.Enforcement_stats,
            PipelinedController.StartupFlows
        ],
                               references={
                                   PipelinedController.Enforcement:
                                   enforcement_controller_reference,
                                   PipelinedController.Testing:
                                   testing_controller_reference,
                                   PipelinedController.Enforcement_stats:
                                   enf_stat_ref,
                                   PipelinedController.StartupFlows:
                                   startup_flows_ref,
                               },
                               config={
                                   'bridge_name': cls.BRIDGE,
                                   'bridge_ip_address': cls.BRIDGE_IP_ADDRESS,
                                   'enforcement': {
                                       'poll_interval': 5
                                   },
                                   'nat_iface': 'eth2',
                                   'enodeb_iface': 'eth1',
                                   'qos': {
                                       'enable': False
                                   },
                                   'clean_restart': False,
                               },
                               mconfig=PipelineD(),
                               loop=loop_mock,
                               service_manager=cls.service_manager,
                               integ_test=False,
                               rpc_stubs={'sessiond': MagicMock()})

        BridgeTools.create_bridge(cls.BRIDGE, cls.IFACE)

        cls.thread = start_ryu_app_thread(test_setup)

        cls.enforcement_controller = enforcement_controller_reference.result()
        cls.enforcement_stats_controller = enf_stat_ref.result()
        cls.startup_flows_contoller = startup_flows_ref.result()
        cls.testing_controller = testing_controller_reference.result()

        cls.enforcement_stats_controller._policy_dict = cls._static_rule_dict
        cls.enforcement_stats_controller._report_usage = MagicMock()

        cls.enforcement_controller._policy_dict = cls._static_rule_dict
        cls.enforcement_controller._redirect_manager._save_redirect_entry =\
            MagicMock()
    def setUpClass(cls):
        """
        Starts the thread which launches ryu apps

        Create a testing bridge, add a port, setup the port interfaces. Then
        launch the ryu apps for testing pipelined. Gets the references
        to apps launched by using futures, mocks the redis policy_dictionary
        of dpi_controller
        """
        super(InternalPktIpfixExportTest, cls).setUpClass()
        warnings.simplefilter('ignore')
        cls._static_rule_dict = {}
        cls.service_manager = create_service_manager(
            [PipelineD.DPI],
            ['ue_mac', 'ipfix'],
        )
        cls._tbl_num = cls.service_manager.get_table_num(
            DPIController.APP_NAME, )

        ue_mac_controller_reference = Future()
        dpi_controller_reference = Future()
        ipfix_controller_reference = Future()
        testing_controller_reference = Future()
        test_setup = TestSetup(
            apps=[
                PipelinedController.UEMac,
                PipelinedController.DPI,
                PipelinedController.IPFIX,
                PipelinedController.Testing,
                PipelinedController.StartupFlows,
            ],
            references={
                PipelinedController.UEMac: ue_mac_controller_reference,
                PipelinedController.DPI: dpi_controller_reference,
                PipelinedController.Arp: Future(),
                PipelinedController.IPFIX: ipfix_controller_reference,
                PipelinedController.Testing: testing_controller_reference,
                PipelinedController.StartupFlows: Future(),
            },
            config={
                'bridge_name': cls.BRIDGE,
                'bridge_ip_address': '192.168.128.1',
                'internal_ip_subnet': '192.168.0.0/16',
                'nat_iface': 'eth2',
                'enodeb_iface': 'eth1',
                'enable_queue_pgm': False,
                'clean_restart': True,
                'setup_type': 'CWF',
                'dpi': {
                    'enabled': True,
                    'mon_port': 'mon1',
                    'mon_port_number': 32769,
                    'idle_timeout': 42,
                },
                'ipfix': {
                    'enabled': True,
                    'probability': 65,
                    'collector_set_id': 1,
                    'collector_ip': '1.1.1.1',
                    'collector_port': 65010,
                    'cache_timeout': 60,
                    'obs_domain_id': 1,
                    'obs_point_id': 1,
                },
                'conntrackd': {
                    'enabled': True,
                },
                'ovs_gtp_port_number': 32768,
            },
            mconfig=PipelineD(),
            loop=None,
            service_manager=cls.service_manager,
            integ_test=False,
        )

        BridgeTools.create_bridge(cls.BRIDGE, cls.IFACE)
        BridgeTools.create_internal_iface(
            cls.BRIDGE,
            cls.DPI_PORT,
            cls.DPI_IP,
        )

        cls.thread = start_ryu_app_thread(test_setup)

        cls.ue_mac_controller = ue_mac_controller_reference.result()
        cls.dpi_controller = dpi_controller_reference.result()
        cls.ipfix_controller = ipfix_controller_reference.result()
        cls.testing_controller = testing_controller_reference.result()

        cls.dpi_controller._policy_dict = cls._static_rule_dict
Example #16
0
    def setUpClass(cls, *_):
        """
        Starts the thread which launches ryu apps

        Create a testing bridge, add a port, setup the port interfaces. Then
        launch the ryu apps for testing pipelined. Gets the references
        to apps launched by using futures.
        """
        super(UEMacAddressTest, cls).setUpClass()
        warnings.simplefilter('ignore')
        cls.service_manager = create_service_manager([],
            ['ue_mac', 'arpd', 'check_quota'])
        check_quota_controller_reference = Future()
        testing_controller_reference = Future()
        arp_controller_reference = Future()
        test_setup = TestSetup(
            apps=[PipelinedController.UEMac,
                  PipelinedController.Arp,
                  PipelinedController.CheckQuotaController,
                  PipelinedController.Testing,
                  PipelinedController.StartupFlows],
            references={
                PipelinedController.CheckQuotaController:
                    check_quota_controller_reference,
                PipelinedController.Testing:
                    testing_controller_reference,
                PipelinedController.UEMac:
                    Future(),
                PipelinedController.Arp:
                    arp_controller_reference,
                PipelinedController.StartupFlows:
                    Future(),
            },
            config={
                'setup_type': 'CWF',
                'allow_unknown_arps': False,
                'bridge_name': cls.BRIDGE,
                'bridge_ip_address': cls.BRIDGE_IP,
                'internal_ip_subnet': '192.168.0.0/16',
                'ovs_gtp_port_number': 32768,
                'has_quota_port': 50001,
                'no_quota_port': 50002,
                'quota_check_ip': '1.2.3.4',
                'local_ue_eth_addr': False,
                'clean_restart': True,
                'dpi': {
                    'enabled': False,
                    'mon_port': 'mon1',
                    'mon_port_number': 32769,
                    'idle_timeout': 42,
                },
            },
            mconfig=PipelineD(
                ue_ip_block='192.168.128.0/24',
            ),
            loop=None,
            service_manager=cls.service_manager,
            integ_test=False,
        )

        BridgeTools.create_bridge(cls.BRIDGE, cls.IFACE)
        BridgeTools.create_internal_iface(cls.BRIDGE, cls.DPI_PORT,
                                          cls.DPI_IP)

        cls.thread = start_ryu_app_thread(test_setup)
        cls.check_quota_controller = check_quota_controller_reference.result()
        cls.arp_controlelr = arp_controller_reference.result()
        cls.testing_controller = testing_controller_reference.result()
Example #17
0
    def setUpNetworkAndController(self,
                                  vlan: str = "",
                                  non_nat_arp_egress_port: str = None,
                                  gw_mac_addr="ff:ff:ff:ff:ff:ff"):
        """
        Starts the thread which launches ryu apps

        Create a testing bridge, add a port, setup the port interfaces. Then
        launch the ryu apps for testing pipelined. Gets the references
        to apps launched by using futures.
        """
        global gw_info_map
        gw_info_map.clear()
        hub.sleep(2)

        cls = self.__class__
        super(InOutNonNatTest, cls).setUpClass()
        inout.get_mobilityd_gw_info = mocked_get_mobilityd_gw_info
        inout.set_mobilityd_gw_info = mocked_set_mobilityd_gw_info

        warnings.simplefilter('ignore')
        cls.setup_uplink_br()

        if vlan != "":
            cls._setup_vlan_network(vlan)

        cls.service_manager = create_service_manager([])

        inout_controller_reference = Future()
        testing_controller_reference = Future()

        if non_nat_arp_egress_port is None:
            non_nat_arp_egress_port = cls.DHCP_PORT

        patch_up_port_no = BridgeTools.get_ofport('patch-up')
        test_setup = TestSetup(apps=[
            PipelinedController.InOut, PipelinedController.Testing,
            PipelinedController.StartupFlows
        ],
                               references={
                                   PipelinedController.InOut:
                                   inout_controller_reference,
                                   PipelinedController.Testing:
                                   testing_controller_reference,
                                   PipelinedController.StartupFlows: Future(),
                               },
                               config={
                                   'setup_type': 'LTE',
                                   'bridge_name': cls.BRIDGE,
                                   'bridge_ip_address': cls.BRIDGE_IP,
                                   'ovs_gtp_port_number': 32768,
                                   'clean_restart': True,
                                   'enable_nat': False,
                                   'non_nat_gw_probe_frequency': 0.5,
                                   'non_nat_arp_egress_port':
                                   non_nat_arp_egress_port,
                                   'uplink_port': patch_up_port_no,
                                   'uplink_gw_mac': gw_mac_addr,
                               },
                               mconfig=None,
                               loop=None,
                               service_manager=cls.service_manager,
                               integ_test=False)

        BridgeTools.create_bridge(cls.BRIDGE, cls.IFACE)
        subprocess.Popen(["ifconfig", cls.UPLINK_BR, "192.168.128.41"]).wait()
        cls.thread = start_ryu_app_thread(test_setup)
        cls.inout_controller = inout_controller_reference.result()

        cls.testing_controller = testing_controller_reference.result()
Example #18
0
    def setUpClass(cls, *_):
        """
        Starts the thread which launches ryu apps

        Create a testing bridge, add a port, setup the port interfaces. Then
        launch the ryu apps for testing pipelined. Gets the references
        to apps launched by using futures.
        """
        super(IPV6RouterSolicitationTableTest, cls).setUpClass()
        warnings.simplefilter('ignore')
        cls.service_manager = create_service_manager(
            [],
            ['ipv6_solicitation'],
        )
        cls._tbl_num = cls.service_manager.get_table_num(
            IPV6SolicitationController.APP_NAME)

        ipv6_controller_reference = Future()
        testing_controller_reference = Future()
        test_setup = TestSetup(
            apps=[
                PipelinedController.IPV6RouterSolicitation,
                PipelinedController.Testing,
                PipelinedController.StartupFlows,
            ],
            references={
                PipelinedController.IPV6RouterSolicitation:
                ipv6_controller_reference,
                PipelinedController.Testing: testing_controller_reference,
                PipelinedController.StartupFlows: Future(),
            },
            config={
                'setup_type': 'LTE',
                'allow_unknown_arps': False,
                'bridge_name': cls.BRIDGE,
                'bridge_ip_address': cls.BRIDGE_IP,
                'ovs_gtp_port_number': 32768,
                'virtual_interface': cls.BRIDGE,
                'local_ue_eth_addr': True,
                'quota_check_ip': '1.2.3.4',
                'ipv6_router_addr': 'd88d:aba4:472f:fc95:7e7d:8457:5301:ebce',
                'clean_restart': True,
                'virtual_mac': 'd6:34:bc:81:5d:40',
                'enable_nat': True,
                'classifier_controller_id': 5,
            },
            mconfig=PipelineD(ue_ip_block=cls.UE_BLOCK, ),
            loop=None,
            service_manager=cls.service_manager,
            integ_test=False,
        )

        BridgeTools.create_bridge(cls.BRIDGE, cls.IFACE)

        cls.thread = start_ryu_app_thread(test_setup)
        cls.solicitation_controller = ipv6_controller_reference.result()
        cls.testing_controller = testing_controller_reference.result()

        cls._prefix_dict = {}
        cls.solicitation_controller._prefix_mapper._prefix_by_interface = \
            cls._prefix_dict
Example #19
0
    def setUp(self):
        super(SubscriberTest, self).setUp()
        warnings.simplefilter('ignore')
        service_manager = create_service_manager([PipelineD.METERING])
        self._tbl_num = service_manager.get_table_num(MeterController.APP_NAME)

        meter_ref = Future()
        testing_controller_reference = Future()
        meter_stat_ref = Future()
        subscriber_ref = Future()

        def mock_thread_safe(cmd, body):
            cmd(body)

        loop_mock = MagicMock()
        loop_mock.call_soon_threadsafe = mock_thread_safe

        test_setup = TestSetup(apps=[
            PipelinedController.Meter,
            PipelinedController.Testing,
            PipelinedController.MeterStats,
            PipelinedController.Subscriber,
            PipelinedController.StartupFlows,
        ],
                               references={
                                   PipelinedController.Meter: meter_ref,
                                   PipelinedController.Testing:
                                   testing_controller_reference,
                                   PipelinedController.MeterStats:
                                   meter_stat_ref,
                                   PipelinedController.Subscriber:
                                   subscriber_ref,
                                   PipelinedController.StartupFlows: Future(),
                               },
                               config={
                                   'bridge_name': self.BRIDGE,
                                   'bridge_ip_address': '192.168.128.1',
                                   'meter': {
                                       'poll_interval': -1,
                                       'enabled': True
                                   },
                                   'subscriber': {
                                       'enabled': True,
                                       'poll_interval': -1
                                   },
                                   'clean_restart': True,
                               },
                               mconfig={},
                               loop=loop_mock,
                               service_manager=service_manager,
                               integ_test=False,
                               rpc_stubs={
                                   'metering_cloud': MagicMock(),
                                   'mobilityd': MagicMock(),
                               })
        BridgeTools.create_bridge(self.BRIDGE, self.BRIDGE)

        self.thread = start_ryu_app_thread(test_setup)

        self.meter_controller = meter_ref.result()
        self.stats_controller = meter_stat_ref.result()
        self.testing_controller = testing_controller_reference.result()
        self.subscriber_controller = subscriber_ref.result()

        self.stats_controller._sync_stats = MagicMock()
        self.subscriber_controller._poll_subscriber_list = MagicMock()
Example #20
0
    def setUpClass(cls):
        """
        Starts the thread which launches ryu apps

        Create a testing bridge, add a port, setup the port interfaces. Then
        launch the ryu apps for testing pipelined. Gets the references
        to apps launched by using futures.
        """
        super(ConntrackTest, cls).setUpClass()
        warnings.simplefilter('ignore')
        cls.service_manager = create_service_manager(
            [],
            ['ue_mac', 'conntrack'],
        )
        cls._tbl_num = cls.service_manager.get_table_num(
            ConntrackController.APP_NAME, )

        conntrack_controller_reference = Future()
        testing_controller_reference = Future()
        test_setup = TestSetup(
            apps=[
                PipelinedController.Conntrack,
                PipelinedController.Testing,
                PipelinedController.StartupFlows,
            ],
            references={
                PipelinedController.Conntrack: conntrack_controller_reference,
                PipelinedController.Testing: testing_controller_reference,
                PipelinedController.StartupFlows: Future(),
            },
            config={
                'setup_type': 'CWF',
                'allow_unknown_arps': False,
                'bridge_name': cls.BRIDGE,
                'bridge_ip_address': cls.BRIDGE_IP,
                'internal_ip_subnet': '192.168.0.0/16',
                'nat_iface': 'eth2',
                'enodeb_iface': 'eth1',
                'qos': {
                    'enable': False
                },
                'clean_restart': True,
                'access_control': {
                    'ip_blocklist': [],
                },
                'conntrackd': {
                    'zone': 897,
                },
            },
            mconfig=PipelineD(allowed_gre_peers=[], ),
            loop=None,
            service_manager=cls.service_manager,
            integ_test=False,
        )

        BridgeTools.create_bridge(cls.BRIDGE, cls.IFACE)
        BridgeTools.flush_conntrack()

        cls.thread = start_ryu_app_thread(test_setup)
        cls.conntrack_controller = \
            conntrack_controller_reference.result()
        cls.testing_controller = testing_controller_reference.result()
Example #21
0
    def setUpClass(cls, *_):
        """
        Starts the thread which launches ryu apps

        Create a testing bridge, add a port, setup the port interfaces. Then
        launch the ryu apps for testing pipelined. Gets the references
        to apps launched by using futures.
        """
        super(UEMacAddressTest, cls).setUpClass()
        warnings.simplefilter('ignore')
        cls.service_manager = create_service_manager([], ['ue_mac', 'arpd'])
        cls._tbl_num = cls.service_manager.get_table_num(
            UEMacAddressController.APP_NAME)
        cls._ingress_tbl_num = cls.service_manager.get_table_num(INGRESS)
        cls._egress_tbl_num = cls.service_manager.get_table_num(EGRESS)

        inout_controller_reference = Future()
        ue_mac_controller_reference = Future()
        testing_controller_reference = Future()
        test_setup = TestSetup(
            apps=[PipelinedController.InOut,
                  PipelinedController.Arp,
                  PipelinedController.UEMac,
                  PipelinedController.Testing,
                  PipelinedController.StartupFlows],
            references={
                PipelinedController.InOut:
                    inout_controller_reference,
                PipelinedController.Arp:
                    Future(),
                PipelinedController.UEMac:
                    ue_mac_controller_reference,
                PipelinedController.Testing:
                    testing_controller_reference,
                PipelinedController.StartupFlows:
                    Future(),
            },
            config={
                'setup_type': 'CWF',
                'allow_unknown_arps': False,
                'bridge_name': cls.BRIDGE,
                'bridge_ip_address': cls.BRIDGE_IP,
                'internal_ip_subnet': '192.168.0.0/16',
                'ovs_gtp_port_number': 32768,
                'virtual_interface': 'testing_br',
                'local_ue_eth_addr': False,
                'quota_check_ip': '1.2.3.4',
                'clean_restart': True,
            },
            mconfig=PipelineD(
                ue_ip_block="192.168.128.0/24",
            ),
            loop=None,
            service_manager=cls.service_manager,
            integ_test=False,
        )

        BridgeTools.create_bridge(cls.BRIDGE, cls.IFACE)

        cls.thread = start_ryu_app_thread(test_setup)
        cls.ue_mac_controller = ue_mac_controller_reference.result()
        cls.testing_controller = testing_controller_reference.result()
    def setUpClass(cls, *_):
        """
        Starts the thread which launches ryu apps

        Create a testing bridge, add a port, setup the port interfaces. Then
        launch the ryu apps for testing pipelined. Gets the references
        to apps launched by using futures, mocks the redis policy_dictionary
        of ue_mac_controller
        """
        super(CWFRestartResilienceTest, cls).setUpClass()
        warnings.simplefilter('ignore')
        cls.service_manager = create_service_manager([], ['ue_mac', 'arpd'])

        ue_mac_controller_reference = Future()
        testing_controller_reference = Future()

        def mock_thread_safe(cmd, body):
            cmd(body)

        loop_mock = MagicMock()
        loop_mock.call_soon_threadsafe = mock_thread_safe

        test_setup = TestSetup(
            apps=[
                PipelinedController.UEMac,
                PipelinedController.Arp,
                PipelinedController.Testing,
                PipelinedController.StartupFlows,
            ],
            references={
                PipelinedController.UEMac: ue_mac_controller_reference,
                PipelinedController.Arp: Future(),
                PipelinedController.Testing: testing_controller_reference,
                PipelinedController.StartupFlows: Future(),
            },
            config={
                'setup_type': 'CWF',
                'bridge_name': cls.BRIDGE,
                'bridge_ip_address': cls.BRIDGE_IP_ADDRESS,
                'enforcement': {
                    'poll_interval': 5
                },
                'internal_ip_subnet': '192.168.0.0/16',
                'nat_iface': 'eth2',
                'local_ue_eth_addr': False,
                'allow_unknown_arps': False,
                'enodeb_iface': 'eth1',
                'qos': {
                    'enable': False
                },
                'clean_restart': False,
                'quota_check_ip': '1.2.3.4',
                'enable_nat': False,
                'dpi': {
                    'enabled': False,
                    'mon_port': 'mon1',
                    'mon_port_number': 32769,
                    'idle_timeout': 42,
                },
            },
            mconfig=PipelineD(ue_ip_block=cls.UE_BLOCK, ),
            loop=loop_mock,
            service_manager=cls.service_manager,
            integ_test=False,
        )

        BridgeTools.create_bridge(cls.BRIDGE, cls.IFACE)
        BridgeTools.create_internal_iface(cls.BRIDGE, cls.DPI_PORT, cls.DPI_IP)

        cls.thread = start_ryu_app_thread(test_setup)

        cls.ue_mac_controller = ue_mac_controller_reference.result()
        cls.testing_controller = testing_controller_reference.result()
Example #23
0
    def setUp(self):
        """
        Starts the thread which launches ryu apps

        Create a testing bridge, add a port, setup the port interfaces. Then
        launch the ryu apps for testing pipelined. Gets the references
        to apps launched by using futures.

        Mocks the redis policy_dictionary of enforcement_controller.
        Mocks the loop for testing EnforcementStatsController
        """
        super(EnforcementStatsTest, self).setUpClass()
        warnings.simplefilter('ignore')
        self._static_rule_dict = {}
        self.service_manager = create_service_manager([PipelineD.ENFORCEMENT])
        self._main_tbl_num = self.service_manager.get_table_num(
            EnforcementController.APP_NAME)

        enforcement_controller_reference = Future()
        testing_controller_reference = Future()
        enf_stat_ref = Future()
        """
        Enforcement_stats reports data by using loop.call_soon_threadsafe, but
        as we don't have an eventloop in testing, just directly call the stats
        handling function

        Here is how the mocked function is used in EnforcementStatsController:
        self.loop.call_soon_threadsafe(self._handle_flow_stats, ev.msg.body)
        """
        def mock_thread_safe(cmd, body):
            cmd(body)

        loop_mock = MagicMock()
        loop_mock.call_soon_threadsafe = mock_thread_safe

        test_setup = TestSetup(apps=[
            PipelinedController.Enforcement,
            PipelinedController.Enforcement_stats, PipelinedController.Testing,
            PipelinedController.StartupFlows
        ],
                               references={
                                   PipelinedController.Enforcement:
                                   enforcement_controller_reference,
                                   PipelinedController.Testing:
                                   testing_controller_reference,
                                   PipelinedController.Enforcement_stats:
                                   enf_stat_ref,
                                   PipelinedController.StartupFlows: Future(),
                               },
                               config={
                                   'bridge_name': self.BRIDGE,
                                   'bridge_ip_address': '192.168.128.1',
                                   'enforcement': {
                                       'poll_interval': 2
                                   },
                                   'nat_iface': 'eth2',
                                   'enodeb_iface': 'eth1',
                                   'qos': {
                                       'enable': False
                                   },
                                   'clean_restart': True,
                               },
                               mconfig=PipelineD(),
                               loop=loop_mock,
                               service_manager=self.service_manager,
                               integ_test=False,
                               rpc_stubs={'sessiond': MagicMock()})

        BridgeTools.create_bridge(self.BRIDGE, self.IFACE)

        self.thread = start_ryu_app_thread(test_setup)

        self.enforcement_stats_controller = enf_stat_ref.result()
        self._scratch_tbl_num = self.enforcement_stats_controller.tbl_num
        self.enforcement_controller = enforcement_controller_reference.result()
        self.testing_controller = testing_controller_reference.result()

        self.enforcement_stats_controller._policy_dict = self._static_rule_dict
        self.enforcement_stats_controller._report_usage = MagicMock()

        self.enforcement_controller._policy_dict = self._static_rule_dict
        self.enforcement_controller._redirect_manager._save_redirect_entry = \
            MagicMock()
Example #24
0
    def setUpClass(cls):
        """
        Starts the thread which launches ryu apps

        Create a testing bridge, add a port, setup the port interfaces. Then
        launch the ryu apps for testing pipelined. Gets the references
        to apps launched by using futures.
        """
        super(InOutTest, cls).setUpClass()
        ingress.get_virtual_iface_mac = mocked_get_virtual_iface_mac
        middle.get_virtual_iface_mac = mocked_get_virtual_iface_mac
        egress.get_virtual_iface_mac = mocked_get_virtual_iface_mac
        warnings.simplefilter('ignore')
        cls.service_manager = create_service_manager([])

        BridgeTools.create_bridge(cls.BRIDGE, cls.IFACE)
        BridgeTools.create_internal_iface(
            cls.BRIDGE,
            cls.MTR_PORT,
            None,
        )
        mtr_port_no = BridgeTools.get_ofport(cls.MTR_PORT)

        ingress_controller_reference = Future()
        middle_controller_reference = Future()
        egress_controller_reference = Future()
        testing_controller_reference = Future()
        test_setup = TestSetup(
            apps=[
                PipelinedController.Ingress,
                PipelinedController.Middle,
                PipelinedController.Egress,
                PipelinedController.Testing,
                PipelinedController.StartupFlows,
            ],
            references={
                PipelinedController.Ingress: ingress_controller_reference,
                PipelinedController.Middle: middle_controller_reference,
                PipelinedController.Egress: egress_controller_reference,
                PipelinedController.Testing: testing_controller_reference,
                PipelinedController.StartupFlows: Future(),
            },
            config={
                'bridge_name': cls.BRIDGE,
                'bridge_ip_address': cls.BRIDGE_IP,
                'ovs_gtp_port_number': 32768,
                'clean_restart': True,
                'enable_nat': True,
                'uplink_gw_mac': '11:22:33:44:55:66',
                'uplink_port': OFPP_LOCAL,
                'virtual_interface': cls.BRIDGE,
                'mtr_ip': '5.6.7.8',
                'mtr_interface': cls.MTR_PORT,
                'ovs_mtr_port_number': mtr_port_no,
            },
            mconfig=None,
            loop=None,
            service_manager=cls.service_manager,
            integ_test=False,
        )

        cls.thread = start_ryu_app_thread(test_setup)
        cls.ingress_controller = ingress_controller_reference.result()
        cls.middle_controller = middle_controller_reference.result()
        cls.egress_controller = egress_controller_reference.result()
        cls.testing_controller = testing_controller_reference.result()