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_spl_ops(self): topo = Topology() streamsx.spl.toolkit.add_toolkit(topo, TestEmSPL._TK) context = _rand_path() name = _rand_path() schema = StreamSchema('tuple<int32 a, rstring b, boolean c>') params = {} params['port'] = 0 params['context'] = context if self._monitor: params['sslAppConfigName'] = self._monitor + '-streams-certs' inject = op.Source(topo, 'com.ibm.streamsx.inet.rest::HTTPTupleInjection', schema, params, name) self._path = '/' + context + '/' + name + '/ports/output/0/inject' self._alias = '/' + context + '/' + name + '/inject' self.tester = Tester(topo) self.tester.local_check = self._form_inject self.tester.contents(inject.stream, [{ '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 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()
def test_expose(self): topo = Topology() streamsx.spl.toolkit.add_toolkit(topo, TestEmExpose._TK) s = topo.source([{'seq': i} for i in range(20)]) s = s.as_json() context = _rand_path() name = _rand_path() endpoint.expose(s.last(3), name=name, context=context, monitor=self._monitor) self._path = '/' + context + '/' + name + '/ports/input/0/tuples' self._alias = '/' + context + '/' + name + '/tuples' self.tester = Tester(topo) self.tester.local_check = self._access self.tester.tuple_count(s, 20) self.tester.test(self.test_ctxtype, self.test_config) self._check_no_endpoint()