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

[Inference API] Avoid potential flaky wire serialization test cases #108605

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
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ protected EmptyTaskSettings createTestInstance() {

@Override
protected EmptyTaskSettings mutateInstance(EmptyTaskSettings instance) {
// All instances are the same and have no fields, nothing to mutate
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ protected InferenceAction.Response createTestInstance() {

@Override
protected InferenceAction.Response mutateInstance(InferenceAction.Response instance) throws IOException {
return null;
return randomValueOtherThan(instance, this::createTestInstance);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,6 @@ protected ChunkedSparseEmbeddingResults createTestInstance() {

@Override
protected ChunkedSparseEmbeddingResults mutateInstance(ChunkedSparseEmbeddingResults instance) throws IOException {
return null;
return randomValueOtherThan(instance, ChunkedSparseEmbeddingResultsTests::createRandomResults);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,6 @@ protected ChunkedTextEmbeddingByteResults createTestInstance() {

@Override
protected ChunkedTextEmbeddingByteResults mutateInstance(ChunkedTextEmbeddingByteResults instance) throws IOException {
return null;
return randomValueOtherThan(instance, ChunkedTextEmbeddingByteResultsTests::createRandomResults);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,6 @@ protected ChunkedTextEmbeddingFloatResults createTestInstance() {

@Override
protected ChunkedTextEmbeddingFloatResults mutateInstance(ChunkedTextEmbeddingFloatResults instance) throws IOException {
return null;
return randomValueOtherThan(instance, this::createTestInstance);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,6 @@ protected ChunkedTextEmbeddingResults createTestInstance() {

@Override
protected ChunkedTextEmbeddingResults mutateInstance(ChunkedTextEmbeddingResults instance) throws IOException {
return null;
return randomValueOtherThan(instance, ChunkedTextEmbeddingResultsTests::createRandomResults);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ protected AzureOpenAiSecretSettings createTestInstance() {

@Override
protected AzureOpenAiSecretSettings mutateInstance(AzureOpenAiSecretSettings instance) throws IOException {
return createRandom();
return randomValueOtherThan(instance, AzureOpenAiSecretSettingsTests::createRandom);
}

public static Map<String, Object> getAzureOpenAiSecretSettingsMap(@Nullable String apiKey, @Nullable String entraId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,6 @@ protected AzureOpenAiCompletionServiceSettings createTestInstance() {

@Override
protected AzureOpenAiCompletionServiceSettings mutateInstance(AzureOpenAiCompletionServiceSettings instance) throws IOException {
return createRandom();
return randomValueOtherThan(instance, AzureOpenAiCompletionServiceSettingsTests::createRandom);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,6 @@ protected AzureOpenAiCompletionTaskSettings createTestInstance() {

@Override
protected AzureOpenAiCompletionTaskSettings mutateInstance(AzureOpenAiCompletionTaskSettings instance) throws IOException {
return createRandomWithUser();
return randomValueOtherThan(instance, AzureOpenAiCompletionTaskSettingsTests::createRandomWithUser);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ protected AzureOpenAiEmbeddingsServiceSettings createTestInstance() {

@Override
protected AzureOpenAiEmbeddingsServiceSettings mutateInstance(AzureOpenAiEmbeddingsServiceSettings instance) throws IOException {
return createRandom();
return randomValueOtherThan(instance, AzureOpenAiEmbeddingsServiceSettingsTests::createRandom);
}

public static Map<String, Object> getPersistentAzureOpenAiServiceSettingsMap(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ protected AzureOpenAiEmbeddingsTaskSettings createTestInstance() {

@Override
protected AzureOpenAiEmbeddingsTaskSettings mutateInstance(AzureOpenAiEmbeddingsTaskSettings instance) throws IOException {
return createRandomWithUser();
return randomValueOtherThan(instance, AzureOpenAiEmbeddingsTaskSettingsTests::createRandomWithUser);
}

public static Map<String, Object> getAzureOpenAiRequestTaskSettingsMap(@Nullable String user) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ protected CohereServiceSettings createTestInstance() {

@Override
protected CohereServiceSettings mutateInstance(CohereServiceSettings instance) throws IOException {
return null;
return randomValueOtherThan(instance, CohereServiceSettingsTests::createRandom);
}

public static Map<String, Object> getServiceSettingsMap(@Nullable String url, @Nullable String model) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ protected CohereEmbeddingsServiceSettings createTestInstance() {

@Override
protected CohereEmbeddingsServiceSettings mutateInstance(CohereEmbeddingsServiceSettings instance) throws IOException {
return null;
return randomValueOtherThan(instance, CohereEmbeddingsServiceSettingsTests::createRandom);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ protected CohereEmbeddingsTaskSettings createTestInstance() {

@Override
protected CohereEmbeddingsTaskSettings mutateInstance(CohereEmbeddingsTaskSettings instance) throws IOException {
return null;
return randomValueOtherThan(instance, CohereEmbeddingsTaskSettingsTests::createRandom);
}

public static Map<String, Object> getTaskSettingsMapEmpty() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ protected CohereRerankServiceSettings createTestInstance() {

@Override
protected CohereRerankServiceSettings mutateInstance(CohereRerankServiceSettings instance) throws IOException {
return null;
return randomValueOtherThan(instance, CohereRerankServiceSettingsTests::createRandom);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ protected HuggingFaceServiceSettings createTestInstance() {

@Override
protected HuggingFaceServiceSettings mutateInstance(HuggingFaceServiceSettings instance) throws IOException {
return createRandom();
return randomValueOtherThan(instance, HuggingFaceServiceSettingsTests::createRandom);
}

public static Map<String, Object> getServiceSettingsMap(String url) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,6 @@ protected HuggingFaceElserSecretSettings createTestInstance() {

@Override
protected HuggingFaceElserSecretSettings mutateInstance(HuggingFaceElserSecretSettings instance) throws IOException {
return createRandom();
return randomValueOtherThan(instance, HuggingFaceElserSecretSettingsTests::createRandom);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,6 @@ protected HuggingFaceElserServiceSettings createTestInstance() {

@Override
protected HuggingFaceElserServiceSettings mutateInstance(HuggingFaceElserServiceSettings instance) throws IOException {
return createRandom();
return randomValueOtherThan(instance, HuggingFaceElserServiceSettingsTests::createRandom);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ protected OpenAiChatCompletionServiceSettings createTestInstance() {

@Override
protected OpenAiChatCompletionServiceSettings mutateInstance(OpenAiChatCompletionServiceSettings instance) throws IOException {
return createRandomWithNonNullUrl();
return randomValueOtherThan(instance, OpenAiChatCompletionServiceSettingsTests::createRandomWithNonNullUrl);
}

private static OpenAiChatCompletionServiceSettings createRandomWithNonNullUrl() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ protected OpenAiEmbeddingsServiceSettings createTestInstance() {

@Override
protected OpenAiEmbeddingsServiceSettings mutateInstance(OpenAiEmbeddingsServiceSettings instance) throws IOException {
return createRandomWithNonNullUrl();
return randomValueOtherThan(instance, OpenAiEmbeddingsServiceSettingsTests::createRandomWithNonNullUrl);
}

public static Map<String, Object> getServiceSettingsMap(String modelId, @Nullable String url, @Nullable String org) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ protected OpenAiEmbeddingsTaskSettings createTestInstance() {

@Override
protected OpenAiEmbeddingsTaskSettings mutateInstance(OpenAiEmbeddingsTaskSettings instance) throws IOException {
return createRandomWithUser();
return randomValueOtherThan(instance, OpenAiEmbeddingsTaskSettingsTests::createRandomWithUser);
}

public static Map<String, Object> getTaskSettingsMap(@Nullable String user) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ protected DefaultSecretSettings createTestInstance() {

@Override
protected DefaultSecretSettings mutateInstance(DefaultSecretSettings instance) throws IOException {
return createRandom();
return randomValueOtherThan(instance, DefaultSecretSettingsTests::createRandom);
}

public static Map<String, Object> getSecretSettingsMap(String apiKey) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,6 @@ protected RateLimitSettings createTestInstance() {

@Override
protected RateLimitSettings mutateInstance(RateLimitSettings instance) throws IOException {
return createRandom();
return randomValueOtherThan(instance, RateLimitSettingsTests::createRandom);
}
}