From efbd0fa567c6428342309e191b850ca1f223fcf8 Mon Sep 17 00:00:00 2001 From: ideoma <2159629+ideoma@users.noreply.github.com> Date: Fri, 10 Oct 2025 15:54:03 +0100 Subject: [PATCH 1/6] test: fix tests, add ci test pipeline --- ci/azure-pipelines.yml | 68 +++++++++++++++++++ ci/run_tests_pipeline.yaml | 32 --------- src/net-questdb-client-tests/HttpTests.cs | 2 +- .../SenderOptionsTests.cs | 6 +- src/net-questdb-client-tests/SenderTests.cs | 5 +- src/net-questdb-client-tests/TcpTests.cs | 2 +- .../net-questdb-client-tests.csproj | 1 - 7 files changed, 77 insertions(+), 39 deletions(-) create mode 100644 ci/azure-pipelines.yml delete mode 100644 ci/run_tests_pipeline.yaml diff --git a/ci/azure-pipelines.yml b/ci/azure-pipelines.yml new file mode 100644 index 0000000..8dc7351 --- /dev/null +++ b/ci/azure-pipelines.yml @@ -0,0 +1,68 @@ +# 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 SDK on $(osName)' + 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) --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/net-questdb-client-tests/HttpTests.cs b/src/net-questdb-client-tests/HttpTests.cs index dfc4458..9f3336a 100644 --- a/src/net-questdb-client-tests/HttpTests.cs +++ b/src/net-questdb-client-tests/HttpTests.cs @@ -886,7 +886,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)); } 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..4d6fb20 100644 --- a/src/net-questdb-client-tests/net-questdb-client-tests.csproj +++ b/src/net-questdb-client-tests/net-questdb-client-tests.csproj @@ -1,7 +1,6 @@ - net6.0;net7.0;net8.0;net9.0 net_questdb_client_tests enable enable From f7f59223cd24d0e094ef33857628ad6ac226ef6d Mon Sep 17 00:00:00 2001 From: ideoma <2159629+ideoma@users.noreply.github.com> Date: Fri, 10 Oct 2025 16:53:57 +0100 Subject: [PATCH 2/6] add test target framework --- src/net-questdb-client-tests/net-questdb-client-tests.csproj | 1 + 1 file changed, 1 insertion(+) 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 4d6fb20..b429505 100644 --- a/src/net-questdb-client-tests/net-questdb-client-tests.csproj +++ b/src/net-questdb-client-tests/net-questdb-client-tests.csproj @@ -1,6 +1,7 @@ + net9.0 net_questdb_client_tests enable enable From b50a136f12c5a7572387d2ddf94af09d6afaf43d Mon Sep 17 00:00:00 2001 From: ideoma <2159629+ideoma@users.noreply.github.com> Date: Fri, 10 Oct 2025 17:02:44 +0100 Subject: [PATCH 3/6] fix pipeline --- ci/azure-pipelines.yml | 25 +++++++++++++++++-- .../net-questdb-client-tests.csproj | 2 +- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/ci/azure-pipelines.yml b/ci/azure-pipelines.yml index 8dc7351..1248050 100644 --- a/ci/azure-pipelines.yml +++ b/ci/azure-pipelines.yml @@ -33,7 +33,28 @@ steps: displayName: 'Checkout code with submodules' - task: UseDotNet@2 - displayName: 'Install .NET SDK on $(osName)' + 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) @@ -57,7 +78,7 @@ steps: inputs: command: 'test' projects: 'src/net-questdb-client-tests/net-questdb-client-tests.csproj' - arguments: '--configuration $(buildConfiguration) --no-build --verbosity normal --logger trx --collect:"XPlat Code Coverage"' + arguments: '--configuration $(buildConfiguration) --framework net9.0 --no-build --verbosity normal --logger trx --collect:"XPlat Code Coverage"' publishTestResults: true - task: PublishCodeCoverageResults@2 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 b429505..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 @@ - net9.0 net_questdb_client_tests enable enable false + net6.0;net7.0;net8.0;net9.0 From 986966920010fb986adafcdd2f95d5fc42c4d28e Mon Sep 17 00:00:00 2001 From: ideoma <2159629+ideoma@users.noreply.github.com> Date: Fri, 10 Oct 2025 17:46:15 +0100 Subject: [PATCH 4/6] fix pipeline to trust cert --- ci/azure-pipelines.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ci/azure-pipelines.yml b/ci/azure-pipelines.yml index 1248050..8ca4540 100644 --- a/ci/azure-pipelines.yml +++ b/ci/azure-pipelines.yml @@ -73,6 +73,18 @@ steps: projects: 'net-questdb-client.sln' arguments: '--configuration $(buildConfiguration) --no-restore' +- script: dotnet dev-certs https --trust + displayName: 'Trust HTTPS dev certificate' + condition: eq(variables['Agent.OS'], 'Windows_NT') + continueOnError: true + +- script: | + dotnet dev-certs https --clean + dotnet dev-certs https + displayName: 'Setup HTTPS dev certificate (Linux/macOS)' + condition: ne(variables['Agent.OS'], 'Windows_NT') + continueOnError: true + - task: DotNetCoreCLI@2 displayName: 'Run tests on $(osName)' inputs: From 7aa7702876745241c197fdba27b578dca188064b Mon Sep 17 00:00:00 2001 From: ideoma <2159629+ideoma@users.noreply.github.com> Date: Fri, 10 Oct 2025 18:41:19 +0100 Subject: [PATCH 5/6] fix tests --- src/dummy-http-server/DummyHttpServer.cs | 3 +- src/net-questdb-client-tests/HttpTests.cs | 36 +++++++++++++++++++---- 2 files changed, 32 insertions(+), 7 deletions(-) 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 9f3336a..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)); } @@ -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)); } From 02412edf782bff9c418b5e500d89f52e9b463504 Mon Sep 17 00:00:00 2001 From: ideoma <2159629+ideoma@users.noreply.github.com> Date: Fri, 10 Oct 2025 18:43:07 +0100 Subject: [PATCH 6/6] fix pipeline --- ci/azure-pipelines.yml | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/ci/azure-pipelines.yml b/ci/azure-pipelines.yml index 8ca4540..1248050 100644 --- a/ci/azure-pipelines.yml +++ b/ci/azure-pipelines.yml @@ -73,18 +73,6 @@ steps: projects: 'net-questdb-client.sln' arguments: '--configuration $(buildConfiguration) --no-restore' -- script: dotnet dev-certs https --trust - displayName: 'Trust HTTPS dev certificate' - condition: eq(variables['Agent.OS'], 'Windows_NT') - continueOnError: true - -- script: | - dotnet dev-certs https --clean - dotnet dev-certs https - displayName: 'Setup HTTPS dev certificate (Linux/macOS)' - condition: ne(variables['Agent.OS'], 'Windows_NT') - continueOnError: true - - task: DotNetCoreCLI@2 displayName: 'Run tests on $(osName)' inputs: