Ejemplo n.º 1
0
        public void JoinGroupRequest(
            [Values(0, 1)] short version,
            [Values("test", "a groupId")] string groupId,
            [Values(1, 20000)] int sessionTimeout,
            [Values("", "an existing member")] string memberId,
            [Values("consumer", "other")] string protocolType,
            [Values(1, 10)] int protocolsPerRequest)
        {
            var protocols = new List <JoinGroupRequest.GroupProtocol>();

            for (var p = 0; p < protocolsPerRequest; p++)
            {
                var bytes = new byte[protocolsPerRequest * 100];
                _randomizer.NextBytes(bytes);
                protocols.Add(new JoinGroupRequest.GroupProtocol(protocolType + p, new ByteMember(bytes)));
            }
            var request = new JoinGroupRequest(groupId, TimeSpan.FromMilliseconds(sessionTimeout), memberId, protocolType, protocols, version >= 1 ? (TimeSpan?)TimeSpan.FromMilliseconds(sessionTimeout * 2) : null);

            request.AssertCanEncodeDecodeRequest(version);
        }
Ejemplo n.º 2
0
        public void JoinConsumerGroupRequest(
            [Values("test", "a groupId")] string groupId,
            [Values(1, 20000)] int sessionTimeout,
            [Values("", "an existing member")] string memberId,
            [Values("consumer")] string protocolType,
            [Values(1, 10)] int protocolsPerRequest)
        {
            var encoder   = new ConsumerEncoder();
            var protocols = new List <JoinGroupRequest.GroupProtocol>();

            for (var p = 0; p < protocolsPerRequest; p++)
            {
                var userData = new byte[protocolsPerRequest * 100];
                _randomizer.NextBytes(userData);
                var metadata = new ConsumerProtocolMetadata(0, new [] { groupId, memberId, protocolType }, userData);
                protocols.Add(new JoinGroupRequest.GroupProtocol(protocolType + p, metadata));
            }
            var request = new JoinGroupRequest(groupId, TimeSpan.FromMilliseconds(sessionTimeout), memberId, protocolType, protocols);

            request.AssertCanEncodeDecodeRequest(0, encoder);
        }