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

feat: Set reverse proxy response content-type to application/json #106

Merged
merged 2 commits into from
Sep 7, 2020
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ cover.out
config.json

.DS_Store
cache/
2 changes: 2 additions & 0 deletions pkg/registry/harbor/harbor.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ func (p Proxy) ServeHTTP(w http.ResponseWriter, r *http.Request) {
resp.Header["Location"] = []string{strings.ReplaceAll(location[0], p.Domain,
viper.GetString(envModelRestirtyExternalAddress))}
}
// It is to solve https://github.com/kleveross/klever-model-registry/issues/104
resp.Header.Set("content-type", "application/json")
return nil
}

Expand Down
22 changes: 16 additions & 6 deletions testutil/integration/registry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package integration

import (
"encoding/json"
"net/http"

httpexpect "github.com/gavv/httpexpect/v2"
"github.com/kleveross/klever-model-registry/pkg/registry/models"
Expand All @@ -14,20 +15,21 @@ var _ = Describe("Model Registry", func() {
Context("ModelJobs", func() {
It("Should get the ModelJobs successfully", func() {
e.GET("/api/v1alpha1/namespaces/{namespace}/modeljobs/",
"default").Expect().Status(200)
"default").Expect().Status(http.StatusOK)
})
})
Context("Servings", func() {
It("Should get the Servings successfully", func() {
e.GET("/api/v1alpha1/namespaces/{namespace}/servings/",
"default").Expect().Status(200)
"default").Expect().Status(http.StatusOK)
})
})
Context("Models", func() {
project := "library"
model := "tensorflow"
version := "test"

It("Should push the model successfully", func() {
project := "library"
model := "tensorflow"
version := "test"
modelContent := models.Model{
ProjectName: project,
ModelName: model,
Expand All @@ -45,7 +47,15 @@ var _ = Describe("Model Registry", func() {
}).
WithMultipart().
WithFile("file", "./models/model.zip").WithFormField("model", string(bytes)).
Expect().Status(201)
Expect().Status(http.StatusCreated)
})
It("Should list the model successfully", func() {
artifact := e.GET("/api/v2.0/projects/{project_name}/repositories/{repository_name}/artifacts/{version}",
project, model, version).Expect().Status(http.StatusOK).JSON().Object()
// Validate that the artifact is a SavedModel.
// It is blocked since goharbor/harbor-helm does not support 2.1 now.
// artifact.Value("extra_attrs").Object().Value("format").Equal("SavedModel")
artifact.Value("type").Equal("MODEL")
})
})
})