You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by bl...@apache.org on 2020/03/29 09:25:47 UTC

[pulsar-dotpulsar] branch master updated (e2a773a -> c18b504)

This is an automated email from the ASF dual-hosted git repository.

blankensteiner pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar-dotpulsar.git.


    from e2a773a  Update NuGet package and use "random" port numbers for the automated tests.
     new 981343b  add regression tests for connection handshake
     new c18b504  moved haproxy.cfg

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 tests/DotPulsar.StressTests/ConnectionTests.cs     | 63 ++++++++++++++++++++++
 .../DotPulsar.StressTests.csproj                   |  3 +-
 tests/docker-compose-standalone-tests.yml          | 13 +++++
 tests/haproxy.cfg                                  | 40 ++++++++++++++
 4 files changed, 118 insertions(+), 1 deletion(-)
 create mode 100644 tests/DotPulsar.StressTests/ConnectionTests.cs
 create mode 100644 tests/haproxy.cfg


[pulsar-dotpulsar] 01/02: add regression tests for connection handshake

Posted by bl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

blankensteiner pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar-dotpulsar.git

commit 981343b60d62dbc708d3716d064d9dc707af0b19
Author: Vince Pergolizzi <pe...@gmail.com>
AuthorDate: Sat Mar 28 22:23:43 2020 -0400

    add regression tests for connection handshake
---
 haproxy.cfg                                        | 40 ++++++++++++++
 tests/DotPulsar.StressTests/ConnectionTests.cs     | 63 ++++++++++++++++++++++
 .../DotPulsar.StressTests.csproj                   |  3 +-
 tests/docker-compose-standalone-tests.yml          | 13 +++++
 4 files changed, 118 insertions(+), 1 deletion(-)

diff --git a/haproxy.cfg b/haproxy.cfg
new file mode 100644
index 0000000..e93369c
--- /dev/null
+++ b/haproxy.cfg
@@ -0,0 +1,40 @@
+global
+        maxconn 10
+        stats socket ipv4@127.0.0.1:9999 level admin
+        stats socket /var/run/hapee-lb.sock mode 666 level admin
+        stats timeout 2m
+defaults
+        timeout connect 5000
+        timeout client 5000
+        timeout server 5000
+        log global
+
+frontend pulsar_tcp
+        bind *:6666
+        mode tcp
+        default_backend pulsar_tcp
+
+frontend admin_http
+        bind *:8888
+        mode http
+        default_backend admin_http
+
+backend pulsar_tcp
+        balance roundrobin
+        mode tcp
+        server pulsar_tcp pulsar:6650
+
+backend admin_http
+        balance roundrobin
+        mode http
+        server pulsar pulsar:8080 check
+        option httpchk GET /metrics/
+        http-check expect status 200
+
+listen stats
+        bind *:9999
+        mode http
+        stats enable
+        stats uri /stats
+        stats refresh 10s
+        stats admin if LOCALHOST
diff --git a/tests/DotPulsar.StressTests/ConnectionTests.cs b/tests/DotPulsar.StressTests/ConnectionTests.cs
new file mode 100644
index 0000000..3a5f694
--- /dev/null
+++ b/tests/DotPulsar.StressTests/ConnectionTests.cs
@@ -0,0 +1,63 @@
+/*
+ * Licensed 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.
+ */
+
+using DotPulsar.Extensions;
+using System;
+using System.Threading;
+using System.Threading.Tasks;
+using DotPulsar.StressTests.Fixtures;
+using Xunit;
+using Xunit.Abstractions;
+
+namespace DotPulsar.StressTests
+{
+    [Collection(nameof(StandaloneClusterTest))]
+    public class ConnectionTests
+    {
+        private readonly ITestOutputHelper _output;
+
+        public ConnectionTests(ITestOutputHelper output) => _output = output;
+
+        [Theory]
+        [InlineData("pulsar://localhost:54545")] // test that we can connect directly to a broker
+        [InlineData("pulsar://localhost:6666")] // test that we can connect through a reverse proxy (NOT a pulsar proxy)
+        public async Task ConnectionHandshake_GivenValidServiceUrls_ShouldEstablishConnection(string serviceUrl)
+        {
+            //Arrange
+            var testRunId = Guid.NewGuid().ToString("N");
+
+            var topic = $"persistent://public/default/consumer-tests-{testRunId}";
+
+            var builder = PulsarClient.Builder()
+                .ExceptionHandler(new XunitExceptionHandler(_output));
+
+            if (!string.IsNullOrEmpty(serviceUrl))
+            {
+                builder.ServiceUrl(new Uri(serviceUrl));
+            }
+
+            await using var client = builder.Build();
+
+            await using var producer = client.NewProducer()
+                .ProducerName($"producer-{testRunId}")
+                .Topic(topic)
+                .Create();
+
+            var cts = new CancellationTokenSource(TimeSpan.FromSeconds(60));
+
+            //Act // Assert
+            await producer.StateChangedTo(ProducerState.Connected, cts.Token);
+        }
+    }
+}
diff --git a/tests/DotPulsar.StressTests/DotPulsar.StressTests.csproj b/tests/DotPulsar.StressTests/DotPulsar.StressTests.csproj
index 9e8b85d..9359a9e 100644
--- a/tests/DotPulsar.StressTests/DotPulsar.StressTests.csproj
+++ b/tests/DotPulsar.StressTests/DotPulsar.StressTests.csproj
@@ -21,10 +21,11 @@
 
   <ItemGroup>
     <None Include="..\docker-compose-standalone-tests.yml" CopyToOutputDirectory="Always" />
+    <None Include="..\..\haproxy.cfg" CopyToOutputDirectory="Always" />
   </ItemGroup>
 
   <ItemGroup>
     <ProjectReference Include="..\..\src\DotPulsar\DotPulsar.csproj" />
   </ItemGroup>
-  
+
 </Project>
diff --git a/tests/docker-compose-standalone-tests.yml b/tests/docker-compose-standalone-tests.yml
index 78ac29e..d591b22 100644
--- a/tests/docker-compose-standalone-tests.yml
+++ b/tests/docker-compose-standalone-tests.yml
@@ -12,3 +12,16 @@ services:
       PULSAR_MEM: " -Xms1g -Xmx1g -XX:MaxDirectMemorySize=2g"
     command: |
       /bin/bash -c "bin/apply-config-from-env.py conf/standalone.conf && bin/pulsar standalone --no-functions-worker"
+
+  loadbalancer:
+    container_name: loadbalancer
+    image: 'haproxy:2.1.3'
+    ports:
+      - '8888:8888'
+      - '6666:6666'
+      - '9999:9999'
+    volumes:
+      - /var/run/docker.sock:/var/run/docker.sock
+      - ./haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
+    depends_on:
+      - pulsar


[pulsar-dotpulsar] 02/02: moved haproxy.cfg

Posted by bl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

blankensteiner pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar-dotpulsar.git

commit c18b5046006f1056687d1bc9329a77aa440cf2bb
Author: Vince Pergolizzi <pe...@gmail.com>
AuthorDate: Sat Mar 28 22:50:41 2020 -0400

    moved haproxy.cfg
---
 tests/DotPulsar.StressTests/DotPulsar.StressTests.csproj | 2 +-
 haproxy.cfg => tests/haproxy.cfg                         | 0
 2 files changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/DotPulsar.StressTests/DotPulsar.StressTests.csproj b/tests/DotPulsar.StressTests/DotPulsar.StressTests.csproj
index 9359a9e..d7dadce 100644
--- a/tests/DotPulsar.StressTests/DotPulsar.StressTests.csproj
+++ b/tests/DotPulsar.StressTests/DotPulsar.StressTests.csproj
@@ -21,7 +21,7 @@
 
   <ItemGroup>
     <None Include="..\docker-compose-standalone-tests.yml" CopyToOutputDirectory="Always" />
-    <None Include="..\..\haproxy.cfg" CopyToOutputDirectory="Always" />
+    <None Include="..\haproxy.cfg" CopyToOutputDirectory="Always" />
   </ItemGroup>
 
   <ItemGroup>
diff --git a/haproxy.cfg b/tests/haproxy.cfg
similarity index 100%
rename from haproxy.cfg
rename to tests/haproxy.cfg