Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[repo] Bump test packages #6157

Merged
merged 4 commits into from
Feb 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="$(LatestRuntimeOutOfBandVer)" />
<PackageVersion Include="Microsoft.Extensions.Telemetry.Abstractions" Version="[9.0.0,)" />
<PackageVersion Include="Microsoft.NETFramework.ReferenceAssemblies" Version="[1.0.3,2.0)" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="[17.11.0,18.0.0)" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="[17.13.0,18.0.0)" />
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="[8.0.0,9.0)" />
<PackageVersion Include="MinVer" Version="[5.0.0,6.0)" />
<PackageVersion Include="NuGet.Versioning" Version="6.11.0" />
Expand All @@ -121,7 +121,7 @@
<PackageVersion Include="StyleCop.Analyzers" Version="[1.2.0-beta.556,2.0)" />
<PackageVersion Include="Swashbuckle.AspNetCore" Version="[6.7.3,)" />
<PackageVersion Include="System.Runtime.InteropServices.RuntimeInformation" Version="4.3.0" />
<PackageVersion Include="xunit" Version="[2.9.0,3.0)" />
<PackageVersion Include="xunit" Version="[2.9.3,3.0)" />
<PackageVersion Include="xunit.runner.visualstudio" Version="[2.8.2,3.0)" />
</ItemGroup>

Expand Down
6 changes: 3 additions & 3 deletions test/OpenTelemetry.Tests/Metrics/MetricApiTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public void MetricInstrumentationScopeIsExportedCorrectly()

Assert.NotNull(metric.MeterTags);

Assert.Single(metric.MeterTags.Where(kvp => kvp.Key == meterTags[0].Key && kvp.Value == meterTags[0].Value));
Assert.Single(metric.MeterTags, kvp => kvp.Key == meterTags[0].Key && kvp.Value == meterTags[0].Value);
}

[Fact]
Expand Down Expand Up @@ -584,7 +584,7 @@ public void MeterSourcesWildcardSupportMatchTest(bool hasView)

meterProvider.ForceFlush(MaxTimeToAllowForFlush);

Assert.True(exportedItems.Count == 5); // "SomeCompany.SomeProduct.SomeComponent" will not be subscribed.
Assert.Equal(5, exportedItems.Count); // "SomeCompany.SomeProduct.SomeComponent" will not be subscribed.

if (hasView)
{
Expand Down Expand Up @@ -629,7 +629,7 @@ public void MeterSourcesWildcardSupportNegativeTestNoMeterAdded(bool hasView)
meter2.CreateObservableGauge("myGauge2", () => measurement);

meterProvider.ForceFlush(MaxTimeToAllowForFlush);
Assert.True(exportedItems.Count == 0);
Assert.Empty(exportedItems);
}

[Theory]
Expand Down
92 changes: 47 additions & 45 deletions test/OpenTelemetry.Tests/Metrics/MetricTestData.cs
Original file line number Diff line number Diff line change
@@ -1,59 +1,61 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

using Xunit;

namespace OpenTelemetry.Metrics.Tests;

public class MetricTestData
{
public static IEnumerable<object[]> InvalidInstrumentNames
=> new List<object[]>
{
new object[] { " " },
new object[] { "-first-char-not-alphabetic" },
new object[] { "1first-char-not-alphabetic" },
new object[] { "invalid+separator" },
new object[] { new string('m', 256) },
new object[] { "a\xb5" }, // `\xb5` is the Micro character
};
public static TheoryData<string> InvalidInstrumentNames
=>
[
" ",
"-first-char-not-alphabetic",
"1first-char-not-alphabetic",
"invalid+separator",
new('m', 256),
"a\xb5", // `\xb5` is the Micro character
];

public static IEnumerable<object[]> ValidInstrumentNames
=> new List<object[]>
{
new object[] { "m" },
new object[] { "first-char-alphabetic" },
new object[] { "my-2-instrument" },
new object[] { "my.metric" },
new object[] { "my_metric2" },
new object[] { new string('m', 255) },
new object[] { "CaSe-InSeNsItIvE" },
new object[] { "my_metric/environment/database" },
};
public static TheoryData<string> ValidInstrumentNames
=>
[
"m",
"first-char-alphabetic",
"my-2-instrument",
"my.metric",
"my_metric2",
new('m', 255),
"CaSe-InSeNsItIvE",
"my_metric/environment/database",
];

public static IEnumerable<object[]> InvalidHistogramBoundaries
=> new List<object[]>
{
new object[] { new double[] { 0, 0 } },
new object[] { new double[] { 1, 0 } },
new object[] { new double[] { 0, 1, 1, 2 } },
new object[] { new double[] { 0, 1, 2, -1 } },
};
public static TheoryData<double[]> InvalidHistogramBoundaries
=>
[
[0.0, 0.0],
[1.0, 0.0],
[0.0, 1.0, 1.0, 2.0],
[0.0, 1.0, 2.0, -1.0],
];

public static IEnumerable<object[]> ValidHistogramMinMax
=> new List<object[]>
{
new object[] { new double[] { -10, 0, 1, 9, 10, 11, 19 }, new HistogramConfiguration(), -10, 19 },
new object[] { new double[] { double.NegativeInfinity }, new HistogramConfiguration(), double.NegativeInfinity, double.NegativeInfinity },
new object[] { new double[] { double.NegativeInfinity, 0, double.PositiveInfinity }, new HistogramConfiguration(), double.NegativeInfinity, double.PositiveInfinity },
new object[] { new double[] { 1 }, new HistogramConfiguration(), 1, 1 },
new object[] { new double[] { 5, 100, 4, 101, -2, 97 }, new ExplicitBucketHistogramConfiguration() { Boundaries = [10.0, 20.0] }, -2, 101 },
new object[] { new double[] { 5, 100, 4, 101, -2, 97 }, new Base2ExponentialBucketHistogramConfiguration(), 4, 101 },
};
public static TheoryData<double[], HistogramConfiguration, double, double> ValidHistogramMinMax =>
new()
{
{ [-10.0, 0.0, 1.0, 9.0, 10.0, 11.0, 19.0], new HistogramConfiguration(), -10.0, 19.0 },
{ [double.NegativeInfinity], new HistogramConfiguration(), double.NegativeInfinity, double.NegativeInfinity },
{ [double.NegativeInfinity, 0.0, double.PositiveInfinity], new HistogramConfiguration(), double.NegativeInfinity, double.PositiveInfinity },
{ [1.0], new HistogramConfiguration(), 1.0, 1.0 },
{ [5.0, 100.0, 4.0, 101.0, -2.0, 97.0], new ExplicitBucketHistogramConfiguration { Boundaries = [10.0, 20.0] }, -2.0, 101.0 },
{ [5.0, 100.0, 4.0, 101.0, -2.0, 97.0], new Base2ExponentialBucketHistogramConfiguration(), 4.0, 101.0 },
};

public static IEnumerable<object[]> InvalidHistogramMinMax
=> new List<object[]>
public static TheoryData<double[], HistogramConfiguration> InvalidHistogramMinMax
=> new()
{
new object[] { new double[] { 1 }, new HistogramConfiguration() { RecordMinMax = false } },
new object[] { new double[] { 1 }, new ExplicitBucketHistogramConfiguration() { Boundaries = [10.0, 20.0], RecordMinMax = false } },
new object[] { new double[] { 1 }, new Base2ExponentialBucketHistogramConfiguration() { RecordMinMax = false } },
{ [1.0], new HistogramConfiguration { RecordMinMax = false } },
{ [1.0], new ExplicitBucketHistogramConfiguration { Boundaries = [10.0, 20.0], RecordMinMax = false } },
{ [1.0], new Base2ExponentialBucketHistogramConfiguration { RecordMinMax = false } },
};
}
2 changes: 1 addition & 1 deletion test/OpenTelemetry.Tests/Metrics/MetricViewTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public void AddViewWithExceptionInUserCallbackNoDefault()
{
var counter1 = meter1.CreateCounter<long>("counter1");
counter1.Add(1);
Assert.Single(inMemoryEventListener.Events.Where((e) => e.EventId == 41));
Assert.Single(inMemoryEventListener.Events, e => e.EventId == 41);
}

meterProvider.ForceFlush(MaxTimeToAllowForFlush);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public void ServiceResource_ServiceName()
var resource = ResourceBuilder.CreateEmpty().AddService("my-service").Build();
Assert.Equal(2, resource.Attributes.Count());
Assert.Contains(new KeyValuePair<string, object>(ResourceSemanticConventions.AttributeServiceName, "my-service"), resource.Attributes);
Assert.Single(resource.Attributes.Where(kvp => kvp.Key == ResourceSemanticConventions.AttributeServiceName));
Assert.Single(resource.Attributes, kvp => kvp.Key == ResourceSemanticConventions.AttributeServiceName);
Assert.True(Guid.TryParse((string)resource.Attributes.Single(kvp => kvp.Key == ResourceSemanticConventions.AttributeServiceInstance).Value, out _));
}

Expand Down
Loading