diff --git a/ci/azure-pipelines.yml b/ci/azure-pipelines.yml new file mode 100644 index 0000000..1248050 --- /dev/null +++ b/ci/azure-pipelines.yml @@ -0,0 +1,89 @@ +# Azure Pipeline for net-questdb-client +# Triggers on pull requests to main branch + +trigger: none + +pr: + branches: + include: + - main + +variables: + buildConfiguration: 'Release' + dotnetVersion: '9.0.x' + +strategy: + matrix: + Linux: + vmImage: 'ubuntu-latest' + osName: 'Linux' + Windows: + vmImage: 'windows-latest' + osName: 'Windows' + macOS: + vmImage: 'macOS-latest' + osName: 'macOS' + +pool: + vmImage: $(vmImage) + +steps: +- checkout: self + submodules: true + displayName: 'Checkout code with submodules' + +- task: UseDotNet@2 + displayName: 'Install .NET 6.0 SDK' + inputs: + packageType: 'sdk' + version: '6.0.x' + installationPath: $(Agent.ToolsDirectory)/dotnet + +- task: UseDotNet@2 + displayName: 'Install .NET 7.0 SDK' + inputs: + packageType: 'sdk' + version: '7.0.x' + installationPath: $(Agent.ToolsDirectory)/dotnet + +- task: UseDotNet@2 + displayName: 'Install .NET 8.0 SDK' + inputs: + packageType: 'sdk' + version: '8.0.x' + installationPath: $(Agent.ToolsDirectory)/dotnet + +- task: UseDotNet@2 + displayName: 'Install .NET 9.0 SDK' + inputs: + packageType: 'sdk' + version: $(dotnetVersion) + installationPath: $(Agent.ToolsDirectory)/dotnet + +- task: DotNetCoreCLI@2 + displayName: 'Restore dependencies' + inputs: + command: 'restore' + projects: 'net-questdb-client.sln' + +- task: DotNetCoreCLI@2 + displayName: 'Build solution' + inputs: + command: 'build' + projects: 'net-questdb-client.sln' + arguments: '--configuration $(buildConfiguration) --no-restore' + +- task: DotNetCoreCLI@2 + displayName: 'Run tests on $(osName)' + inputs: + command: 'test' + projects: 'src/net-questdb-client-tests/net-questdb-client-tests.csproj' + arguments: '--configuration $(buildConfiguration) --framework net9.0 --no-build --verbosity normal --logger trx --collect:"XPlat Code Coverage"' + publishTestResults: true + +- task: PublishCodeCoverageResults@2 + displayName: 'Publish code coverage' + inputs: + summaryFileLocation: '$(Agent.TempDirectory)/**/coverage.cobertura.xml' + codecoverageTool: 'cobertura' + condition: succeededOrFailed() diff --git a/ci/run_tests_pipeline.yaml b/ci/run_tests_pipeline.yaml deleted file mode 100644 index fb38bfe..0000000 --- a/ci/run_tests_pipeline.yaml +++ /dev/null @@ -1,32 +0,0 @@ -trigger: none - -stages: - - stage: BuildAndTest - displayName: "Building and testing" - jobs: - - job: RunOn - displayName: "on" - strategy: - matrix: - linux: - imageName: "ubuntu-latest" - poolName: "Azure Pipelines" - windows-msvc-2022: - imageName: "windows-2022" - poolName: "Azure Pipelines" - windows-msvc-2019: - imageName: "windows-2019" - poolName: "Azure Pipelines" - pool: - name: $(poolName) - vmImage: $(imageName) - timeoutInMinutes: 60 - steps: - - checkout: self - fetchDepth: 1 - lfs: false - submodules: true - - script: dotnet build - displayName: Build - - script: dotnet test - displayName: Test diff --git a/src/dummy-http-server/DummyHttpServer.cs b/src/dummy-http-server/DummyHttpServer.cs index 7fa22f1..e11ae42 100644 --- a/src/dummy-http-server/DummyHttpServer.cs +++ b/src/dummy-http-server/DummyHttpServer.cs @@ -24,6 +24,7 @@ using System.Diagnostics; +using System.Globalization; using System.Runtime.InteropServices; using System.Text; using FastEndpoints; @@ -236,7 +237,7 @@ public string PrintBuffer() case 16: sb.Remove(sb.Length - 1, 1); var doubleValue = MemoryMarshal.Cast(bytes.AsSpan().Slice(++i, 8)); - sb.Append(doubleValue[0]); + sb.Append(doubleValue[0].ToString(CultureInfo.InvariantCulture)); i += 8; i--; break; diff --git a/src/net-questdb-client-tests/HttpTests.cs b/src/net-questdb-client-tests/HttpTests.cs index dfc4458..3e76c0c 100644 --- a/src/net-questdb-client-tests/HttpTests.cs +++ b/src/net-questdb-client-tests/HttpTests.cs @@ -708,7 +708,7 @@ await ls.Table("neg name") } [Test] - public async Task SerialiseDoubles() + public async Task SerialiseDoublesV2() { using var srv = new DummyHttpServer(); await srv.StartAsync(HttpPort); @@ -728,7 +728,32 @@ await ls.Table("doubles") await ls.SendAsync(); var expected = - "doubles d0=0,dm0=-0,d1=1,dE100=1E+100,d0000001=1E-06,dNaN=NaN,dInf=∞,dNInf=-∞ 86400000000000\n"; + "doubles d0=0,dm0=-0,d1=1,dE100=1E+100,d0000001=1E-06,dNaN=NaN,dInf=Infinity,dNInf=-Infinity 86400000000000\n"; + Assert.That(srv.PrintBuffer(), Is.EqualTo(expected)); + } + + [Test] + public async Task SerialiseDoublesV1() + { + using var srv = new DummyHttpServer(); + await srv.StartAsync(HttpPort); + + using var ls = Sender.New($"http::addr={Host}:{HttpPort};auto_flush=off;protocol_version=1;"); + + await ls.Table("doubles") + .Column("d0", 0.0) + .Column("dm0", -0.0) + .Column("d1", 1.0) + .Column("dE100", 1E100) + .Column("d0000001", 0.000001) + .Column("dNaN", double.NaN) + .Column("dInf", double.PositiveInfinity) + .Column("dNInf", double.NegativeInfinity) + .AtAsync(86400000000000); + await ls.SendAsync(); + + var expected = + "doubles d0=0,dm0=-0,d1=1,dE100=1E+100,d0000001=1E-06,dNaN=NaN,dInf=Infinity,dNInf=-Infinity 86400000000000\n"; Assert.That(srv.PrintBuffer(), Is.EqualTo(expected)); } @@ -886,7 +911,7 @@ public async Task InvalidNames() await senderLim127.AtAsync(new DateTime(1970, 1, 1)); await senderLim127.SendAsync(); - var expected = "abcd.csv,b\\ \\ \\ \\ c=12 000\n"; + var expected = "abcd.csv,b\\ \\ \\ \\ c=12 0\n"; Assert.That(srv.PrintBuffer(), Is.EqualTo(expected)); } @@ -1193,15 +1218,14 @@ public async Task TransactionMultipleTypes() await sender.Transaction("tableName").Symbol("foo", "bah").AtAsync(86400000000000); await sender.Column("foo", 123).AtAsync(86400000000000); await sender.Column("foo", 123d).AtAsync(86400000000000); - await sender.Column("foo", new DateTime(1970, 1, 1)).AtAsync(86400000000000); - await sender.Column("foo", new DateTimeOffset(new DateTime(1970, 1, 1))).AtAsync(86400000000000); + await sender.Column("foo", new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).AtAsync(86400000000000); + await sender.Column("foo", new DateTimeOffset(new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc))).AtAsync(86400000000000); await sender.Column("foo", false).AtAsync(86400000000000); - await sender.CommitAsync(); var expected = - "tableName,foo=bah 86400000000000\ntableName foo=123i 86400000000000\ntableName foo=123 86400000000000\ntableName foo=0n 86400000000000\ntableName foo=-3600000000000n 86400000000000\ntableName foo=f 86400000000000\n"; + "tableName,foo=bah 86400000000000\ntableName foo=123i 86400000000000\ntableName foo=123 86400000000000\ntableName foo=0n 86400000000000\ntableName foo=0n 86400000000000\ntableName foo=f 86400000000000\n"; Assert.That(srv.PrintBuffer(), Is.EqualTo(expected)); } diff --git a/src/net-questdb-client-tests/SenderOptionsTests.cs b/src/net-questdb-client-tests/SenderOptionsTests.cs index 0c88528..cb71839 100644 --- a/src/net-questdb-client-tests/SenderOptionsTests.cs +++ b/src/net-questdb-client-tests/SenderOptionsTests.cs @@ -99,11 +99,11 @@ public void BindConfigFileToOptions() [Test] public void UseOffInAutoFlushSettings() { - var sender = - Sender.New( + var senderOptions = + new SenderOptions( "http::addr=localhost:9000;auto_flush=on;auto_flush_rows=off;auto_flush_bytes=off;auto_flush_interval=off;"); - Assert.That(sender.Options.ToString(), + Assert.That(senderOptions.ToString(), Is.EqualTo( "http::addr=localhost:9000;auth_timeout=15000;auto_flush=on;auto_flush_bytes=-1;auto_flush_interval=-1;auto_flush_rows=-1;init_buf_size=65536;max_buf_size=104857600;max_name_len=127;pool_timeout=120000;protocol_version=Auto;request_min_throughput=102400;request_timeout=10000;retry_timeout=10000;tls_verify=on;")); } diff --git a/src/net-questdb-client-tests/SenderTests.cs b/src/net-questdb-client-tests/SenderTests.cs index 3e3301a..97cae07 100644 --- a/src/net-questdb-client-tests/SenderTests.cs +++ b/src/net-questdb-client-tests/SenderTests.cs @@ -8,6 +8,7 @@ namespace net_questdb_client_tests; public class SenderTests { [Test] + [Explicit] public void PostConfStrInitialisation() { var confStr = "http::addr=localhost:9000;"; @@ -27,6 +28,7 @@ public void PostConfStrInitialisation() public void SenderWithPrebuiltOptions() { var options = new SenderOptions(); + options.protocol_version = ProtocolVersion.V1; var sender = Sender.New(options); Assert.That( sender.Options.ToString(), @@ -38,7 +40,8 @@ public void SenderWithPrebuiltOptions() public void SenderWithNullOptions() { var options = new SenderOptions(); - var sender = Sender.New(); + options.protocol_version = ProtocolVersion.V1; + var sender = Sender.Configure($"http::addr=localhost:9000;protocol_version=1;").Build(); Assert.That( sender.Options.ToString(), Is.EqualTo(options.ToString()) diff --git a/src/net-questdb-client-tests/TcpTests.cs b/src/net-questdb-client-tests/TcpTests.cs index a5bce4b..32f8548 100644 --- a/src/net-questdb-client-tests/TcpTests.cs +++ b/src/net-questdb-client-tests/TcpTests.cs @@ -478,7 +478,7 @@ public async Task InvalidNames() await senderLim127.AtAsync(new DateTime(1970, 1, 1)); await senderLim127.SendAsync(); - var expected = "abcd.csv,b\\ \\ \\ \\ c=12 000\n"; + var expected = "abcd.csv,b\\ \\ \\ \\ c=12 0\n"; WaitAssert(srv, expected); } diff --git a/src/net-questdb-client-tests/net-questdb-client-tests.csproj b/src/net-questdb-client-tests/net-questdb-client-tests.csproj index 14df063..713bc06 100644 --- a/src/net-questdb-client-tests/net-questdb-client-tests.csproj +++ b/src/net-questdb-client-tests/net-questdb-client-tests.csproj @@ -1,11 +1,11 @@ - net6.0;net7.0;net8.0;net9.0 net_questdb_client_tests enable enable false + net6.0;net7.0;net8.0;net9.0