Skip to content

Commit

Permalink
integration test cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
tippmar-nr committed Jan 15, 2025
1 parent 1c4e161 commit 7b39edf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace NewRelic.Agent.ContainerIntegrationTests.Tests.AwsSdk;

public abstract class AwsSdkDynamoDBTestBase : NewRelicIntegrationTest<AwsSdkContainerDynamoDBTestFixture>
public class AwsSdkDynamoDBTest : NewRelicIntegrationTest<AwsSdkContainerDynamoDBTestFixture>
{
private readonly AwsSdkContainerDynamoDBTestFixture _fixture;

Expand All @@ -21,7 +21,7 @@ public abstract class AwsSdkDynamoDBTestBase : NewRelicIntegrationTest<AwsSdkCon

private const string _accountId = "520056171328"; // matches the account ID parsed from the fake access key used in AwsSdkDynamoDBExerciser

protected AwsSdkDynamoDBTestBase(AwsSdkContainerDynamoDBTestFixture fixture, ITestOutputHelper output) : base(fixture)
public AwsSdkDynamoDBTest(AwsSdkContainerDynamoDBTestFixture fixture, ITestOutputHelper output) : base(fixture)
{
_fixture = fixture;
_fixture.TestLogger = output;
Expand Down Expand Up @@ -114,9 +114,9 @@ public void Test()
};


// get all datastore span events for dynamodb so we can verify counts and operations
// get all datastore span events so we can verify counts and operations
var datastoreSpanEvents = _fixture.AgentLog.GetSpanEvents()
.Where(se => se.AgentAttributes.ContainsKey("db.system") && (string)se.AgentAttributes["db.system"] == "dynamodb")
.Where(se => (string)se.IntrinsicAttributes["category"] == "datastore")
.ToList();

// select the set of AgentAttributes values with a key of "aws.operation"
Expand All @@ -137,14 +137,3 @@ public void Test()
);
}
}

// Base class with derived classes pattern copied from another tests file
// but we currently don't need to use it for anything

public class AwsSdkDynamoDBTest : AwsSdkDynamoDBTestBase
{
public AwsSdkDynamoDBTest(AwsSdkContainerDynamoDBTestFixture fixture, ITestOutputHelper output) : base(fixture, output)
{
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,13 @@ public void Test()
var cloudResourceIdSpanEvents = spanEvents.Where(spanEvent => spanEvent.AgentAttributes.ContainsKey("cloud.resource_id")).ToList();

string expectedArn = $"arn:aws:dynamodb:(unknown):{_expectedAccountId}:table/{_tableName}";
string unExpectedArn = $"arn:aws:dynamodb:(unknown):{_unxpectedAccountId}:table/{_tableName}";

// verify all span events contain the expected arn, and do not contain the unexpected arn and all are of category datastore
Assert.Multiple(
() => Assert.All(cloudResourceIdSpanEvents,
se => Assert.Equal(expectedArn, se.AgentAttributes["cloud.resource_id"]))
() => Assert.All(cloudResourceIdSpanEvents, se => Assert.Equal(expectedArn, se.AgentAttributes["cloud.resource_id"])),
() => Assert.All(cloudResourceIdSpanEvents, se => Assert.NotEqual(_unxpectedAccountId, se.AgentAttributes["cloud.resource_id"])),
() => Assert.All(cloudResourceIdSpanEvents, se => Assert.Equal("datastore", se.IntrinsicAttributes["category"]))
);
}
}

0 comments on commit 7b39edf

Please sign in to comment.