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/28 15:45:40 UTC

[pulsar-dotpulsar] branch master updated: Minor refactoring

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


The following commit(s) were added to refs/heads/master by this push:
     new 180d655  Minor refactoring
180d655 is described below

commit 180d655999e28fd9a129c415ae32917c663bc123
Author: Daniel Blankensteiner <db...@vmail.dk>
AuthorDate: Sat Mar 28 16:45:29 2020 +0100

    Minor refactoring
---
 DotPulsar.sln                                      |  4 +--
 .../Fixtures/StandaloneClusterTests.cs             | 10 --------
 tests/Directory.Build.props                        |  8 ++++++
 .../DotPulsar.StressTests}/ConsumerTests.cs        |  6 ++---
 .../DotPulsar.StressTests.csproj                   |  5 ++--
 .../EnumerableTaskExtensions.cs                    |  2 +-
 .../Fixtures/StandaloneClusterFixture.cs           | 30 +++++++++++++++++-----
 .../Fixtures/StandaloneClusterTests.cs             | 22 ++++------------
 .../XunitExceptionHandler.cs                       |  2 +-
 .../DotPulsar.Tests/DotPulsar.Tests.csproj         |  2 +-
 .../DotPulsar.Tests/Internal/AsyncLockTests.cs     |  0
 .../DotPulsar.Tests/Internal/AsyncQueueTests.cs    |  0
 .../DotPulsar.Tests/Internal/Crc32CTests.cs        |  0
 .../Extensions/ReadOnlySequenceExtensionsTests.cs  |  0
 .../Internal/SequenceBuilderTests.cs               |  0
 .../DotPulsar.Tests/Internal/SerializerTests.cs    |  0
 .../DotPulsar.Tests/Internal/StateManagerTests.cs  |  0
 .../docker-compose-standalone-tests.yml            |  2 +-
 18 files changed, 49 insertions(+), 44 deletions(-)

diff --git a/DotPulsar.sln b/DotPulsar.sln
index 4e4f131..de49e5f 100644
--- a/DotPulsar.sln
+++ b/DotPulsar.sln
@@ -5,9 +5,9 @@ VisualStudioVersion = 16.0.29209.62
 MinimumVisualStudioVersion = 10.0.40219.1
 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DotPulsar", "src\DotPulsar\DotPulsar.csproj", "{8D300FC3-2E35-4D23-B0DD-FEE9E153330A}"
 EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DotPulsar.Tests", "src\DotPulsar.Tests\DotPulsar.Tests.csproj", "{B3FCD2D5-8009-4281-ACDB-6A7BC99606B4}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DotPulsar.Tests", "tests\DotPulsar.Tests\DotPulsar.Tests.csproj", "{B3FCD2D5-8009-4281-ACDB-6A7BC99606B4}"
 EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DotPulsar.Stress.Tests", "src\DotPulsar.Stress.Tests\DotPulsar.Stress.Tests.csproj", "{DDC68F51-DE1B-4794-9EE7-392C303CF5EB}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DotPulsar.StressTests", "tests\DotPulsar.StressTests\DotPulsar.StressTests.csproj", "{DDC68F51-DE1B-4794-9EE7-392C303CF5EB}"
 EndProject
 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{E1C932A9-6D4C-4DDF-8922-BE7B71F12F1C}"
 EndProject
diff --git a/src/DotPulsar.Stress.Tests/Fixtures/StandaloneClusterTests.cs b/src/DotPulsar.Stress.Tests/Fixtures/StandaloneClusterTests.cs
deleted file mode 100644
index 0f05954..0000000
--- a/src/DotPulsar.Stress.Tests/Fixtures/StandaloneClusterTests.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using Xunit;
-
-namespace DotPulsar.Stress.Tests.Fixtures
-{
-    [CollectionDefinition(nameof(StandaloneClusterTest))]
-    public class StandaloneClusterTest : ICollectionFixture<StandaloneClusterFixture>
-    {
-
-    }
-}
\ No newline at end of file
diff --git a/tests/Directory.Build.props b/tests/Directory.Build.props
new file mode 100644
index 0000000..9ff9438
--- /dev/null
+++ b/tests/Directory.Build.props
@@ -0,0 +1,8 @@
+<Project>
+
+  <PropertyGroup>
+    <LangVersion>8.0</LangVersion>
+    <Nullable>enable</Nullable>
+  </PropertyGroup>
+
+</Project>
\ No newline at end of file
diff --git a/src/DotPulsar.Stress.Tests/ConsumerTests.cs b/tests/DotPulsar.StressTests/ConsumerTests.cs
similarity index 96%
rename from src/DotPulsar.Stress.Tests/ConsumerTests.cs
rename to tests/DotPulsar.StressTests/ConsumerTests.cs
index 0f81a84..eb06762 100644
--- a/src/DotPulsar.Stress.Tests/ConsumerTests.cs
+++ b/tests/DotPulsar.StressTests/ConsumerTests.cs
@@ -20,11 +20,11 @@ using System.Linq;
 using System.Text;
 using System.Threading;
 using System.Threading.Tasks;
-using DotPulsar.Stress.Tests.Fixtures;
+using DotPulsar.StressTests.Fixtures;
 using Xunit;
 using Xunit.Abstractions;
 
-namespace DotPulsar.Stress.Tests
+namespace DotPulsar.StressTests
 {
     [Collection(nameof(StandaloneClusterTest))]
     public class ConsumerTests
@@ -34,7 +34,7 @@ namespace DotPulsar.Stress.Tests
         public ConsumerTests(ITestOutputHelper output) => _output = output;
 
         [Theory]
-        [InlineData(1000)]
+        [InlineData(10000)]
         public async Task Messages_GivenTopicWithMessages_ShouldConsumeAll(int numberOfMessages)
         {
             //Arrange
diff --git a/src/DotPulsar.Stress.Tests/DotPulsar.Stress.Tests.csproj b/tests/DotPulsar.StressTests/DotPulsar.StressTests.csproj
similarity index 85%
rename from src/DotPulsar.Stress.Tests/DotPulsar.Stress.Tests.csproj
rename to tests/DotPulsar.StressTests/DotPulsar.StressTests.csproj
index 86f59f6..9e8b85d 100644
--- a/src/DotPulsar.Stress.Tests/DotPulsar.Stress.Tests.csproj
+++ b/tests/DotPulsar.StressTests/DotPulsar.StressTests.csproj
@@ -20,10 +20,11 @@
   </ItemGroup>
 
   <ItemGroup>
-    <ProjectReference Include="..\DotPulsar\DotPulsar.csproj" />
+    <None Include="..\docker-compose-standalone-tests.yml" CopyToOutputDirectory="Always" />
   </ItemGroup>
 
   <ItemGroup>
-    <None Include="..\..\docker-compose-standalone-tests.yml" CopyToOutputDirectory="Always" />
+    <ProjectReference Include="..\..\src\DotPulsar\DotPulsar.csproj" />
   </ItemGroup>
+  
 </Project>
diff --git a/src/DotPulsar.Stress.Tests/EnumerableTaskExtensions.cs b/tests/DotPulsar.StressTests/EnumerableTaskExtensions.cs
similarity index 98%
rename from src/DotPulsar.Stress.Tests/EnumerableTaskExtensions.cs
rename to tests/DotPulsar.StressTests/EnumerableTaskExtensions.cs
index b7222e9..c633558 100644
--- a/src/DotPulsar.Stress.Tests/EnumerableTaskExtensions.cs
+++ b/tests/DotPulsar.StressTests/EnumerableTaskExtensions.cs
@@ -17,7 +17,7 @@ using System.Diagnostics;
 using System.Linq;
 using System.Threading.Tasks;
 
-namespace DotPulsar.Stress.Tests
+namespace DotPulsar.StressTests
 {
     public static class EnumerableValueTaskExtensions
     {
diff --git a/src/DotPulsar.Stress.Tests/Fixtures/StandaloneClusterFixture.cs b/tests/DotPulsar.StressTests/Fixtures/StandaloneClusterFixture.cs
similarity index 69%
rename from src/DotPulsar.Stress.Tests/Fixtures/StandaloneClusterFixture.cs
rename to tests/DotPulsar.StressTests/Fixtures/StandaloneClusterFixture.cs
index fff27ed..a3ab33b 100644
--- a/src/DotPulsar.Stress.Tests/Fixtures/StandaloneClusterFixture.cs
+++ b/tests/DotPulsar.StressTests/Fixtures/StandaloneClusterFixture.cs
@@ -1,10 +1,24 @@
+/*
+ * 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 System;
 using System.Diagnostics;
 using System.Net.Http;
 using System.Threading.Tasks;
 using Xunit;
 
-namespace DotPulsar.Stress.Tests.Fixtures
+namespace DotPulsar.StressTests.Fixtures
 {
     public class StandaloneClusterFixture : IAsyncLifetime
     {
@@ -15,10 +29,13 @@ namespace DotPulsar.Stress.Tests.Fixtures
             RunProcess("docker-compose", "-f docker-compose-standalone-tests.yml build");
             RunProcess("docker-compose", "-f docker-compose-standalone-tests.yml up -d");
 
-            int waitTries = 10;
+            var waitTries = 10;
+
+            using var handler = new HttpClientHandler
+            {
+                AllowAutoRedirect = true
+            };
 
-            using var handler = new HttpClientHandler();
-            handler.AllowAutoRedirect = true;
             using var client = new HttpClient(handler);
 
             while (waitTries > 0)
@@ -28,7 +45,7 @@ namespace DotPulsar.Stress.Tests.Fixtures
                     await client.GetAsync("http://localhost:8080/metrics/").ConfigureAwait(false);
                     return;
                 }
-                catch (Exception ex)
+                catch
                 {
                     waitTries--;
                     await Task.Delay(5000).ConfigureAwait(false);
@@ -38,9 +55,10 @@ namespace DotPulsar.Stress.Tests.Fixtures
             throw new Exception("Unable to confirm Pulsar has initialized");
         }
 
-        public async Task DisposeAsync()
+        public Task DisposeAsync()
         {
             RunProcess("docker-compose", "-f docker-compose-standalone-tests.yml down");
+            return Task.CompletedTask;
         }
 
         private void RunProcess(string name, string arguments)
diff --git a/src/DotPulsar.Tests/Internal/SerializerTests.cs b/tests/DotPulsar.StressTests/Fixtures/StandaloneClusterTests.cs
similarity index 54%
copy from src/DotPulsar.Tests/Internal/SerializerTests.cs
copy to tests/DotPulsar.StressTests/Fixtures/StandaloneClusterTests.cs
index 81375a2..3379607 100644
--- a/src/DotPulsar.Tests/Internal/SerializerTests.cs
+++ b/tests/DotPulsar.StressTests/Fixtures/StandaloneClusterTests.cs
@@ -1,4 +1,4 @@
-/*
+/*
  * 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
@@ -12,25 +12,13 @@
  * limitations under the License.
  */
 
-using DotPulsar.Internal;
 using Xunit;
 
-namespace DotPulsar.Tests.Internal
+namespace DotPulsar.StressTests.Fixtures
 {
-    public class SerializerTests
+    [CollectionDefinition(nameof(StandaloneClusterTest))]
+    public class StandaloneClusterTest : ICollectionFixture<StandaloneClusterFixture>
     {
-        [Fact]
-        public void ToBigEndianBytes_GivenUnsignedInteger_ShouldReturnExpectedBytes()
-        {
-            //Arrange
-            uint value = 66051;
 
-            //Act
-            var actual = Serializer.ToBigEndianBytes(value);
-
-            //Assert
-            var expected = new byte[] { 0x00, 0x01, 0x02, 0x03 };
-            Assert.Equal(expected, actual);
-        }
     }
-}
+}
\ No newline at end of file
diff --git a/src/DotPulsar.Stress.Tests/XunitExceptionHandler.cs b/tests/DotPulsar.StressTests/XunitExceptionHandler.cs
similarity index 98%
rename from src/DotPulsar.Stress.Tests/XunitExceptionHandler.cs
rename to tests/DotPulsar.StressTests/XunitExceptionHandler.cs
index 2a75d3c..52c168c 100644
--- a/src/DotPulsar.Stress.Tests/XunitExceptionHandler.cs
+++ b/tests/DotPulsar.StressTests/XunitExceptionHandler.cs
@@ -18,7 +18,7 @@ using System;
 using System.Threading.Tasks;
 using Xunit.Abstractions;
 
-namespace DotPulsar.Stress.Tests
+namespace DotPulsar.StressTests
 {
     internal class XunitExceptionHandler : IHandleException
     {
diff --git a/src/DotPulsar.Tests/DotPulsar.Tests.csproj b/tests/DotPulsar.Tests/DotPulsar.Tests.csproj
similarity index 92%
rename from src/DotPulsar.Tests/DotPulsar.Tests.csproj
rename to tests/DotPulsar.Tests/DotPulsar.Tests.csproj
index f06fd7a..2f62d2d 100644
--- a/src/DotPulsar.Tests/DotPulsar.Tests.csproj
+++ b/tests/DotPulsar.Tests/DotPulsar.Tests.csproj
@@ -19,7 +19,7 @@
   </ItemGroup>
 
   <ItemGroup>
-    <ProjectReference Include="..\DotPulsar\DotPulsar.csproj" />
+    <ProjectReference Include="..\..\src\DotPulsar\DotPulsar.csproj" />
   </ItemGroup>
 
 </Project>
diff --git a/src/DotPulsar.Tests/Internal/AsyncLockTests.cs b/tests/DotPulsar.Tests/Internal/AsyncLockTests.cs
similarity index 100%
rename from src/DotPulsar.Tests/Internal/AsyncLockTests.cs
rename to tests/DotPulsar.Tests/Internal/AsyncLockTests.cs
diff --git a/src/DotPulsar.Tests/Internal/AsyncQueueTests.cs b/tests/DotPulsar.Tests/Internal/AsyncQueueTests.cs
similarity index 100%
rename from src/DotPulsar.Tests/Internal/AsyncQueueTests.cs
rename to tests/DotPulsar.Tests/Internal/AsyncQueueTests.cs
diff --git a/src/DotPulsar.Tests/Internal/Crc32CTests.cs b/tests/DotPulsar.Tests/Internal/Crc32CTests.cs
similarity index 100%
rename from src/DotPulsar.Tests/Internal/Crc32CTests.cs
rename to tests/DotPulsar.Tests/Internal/Crc32CTests.cs
diff --git a/src/DotPulsar.Tests/Internal/Extensions/ReadOnlySequenceExtensionsTests.cs b/tests/DotPulsar.Tests/Internal/Extensions/ReadOnlySequenceExtensionsTests.cs
similarity index 100%
rename from src/DotPulsar.Tests/Internal/Extensions/ReadOnlySequenceExtensionsTests.cs
rename to tests/DotPulsar.Tests/Internal/Extensions/ReadOnlySequenceExtensionsTests.cs
diff --git a/src/DotPulsar.Tests/Internal/SequenceBuilderTests.cs b/tests/DotPulsar.Tests/Internal/SequenceBuilderTests.cs
similarity index 100%
rename from src/DotPulsar.Tests/Internal/SequenceBuilderTests.cs
rename to tests/DotPulsar.Tests/Internal/SequenceBuilderTests.cs
diff --git a/src/DotPulsar.Tests/Internal/SerializerTests.cs b/tests/DotPulsar.Tests/Internal/SerializerTests.cs
similarity index 100%
rename from src/DotPulsar.Tests/Internal/SerializerTests.cs
rename to tests/DotPulsar.Tests/Internal/SerializerTests.cs
diff --git a/src/DotPulsar.Tests/Internal/StateManagerTests.cs b/tests/DotPulsar.Tests/Internal/StateManagerTests.cs
similarity index 100%
rename from src/DotPulsar.Tests/Internal/StateManagerTests.cs
rename to tests/DotPulsar.Tests/Internal/StateManagerTests.cs
diff --git a/docker-compose-standalone-tests.yml b/tests/docker-compose-standalone-tests.yml
similarity index 90%
rename from docker-compose-standalone-tests.yml
rename to tests/docker-compose-standalone-tests.yml
index 755301b..00a23ae 100644
--- a/docker-compose-standalone-tests.yml
+++ b/tests/docker-compose-standalone-tests.yml
@@ -3,7 +3,7 @@ version: '3.5'
 services:
 
   pulsar:
-    container_name: pulsar
+    container_name: pulsar-stresstests
     image: 'apachepulsar/pulsar:2.5.0'
     ports:
       - '8080:8080'