Skip to content

Commit

Permalink
SqlTest improvements (#1122)
Browse files Browse the repository at this point in the history
* SqlClientTest - simplify assertions for tags

* remove unnecessary interpolation

* connect using 127.0.0.1 instead of localhost

* remove unnecessary interpolation

* build - execute integration tests after unit tests

Co-authored-by: Rajkumar Rangaraj <rajrang@microsoft.com>
  • Loading branch information
Kielek and rajkumar-rangaraj authored Aug 23, 2022
1 parent 0723264 commit 0a2664b
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 9 deletions.
1 change: 1 addition & 0 deletions build/nuke/Build.Steps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ partial class Build

Target RunManagedIntegrationTests => _ => _
.Unlisted()
.After(RunManagedUnitTests)
.Executes(() =>
{
var project = Solution.GetProject("IntegrationTests");
Expand Down
2 changes: 1 addition & 1 deletion test/IntegrationTests/Helpers/InstrumentedProcessHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public static Process StartInstrumentedProcess(
// clear all relevant environment variables to start with a clean slate
EnvironmentHelper.ClearProfilerEnvironmentVariables();

var startInfo = new ProcessStartInfo(executable, $"{arguments ?? string.Empty}");
var startInfo = new ProcessStartInfo(executable, arguments ?? string.Empty);

environmentHelper.SetEnvironmentVariables(testSettings, startInfo.EnvironmentVariables, executable);

Expand Down
2 changes: 1 addition & 1 deletion test/IntegrationTests/Helpers/TestHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ private void RunTestApplication(TestSettings testSettings)
Output.WriteResult(helper);

processTimeout.Should().BeFalse("Test application timed out");
process.ExitCode.Should().Be(0, $"Test application exited with non-zero exit code");
process.ExitCode.Should().Be(0, "Test application exited with non-zero exit code");
}

private Process StartTestApplication(TestSettings testSettings)
Expand Down
7 changes: 1 addition & 6 deletions test/IntegrationTests/SqlClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,7 @@ public void SubmitTraces()

foreach (var span in spans)
{
span.Service.Should().Be(ServiceName);
span.Name.Should().Be("master");
span.Tags.Should().Contain(new KeyValuePair<string, string>("db.system", "mssql"));
span.Tags.Should().Contain(new KeyValuePair<string, string>("db.name", "master"));
span.Tags.Should().Contain(new KeyValuePair<string, string>("peer.service", $"localhost,{_sqlServerFixture.Port}"));
span.Tags.Should().Contain(new KeyValuePair<string, string>("span.kind", "client"));
span.Tags.Should().Contain(new KeyValuePair<string, string>("otel.library.name", "OpenTelemetry.SqlClient"));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ private static async Task ExecuteDropAsync(SqlConnection connection)

private static string GetConnectionString(string databasePassword, string databasePort)
{
return $"Server=localhost,{databasePort};User=sa;Password={databasePassword};TrustServerCertificate=True;";
return $"Server=127.0.0.1,{databasePort};User=sa;Password={databasePassword};TrustServerCertificate=True;";
}

private static (string DatabasePassword, string Port) ParseArgs(IReadOnlyList<string> args)
Expand Down

0 comments on commit 0a2664b

Please sign in to comment.