Skip to content

Commit 65212a4

Browse files
committed
chore: fix gofmt formatting and extract assertAPIFormats test helper
Signed-off-by: Vivek Karunai Kiri Ragavan <vkarunai@redhat.com>
1 parent 7040ab8 commit 65212a4

7 files changed

Lines changed: 147 additions & 165 deletions

File tree

providers/dynamo/config.go

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -105,45 +105,45 @@ func GetProviderConfigSpec() airunwayv1alpha1.InferenceProviderConfigSpec {
105105
return airunwayv1alpha1.InferenceProviderConfigSpec{
106106
Capabilities: &airunwayv1alpha1.ProviderCapabilities{
107107
Engines: []airunwayv1alpha1.EngineCapability{
108-
{
109-
Name: airunwayv1alpha1.EngineTypeVLLM,
110-
ServingModes: []airunwayv1alpha1.ServingMode{
111-
airunwayv1alpha1.ServingModeAggregated,
112-
airunwayv1alpha1.ServingModeDisaggregated,
108+
{
109+
Name: airunwayv1alpha1.EngineTypeVLLM,
110+
ServingModes: []airunwayv1alpha1.ServingMode{
111+
airunwayv1alpha1.ServingModeAggregated,
112+
airunwayv1alpha1.ServingModeDisaggregated,
113+
},
114+
APIFormats: []airunwayv1alpha1.APIFormat{
115+
airunwayv1alpha1.APIFormatOpenAIChat,
116+
airunwayv1alpha1.APIFormatOpenAIResponses,
117+
airunwayv1alpha1.APIFormatAnthropicMessages,
118+
},
119+
GPUSupport: true,
120+
Gateway: dynamoGatewayCapabilities(),
113121
},
114-
APIFormats: []airunwayv1alpha1.APIFormat{
115-
airunwayv1alpha1.APIFormatOpenAIChat,
116-
airunwayv1alpha1.APIFormatOpenAIResponses,
117-
airunwayv1alpha1.APIFormatAnthropicMessages,
118-
},
119-
GPUSupport: true,
120-
Gateway: dynamoGatewayCapabilities(),
121-
},
122-
{
123-
Name: airunwayv1alpha1.EngineTypeSGLang,
124-
ServingModes: []airunwayv1alpha1.ServingMode{
125-
airunwayv1alpha1.ServingModeAggregated,
126-
airunwayv1alpha1.ServingModeDisaggregated,
122+
{
123+
Name: airunwayv1alpha1.EngineTypeSGLang,
124+
ServingModes: []airunwayv1alpha1.ServingMode{
125+
airunwayv1alpha1.ServingModeAggregated,
126+
airunwayv1alpha1.ServingModeDisaggregated,
127+
},
128+
APIFormats: []airunwayv1alpha1.APIFormat{
129+
airunwayv1alpha1.APIFormatOpenAIChat,
130+
airunwayv1alpha1.APIFormatAnthropicMessages,
131+
},
132+
GPUSupport: true,
133+
Gateway: dynamoGatewayCapabilities(),
127134
},
128-
APIFormats: []airunwayv1alpha1.APIFormat{
129-
airunwayv1alpha1.APIFormatOpenAIChat,
130-
airunwayv1alpha1.APIFormatAnthropicMessages,
135+
{
136+
Name: airunwayv1alpha1.EngineTypeTRTLLM,
137+
ServingModes: []airunwayv1alpha1.ServingMode{
138+
airunwayv1alpha1.ServingModeAggregated,
139+
},
140+
APIFormats: []airunwayv1alpha1.APIFormat{
141+
airunwayv1alpha1.APIFormatOpenAIChat,
142+
airunwayv1alpha1.APIFormatOpenAIResponses,
143+
},
144+
GPUSupport: true,
145+
Gateway: dynamoGatewayCapabilities(),
131146
},
132-
GPUSupport: true,
133-
Gateway: dynamoGatewayCapabilities(),
134-
},
135-
{
136-
Name: airunwayv1alpha1.EngineTypeTRTLLM,
137-
ServingModes: []airunwayv1alpha1.ServingMode{
138-
airunwayv1alpha1.ServingModeAggregated,
139-
},
140-
APIFormats: []airunwayv1alpha1.APIFormat{
141-
airunwayv1alpha1.APIFormatOpenAIChat,
142-
airunwayv1alpha1.APIFormatOpenAIResponses,
143-
},
144-
GPUSupport: true,
145-
Gateway: dynamoGatewayCapabilities(),
146-
},
147147
},
148148
},
149149
SelectionRules: []airunwayv1alpha1.SelectionRule{

providers/dynamo/config_test.go

Lines changed: 25 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -44,26 +44,11 @@ func TestGetProviderConfigSpec(t *testing.T) {
4444
if len(vllmCap.ServingModes) != 2 {
4545
t.Fatalf("expected vllm to support 2 serving modes, got %d", len(vllmCap.ServingModes))
4646
}
47-
expectedVLLMFormats := []airunwayv1alpha1.APIFormat{
47+
assertAPIFormats(t, "vllm", vllmCap.APIFormats, []airunwayv1alpha1.APIFormat{
4848
airunwayv1alpha1.APIFormatOpenAIChat,
4949
airunwayv1alpha1.APIFormatOpenAIResponses,
5050
airunwayv1alpha1.APIFormatAnthropicMessages,
51-
}
52-
if len(vllmCap.APIFormats) != len(expectedVLLMFormats) {
53-
t.Fatalf("expected vllm to support %d API formats, got %d", len(expectedVLLMFormats), len(vllmCap.APIFormats))
54-
}
55-
for _, expected := range expectedVLLMFormats {
56-
found := false
57-
for _, actual := range vllmCap.APIFormats {
58-
if actual == expected {
59-
found = true
60-
break
61-
}
62-
}
63-
if !found {
64-
t.Errorf("expected vllm to support API format %s", expected)
65-
}
66-
}
51+
})
6752

6853
sglangCap := spec.Capabilities.GetEngineCapability(airunwayv1alpha1.EngineTypeSGLang)
6954
if sglangCap == nil {
@@ -75,25 +60,10 @@ func TestGetProviderConfigSpec(t *testing.T) {
7560
if len(sglangCap.ServingModes) != 2 {
7661
t.Fatalf("expected sglang to support 2 serving modes, got %d", len(sglangCap.ServingModes))
7762
}
78-
expectedSGLangFormats := []airunwayv1alpha1.APIFormat{
63+
assertAPIFormats(t, "sglang", sglangCap.APIFormats, []airunwayv1alpha1.APIFormat{
7964
airunwayv1alpha1.APIFormatOpenAIChat,
8065
airunwayv1alpha1.APIFormatAnthropicMessages,
81-
}
82-
if len(sglangCap.APIFormats) != len(expectedSGLangFormats) {
83-
t.Fatalf("expected sglang to support %d API formats, got %d", len(expectedSGLangFormats), len(sglangCap.APIFormats))
84-
}
85-
for _, expected := range expectedSGLangFormats {
86-
found := false
87-
for _, actual := range sglangCap.APIFormats {
88-
if actual == expected {
89-
found = true
90-
break
91-
}
92-
}
93-
if !found {
94-
t.Errorf("expected sglang to support API format %s", expected)
95-
}
96-
}
66+
})
9767

9868
trtllmCap := spec.Capabilities.GetEngineCapability(airunwayv1alpha1.EngineTypeTRTLLM)
9969
if trtllmCap == nil {
@@ -105,25 +75,10 @@ func TestGetProviderConfigSpec(t *testing.T) {
10575
if len(trtllmCap.ServingModes) != 1 || trtllmCap.ServingModes[0] != airunwayv1alpha1.ServingModeAggregated {
10676
t.Errorf("expected trtllm to support only aggregated serving mode")
10777
}
108-
expectedTRTLLMFormats := []airunwayv1alpha1.APIFormat{
78+
assertAPIFormats(t, "trtllm", trtllmCap.APIFormats, []airunwayv1alpha1.APIFormat{
10979
airunwayv1alpha1.APIFormatOpenAIChat,
11080
airunwayv1alpha1.APIFormatOpenAIResponses,
111-
}
112-
if len(trtllmCap.APIFormats) != len(expectedTRTLLMFormats) {
113-
t.Fatalf("expected trtllm to support %d API formats, got %d", len(expectedTRTLLMFormats), len(trtllmCap.APIFormats))
114-
}
115-
for _, expected := range expectedTRTLLMFormats {
116-
found := false
117-
for _, actual := range trtllmCap.APIFormats {
118-
if actual == expected {
119-
found = true
120-
break
121-
}
122-
}
123-
if !found {
124-
t.Errorf("expected trtllm to support API format %s", expected)
125-
}
126-
}
81+
})
12782

12883
if len(spec.SelectionRules) != 4 {
12984
t.Fatalf("expected 4 selection rules, got %d", len(spec.SelectionRules))
@@ -372,3 +327,22 @@ func TestUpdateStatusNotFound(t *testing.T) {
372327
t.Fatal("expected error when config not found")
373328
}
374329
}
330+
331+
func assertAPIFormats(t *testing.T, engine string, got, expected []airunwayv1alpha1.APIFormat) {
332+
t.Helper()
333+
if len(got) != len(expected) {
334+
t.Fatalf("expected %s to support %d API formats, got %d: %v", engine, len(expected), len(got), got)
335+
}
336+
for _, e := range expected {
337+
found := false
338+
for _, a := range got {
339+
if a == e {
340+
found = true
341+
break
342+
}
343+
}
344+
if !found {
345+
t.Errorf("expected %s to support API format %s", engine, e)
346+
}
347+
}
348+
}

providers/kaito/config.go

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -65,28 +65,28 @@ func GetProviderConfigSpec() airunwayv1alpha1.InferenceProviderConfigSpec {
6565
return airunwayv1alpha1.InferenceProviderConfigSpec{
6666
Capabilities: &airunwayv1alpha1.ProviderCapabilities{
6767
Engines: []airunwayv1alpha1.EngineCapability{
68-
{
69-
Name: airunwayv1alpha1.EngineTypeVLLM,
70-
ServingModes: []airunwayv1alpha1.ServingMode{
71-
airunwayv1alpha1.ServingModeAggregated,
72-
},
73-
APIFormats: []airunwayv1alpha1.APIFormat{
74-
airunwayv1alpha1.APIFormatOpenAIChat,
75-
airunwayv1alpha1.APIFormatOpenAIResponses,
76-
airunwayv1alpha1.APIFormatAnthropicMessages,
77-
},
78-
GPUSupport: true,
79-
},
80-
{
81-
Name: airunwayv1alpha1.EngineTypeLlamaCpp,
82-
ServingModes: []airunwayv1alpha1.ServingMode{
83-
airunwayv1alpha1.ServingModeAggregated,
84-
},
85-
APIFormats: []airunwayv1alpha1.APIFormat{
86-
airunwayv1alpha1.APIFormatOpenAIChat,
68+
{
69+
Name: airunwayv1alpha1.EngineTypeVLLM,
70+
ServingModes: []airunwayv1alpha1.ServingMode{
71+
airunwayv1alpha1.ServingModeAggregated,
72+
},
73+
APIFormats: []airunwayv1alpha1.APIFormat{
74+
airunwayv1alpha1.APIFormatOpenAIChat,
75+
airunwayv1alpha1.APIFormatOpenAIResponses,
76+
airunwayv1alpha1.APIFormatAnthropicMessages,
77+
},
78+
GPUSupport: true,
8779
},
88-
GPUSupport: true,
89-
CPUSupport: true,
80+
{
81+
Name: airunwayv1alpha1.EngineTypeLlamaCpp,
82+
ServingModes: []airunwayv1alpha1.ServingMode{
83+
airunwayv1alpha1.ServingModeAggregated,
84+
},
85+
APIFormats: []airunwayv1alpha1.APIFormat{
86+
airunwayv1alpha1.APIFormatOpenAIChat,
87+
},
88+
GPUSupport: true,
89+
CPUSupport: true,
9090
// KAITO's llama.cpp deployment does not expose an
9191
// OpenAI-style served-name endpoint, so gateway routing
9292
// must fall back to spec.model.id rather than honoring

providers/kaito/config_test.go

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -50,26 +50,11 @@ func TestGetProviderConfigSpec(t *testing.T) {
5050
if len(vllmCap.ServingModes) != 1 || vllmCap.ServingModes[0] != airunwayv1alpha1.ServingModeAggregated {
5151
t.Errorf("expected vllm to support only aggregated serving mode")
5252
}
53-
expectedVLLMFormats := []airunwayv1alpha1.APIFormat{
53+
assertAPIFormats(t, "vllm", vllmCap.APIFormats, []airunwayv1alpha1.APIFormat{
5454
airunwayv1alpha1.APIFormatOpenAIChat,
5555
airunwayv1alpha1.APIFormatOpenAIResponses,
5656
airunwayv1alpha1.APIFormatAnthropicMessages,
57-
}
58-
if len(vllmCap.APIFormats) != len(expectedVLLMFormats) {
59-
t.Fatalf("expected vllm to support %d API formats, got %d", len(expectedVLLMFormats), len(vllmCap.APIFormats))
60-
}
61-
for _, expected := range expectedVLLMFormats {
62-
found := false
63-
for _, actual := range vllmCap.APIFormats {
64-
if actual == expected {
65-
found = true
66-
break
67-
}
68-
}
69-
if !found {
70-
t.Errorf("expected vllm to support API format %s", expected)
71-
}
72-
}
57+
})
7358

7459
llamaCap := spec.Capabilities.GetEngineCapability(airunwayv1alpha1.EngineTypeLlamaCpp)
7560
if llamaCap == nil {
@@ -294,3 +279,22 @@ func newFakeClientWithWorkspace(scheme *runtime.Scheme, objs ...client.Object) c
294279
WithStatusSubresource(&airunwayv1alpha1.InferenceProviderConfig{}).
295280
Build()
296281
}
282+
283+
func assertAPIFormats(t *testing.T, engine string, got, expected []airunwayv1alpha1.APIFormat) {
284+
t.Helper()
285+
if len(got) != len(expected) {
286+
t.Fatalf("expected %s to support %d API formats, got %d: %v", engine, len(expected), len(got), got)
287+
}
288+
for _, e := range expected {
289+
found := false
290+
for _, a := range got {
291+
if a == e {
292+
found = true
293+
break
294+
}
295+
}
296+
if !found {
297+
t.Errorf("expected %s to support API format %s", engine, e)
298+
}
299+
}
300+
}

providers/kuberay/config.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -71,17 +71,17 @@ func GetProviderConfigSpec() airunwayv1alpha1.InferenceProviderConfigSpec {
7171
return airunwayv1alpha1.InferenceProviderConfigSpec{
7272
Capabilities: &airunwayv1alpha1.ProviderCapabilities{
7373
Engines: []airunwayv1alpha1.EngineCapability{
74-
{
75-
Name: airunwayv1alpha1.EngineTypeVLLM,
76-
ServingModes: []airunwayv1alpha1.ServingMode{
77-
airunwayv1alpha1.ServingModeAggregated,
78-
airunwayv1alpha1.ServingModeDisaggregated,
74+
{
75+
Name: airunwayv1alpha1.EngineTypeVLLM,
76+
ServingModes: []airunwayv1alpha1.ServingMode{
77+
airunwayv1alpha1.ServingModeAggregated,
78+
airunwayv1alpha1.ServingModeDisaggregated,
79+
},
80+
APIFormats: []airunwayv1alpha1.APIFormat{
81+
airunwayv1alpha1.APIFormatOpenAIChat,
82+
},
83+
GPUSupport: true,
7984
},
80-
APIFormats: []airunwayv1alpha1.APIFormat{
81-
airunwayv1alpha1.APIFormatOpenAIChat,
82-
},
83-
GPUSupport: true,
84-
},
8585
},
8686
},
8787
SelectionRules: []airunwayv1alpha1.SelectionRule{

providers/llmd/config.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -64,20 +64,20 @@ func GetProviderConfigSpec() airunwayv1alpha1.InferenceProviderConfigSpec {
6464
return airunwayv1alpha1.InferenceProviderConfigSpec{
6565
Capabilities: &airunwayv1alpha1.ProviderCapabilities{
6666
Engines: []airunwayv1alpha1.EngineCapability{
67-
{
68-
Name: airunwayv1alpha1.EngineTypeVLLM,
69-
ServingModes: []airunwayv1alpha1.ServingMode{
70-
airunwayv1alpha1.ServingModeAggregated,
71-
airunwayv1alpha1.ServingModeDisaggregated,
67+
{
68+
Name: airunwayv1alpha1.EngineTypeVLLM,
69+
ServingModes: []airunwayv1alpha1.ServingMode{
70+
airunwayv1alpha1.ServingModeAggregated,
71+
airunwayv1alpha1.ServingModeDisaggregated,
72+
},
73+
APIFormats: []airunwayv1alpha1.APIFormat{
74+
airunwayv1alpha1.APIFormatOpenAIChat,
75+
airunwayv1alpha1.APIFormatOpenAIResponses,
76+
airunwayv1alpha1.APIFormatAnthropicMessages,
77+
},
78+
GPUSupport: true,
79+
RequiresCRD: &requiresCRD,
7280
},
73-
APIFormats: []airunwayv1alpha1.APIFormat{
74-
airunwayv1alpha1.APIFormatOpenAIChat,
75-
airunwayv1alpha1.APIFormatOpenAIResponses,
76-
airunwayv1alpha1.APIFormatAnthropicMessages,
77-
},
78-
GPUSupport: true,
79-
RequiresCRD: &requiresCRD,
80-
},
8181
},
8282
},
8383
SelectionRules: []airunwayv1alpha1.SelectionRule{},

0 commit comments

Comments
 (0)