Skip to content

Commit

Permalink
e2e: add models test using the openai client (#338)
Browse files Browse the repository at this point in the history
**Commit Message**

e2e: add test for the models endpoint using the openai client

**Related Issues/PRs (if applicable)**

Related to #325

**Special notes for reviewers (if applicable)**

N/A

---------

Signed-off-by: Ignasi Barrera <ignasi@tetrate.io>
  • Loading branch information
nacx authored Feb 13, 2025
1 parent 0b92c0b commit a25739d
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/extproc/real_providers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (

"github.com/openai/openai-go"
"github.com/openai/openai-go/option"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/envoyproxy/ai-gateway/filterapi"
Expand Down Expand Up @@ -230,6 +231,29 @@ func TestWithRealProviders(t *testing.T) {
return returnsToolCall
}, 30*time.Second, 2*time.Second)
})

// Models are served by the extproc filter as a direct response so this can run even if the
// real credentials are not present.
// We don't need to run it on a concrete backend, as it will not route anywhere.
t.Run("list-models", func(t *testing.T) {
client := openai.NewClient(option.WithBaseURL(listenerAddress + "/v1/"))

var models []string

require.EventuallyWithT(t, func(c *assert.CollectT) {
it := client.Models.ListAutoPaging(t.Context())
for it.Next() {
models = append(models, it.Current().ID)
}
assert.NoError(c, it.Err())
}, 30*time.Second, 2*time.Second)

require.Equal(t, []string{
"gpt-4o-mini",
"us.meta.llama3-2-1b-instruct-v1:0",
"us.anthropic.claude-3-5-sonnet-20240620-v1:0",
}, models)
})
}

// realProvidersTestCase is a base test case for the real providers, which is mainly for the centralization of the
Expand Down

0 comments on commit a25739d

Please sign in to comment.