move tests from OpenTelemetry.Tests project to OpenTelemetry.Api.Tests (#4368)
This commit is contained in:
parent
b449fa1d15
commit
807f703e1b
|
|
@ -18,7 +18,6 @@ using System.Runtime.CompilerServices;
|
||||||
|
|
||||||
[assembly: InternalsVisibleTo("OpenTelemetry" + AssemblyInfo.PublicKey)]
|
[assembly: InternalsVisibleTo("OpenTelemetry" + AssemblyInfo.PublicKey)]
|
||||||
[assembly: InternalsVisibleTo("OpenTelemetry.Api.ProviderBuilderExtensions" + AssemblyInfo.PublicKey)]
|
[assembly: InternalsVisibleTo("OpenTelemetry.Api.ProviderBuilderExtensions" + AssemblyInfo.PublicKey)]
|
||||||
[assembly: InternalsVisibleTo("OpenTelemetry.Tests" + AssemblyInfo.PublicKey)]
|
|
||||||
[assembly: InternalsVisibleTo("OpenTelemetry.Api.Tests" + AssemblyInfo.PublicKey)]
|
[assembly: InternalsVisibleTo("OpenTelemetry.Api.Tests" + AssemblyInfo.PublicKey)]
|
||||||
[assembly: InternalsVisibleTo("OpenTelemetry.Shims.OpenTracing.Tests" + AssemblyInfo.PublicKey)]
|
[assembly: InternalsVisibleTo("OpenTelemetry.Shims.OpenTracing.Tests" + AssemblyInfo.PublicKey)]
|
||||||
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2" + AssemblyInfo.MoqPublicKey)]
|
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2" + AssemblyInfo.MoqPublicKey)]
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
// <copyright file="EventSourceTest.cs" company="OpenTelemetry Authors">
|
||||||
|
// Copyright The OpenTelemetry Authors
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
// </copyright>
|
||||||
|
|
||||||
|
using OpenTelemetry.Internal;
|
||||||
|
using OpenTelemetry.Tests;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
|
namespace OpenTelemetry.Api.Tests
|
||||||
|
{
|
||||||
|
public class EventSourceTest
|
||||||
|
{
|
||||||
|
[Fact]
|
||||||
|
public void EventSourceTest_OpenTelemetryApiEventSource()
|
||||||
|
{
|
||||||
|
EventSourceTestHelper.MethodsAreImplementedConsistentlyWithTheirAttributes(OpenTelemetryApiEventSource.Log);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -11,7 +11,13 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry.Api\OpenTelemetry.Api.csproj" />
|
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry.Exporter.InMemory\OpenTelemetry.Exporter.InMemory.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="$(RepoRoot)\test\OpenTelemetry.Tests\Shared\EventSourceTestHelper.cs" Link="Includes\EventSourceTestHelper.cs" />
|
||||||
|
<Compile Include="$(RepoRoot)\test\OpenTelemetry.Tests\Shared\TestEventListener.cs" Link="Includes\TestEventListener.cs" />
|
||||||
|
<Compile Include="$(RepoRoot)\test\OpenTelemetry.Tests\Shared\Utils.cs" Link="Includes\Utils.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
||||||
|
|
@ -28,12 +28,6 @@ namespace OpenTelemetry.Tests
|
||||||
EventSourceTestHelper.MethodsAreImplementedConsistentlyWithTheirAttributes(InstrumentationEventSource.Log);
|
EventSourceTestHelper.MethodsAreImplementedConsistentlyWithTheirAttributes(InstrumentationEventSource.Log);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public void EventSourceTest_OpenTelemetryApiEventSource()
|
|
||||||
{
|
|
||||||
EventSourceTestHelper.MethodsAreImplementedConsistentlyWithTheirAttributes(OpenTelemetryApiEventSource.Log);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void EventSourceTest_OpenTelemetrySdkEventSource()
|
public void EventSourceTest_OpenTelemetrySdkEventSource()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -86,23 +86,23 @@ namespace OpenTelemetry.Trace.Tests
|
||||||
}
|
}
|
||||||
|
|
||||||
Assert.Equal(StatusCode.Error, activity1.GetStatus().StatusCode);
|
Assert.Equal(StatusCode.Error, activity1.GetStatus().StatusCode);
|
||||||
Assert.Null(activity1.GetTagValue("otel.exception_pointers"));
|
Assert.Null(GetTagValue(activity1, "otel.exception_pointers"));
|
||||||
Assert.Equal(StatusCode.Error, activity2.GetStatus().StatusCode);
|
Assert.Equal(StatusCode.Error, activity2.GetStatus().StatusCode);
|
||||||
Assert.Null(activity2.GetTagValue("otel.exception_pointers"));
|
Assert.Null(GetTagValue(activity2, "otel.exception_pointers"));
|
||||||
Assert.Equal(StatusCode.Unset, activity3.GetStatus().StatusCode);
|
Assert.Equal(StatusCode.Unset, activity3.GetStatus().StatusCode);
|
||||||
Assert.Null(activity3.GetTagValue("otel.exception_pointers"));
|
Assert.Null(GetTagValue(activity3, "otel.exception_pointers"));
|
||||||
Assert.Equal(StatusCode.Unset, activity4.GetStatus().StatusCode);
|
Assert.Equal(StatusCode.Unset, activity4.GetStatus().StatusCode);
|
||||||
Assert.Null(activity4.GetTagValue("otel.exception_pointers"));
|
Assert.Null(GetTagValue(activity4, "otel.exception_pointers"));
|
||||||
Assert.Equal(StatusCode.Unset, activity5.GetStatus().StatusCode);
|
Assert.Equal(StatusCode.Unset, activity5.GetStatus().StatusCode);
|
||||||
#if !NETFRAMEWORK
|
#if !NETFRAMEWORK
|
||||||
if (Environment.Is64BitProcess)
|
if (Environment.Is64BitProcess)
|
||||||
{
|
{
|
||||||
// In this rare case, the following Activity tag will not get cleaned up due to perf consideration.
|
// In this rare case, the following Activity tag will not get cleaned up due to perf consideration.
|
||||||
Assert.NotNull(activity5.GetTagValue("otel.exception_pointers"));
|
Assert.NotNull(GetTagValue(activity5, "otel.exception_pointers"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Assert.Null(activity5.GetTagValue("otel.exception_pointers"));
|
Assert.Null(GetTagValue(activity5, "otel.exception_pointers"));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
@ -132,5 +132,20 @@ namespace OpenTelemetry.Trace.Tests
|
||||||
|
|
||||||
Assert.Equal(StatusCode.Unset, activity.GetStatus().StatusCode);
|
Assert.Equal(StatusCode.Unset, activity.GetStatus().StatusCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static object GetTagValue(Activity activity, string tagName)
|
||||||
|
{
|
||||||
|
Debug.Assert(activity != null, "Activity should not be null");
|
||||||
|
|
||||||
|
foreach (ref readonly var tag in activity.EnumerateTagObjects())
|
||||||
|
{
|
||||||
|
if (tag.Key == tagName)
|
||||||
|
{
|
||||||
|
return tag.Value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue