예제 #1
0
    def test_get_greatest_operative_mip_version_wrong_log_level_value(self):
        class Source1(bt2._UserSourceComponent,
                      message_iterator_class=bt2._UserMessageIterator):
            pass

        descriptors = [bt2.ComponentDescriptor(Source1)]

        with self.assertRaises(ValueError):
            bt2.get_greatest_operative_mip_version(descriptors, 12345)
예제 #2
0
    def test_get_greatest_operative_mip_version_wrong_descriptor_type(self):
        class Source1(bt2._UserSourceComponent,
                      message_iterator_class=bt2._UserMessageIterator):
            @classmethod
            def _user_get_supported_mip_versions(cls, params, obj, log_level):
                return [0, 1]

        descriptors = [bt2.ComponentDescriptor(Source1), object()]

        with self.assertRaises(TypeError):
            bt2.get_greatest_operative_mip_version(descriptors)
예제 #3
0
    def _get_greatest_operative_mip_version(self):
        def append_comp_specs_descriptors(descriptors, comp_specs):
            for comp_spec in comp_specs:
                descriptors.append(
                    bt2.ComponentDescriptor(
                        comp_spec.component_class, comp_spec.params, comp_spec.obj
                    )
                )

        descriptors = []
        append_comp_specs_descriptors(descriptors, self._src_comp_specs)
        append_comp_specs_descriptors(descriptors, self._flt_comp_specs)

        if self._stream_intersection_mode:
            # we also need at least one `flt.utils.trimmer` component
            comp_spec = ComponentSpec.from_named_plugin_and_component_class(
                'utils', 'trimmer'
            )
            append_comp_specs_descriptors(descriptors, [comp_spec])

        mip_version = bt2.get_greatest_operative_mip_version(descriptors)

        if mip_version is None:
            msg = 'failed to find an operative message interchange protocol version (components are not interoperable)'
            raise RuntimeError(msg)

        return mip_version
예제 #4
0
    def test_get_greatest_operative_mip_version_no_match(self):
        class Source1(bt2._UserSourceComponent,
                      message_iterator_class=bt2._UserMessageIterator):
            @classmethod
            def _user_get_supported_mip_versions(cls, params, obj, log_level):
                return [0]

        class Source2(bt2._UserSourceComponent,
                      message_iterator_class=bt2._UserMessageIterator):
            @classmethod
            def _user_get_supported_mip_versions(cls, params, obj, log_level):
                return [1]

        descriptors = [
            bt2.ComponentDescriptor(Source1),
            bt2.ComponentDescriptor(Source2),
        ]

        version = bt2.get_greatest_operative_mip_version(descriptors)
        self.assertIsNone(version)
예제 #5
0
 def test_get_greatest_operative_mip_version_empty_descriptors(self):
     with self.assertRaises(ValueError):
         bt2.get_greatest_operative_mip_version([])