Skip to content

Commit

Permalink
use FQNs in test attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
brettmc committed May 15, 2024
1 parent bd6dd86 commit 3ccc288
Show file tree
Hide file tree
Showing 212 changed files with 895 additions and 581 deletions.
8 changes: 5 additions & 3 deletions tests/Integration/Config/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@

declare(strict_types=1);

namespace Config;
namespace OpenTelemetry\Tests\Integration\Config;

use OpenTelemetry\Config\SDK\Configuration;
use PHPUnit\Framework\Attributes\CoversNothing;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

#[CoversNothing]
final class ConfigurationTest extends TestCase
{

#[\PHPUnit\Framework\Attributes\DataProvider('openTelemetryConfigurationDataProvider')]
#[\PHPUnit\Framework\Attributes\CoversNothing]
#[DataProvider('openTelemetryConfigurationDataProvider')]
public function test_open_telemetry_configuration(string $file): void
{
$this->expectNotToPerformAssertions();
Expand Down
13 changes: 0 additions & 13 deletions tests/Integration/Config/autoload_spi_with_defaults.phpt

This file was deleted.

3 changes: 2 additions & 1 deletion tests/Integration/SDK/AlwaysOffSamplerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
use OpenTelemetry\SDK\Common\Attribute\Attributes;
use OpenTelemetry\SDK\Trace\Sampler\AlwaysOffSampler;
use OpenTelemetry\SDK\Trace\SamplingResult;
use PHPUnit\Framework\Attributes\CoversNothing;
use PHPUnit\Framework\TestCase;

#[\PHPUnit\Framework\Attributes\CoversNothing]
#[CoversNothing]
class AlwaysOffSamplerTest extends TestCase
{
public function test_always_off_sampler(): void
Expand Down
3 changes: 2 additions & 1 deletion tests/Integration/SDK/AlwaysOnSamplerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
use OpenTelemetry\SDK\Common\Attribute\Attributes;
use OpenTelemetry\SDK\Trace\Sampler\AlwaysOnSampler;
use OpenTelemetry\SDK\Trace\SamplingResult;
use PHPUnit\Framework\Attributes\CoversNothing;
use PHPUnit\Framework\TestCase;

#[\PHPUnit\Framework\Attributes\CoversNothing]
#[CoversNothing]
class AlwaysOnSamplerTest extends TestCase
{
public function test_always_on_sampler_decision(): void
Expand Down
11 changes: 7 additions & 4 deletions tests/Integration/SDK/Context/SpanContextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@
use OpenTelemetry\API\Trace\SpanContextValidator;
use OpenTelemetry\API\Trace\TraceState;
use OpenTelemetry\SDK\Trace\RandomIdGenerator;
use PHPUnit\Framework\Attributes\CoversNothing;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;

#[\PHPUnit\Framework\Attributes\CoversNothing]
#[CoversNothing]
class SpanContextTest extends TestCase
{
#[\PHPUnit\Framework\Attributes\DataProvider('invalidSpanData')]
#[DataProvider('invalidSpanData')]
public function test_invalid_span(string $traceId, string $spanId): void
{
$spanContext = SpanContext::create($traceId, $spanId);
Expand All @@ -36,14 +39,14 @@ public static function invalidSpanData(): array
];
}

#[\PHPUnit\Framework\Attributes\Group('trace-compliance')]
#[Group('trace-compliance')]
public function test_valid_span(): void
{
$spanContext = SpanContext::create('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'bbbbbbbbbbbbbbbb', API\TraceFlags::SAMPLED);
$this->assertTrue($spanContext->isValid());
}

#[\PHPUnit\Framework\Attributes\Group('trace-compliance')]
#[Group('trace-compliance')]
public function test_context_is_remote_from_restore(): void
{
$spanContext = SpanContext::createFromRemoteParent('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'bbbbbbbbbbbbbbbb', API\TraceFlags::SAMPLED);
Expand Down
3 changes: 2 additions & 1 deletion tests/Integration/SDK/MeterProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@
use OpenTelemetry\SDK\Metrics\View\CriteriaViewRegistry;
use OpenTelemetry\SDK\Resource\ResourceInfoFactory;
use OpenTelemetry\Tests\TestState;
use PHPUnit\Framework\Attributes\CoversNothing;
use PHPUnit\Framework\TestCase;

#[\PHPUnit\Framework\Attributes\CoversNothing]
#[CoversNothing]
final class MeterProviderTest extends TestCase
{
use TestState;
Expand Down
7 changes: 5 additions & 2 deletions tests/Integration/SDK/MeterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@
use OpenTelemetry\API\Metrics\Noop\NoopObservableCounter;
use OpenTelemetry\API\Metrics\ObserverInterface;
use OpenTelemetry\SDK\Metrics\Data\Sum;
use OpenTelemetry\SDK\Metrics\Meter;
use OpenTelemetry\SDK\Metrics\MeterProviderBuilder;
use OpenTelemetry\SDK\Metrics\MetricExporter\InMemoryExporter;
use OpenTelemetry\SDK\Metrics\MetricReader\ExportingReader;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\CoversNothing;
use PHPUnit\Framework\TestCase;
use Psr\Log\LogLevel;

#[\PHPUnit\Framework\Attributes\CoversClass(\OpenTelemetry\SDK\Metrics\Meter::class)]
#[CoversClass(Meter::class)]
final class MeterTest extends TestCase
{
public function test_batch_observe_observes_all_provided_instruments(): void
Expand Down Expand Up @@ -214,7 +217,7 @@ static function (ObserverInterface $a, ObserverInterface $b): void {
}
}

#[\PHPUnit\Framework\Attributes\CoversNothing]
#[CoversNothing]
public function test_batch_observe_detach_with_repeated_instrument_does_not_trigger_undefined_offset_warning(): void
{
$this->expectNotToPerformAssertions();
Expand Down
3 changes: 2 additions & 1 deletion tests/Integration/SDK/ParentBasedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
use OpenTelemetry\SDK\Trace\Sampler\ParentBased;
use OpenTelemetry\SDK\Trace\SamplerInterface;
use OpenTelemetry\SDK\Trace\SamplingResult;
use PHPUnit\Framework\Attributes\CoversNothing;
use PHPUnit\Framework\TestCase;

#[\PHPUnit\Framework\Attributes\CoversNothing]
#[CoversNothing]
class ParentBasedTest extends TestCase
{
public function test_parent_based_root_span(): void
Expand Down
3 changes: 2 additions & 1 deletion tests/Integration/SDK/Resource/ResourceInfoFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
use OpenTelemetry\SDK\Resource\ResourceInfoFactory;
use OpenTelemetry\SemConv\ResourceAttributes;
use OpenTelemetry\Tests\TestState;
use PHPUnit\Framework\Attributes\CoversNothing;
use PHPUnit\Framework\TestCase;

#[\PHPUnit\Framework\Attributes\CoversNothing]
#[CoversNothing]
class ResourceInfoFactoryTest extends TestCase
{
use TestState;
Expand Down
9 changes: 6 additions & 3 deletions tests/Integration/SDK/Resource/ResourceInfoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,18 @@
use OpenTelemetry\SDK\Resource\Detectors;
use OpenTelemetry\SDK\Resource\ResourceInfo;
use OpenTelemetry\Tests\TestState;
use PHPUnit\Framework\Attributes\CoversNothing;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;

#[\PHPUnit\Framework\Attributes\CoversNothing]
#[CoversNothing]
class ResourceInfoTest extends TestCase
{
use TestState;

#[\PHPUnit\Framework\Attributes\DataProvider('environmentResourceProvider')]
#[\PHPUnit\Framework\Attributes\Group('compliance')]
#[DataProvider('environmentResourceProvider')]
#[Group('compliance')]
public function test_resource_from_environment(string $envAttributes, array $userAttributes, array $expected): void
{
$this->setEnvironmentVariable('OTEL_RESOURCE_ATTRIBUTES', $envAttributes);
Expand Down
20 changes: 11 additions & 9 deletions tests/Integration/SDK/SpanBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@
use OpenTelemetry\SDK\Trace\SpanLimitsBuilder;
use OpenTelemetry\SDK\Trace\SpanProcessorInterface;
use OpenTelemetry\SDK\Trace\TracerProvider;
use PHPUnit\Framework\Attributes\CoversNothing;
use PHPUnit\Framework\Attributes\Group;
use function range;
use function str_repeat;

#[\PHPUnit\Framework\Attributes\CoversNothing]
#[CoversNothing]
class SpanBuilderTest extends MockeryTestCase
{
private const SPAN_NAME = 'span_name';
Expand All @@ -50,7 +52,7 @@ protected function setUp(): void
);
}

#[\PHPUnit\Framework\Attributes\Group('trace-compliance')]
#[Group('trace-compliance')]
public function test_add_link(): void
{
/** @var Span $span */
Expand All @@ -64,7 +66,7 @@ public function test_add_link(): void
$this->assertCount(2, $span->toSpanData()->getLinks());
}

#[\PHPUnit\Framework\Attributes\Group('trace-compliance')]
#[Group('trace-compliance')]
public function test_add_link_after_span_creation(): void
{
/** @var Span $span */
Expand Down Expand Up @@ -177,7 +179,7 @@ public function test_add_link_truncate_link_attribute_value(): void
);
}

#[\PHPUnit\Framework\Attributes\Group('trace-compliance')]
#[Group('trace-compliance')]
public function test_add_link_no_effect_after_start_span(): void
{
$spanBuilder = $this->tracer->spanBuilder(self::SPAN_NAME);
Expand All @@ -201,7 +203,7 @@ public function test_add_link_no_effect_after_start_span(): void
$this->assertCount(1, $span->toSpanData()->getLinks());
}

#[\PHPUnit\Framework\Attributes\Group('trace-compliance')]
#[Group('trace-compliance')]
public function test_set_attribute(): void
{
/** @var Span $span */
Expand All @@ -225,7 +227,7 @@ public function test_set_attribute(): void
$this->assertNull($attributes->get('nil'));
}

#[\PHPUnit\Framework\Attributes\Group('trace-compliance')]
#[Group('trace-compliance')]
public function test_set_attribute_no_effect_after_end(): void
{
/** @var Span $span */
Expand Down Expand Up @@ -264,7 +266,7 @@ public function test_set_attribute_no_effect_after_end(): void
// $this->assertNull($attributes->get('nil'));
// $span->end();
// }
#[\PHPUnit\Framework\Attributes\Group('trace-compliance')]
#[Group('trace-compliance')]
public function test_set_attribute_only_null_string_value_should_not_be_set(): void
{
/** @var Span $span */
Expand All @@ -279,7 +281,7 @@ public function test_set_attribute_only_null_string_value_should_not_be_set(): v
$this->assertNull($attributes->get('nil'));
}

#[\PHPUnit\Framework\Attributes\Group('trace-compliance')]
#[Group('trace-compliance')]
public function test_set_attribute_no_effect_after_start_span(): void
{
$spanBuilder = $this->tracer->spanBuilder(self::SPAN_NAME);
Expand Down Expand Up @@ -373,7 +375,7 @@ public function test_set_attributes(): void
$this->assertSame(1, $attributes->get('id'));
}

#[\PHPUnit\Framework\Attributes\Group('trace-compliance')]
#[Group('trace-compliance')]
public function test_set_attributes_merges_attributes_correctly(): void
{
$attributes = ['id' => 2, 'foo' => 'bar', 'key' => 'val'];
Expand Down
24 changes: 13 additions & 11 deletions tests/Integration/SDK/SpanLimitsBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@
use OpenTelemetry\SDK\Common\Attribute\Attributes;
use OpenTelemetry\SDK\Trace\SpanLimitsBuilder;
use OpenTelemetry\Tests\TestState;
use PHPUnit\Framework\Attributes\CoversNothing;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;

#[\PHPUnit\Framework\Attributes\CoversNothing]
#[CoversNothing]
class SpanLimitsBuilderTest extends TestCase
{
use TestState;

#[\PHPUnit\Framework\Attributes\Group('trace-compliance')]
#[Group('trace-compliance')]
public function test_span_length_limits_builder_uses_environment_variable(): void
{
$this->setEnvironmentVariable('OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT', 9);
Expand All @@ -24,7 +26,7 @@ public function test_span_length_limits_builder_uses_environment_variable(): voi
$this->assertEquals(Attributes::factory(128, 9), $spanLimits->getAttributesFactory());
}

#[\PHPUnit\Framework\Attributes\Group('trace-compliance')]
#[Group('trace-compliance')]
public function test_span_length_limits_builder_uses_configured_value(): void
{
$this->setEnvironmentVariable('OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT', 9);
Expand All @@ -35,7 +37,7 @@ public function test_span_length_limits_builder_uses_configured_value(): void
$this->assertEquals(Attributes::factory(128, 201), $spanLimits->getAttributesFactory());
}

#[\PHPUnit\Framework\Attributes\Group('trace-compliance')]
#[Group('trace-compliance')]
public function test_span_event_limits_builder_uses_environment_variable(): void
{
$this->setEnvironmentVariable('OTEL_SPAN_EVENT_COUNT_LIMIT', 200);
Expand All @@ -44,7 +46,7 @@ public function test_span_event_limits_builder_uses_environment_variable(): void
$this->assertEquals(200, $spanLimits->getEventCountLimit());
}

#[\PHPUnit\Framework\Attributes\Group('trace-compliance')]
#[Group('trace-compliance')]
public function test_span_event_limits_builder_uses_configured_value(): void
{
$this->setEnvironmentVariable('OTEL_SPAN_EVENT_COUNT_LIMIT', 200);
Expand All @@ -54,7 +56,7 @@ public function test_span_event_limits_builder_uses_configured_value(): void
$this->assertEquals(185, $spanLimits->getEventCountLimit());
}

#[\PHPUnit\Framework\Attributes\Group('trace-compliance')]
#[Group('trace-compliance')]
public function test_span_limits_link_builder_uses_environment_variable(): void
{
$this->setEnvironmentVariable('OTEL_SPAN_LINK_COUNT_LIMIT', 1101);
Expand All @@ -63,7 +65,7 @@ public function test_span_limits_link_builder_uses_environment_variable(): void
$this->assertEquals(1101, $spanLimits->getLinkCountLimit());
}

#[\PHPUnit\Framework\Attributes\Group('trace-compliance')]
#[Group('trace-compliance')]
public function test_span_limits_link_builder_uses_configured_value(): void
{
$this->setEnvironmentVariable('OTEL_SPAN_LINK_COUNT_LIMIT', 1102);
Expand All @@ -73,7 +75,7 @@ public function test_span_limits_link_builder_uses_configured_value(): void
$this->assertEquals(193, $spanLimits->getLinkCountLimit());
}

#[\PHPUnit\Framework\Attributes\Group('trace-compliance')]
#[Group('trace-compliance')]
public function test_span_attribute_per_event_count_limits_builder_uses_environment_variable(): void
{
$this->setEnvironmentVariable('OTEL_EVENT_ATTRIBUTE_COUNT_LIMIT', 400);
Expand All @@ -82,7 +84,7 @@ public function test_span_attribute_per_event_count_limits_builder_uses_environm
$this->assertEquals(Attributes::factory(400), $spanLimits->getEventAttributesFactory());
}

#[\PHPUnit\Framework\Attributes\Group('trace-compliance')]
#[Group('trace-compliance')]
public function test_span_event_attribute_per_event_count_limits_builder_uses_configured_value(): void
{
$this->setEnvironmentVariable('OTEL_EVENT_ATTRIBUTE_COUNT_LIMIT', 400);
Expand All @@ -92,7 +94,7 @@ public function test_span_event_attribute_per_event_count_limits_builder_uses_co
$this->assertEquals(Attributes::factory(155), $spanLimits->getEventAttributesFactory());
}

#[\PHPUnit\Framework\Attributes\Group('trace-compliance')]
#[Group('trace-compliance')]
public function test_span_attribute_per_link_count_limits_builder_uses_environment_variable(): void
{
$this->setEnvironmentVariable('OTEL_LINK_ATTRIBUTE_COUNT_LIMIT', 500);
Expand All @@ -101,7 +103,7 @@ public function test_span_attribute_per_link_count_limits_builder_uses_environme
$this->assertEquals(Attributes::factory(500), $spanLimits->getLinkAttributesFactory());
}

#[\PHPUnit\Framework\Attributes\Group('trace-compliance')]
#[Group('trace-compliance')]
public function test_span_link_attribute_per_event_count_limits_builder_uses_configured_value(): void
{
$this->setEnvironmentVariable('OTEL_LINK_ATTRIBUTE_COUNT_LIMIT', 500);
Expand Down
3 changes: 2 additions & 1 deletion tests/Integration/SDK/SpanProcessorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
use OpenTelemetry\Context\Context;
use OpenTelemetry\SDK\Trace\SpanProcessorInterface;
use OpenTelemetry\SDK\Trace\TracerProvider;
use PHPUnit\Framework\Attributes\CoversNothing;
use PHPUnit\Framework\TestCase;

#[\PHPUnit\Framework\Attributes\CoversNothing]
#[CoversNothing]
class SpanProcessorTest extends TestCase
{
public function test_parent_context_should_be_passed_to_span_processor(): void
Expand Down
3 changes: 2 additions & 1 deletion tests/Integration/SDK/TraceIdRatioBasedSamplerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
use OpenTelemetry\SDK\Common\Attribute\Attributes;
use OpenTelemetry\SDK\Trace\Sampler\TraceIdRatioBasedSampler;
use OpenTelemetry\SDK\Trace\SamplingResult;
use PHPUnit\Framework\Attributes\CoversNothing;
use PHPUnit\Framework\TestCase;

#[\PHPUnit\Framework\Attributes\CoversNothing]
#[CoversNothing]
class TraceIdRatioBasedSamplerTest extends TestCase
{
public function test_never_trace_id_ratio_based_sampler_decision(): void
Expand Down
Loading

0 comments on commit 3ccc288

Please sign in to comment.