Skip to content
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
15 changes: 15 additions & 0 deletions dotnet/src/Shared/IntegrationTests/TestSkipReasons.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright (c) Microsoft. All rights reserved.

namespace Shared.IntegrationTests;

/// <summary>
/// Skip reasons used to temporarily disable integration tests whose backing service is unavailable in CI.
/// </summary>
internal static class TestSkipReasons
{
/// <summary>
/// Skips every OpenAI integration test while the CI OpenAI API key is rejected.
/// Set to <see langword="null"/> to run the OpenAI integration tests again.
/// </summary>
public const string? OpenAIIntegrationTests = "OpenAI integration tests are temporarily disabled: the CI OpenAI API key is invalid.";
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public sealed class OpenAIResponsesClientFunctionToolsLiveTests
private static string ModelName =>
Environment.GetEnvironmentVariable(TestSettings.OpenAIChatModelName) ?? "gpt-4o-mini";

[Fact]
[Fact(Skip = TestSkipReasons.OpenAIIntegrationTests)]
public async Task AllowedClientFunction_ReturnsFunctionCallAsync()
{
// Arrange
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public sealed class OpenAIResponsesHostingLiveTests
private static string? ApiKey => Environment.GetEnvironmentVariable(TestSettings.OpenAIApiKey);
private static string ModelName => Environment.GetEnvironmentVariable(TestSettings.OpenAIChatModelName) ?? "gpt-4o-mini";

[Fact]
[Fact(Skip = TestSkipReasons.OpenAIIntegrationTests)]
public async Task NonStreamingRun_RendersResponsesShapedPayloadAsync()
{
// Arrange
Expand All @@ -49,7 +49,7 @@ public async Task NonStreamingRun_RendersResponsesShapedPayloadAsync()
Assert.Contains("output", payload.EnumerateObject().Select(p => p.Name));
}

[Fact]
[Fact(Skip = TestSkipReasons.OpenAIIntegrationTests)]
public async Task MultiTurn_ContinuesSessionAcrossTurnsAsync()
{
// Arrange
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,13 @@ public Task DeleteSessionAsync(AgentSession session) =>
// Chat Completion does not require/support deleting threads, so this is a no-op.
Task.CompletedTask;

public async ValueTask InitializeAsync() =>
public async ValueTask InitializeAsync()
{
// Skipping here covers every conformance test in this project, because each test initializes this fixture first.
Assert.SkipWhen(!string.IsNullOrEmpty(TestSkipReasons.OpenAIIntegrationTests), TestSkipReasons.OpenAIIntegrationTests ?? string.Empty);

this._agent = await this.CreateChatClientAgentAsync();
}

public ValueTask DisposeAsync()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ public Task DeleteSessionAsync(AgentSession session) =>

public async ValueTask InitializeAsync()
{
// Skipping here covers every conformance test in this project, because each test initializes this fixture first.
Assert.SkipWhen(!string.IsNullOrEmpty(TestSkipReasons.OpenAIIntegrationTests), TestSkipReasons.OpenAIIntegrationTests ?? string.Empty);

this._modelName = TestConfiguration.GetRequiredValue(TestSettings.OpenAIChatModelName);
this._openAIResponseClient = new OpenAIClient(TestConfiguration.GetRequiredValue(TestSettings.OpenAIApiKey))
.GetResponsesClient();
Expand Down
20 changes: 19 additions & 1 deletion python/packages/openai/tests/openai/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,25 @@

from opentelemetry.sdk.trace.export import SimpleSpanProcessor, SpanExporter
from opentelemetry.sdk.trace.export.in_memory_span_exporter import InMemorySpanExporter
from pytest import fixture
from pytest import FixtureRequest, fixture, skip

# Temporarily skips every OpenAI integration test while the CI OpenAI API key is rejected.
# Set to None to run the OpenAI integration tests again.
OPENAI_INTEGRATION_TESTS_SKIP_REASON: str | None = (
"OpenAI integration tests are temporarily disabled: the CI OpenAI API key is invalid."
)


@fixture(autouse=True)
def _skip_openai_integration_tests(request: FixtureRequest) -> None:
"""Skip OpenAI integration tests while OPENAI_INTEGRATION_TESTS_SKIP_REASON is set."""
# Azure-marked tests use Azure OpenAI credentials, not the broken OpenAI key, and have their own skip switch.
if (
OPENAI_INTEGRATION_TESTS_SKIP_REASON
and request.node.get_closest_marker("integration") is not None
and request.node.get_closest_marker("azure") is None
):
skip(OPENAI_INTEGRATION_TESTS_SKIP_REASON)


def _reset_env(monkeypatch, env_names: list[str]) -> None: # type: ignore
Expand Down
Loading