def _multi_injection(self, raw_overlay=None): topo = Topology() streamsx.spl.toolkit.add_toolkit(topo, TestEmInject._TK) context = _rand_path() name = _rand_path() job_name = _rand_path() s1 = endpoint.inject(topo, name=name+'N1', context=context+'C1', monitor=self._monitor) s2 = endpoint.inject(topo, name=name+'N2', context=context+'C2', monitor=self._monitor) jc = JobConfig() self._job_name = _rand_path() jc.job_name = self._job_name jc.add(self.test_config) # Force separate PEs for the inject operators if raw_overlay: jc.raw_overlay = raw_overlay else: s1.colocate(s2) self._path = '/' + context + 'C1/' + name + 'N1/ports/output/0/inject' self.tester = Tester(topo) self.tester.local_check = self._multi_inject self.tester.contents(s1, [{'seq1':i} for i in range(self.N)]) self.tester.contents(s2, [{'seq2':i} for i in range(self.N)]) self.tester.test(self.test_ctxtype, self.test_config) self._check_no_endpoint()
def test_basic_xml_injection(self): name = 'test_basic_xml_injection' topo = Topology(name) res = endpoint.inject(topo, name='jsoninject', schema=CommonSchema.XML, monitor='xml', context='sample') self._build_only(name, topo)
def test_basic_json_injection(self): name = 'test_basic_json_injection' topo = Topology(name) res = endpoint.inject(topo, name='jsoninject', monitor=None, context='sample') res.print() self._build_only(name, topo)
def test_basic_string_injection(self): name = 'test_basic_string_injection' topo = Topology(name) res = endpoint.inject(topo, name='jsoninject', schema=CommonSchema.String, monitor='sample', context='sample') res.print() self._build_only(name, topo)
def test_basic_stream_schema_injection(self): name = 'test_basic_stream_schema_injection' topo = Topology(name) res = endpoint.inject( topo, name='jsoninject', schema=StreamSchema('tuple<int32 a, boolean alert>'), monitor=None, context='sample') res.print() self._build_only(name, topo)
def test_inject(self): """ Test injecting. """ topo = Topology() s = endpoint.inject(topo, name='T', context='test1') streamsx.spl.toolkit.add_toolkit(topo, self._tk) self._path = '/test1/T/ports/output/0/inject' self.tester = Tester(topo) self.tester.local_check = self._inject self.tester.tuple_count(s, self.N) self.tester.contents(s, [{'seq': i} for i in range(self.N)]) self.tester.test(self.test_ctxtype, self.test_config) self._check_no_endpoint()
def test_form_inject(self): topo = Topology() context = _rand_path() name = _rand_path() schema = StreamSchema('tuple<int32 a, rstring b, boolean c>') s = endpoint.inject(topo, name=name, context=context, monitor=self._monitor, schema=schema) streamsx.spl.toolkit.add_toolkit(topo, TestEmInject._TK) self._path = '/' + context + '/' + name + '/ports/output/0/inject' self._alias = '/' + context + '/' + name + '/inject' self.tester = Tester(topo) self.tester.local_check = self._form_inject s.print() self.tester.contents(s, [{'a':42, 'b':'HHGTTG', 'c':True}, {'a':93, 'b':'ABCDE', 'c':False}]) self.tester.test(self.test_ctxtype, self.test_config) self._check_no_endpoint()
def _inject_tester(self): """ Test injecting. """ topo = Topology() context = _rand_path() name = _rand_path() s = endpoint.inject(topo, name=name, context=context, monitor=self._monitor) streamsx.spl.toolkit.add_toolkit(topo, TestEmInject._TK) self._path = '/' + context + '/' + name + '/ports/output/0/inject' self._alias = '/' + context + '/' + name + '/inject' self.tester = Tester(topo) self.tester.local_check = self._inject self.tester.tuple_count(s, self.N) self.tester.contents(s, [{self.K:i} for i in range(self.N)]) self.tester.test(self.test_ctxtype, self.test_config) self._check_no_endpoint()