-
Notifications
You must be signed in to change notification settings - Fork 155
Expand file tree
/
Copy pathAerospikeTests.cs
More file actions
80 lines (69 loc) · 3.54 KB
/
AerospikeTests.cs
File metadata and controls
80 lines (69 loc) · 3.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// <copyright file="AerospikeTests.cs" company="Datadog">
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License.
// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc.
// </copyright>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Datadog.Trace.ClrProfiler.IntegrationTests.Helpers;
using Datadog.Trace.Configuration;
using Datadog.Trace.TestHelpers;
using Datadog.Trace.TestHelpers.AutoInstrumentation.Containers;
using FluentAssertions;
using FluentAssertions.Execution;
using VerifyXunit;
using Xunit;
using Xunit.Abstractions;
namespace Datadog.Trace.ClrProfiler.IntegrationTests
{
[Trait("RequiresDockerDependency", "true")]
[Trait("DockerGroup", "2")]
[UsesVerify]
[Collection(AerospikeCollection.Name)]
public class AerospikeTests : TracingIntegrationTest
{
public AerospikeTests(ITestOutputHelper output, AerospikeFixture aerospikeFixture)
: base("Aerospike", output)
{
SetServiceVersion("1.0.0");
ConfigureContainers(aerospikeFixture);
}
public static IEnumerable<object[]> GetEnabledConfig()
=> from packageVersionArray in PackageVersions.Aerospike
from metadataSchemaVersion in new[] { "v0", "v1" }
select new[] { packageVersionArray[0], metadataSchemaVersion };
public override Result ValidateIntegrationSpan(MockSpan span, string metadataSchemaVersion) => span.IsAerospike(metadataSchemaVersion);
[SkippableTheory]
[MemberData(nameof(GetEnabledConfig))]
[Trait("Category", "EndToEnd")]
[Trait("Category", "ArmUnsupported")]
public async Task SubmitTraces(string packageVersion, string metadataSchemaVersion)
{
SetEnvironmentVariable("DD_TRACE_SPAN_ATTRIBUTE_SCHEMA", metadataSchemaVersion);
var isExternalSpan = metadataSchemaVersion == "v0";
var clientSpanServiceName = isExternalSpan ? $"{EnvironmentHelper.FullSampleName}-aerospike" : EnvironmentHelper.FullSampleName;
using var telemetry = this.ConfigureTelemetry();
using (var agent = EnvironmentHelper.GetMockAgent())
using (await RunSampleAndWaitForExit(agent, packageVersion: packageVersion))
{
const int expectedSpanCount = 10 + 9; // Sync + async
var spans = await agent.WaitForSpansAsync(expectedSpanCount);
using var s = new AssertionScope();
spans.Count.Should().Be(expectedSpanCount);
ValidateIntegrationSpans(spans, metadataSchemaVersion, expectedServiceName: clientSpanServiceName, isExternalSpan);
var settings = VerifyHelper.GetSpanVerifierSettings();
// older versions of Aerospike use QueryRecord instead of QueryPartition
// Normalize to QueryPartition for simplicity
if (string.IsNullOrEmpty(packageVersion) || new Version(packageVersion) < new Version(5, 0, 0))
{
settings.AddSimpleScrubber("QueryRecord", "QueryPartition");
}
await VerifyHelper.VerifySpans(spans, settings)
.DisableRequireUniquePrefix()
.UseFileName(nameof(AerospikeTests) + $".Schema{metadataSchemaVersion.ToUpper()}");
await telemetry.AssertIntegrationEnabledAsync(IntegrationId.Aerospike);
}
}
}
}