Skip to content

Commit ae56498

Browse files
authored
test: fix tests, add ci test pipeline (#51)
1 parent 12af39c commit ae56498

File tree

8 files changed

+131
-46
lines changed

8 files changed

+131
-46
lines changed

ci/azure-pipelines.yml

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# Azure Pipeline for net-questdb-client
2+
# Triggers on pull requests to main branch
3+
4+
trigger: none
5+
6+
pr:
7+
branches:
8+
include:
9+
- main
10+
11+
variables:
12+
buildConfiguration: 'Release'
13+
dotnetVersion: '9.0.x'
14+
15+
strategy:
16+
matrix:
17+
Linux:
18+
vmImage: 'ubuntu-latest'
19+
osName: 'Linux'
20+
Windows:
21+
vmImage: 'windows-latest'
22+
osName: 'Windows'
23+
macOS:
24+
vmImage: 'macOS-latest'
25+
osName: 'macOS'
26+
27+
pool:
28+
vmImage: $(vmImage)
29+
30+
steps:
31+
- checkout: self
32+
submodules: true
33+
displayName: 'Checkout code with submodules'
34+
35+
- task: UseDotNet@2
36+
displayName: 'Install .NET 6.0 SDK'
37+
inputs:
38+
packageType: 'sdk'
39+
version: '6.0.x'
40+
installationPath: $(Agent.ToolsDirectory)/dotnet
41+
42+
- task: UseDotNet@2
43+
displayName: 'Install .NET 7.0 SDK'
44+
inputs:
45+
packageType: 'sdk'
46+
version: '7.0.x'
47+
installationPath: $(Agent.ToolsDirectory)/dotnet
48+
49+
- task: UseDotNet@2
50+
displayName: 'Install .NET 8.0 SDK'
51+
inputs:
52+
packageType: 'sdk'
53+
version: '8.0.x'
54+
installationPath: $(Agent.ToolsDirectory)/dotnet
55+
56+
- task: UseDotNet@2
57+
displayName: 'Install .NET 9.0 SDK'
58+
inputs:
59+
packageType: 'sdk'
60+
version: $(dotnetVersion)
61+
installationPath: $(Agent.ToolsDirectory)/dotnet
62+
63+
- task: DotNetCoreCLI@2
64+
displayName: 'Restore dependencies'
65+
inputs:
66+
command: 'restore'
67+
projects: 'net-questdb-client.sln'
68+
69+
- task: DotNetCoreCLI@2
70+
displayName: 'Build solution'
71+
inputs:
72+
command: 'build'
73+
projects: 'net-questdb-client.sln'
74+
arguments: '--configuration $(buildConfiguration) --no-restore'
75+
76+
- task: DotNetCoreCLI@2
77+
displayName: 'Run tests on $(osName)'
78+
inputs:
79+
command: 'test'
80+
projects: 'src/net-questdb-client-tests/net-questdb-client-tests.csproj'
81+
arguments: '--configuration $(buildConfiguration) --framework net9.0 --no-build --verbosity normal --logger trx --collect:"XPlat Code Coverage"'
82+
publishTestResults: true
83+
84+
- task: PublishCodeCoverageResults@2
85+
displayName: 'Publish code coverage'
86+
inputs:
87+
summaryFileLocation: '$(Agent.TempDirectory)/**/coverage.cobertura.xml'
88+
codecoverageTool: 'cobertura'
89+
condition: succeededOrFailed()

ci/run_tests_pipeline.yaml

Lines changed: 0 additions & 32 deletions
This file was deleted.

src/dummy-http-server/DummyHttpServer.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525

2626
using System.Diagnostics;
27+
using System.Globalization;
2728
using System.Runtime.InteropServices;
2829
using System.Text;
2930
using FastEndpoints;
@@ -236,7 +237,7 @@ public string PrintBuffer()
236237
case 16:
237238
sb.Remove(sb.Length - 1, 1);
238239
var doubleValue = MemoryMarshal.Cast<byte, double>(bytes.AsSpan().Slice(++i, 8));
239-
sb.Append(doubleValue[0]);
240+
sb.Append(doubleValue[0].ToString(CultureInfo.InvariantCulture));
240241
i += 8;
241242
i--;
242243
break;

src/net-questdb-client-tests/HttpTests.cs

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,7 @@ await ls.Table("neg name")
708708
}
709709

710710
[Test]
711-
public async Task SerialiseDoubles()
711+
public async Task SerialiseDoublesV2()
712712
{
713713
using var srv = new DummyHttpServer();
714714
await srv.StartAsync(HttpPort);
@@ -728,7 +728,32 @@ await ls.Table("doubles")
728728
await ls.SendAsync();
729729

730730
var expected =
731-
"doubles d0=0,dm0=-0,d1=1,dE100=1E+100,d0000001=1E-06,dNaN=NaN,dInf=∞,dNInf=-∞ 86400000000000\n";
731+
"doubles d0=0,dm0=-0,d1=1,dE100=1E+100,d0000001=1E-06,dNaN=NaN,dInf=Infinity,dNInf=-Infinity 86400000000000\n";
732+
Assert.That(srv.PrintBuffer(), Is.EqualTo(expected));
733+
}
734+
735+
[Test]
736+
public async Task SerialiseDoublesV1()
737+
{
738+
using var srv = new DummyHttpServer();
739+
await srv.StartAsync(HttpPort);
740+
741+
using var ls = Sender.New($"http::addr={Host}:{HttpPort};auto_flush=off;protocol_version=1;");
742+
743+
await ls.Table("doubles")
744+
.Column("d0", 0.0)
745+
.Column("dm0", -0.0)
746+
.Column("d1", 1.0)
747+
.Column("dE100", 1E100)
748+
.Column("d0000001", 0.000001)
749+
.Column("dNaN", double.NaN)
750+
.Column("dInf", double.PositiveInfinity)
751+
.Column("dNInf", double.NegativeInfinity)
752+
.AtAsync(86400000000000);
753+
await ls.SendAsync();
754+
755+
var expected =
756+
"doubles d0=0,dm0=-0,d1=1,dE100=1E+100,d0000001=1E-06,dNaN=NaN,dInf=Infinity,dNInf=-Infinity 86400000000000\n";
732757
Assert.That(srv.PrintBuffer(), Is.EqualTo(expected));
733758
}
734759

@@ -886,7 +911,7 @@ public async Task InvalidNames()
886911
await senderLim127.AtAsync(new DateTime(1970, 1, 1));
887912
await senderLim127.SendAsync();
888913

889-
var expected = "abcd.csv,b\\ \\ \\ \\ c=12 000\n";
914+
var expected = "abcd.csv,b\\ \\ \\ \\ c=12 0\n";
890915
Assert.That(srv.PrintBuffer(), Is.EqualTo(expected));
891916
}
892917

@@ -1193,15 +1218,14 @@ public async Task TransactionMultipleTypes()
11931218
await sender.Transaction("tableName").Symbol("foo", "bah").AtAsync(86400000000000);
11941219
await sender.Column("foo", 123).AtAsync(86400000000000);
11951220
await sender.Column("foo", 123d).AtAsync(86400000000000);
1196-
await sender.Column("foo", new DateTime(1970, 1, 1)).AtAsync(86400000000000);
1197-
await sender.Column("foo", new DateTimeOffset(new DateTime(1970, 1, 1))).AtAsync(86400000000000);
1221+
await sender.Column("foo", new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).AtAsync(86400000000000);
1222+
await sender.Column("foo", new DateTimeOffset(new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc))).AtAsync(86400000000000);
11981223
await sender.Column("foo", false).AtAsync(86400000000000);
11991224

1200-
12011225
await sender.CommitAsync();
12021226

12031227
var expected =
1204-
"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";
1228+
"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";
12051229
Assert.That(srv.PrintBuffer(), Is.EqualTo(expected));
12061230
}
12071231

src/net-questdb-client-tests/SenderOptionsTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,11 @@ public void BindConfigFileToOptions()
9999
[Test]
100100
public void UseOffInAutoFlushSettings()
101101
{
102-
var sender =
103-
Sender.New(
102+
var senderOptions =
103+
new SenderOptions(
104104
"http::addr=localhost:9000;auto_flush=on;auto_flush_rows=off;auto_flush_bytes=off;auto_flush_interval=off;");
105105

106-
Assert.That(sender.Options.ToString(),
106+
Assert.That(senderOptions.ToString(),
107107
Is.EqualTo(
108108
"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;"));
109109
}

src/net-questdb-client-tests/SenderTests.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ namespace net_questdb_client_tests;
88
public class SenderTests
99
{
1010
[Test]
11+
[Explicit]
1112
public void PostConfStrInitialisation()
1213
{
1314
var confStr = "http::addr=localhost:9000;";
@@ -27,6 +28,7 @@ public void PostConfStrInitialisation()
2728
public void SenderWithPrebuiltOptions()
2829
{
2930
var options = new SenderOptions();
31+
options.protocol_version = ProtocolVersion.V1;
3032
var sender = Sender.New(options);
3133
Assert.That(
3234
sender.Options.ToString(),
@@ -38,7 +40,8 @@ public void SenderWithPrebuiltOptions()
3840
public void SenderWithNullOptions()
3941
{
4042
var options = new SenderOptions();
41-
var sender = Sender.New();
43+
options.protocol_version = ProtocolVersion.V1;
44+
var sender = Sender.Configure($"http::addr=localhost:9000;protocol_version=1;").Build();
4245
Assert.That(
4346
sender.Options.ToString(),
4447
Is.EqualTo(options.ToString())

src/net-questdb-client-tests/TcpTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ public async Task InvalidNames()
478478
await senderLim127.AtAsync(new DateTime(1970, 1, 1));
479479
await senderLim127.SendAsync();
480480

481-
var expected = "abcd.csv,b\\ \\ \\ \\ c=12 000\n";
481+
var expected = "abcd.csv,b\\ \\ \\ \\ c=12 0\n";
482482
WaitAssert(srv, expected);
483483
}
484484

src/net-questdb-client-tests/net-questdb-client-tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net6.0;net7.0;net8.0;net9.0</TargetFrameworks>
54
<RootNamespace>net_questdb_client_tests</RootNamespace>
65
<ImplicitUsings>enable</ImplicitUsings>
76
<Nullable>enable</Nullable>
87
<IsPackable>false</IsPackable>
8+
<TargetFrameworks>net6.0;net7.0;net8.0;net9.0</TargetFrameworks>
99
</PropertyGroup>
1010

1111
<ItemGroup>

0 commit comments

Comments
 (0)