public async Task Produce_And_Consume_Without_Key(string producerFunctionName, Type triggerFunctionType, string topicName)
        {
            const int producedMessagesCount = 20;
            var       messagePrefix         = Guid.NewGuid().ToString() + ":";

            using (var host = await StartHostAsync(new[] { typeof(KafkaOutputFunctions), triggerFunctionType }))
            {
                var jobHost = host.GetJobHost();

                await jobHost.CallOutputTriggerStringAsync(
                    GetStaticMethod(typeof(KafkaOutputFunctions), producerFunctionName),
                    topicName,
                    Enumerable.Range(1, producedMessagesCount).Select(x => messagePrefix + x)
                    );

                await TestHelpers.Await(() =>
                {
                    var foundCount = loggerProvider.GetAllUserLogMessages().Count(p => p.FormattedMessage != null && p.FormattedMessage.Contains(messagePrefix));
                    return(foundCount == producedMessagesCount);
                });

                // Give time for the commit to be saved
                await Task.Delay(1000);
            }
        }
Exemple #2
0
        public async Task Produce_And_Consume_Specific_Avro()
        {
            const int producedMessagesCount = 80;
            var       messagePrefix         = Guid.NewGuid().ToString() + ":";

            using (var host = await StartHostAsync(new[] { typeof(KafkaOutputFunctions), typeof(MyRecordAvroTrigger) }))
            {
                var jobHost = host.GetJobHost();

                await jobHost.CallOutputTriggerStringWithStringKeyAsync(
                    GetStaticMethod(typeof(KafkaOutputFunctions), nameof(KafkaOutputFunctions.SendAvroWithStringKeyTopic)),
                    endToEndTestFixture.MyAvroRecordTopic.Name,
                    Enumerable.Range(1, producedMessagesCount).Select(x => messagePrefix + x),
                    Enumerable.Range(1, producedMessagesCount).Select(x => "record_" + (x % 20).ToString())
                    );

                await TestHelpers.Await(() =>
                {
                    var foundCount = loggerProvider.GetAllUserLogMessages().Count(p => p.FormattedMessage != null && p.FormattedMessage.Contains(messagePrefix));
                    return(foundCount == producedMessagesCount);
                });

                // Give time for the commit to be saved
                await Task.Delay(1500);
            }
        }