Exemple #1
0
    def test_topic(self):
        kafka = Kafka()

        kafka = kafka.topic("topic1")

        properties = kafka.to_properties()
        expected = {'connector.type': 'kafka',
                    'connector.topic': 'topic1',
                    'connector.property-version': '1'}
        assert properties == expected
Exemple #2
0
    def test_start_from_earliest(self):
        kafka = Kafka()

        kafka = kafka.start_from_earliest()

        properties = kafka.to_properties()
        expected = {'connector.type': 'kafka',
                    'connector.startup-mode': 'earliest-offset',
                    'connector.property-version': '1'}
        assert properties == expected
Exemple #3
0
    def test_sink_partitioner_round_robin(self):
        kafka = Kafka()

        kafka = kafka.sink_partitioner_round_robin()

        properties = kafka.to_properties()
        expected = {'connector.sink-partitioner': 'round-robin',
                    'connector.type': 'kafka',
                    'connector.property-version': '1'}
        assert properties == expected
Exemple #4
0
    def test_version(self):
        kafka = Kafka()

        kafka = kafka.version("0.11")

        properties = kafka.to_properties()
        expected = {'connector.version': '0.11',
                    'connector.type': 'kafka',
                    'connector.property-version': '1'}
        assert properties == expected
Exemple #5
0
    def test_start_from_group_offsets():
        kafka = Kafka()

        kafka = kafka.start_from_group_offsets()

        properties = kafka.to_properties()
        expected = {'connector.type': 'kafka',
                    'connector.startup-mode': 'group-offsets',
                    'connector.property-version': '1'}
        assert properties == expected
Exemple #6
0
    def test_sink_partitioner_fixed():
        kafka = Kafka()

        kafka = kafka.sink_partitioner_fixed()

        properties = kafka.to_properties()
        expected = {'connector.sink-partitioner': 'fixed',
                    'connector.type': 'kafka',
                    'connector.property-version': '1'}
        assert properties == expected
Exemple #7
0
    def test_topic(self):
        kafka = Kafka().topic("topic1")

        properties = kafka.to_properties()
        expected = {
            'connector.type': 'kafka',
            'connector.topic': 'topic1',
            'connector.property-version': '1'
        }
        self.assertEqual(expected, properties)
Exemple #8
0
    def test_version(self):
        kafka = Kafka().version("0.11")

        properties = kafka.to_properties()
        expected = {
            'connector.version': '0.11',
            'connector.type': 'kafka',
            'connector.property-version': '1'
        }
        self.assertEqual(expected, properties)
Exemple #9
0
    def test_sink_partitioner_fixed(self):
        kafka = Kafka().sink_partitioner_fixed()

        properties = kafka.to_properties()
        expected = {
            'connector.sink-partitioner': 'fixed',
            'connector.type': 'kafka',
            'connector.property-version': '1'
        }
        self.assertEqual(expected, properties)
Exemple #10
0
    def test_start_from_group_offsets(self):
        kafka = Kafka().start_from_group_offsets()

        properties = kafka.to_properties()
        expected = {
            'connector.type': 'kafka',
            'connector.startup-mode': 'group-offsets',
            'connector.property-version': '1'
        }
        self.assertEqual(expected, properties)
Exemple #11
0
    def test_property(self):
        kafka = Kafka()

        kafka = kafka.property("group.id", "testGroup")

        properties = kafka.to_properties()
        expected = {'connector.type': 'kafka',
                    'connector.properties.0.key': 'group.id',
                    'connector.properties.0.value': 'testGroup',
                    'connector.property-version': '1'}
        assert properties == expected
Exemple #12
0
    def test_start_from_specific_offset(self):
        kafka = Kafka()

        kafka = kafka.start_from_specific_offset(3, 300)

        properties = kafka.to_properties()
        expected = {'connector.startup-mode': 'specific-offsets',
                    'connector.specific-offsets.0.partition': '3',
                    'connector.specific-offsets.0.offset': '300',
                    'connector.type': 'kafka',
                    'connector.property-version': '1'}
        assert properties == expected
Exemple #13
0
    def test_properties(self):
        kafka = Kafka()

        kafka = kafka.properties({"zookeeper.connect": "localhost:2181",
                                  "bootstrap.servers": "localhost:9092"})

        properties = kafka.to_properties()
        expected = {'connector.type': 'kafka',
                    'connector.properties.0.key': 'zookeeper.connect',
                    'connector.properties.0.value': 'localhost:2181',
                    'connector.properties.1.key': 'bootstrap.servers',
                    'connector.properties.1.value': 'localhost:9092',
                    'connector.property-version': '1'}
        assert properties == expected
Exemple #14
0
    def test_sink_partitioner_custom(self):
        kafka = Kafka()

        kafka = kafka.sink_partitioner_custom(
            "org.apache.flink.streaming.connectors.kafka.partitioner.FlinkFixedPartitioner")

        properties = kafka.to_properties()
        expected = {'connector.sink-partitioner': 'custom',
                    'connector.sink-partitioner-class':
                        'org.apache.flink.streaming.connectors.kafka.partitioner.'
                        'FlinkFixedPartitioner',
                    'connector.type': 'kafka',
                    'connector.property-version': '1'}
        assert properties == expected
Exemple #15
0
    def test_start_from_specific_offsets():
        kafka = Kafka()

        kafka = kafka.start_from_specific_offsets({1: 220, 3: 400})

        properties = kafka.to_properties()
        expected = {'connector.startup-mode': 'specific-offsets',
                    'connector.specific-offsets.0.partition': '1',
                    'connector.specific-offsets.0.offset': '220',
                    'connector.specific-offsets.1.partition': '3',
                    'connector.specific-offsets.1.offset': '400',
                    'connector.type': 'kafka',
                    'connector.property-version': '1'}
        assert properties == expected