arpadboda commented on a change in pull request #657: MINIFICPP-1048 - Add PublishKafka docker tests URL: https://github.com/apache/nifi-minifi-cpp/pull/657#discussion_r332080117
########## File path: docker/test/integration/test_rdkafka.py ########## @@ -0,0 +1,76 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the \"License\"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an \"AS IS\" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from minifi import * +from minifi.test import * + + +def test_publish_kafka(): + """ + Verify delivery of message to kafka broker + """ + producer_flow = GetFile('/tmp/input') >> PublishKafka() >> ('success', LogAttribute()) + + with DockerTestCluster(KafkaValidator('test')) as cluster: + cluster.put_test_data('test') + cluster.deploy_flow(None, engine='kafka-broker') + cluster.deploy_flow(producer_flow, name='minifi-producer', engine='minifi-cpp') + + assert cluster.check_output(10) + +def test_no_broker(): + """ + Verify failure case when broker is down + """ + producer_flow = (GetFile('/tmp/input') >> PublishKafka() + >> (('failure', PutFile('/tmp/output')), + ('success', LogAttribute()))) + + with DockerTestCluster(SingleFileOutputValidator('no broker')) as cluster: + cluster.put_test_data('no broker') + cluster.deploy_flow(producer_flow, name='minifi-producer', engine='minifi-cpp') + + assert cluster.check_output(30) + +def test_broker_on_off(): + """ + Verify delivery of message when broker is unstable + """ + producer_flow = (GetFile('/tmp/input') >> PublishKafka() + >> (('success', PutFile('/tmp/output/success')), + ('failure', PutFile('/tmp/output/failure')))) + + with DockerTestCluster(SingleFileOutputValidator('test')) as cluster: Review comment: I really like this, thanks! ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
