示例#1
0
        public void RepartitionWithPartitioner()
        {
            var records = SetupTest((builder) =>
            {
                builder
                .Stream <string, string>("topic")
                .Repartition(Repartitioned <string, string> .Empty().WithStreamPartitioner((t, k, v) => 0))
                .To("output");
            }, TopologyTestDriver.Mode.ASYNC_CLUSTER_IN_MEMORY, 10);

            Assert.AreEqual(0, records.ToList()[0].Partition.Value);
            Assert.AreEqual(0, records.ToList()[1].Partition.Value);
            Assert.AreEqual(0, records.ToList()[2].Partition.Value);
        }
示例#2
0
        public void RepartitionWithPartitionNumber()
        {
            var records = SetupTest((builder) =>
            {
                builder
                .Stream <string, string>("topic")
                .Repartition(Repartitioned <string, string> .Empty().WithNumberOfPartitions(20))
                .To("output");
            }, TopologyTestDriver.Mode.ASYNC_CLUSTER_IN_MEMORY);

            // topic - 1 partitions
            // repartitionTopic - 20 partitions
            // output - 1 partitions

            Assert.AreEqual(0, records.ToList()[0].Partition.Value);
            Assert.AreEqual(0, records.ToList()[1].Partition.Value);
            Assert.AreEqual(0, records.ToList()[2].Partition.Value);
        }