Skip to content

Commit 6737414

Browse files
authored
test: Cleanup / refactor to remove database dependencies in unbounded tests project (#3061)
1 parent 15ddaeb commit 6737414

18 files changed

Lines changed: 83 additions & 180 deletions

.github/workflows/all_solutions.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ jobs:
444444

445445
env:
446446
integration_tests_shared_project: ${{ github.workspace }}/tests/Agent/IntegrationTests/Shared
447-
unbounded_tests_path: ${{ github.workspace }}/tests/Agent/IntegrationTests/UnboundedIntegrationTests/bin/Release/net481
447+
unbounded_tests_path: ${{ github.workspace }}/tests/Agent/IntegrationTests/UnboundedIntegrationTests/bin/Release/net9.0
448448
NR_DOTNET_TEST_SAVE_WORKING_DIRECTORY: 1
449449
# Make this variable true to enable extra data-gathering and logging to help troubleshoot test failures, at the cost of additional time and resources
450450
enhanced_logging: false

tests/Agent/IntegrationTests/UnboundedApplications/BasicMvcApplication/BasicMvcApplication.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@
8181
<PackageReference Include="Microsoft.Web.Infrastructure">
8282
<Version>1.0.0.0</Version>
8383
</PackageReference>
84+
<PackageReference Include="NewRelic.Agent.Api">
85+
<Version>10.39.0</Version>
86+
</PackageReference>
8487
<PackageReference Include="Newtonsoft.Json">
8588
<Version>13.0.3</Version>
8689
</PackageReference>

tests/Agent/IntegrationTests/UnboundedApplications/BasicMvcApplication/Controllers/OracleController.cs

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
using System.Configuration;
1010
using System.Data;
1111
using System.Web.Mvc;
12+
using NewRelic.Api.Agent;
13+
using Oracle.ManagedDataAccess.Client;
1214

1315
namespace BasicMvcApplication.Controllers
1416
{
@@ -18,6 +20,11 @@ public class OracleController : Controller
1820
private const string DeleteHotelOracleSql = "DELETE FROM {0} WHERE HOTEL_ID = 1";
1921
private const string CountHotelOracleSql = "SELECT COUNT(*) FROM {0}";
2022

23+
private const string CreateHotelTableOracleSql = "CREATE TABLE {0} (HOTEL_ID INT NOT NULL, BOOKING_DATE DATE NOT NULL, " +
24+
"ROOMS_TAKEN INT DEFAULT 0, PRIMARY KEY (HOTEL_ID, BOOKING_DATE))";
25+
private const string DropHotelTableOracleSql = "DROP TABLE {0}";
26+
27+
2128
[HttpGet]
2229
public string EnterpriseLibraryOracle(string tableName)
2330
{
@@ -49,5 +56,51 @@ public string EnterpriseLibraryOracle(string tableName)
4956

5057
return string.Join(",", teamMembers);
5158
}
59+
60+
[HttpGet]
61+
public void CreateTable(string tableName)
62+
{
63+
NewRelic.Api.Agent.NewRelic.IgnoreTransaction(); // this is a setup method, don't need a transaction for it
64+
65+
CreateTableInternal(tableName);
66+
}
67+
68+
[HttpGet]
69+
public void DropTable(string tableName)
70+
{
71+
NewRelic.Api.Agent.NewRelic.IgnoreTransaction(); // this is a teardown method, don't need a transaction for it
72+
73+
DropTableInternal(tableName);
74+
}
75+
76+
private void CreateTableInternal(string tableName)
77+
{
78+
var createTable = string.Format(CreateHotelTableOracleSql, tableName);
79+
using (var connection = new OracleConnection(OracleConfiguration.OracleConnectionString))
80+
{
81+
connection.Open();
82+
83+
using (var command = new OracleCommand(createTable, connection))
84+
{
85+
command.ExecuteNonQuery();
86+
}
87+
}
88+
}
89+
90+
private void DropTableInternal(string tableName)
91+
{
92+
var dropTableSql = string.Format(DropHotelTableOracleSql, tableName);
93+
94+
using (var connection = new OracleConnection(OracleConfiguration.OracleConnectionString))
95+
{
96+
connection.Open();
97+
98+
using (var command = new OracleCommand(dropTableSql, connection))
99+
{
100+
command.ExecuteNonQuery();
101+
}
102+
}
103+
}
104+
52105
}
53106
}

tests/Agent/IntegrationTests/UnboundedIntegrationTests/CosmosDB/CosmosDBTests.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// SPDX-License-Identifier: Apache-2.0
33

44

5-
using Azure;
6-
using Couchbase.Core;
75
using NewRelic.Agent.IntegrationTestHelpers;
86
using NewRelic.Agent.IntegrationTestHelpers.RemoteServiceFixtures;
97
using NewRelic.Testing.Assertions;
@@ -15,7 +13,6 @@
1513
using System.Net.NetworkInformation;
1614
using System.Net.PeerToPeer.Collaboration;
1715
using System.Reflection;
18-
using System.Windows.Forms;
1916
using NewRelic.Agent.Tests.TestSerializationHelpers.Models;
2017
using Xunit;
2118
using Xunit.Abstractions;

tests/Agent/IntegrationTests/UnboundedIntegrationTests/MsSql/MsSqlQueryParamTests.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ public abstract class MsSqlQueryParamTestsBase<TFixture> : NewRelicIntegrationTe
2525

2626
public MsSqlQueryParamTestsBase(TFixture fixture, ITestOutputHelper output, string excerciserName, bool paramsWithAtSign) : base(fixture)
2727
{
28-
MsSqlWarmupHelper.WarmupMsSql();
29-
3028
_fixture = fixture;
3129
_fixture.TestLogger = output;
3230
_expectedTransactionName = $"OtherTransaction/Custom/MultiFunctionApplicationHelpers.NetStandardLibraries.MsSql.{excerciserName}/MsSqlWithParameterizedQuery";

tests/Agent/IntegrationTests/UnboundedIntegrationTests/MsSql/MsSqlStoredProcedureTests.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ public abstract class MsSqlStoredProcedureTestsBase<TFixture> : NewRelicIntegrat
2424

2525
public MsSqlStoredProcedureTestsBase(TFixture fixture, ITestOutputHelper output, string excerciserName) : base(fixture)
2626
{
27-
MsSqlWarmupHelper.WarmupMsSql();
28-
2927
_fixture = fixture;
3028
_fixture.TestLogger = output;
3129
_expectedTransactionName = $"OtherTransaction/Custom/MultiFunctionApplicationHelpers.NetStandardLibraries.MsSql.{excerciserName}/MsSqlParameterizedStoredProcedure";

tests/Agent/IntegrationTests/UnboundedIntegrationTests/MsSql/MsSqlStoredProcedureUsingOdbcDriverTests.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ public abstract class MsSqlStoredProcedureUsingOdbcDriverTestsBase<TFixture> : N
2525

2626
public MsSqlStoredProcedureUsingOdbcDriverTestsBase(TFixture fixture, ITestOutputHelper output, string excerciserName) : base(fixture)
2727
{
28-
MsSqlWarmupHelper.WarmupMsSql();
29-
3028
_fixture = fixture;
3129
_fixture.TestLogger = output;
3230
_expectedTransactionName = $"OtherTransaction/Custom/MultiFunctionApplicationHelpers.NetStandardLibraries.MsSql.{excerciserName}/OdbcParameterizedStoredProcedure";

tests/Agent/IntegrationTests/UnboundedIntegrationTests/MsSql/MsSqlStoredProcedureUsingOleDbDriverTests.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ public abstract class MsSqlStoredProcedureUsingOleDbDriverTestsBase<TFixture> :
2525

2626
public MsSqlStoredProcedureUsingOleDbDriverTestsBase(TFixture fixture, ITestOutputHelper output, string excerciserName) : base(fixture)
2727
{
28-
MsSqlWarmupHelper.WarmupMsSql();
29-
3028
_fixture = fixture;
3129
_fixture.TestLogger = output;
3230
_expectedTransactionName = $"OtherTransaction/Custom/MultiFunctionApplicationHelpers.NetStandardLibraries.MsSql.{excerciserName}/MsSqlParameterizedStoredProcedureUsingOleDbDriver";

tests/Agent/IntegrationTests/UnboundedIntegrationTests/MsSql/MsSqlTests.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ public abstract class MsSqlTestsBase<TFixture> : NewRelicIntegrationTest<TFixtur
2929

3030
public MsSqlTestsBase(TFixture fixture, ITestOutputHelper output, string excerciserName, string libraryName) : base(fixture)
3131
{
32-
MsSqlWarmupHelper.WarmupMsSql();
33-
3432
_fixture = fixture;
3533
_fixture.TestLogger = output;
3634
_expectedTransactionName = $"OtherTransaction/Custom/MultiFunctionApplicationHelpers.NetStandardLibraries.MsSql.{excerciserName}/MsSql";

tests/Agent/IntegrationTests/UnboundedIntegrationTests/MsSql/MsSqlWarmupHelper.cs

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

0 commit comments

Comments
 (0)