Merged in jb/openapi (pull request #22)
add openapi infra * add openapi infra Includes generated stubs and all deps * generatetolocation * basesetupoffunctionsandclient * round1controllertests * passintegrationtests * cleanupfromfullsuite * storedjson * fixjsonyaml * fixtests Approved-by: Michael McGuinness
This commit is contained in:
committed by
Michael McGuinness
parent
5ca36b0502
commit
174644b63c
@@ -2,8 +2,8 @@ package integration_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
serviceinterfaces "queryorchestration/api/serviceInterfaces"
|
||||
"queryorchestration/internal/test"
|
||||
queryservice "queryorchestration/pkg/queryService"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
@@ -12,12 +12,13 @@ import (
|
||||
func TestExportService(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
|
||||
conn, cleanup := test.CreateAPIWithDependencies(t, ctx, "queryService")
|
||||
address, cleanup := test.CreateAPIWithDependencies(t, ctx, "queryService")
|
||||
defer cleanup()
|
||||
|
||||
expClient := serviceinterfaces.NewExportServiceClient(conn)
|
||||
client, err := queryservice.NewClientWithResponses(address)
|
||||
assert.Nil(t, err)
|
||||
|
||||
idRes, err := expClient.Trigger(ctx, &serviceinterfaces.ExportTrigger{})
|
||||
idRes, err := client.TriggerExportWithResponse(ctx, queryservice.ExportTrigger{})
|
||||
assert.Nil(t, err)
|
||||
assert.NotNil(t, idRes)
|
||||
}
|
||||
|
||||
@@ -2,30 +2,34 @@ package integration_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
serviceinterfaces "queryorchestration/api/serviceInterfaces"
|
||||
"queryorchestration/internal/test"
|
||||
queryservice "queryorchestration/pkg/queryService"
|
||||
"testing"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestJobCollectorService(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
|
||||
conn, cleanup := test.CreateAPIWithDependencies(t, ctx, "queryService")
|
||||
address, cleanup := test.CreateAPIWithDependencies(t, ctx, "queryService")
|
||||
defer cleanup()
|
||||
|
||||
collClient := serviceinterfaces.NewJobCollectorServiceClient(conn)
|
||||
client, err := queryservice.NewClientWithResponses(address)
|
||||
assert.Nil(t, err)
|
||||
|
||||
idRes, err := collClient.Create(ctx, &serviceinterfaces.JobCollectorCreate{})
|
||||
idRes, err := client.CreateJobCollectorWithResponse(ctx, queryservice.JobCollectorCreate{})
|
||||
assert.Nil(t, err)
|
||||
assert.NotNil(t, idRes)
|
||||
|
||||
collRes, err := collClient.Get(ctx, &serviceinterfaces.IdMessage{})
|
||||
id := uuid.New()
|
||||
|
||||
collRes, err := client.GetJobCollectorByIdWithResponse(ctx, id.String())
|
||||
assert.Nil(t, err)
|
||||
assert.NotNil(t, collRes)
|
||||
|
||||
res, err := collClient.Update(ctx, &serviceinterfaces.JobCollectorUpdate{})
|
||||
res, err := client.UpdateJobCollectorWithResponse(ctx, id.String(), queryservice.JobCollectorUpdate{})
|
||||
assert.Nil(t, err)
|
||||
assert.NotNil(t, res)
|
||||
}
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
package integration_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
serviceinterfaces "queryorchestration/api/serviceInterfaces"
|
||||
"queryorchestration/internal/test"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestQueryServiceList(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
|
||||
conn, cleanup := test.CreateAPIWithDependencies(t, ctx, "queryService")
|
||||
defer cleanup()
|
||||
|
||||
client := serviceinterfaces.NewQueryServiceClient(conn)
|
||||
|
||||
contextRes, err := client.Create(ctx, &serviceinterfaces.QueryCreate{
|
||||
Type: serviceinterfaces.QueryType_QUERY_TYPE_CONTEXT_FULL,
|
||||
Config: nil,
|
||||
RequiredQueries: []string{},
|
||||
})
|
||||
assert.Nil(t, err)
|
||||
|
||||
config := "\"path\":\".key\""
|
||||
_, err = client.Create(ctx, &serviceinterfaces.QueryCreate{
|
||||
Type: serviceinterfaces.QueryType_QUERY_TYPE_JSON_EXTRACTOR,
|
||||
Config: &config,
|
||||
RequiredQueries: []string{
|
||||
contextRes.Id,
|
||||
},
|
||||
})
|
||||
assert.Nil(t, err)
|
||||
|
||||
queriesRes, err := client.List(ctx, &serviceinterfaces.QueryFilter{})
|
||||
assert.Nil(t, err)
|
||||
assert.Len(t, queriesRes.Queries, 2)
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package integration_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"queryorchestration/internal/test"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestQueryServiceOpenAPI(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
|
||||
address, cleanup := test.CreateAPIWithDependencies(t, ctx, "queryService")
|
||||
defer cleanup()
|
||||
|
||||
resp, err := http.Get(fmt.Sprintf("%s/swagger/doc.json", address))
|
||||
assert.Nil(t, err)
|
||||
assert.NotNil(t, resp)
|
||||
assert.Equal(t, http.StatusOK, resp.StatusCode)
|
||||
|
||||
resp, err = http.Get(fmt.Sprintf("%s/swagger/doc.yaml", address))
|
||||
assert.Nil(t, err)
|
||||
assert.NotNil(t, resp)
|
||||
assert.Equal(t, http.StatusOK, resp.StatusCode)
|
||||
|
||||
resp, err = http.Get(fmt.Sprintf("%s/swagger/index.html", address))
|
||||
assert.Nil(t, err)
|
||||
assert.NotNil(t, resp)
|
||||
assert.Equal(t, http.StatusOK, resp.StatusCode)
|
||||
}
|
||||
@@ -2,8 +2,8 @@ package integration_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
serviceinterfaces "queryorchestration/api/serviceInterfaces"
|
||||
"queryorchestration/internal/test"
|
||||
queryservice "queryorchestration/pkg/queryService"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
@@ -12,48 +12,49 @@ import (
|
||||
func TestQueryService(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
|
||||
conn, cleanup := test.CreateAPIWithDependencies(t, ctx, "queryService")
|
||||
address, cleanup := test.CreateAPIWithDependencies(t, ctx, "queryService")
|
||||
defer cleanup()
|
||||
|
||||
client := serviceinterfaces.NewQueryServiceClient(conn)
|
||||
client, err := queryservice.NewClientWithResponses(address)
|
||||
assert.Nil(t, err)
|
||||
|
||||
idRes, err := client.Create(ctx, &serviceinterfaces.QueryCreate{
|
||||
Type: serviceinterfaces.QueryType_QUERY_TYPE_CONTEXT_FULL,
|
||||
Config: nil,
|
||||
RequiredQueries: []string{},
|
||||
idRes, err := client.CreateQueryWithResponse(ctx, queryservice.QueryCreate{
|
||||
Type: queryservice.CONTEXTFULL,
|
||||
})
|
||||
assert.Nil(t, err)
|
||||
id := idRes.GetId()
|
||||
assert.NotNil(t, idRes)
|
||||
assert.NotNil(t, idRes.JSON201)
|
||||
id := idRes.JSON201.Id
|
||||
assert.NotEmpty(t, id)
|
||||
|
||||
queryRes, err := client.Get(ctx, &serviceinterfaces.IdMessage{
|
||||
Id: id,
|
||||
})
|
||||
queryRes, err := client.GetQueryByIdWithResponse(ctx, id)
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, id, queryRes.Id)
|
||||
assert.Equal(t, serviceinterfaces.QueryType_QUERY_TYPE_CONTEXT_FULL, queryRes.Type)
|
||||
assert.Equal(t, int32(1), queryRes.ActiveVersion)
|
||||
assert.Equal(t, int32(1), queryRes.LatestVersion)
|
||||
assert.Equal(t, "", *queryRes.Config)
|
||||
assert.Equal(t, []string(nil), queryRes.RequiredQueries)
|
||||
assert.Equal(t, id, queryRes.JSON200.Id)
|
||||
assert.Equal(t, queryservice.CONTEXTFULL, queryRes.JSON200.Type)
|
||||
assert.Equal(t, int32(1), queryRes.JSON200.ActiveVersion)
|
||||
assert.Equal(t, int32(1), queryRes.JSON200.LatestVersion)
|
||||
assert.Nil(t, queryRes.JSON200.Config)
|
||||
assert.Nil(t, queryRes.JSON200.RequiredQueries)
|
||||
|
||||
res, err := client.Update(ctx, &serviceinterfaces.QueryUpdate{
|
||||
Id: id,
|
||||
queriesRes, err := client.ListQueriesWithResponse(ctx)
|
||||
assert.Nil(t, err)
|
||||
assert.Len(t, queriesRes.JSON200.Queries, 1)
|
||||
assert.Equal(t, id, queriesRes.JSON200.Queries[0].Id)
|
||||
|
||||
res, err := client.UpdateQueryWithResponse(ctx, id, queryservice.QueryUpdate{
|
||||
Config: nil,
|
||||
ActiveVersion: nil,
|
||||
RequiredQueries: []string{},
|
||||
RequiredQueries: &[]string{},
|
||||
})
|
||||
assert.Nil(t, err)
|
||||
assert.NotNil(t, res)
|
||||
|
||||
queryRes, err = client.Get(ctx, &serviceinterfaces.IdMessage{
|
||||
Id: id,
|
||||
})
|
||||
queryRes, err = client.GetQueryByIdWithResponse(ctx, id)
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, id, queryRes.Id)
|
||||
assert.Equal(t, serviceinterfaces.QueryType_QUERY_TYPE_CONTEXT_FULL, queryRes.Type)
|
||||
assert.Equal(t, int32(1), queryRes.ActiveVersion)
|
||||
assert.Equal(t, int32(1), queryRes.LatestVersion)
|
||||
assert.Equal(t, "", *queryRes.Config)
|
||||
assert.Equal(t, []string(nil), queryRes.RequiredQueries)
|
||||
assert.Equal(t, id, queryRes.JSON200.Id)
|
||||
assert.Equal(t, queryservice.CONTEXTFULL, queryRes.JSON200.Type)
|
||||
assert.Equal(t, int32(1), queryRes.JSON200.ActiveVersion)
|
||||
assert.Equal(t, int32(1), queryRes.JSON200.LatestVersion)
|
||||
assert.Nil(t, queryRes.JSON200.Config)
|
||||
assert.Nil(t, queryRes.JSON200.RequiredQueries)
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@ package integration_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
serviceinterfaces "queryorchestration/api/serviceInterfaces"
|
||||
"queryorchestration/internal/test"
|
||||
queryservice "queryorchestration/pkg/queryService"
|
||||
"testing"
|
||||
|
||||
"github.com/google/uuid"
|
||||
@@ -13,24 +13,22 @@ import (
|
||||
func TestQueryServiceTest(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
|
||||
conn, cleanup := test.CreateAPIWithDependencies(t, ctx, "queryService")
|
||||
address, cleanup := test.CreateAPIWithDependencies(t, ctx, "queryService")
|
||||
defer cleanup()
|
||||
|
||||
client := serviceinterfaces.NewQueryServiceClient(conn)
|
||||
client, err := queryservice.NewClientWithResponses(address)
|
||||
assert.Nil(t, err)
|
||||
|
||||
idRes, err := client.Create(ctx, &serviceinterfaces.QueryCreate{
|
||||
Type: serviceinterfaces.QueryType_QUERY_TYPE_CONTEXT_FULL,
|
||||
Config: nil,
|
||||
RequiredQueries: []string{},
|
||||
idRes, err := client.CreateQueryWithResponse(ctx, queryservice.QueryCreate{
|
||||
Type: queryservice.CONTEXTFULL,
|
||||
})
|
||||
assert.Nil(t, err)
|
||||
id := idRes.GetId()
|
||||
id := idRes.JSON201.Id
|
||||
assert.NotEmpty(t, id)
|
||||
|
||||
docId := uuid.New()
|
||||
|
||||
testRes, err := client.Test(ctx, &serviceinterfaces.QueryTestRequest{
|
||||
QueryId: id,
|
||||
testRes, err := client.TestQueryWithResponse(ctx, id, queryservice.QueryTestRequest{
|
||||
DocumentId: docId.String(),
|
||||
QueryVersion: int32(1),
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user