Пример #1
0
 def test_compile_MQTTSource(self):
     print ('\n---------'+str(self))
     name = 'test_MQTTSource'
     topo = Topology(name)
     streamsx.spl.toolkit.add_toolkit(topo, self.mqtt_toolkit_home)
     src = MQTTSource(server_uri='tcp://server:1833', topics=['topic1', 'topic2'], schema=MqttDataTuple)
     # simply add all parameters; let' see if it compiles
     src.qos = [1, 2]
     src.message_queue_size = 122
     src.client_id = "client-IDsrc"
     src.reconnection_bound = 25
     src.trusted_certs = [TRUSTED_CERT_PEM, CLIENT_CA_CERT_PEM]
     src.client_cert = CLIENT_CERT_PEM
     src.client_private_key = PRIVATE_KEY_PEM
     src.ssl_protocol = 'TLSv1.1'
     src.vm_arg = ["-Xmx13G"]
     src.ssl_debug = True
     src.app_config_name = "abbconf2"
     src.command_timeout_millis=30000
     src.keep_alive_seconds = 65
     src.password = "******"
     src.username = "******"
     src.app_config_name = "mqtt_app_cfg"
     
     source_stream = topo.source(src, name='MqttStream')
     source_stream.print()
     # build only
     self._build_only(name, topo)
Пример #2
0
  def test_bad_param(self):
      print ('\n---------'+str(self))
      # constructor tests
      self.assertRaises(ValueError, MQTTSource, server_uri=None, topics='topic1', schema=MqttDataTuple)
      # topics = None
      self.assertRaises(ValueError, MQTTSource, server_uri='tcp://server:1234', topics=None, schema=MqttDataTuple)
      # schema = None
      self.assertRaises(ValueError, MQTTSource, server_uri='tcp://server:1234', topics='topic1', schema=None)
      # server_uri = None
      self.assertRaises(ValueError, MQTTSink, server_uri=None, topic='topic1')
      # topic and topic_attribute_name = None
      self.assertRaises(ValueError, MQTTSink, server_uri='tcp://server:1234', topic=None, topic_attribute_name=None)
      # topic and topic_attribute_name = Not None
      self.assertRaises(ValueError, MQTTSink, server_uri='tcp://server:1234', topic='topic1', topic_attribute_name='topic')
 
      # setter tests
      src = MQTTSource(server_uri='tcp://server:1833', topics=['topic1', 'topic2'], schema=MqttDataTuple)
      with self.assertRaises(TypeError):
          src.qos = ['0', '2']
      with self.assertRaises(ValueError):
          src.qos = 3
      with self.assertRaises(ValueError):
          src.qos = -1
      with self.assertRaises(ValueError):
          src.qos = [0, 3]
      with self.assertRaises(ValueError):
          src.reconnection_bound = -2
      with self.assertRaises(ValueError):
          src.keep_alive_seconds = -1
      with self.assertRaises(ValueError):
          src.command_timeout_millis = -1
      with self.assertRaises(ValueError):
          src.message_queue_size = 0
          
      sink = MQTTSink(server_uri='tcp://server:1833', topic='topic1')
      with self.assertRaises(ValueError):
          sink.qos = 3
      with self.assertRaises(ValueError):
          sink.qos = -1
      with self.assertRaises(TypeError):
          sink.qos = [0, 3]
      with self.assertRaises(ValueError):
          sink.reconnection_bound = -2
      with self.assertRaises(ValueError):
          sink.keep_alive_seconds = -1
      with self.assertRaises(ValueError):
          sink.command_timeout_millis = -1
src.reconnection_bound = -1
src.trusted_certs = [
    '/tmp/secrets/cluster_ca_cert.pem', '/tmp/secrets/cluster-ca.crt'
]
#src.truststore = "/tmp/truststore-4657686007309004.jks"
src.truststore_password = '******'
src.client_cert = '/home/rolef/infosphereStreams/development/tk/ws_el7_43/kafkaTransactionSupport/etc/amqstreams/rolef.crt'
src.client_private_key = '/home/rolef/infosphereStreams/development/tk/ws_el7_43/kafkaTransactionSupport/etc/amqstreams/rolef.key'
#src.keystore = "/tmp/keystore-8728817490056367.jks"
src.keystore_password = '******'
src.ssl_protocol = 'TLSv1.1'
src.vm_arg = ["-Xmx13G"]
src.ssl_debug = True
src.app_config_name = "abbconf2"
src.command_timeout_millis = 247
src.keep_alive_seconds = 23
src.password = "******"
src.username = "******"

topo = Topology()
#data = topo.source(["A","B","C","D","E","F","G","H","I","J"]).as_string()

data = topo.source(src, "MQTTsubscribe")
data.for_each(sk, name="MQTTpublish")

#submission = context.submit(context.ContextTypes.TOOLKIT, topo)
submission = context.submit(context.ContextTypes.BUNDLE, topo)
#c._check_types()
#c._check_adjust()
#print(sk.__dict__)
#print(sk._config.__dict__)