def _test_insert_consistent_region(self): print('\n---------' + str(self)) name = 'test_insert_consistent_region' topo = Topology(name) self._add_toolkits(topo, None) # configuration of consistent region trigger period trigger_period = 10 num_expected_tuples = 8000 num_resets = 2 run_for = 120 # in seconds beacon = op.Source(topo, "spl.utility::Beacon", 'tuple<int64 id, rstring val>', params={ 'period': 0.01, 'iterations': num_expected_tuples }) beacon.id = beacon.output('(int64)IterationCount()') beacon.val = beacon.output(spltypes.rstring('CR_TEST')) beacon.stream.set_consistent( ConsistentRegionConfig.periodic(trigger_period)) es.insert(beacon.stream, connection=self.connection, database=self.database, table='StreamsCRTable', primary_key='id', partitioning_key='id', front_end_connection_flag=False, user=self.es_user, password=self.es_password, truststore=self.es_truststore, truststore_password=self.es_truststore_password, keystore=self.es_keystore, keystore_password=self.es_keystore_password) #self._build_only(name, topo) tester = Tester(topo) tester.run_for(run_for) tester.resets(num_resets) # minimum number of resets for each region cfg = {} # change trace level job_config = streamsx.topology.context.JobConfig(tracing='warn') job_config.add(cfg) cfg[streamsx.topology.context.ConfigParams.SSL_VERIFY] = False tester.test(self.test_ctxtype, cfg, always_collect_logs=True) print(str(tester.result))
def test_schema_view(self): """ Test a view of SPL tuples. """ topo = Topology() beacon = op.Source(topo, "spl.utility::Beacon", 'tuple<uint64 seq, rstring fixed>', params = {'period': 0.05, 'iterations':1000}) beacon.seq = beacon.output('IterationCount()') beacon.fixed = beacon.output(spltypes.rstring('FixedValue')) s = beacon.stream self._ov = s.view() self._expected_type = dict tester = Tester(topo) tester.local_check = self._object_view tester.tuple_count(s, 1000) tester.test(self.test_ctxtype, self.test_config)
def test_schema_view(self): """ Test a view of SPL tuples. """ topo = Topology() beacon = op.Source(topo, "spl.utility::Beacon", 'tuple<uint64 seq, rstring fixed>', params = {'period': 0.05}) beacon.seq = beacon.output('IterationCount()') beacon.fixed = beacon.output(spltypes.rstring('FixedValue')) s = beacon.stream self._ov = s.view(name='DoTwice') self._ov = s.view(name='DoTwice') self._expected_type = dict tester = Tester(topo) tester.local_check = self._object_view tester.tuple_count(s, 1000, exact=False) tester.test(self.test_ctxtype, self.test_config)