-
Notifications
You must be signed in to change notification settings - Fork 100
/
Copy pathOracleMdaTests.cs
81 lines (67 loc) · 2.31 KB
/
OracleMdaTests.cs
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
81
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
using IntegrationTests.Helpers;
using Xunit.Abstractions;
namespace IntegrationTests;
[Collection(OracleCollection.Name)]
public class OracleMdaTests : TestHelper
{
private readonly OracleFixture _oracle;
public OracleMdaTests(ITestOutputHelper output, OracleFixture oracle)
#if NETFRAMEWORK
: base("OracleMda.NetFramework", output)
#else
: base("OracleMda.Core", output)
#endif
{
_oracle = oracle;
}
public static TheoryData<string, bool> GetData()
{
var theoryData = new TheoryData<string, bool>();
#if NETFRAMEWORK
foreach (var version in LibraryVersion.OracleMda)
#else
foreach (var version in LibraryVersion.GetPlatformVersions(nameof(LibraryVersion.OracleMdaCore)))
#endif
{
theoryData.Add(version, true);
theoryData.Add(version, false);
}
return theoryData;
}
[SkippableTheory]
[Trait("Category", "EndToEnd")]
[Trait("Containers", "Linux")]
[MemberData(nameof(GetData))]
public void SubmitTraces(string packageVersion, bool dbStatementForText)
{
// Skip the test if fixture does not support current platform
_oracle.SkipIfUnsupportedPlatform();
SetEnvironmentVariable("OTEL_DOTNET_AUTO_ORACLEMDA_SET_DBSTATEMENT_FOR_TEXT", dbStatementForText.ToString());
using var collector = new MockSpansCollector(Output);
SetExporter(collector);
#if NETFRAMEWORK
const string instrumentationScopeName = "Oracle.ManagedDataAccess";
#else
const string instrumentationScopeName = "Oracle.ManagedDataAccess.Core";
#endif
if (dbStatementForText)
{
collector.Expect(instrumentationScopeName, span => span.Attributes.Any(attr => attr.Key == "db.statement" && !string.IsNullOrWhiteSpace(attr.Value?.StringValue)));
}
else
{
collector.Expect(instrumentationScopeName, span => span.Attributes.All(attr => attr.Key != "db.statement"));
}
RunTestApplication(new()
{
#if NET462
Framework = "net472",
#endif
Arguments = $"--port {_oracle.Port} --password {_oracle.Password}",
PackageVersion = packageVersion
});
collector.AssertExpectations();
}
}