7001ca854c
Queuing Changes and Cfg Testing * staarting * staarting * startedpush * note * save * mocking * removederrs * fixtests * cleanuperrs * newenvsetup * preppingtests * queue * mmovetocfgpassunittests * sortoutconfig * passinginteg * deps * fixtests
88 lines
2.5 KiB
Go
88 lines
2.5 KiB
Go
package integration_test
|
|
|
|
import (
|
|
"context"
|
|
"queryorchestration/internal/test"
|
|
queryservice "queryorchestration/pkg/queryService"
|
|
"testing"
|
|
|
|
"github.com/oapi-codegen/runtime/types"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestJobCollectorService(t *testing.T) {
|
|
t.SkipNow()
|
|
ctx := context.Background()
|
|
|
|
c, cleanup := test.CreateServiceNetwork(t, ctx, &test.ServiceNetworkConfig{
|
|
Name: test.QueryService,
|
|
})
|
|
defer cleanup()
|
|
|
|
client, err := queryservice.NewClientWithResponses(c.URI)
|
|
assert.NoError(t, err)
|
|
|
|
contextRes, err := client.CreateQueryWithResponse(ctx, queryservice.QueryCreate{
|
|
Type: queryservice.CONTEXTFULL,
|
|
})
|
|
assert.NoError(t, err)
|
|
|
|
jsoncfg := "{\"path\":\"key\"}"
|
|
jsonRes, err := client.CreateQueryWithResponse(ctx, queryservice.QueryCreate{
|
|
Type: queryservice.JSONEXTRACTOR,
|
|
Config: &jsoncfg,
|
|
RequiredQueries: &[]types.UUID{
|
|
contextRes.JSON201.Id,
|
|
},
|
|
})
|
|
assert.NoError(t, err)
|
|
|
|
clientRes, err := client.CreateClientWithResponse(ctx, queryservice.ClientCreate{
|
|
Name: "example_name",
|
|
})
|
|
assert.NoError(t, err)
|
|
jobRes, err := client.CreateJobWithResponse(ctx, queryservice.JobCreate{
|
|
ClientId: clientRes.JSON201.Id,
|
|
})
|
|
assert.NoError(t, err)
|
|
id := jobRes.JSON201.Id
|
|
|
|
fields := []queryservice.JobCollectorField{
|
|
{
|
|
Name: "json_output",
|
|
QueryId: jsonRes.JSON201.Id,
|
|
},
|
|
}
|
|
|
|
collRes, err := client.GetJobCollectorByJobIdWithResponse(ctx, id)
|
|
assert.NoError(t, err)
|
|
assert.Equal(t, id, collRes.JSON200.JobId)
|
|
assert.Equal(t, 1, collRes.JSON200.ActiveVersion)
|
|
assert.Equal(t, 1, collRes.JSON200.LatestVersion)
|
|
assert.Equal(t, 1, collRes.JSON200.MinimumCleanerVersion)
|
|
assert.Equal(t, 1, collRes.JSON200.MinimumTextVersion)
|
|
assert.Len(t, collRes.JSON200.Fields, 0)
|
|
|
|
av := int32(2)
|
|
minClean := int32(2)
|
|
minText := int32(2)
|
|
uRes, err := client.UpdateJobCollectorByJobIdWithResponse(ctx, id, queryservice.JobCollectorUpdate{
|
|
ActiveVersion: &av,
|
|
MinimumCleanerVersion: &minClean,
|
|
MinimumTextVersion: &minText,
|
|
Fields: &fields,
|
|
})
|
|
assert.NoError(t, err)
|
|
assert.Nil(t, uRes)
|
|
|
|
collRes, err = client.GetJobCollectorByJobIdWithResponse(ctx, id)
|
|
assert.NoError(t, err)
|
|
assert.Equal(t, id, collRes.JSON200.JobId)
|
|
assert.Equal(t, 2, collRes.JSON200.ActiveVersion)
|
|
assert.Equal(t, 2, collRes.JSON200.LatestVersion)
|
|
assert.Equal(t, 2, collRes.JSON200.MinimumCleanerVersion)
|
|
assert.Equal(t, 2, collRes.JSON200.MinimumTextVersion)
|
|
assert.Len(t, collRes.JSON200.Fields, 1)
|
|
assert.ElementsMatch(t, fields, collRes.JSON200.Fields)
|
|
}
|