00e7dca3c7
Move queue to config * movequeue * passtests
88 lines
2.1 KiB
Go
88 lines
2.1 KiB
Go
package integration_test
|
|
|
|
import (
|
|
"context"
|
|
"os"
|
|
"path"
|
|
documentinit "queryorchestration/internal/document/init"
|
|
"queryorchestration/internal/serviceconfig/queue"
|
|
"queryorchestration/internal/test"
|
|
queryservice "queryorchestration/pkg/queryService"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestDocInitRunner(t *testing.T) {
|
|
ctx := context.Background()
|
|
|
|
cfg := test.CreateBaseConfig()
|
|
cfg.BasePath = path.Join(os.Getenv("PWD"), "../..")
|
|
|
|
network, ncleanup := test.CreateNetwork(t, ctx)
|
|
defer ncleanup()
|
|
|
|
qcleanup := test.CreateQueueClient(t, ctx, &test.CreateQueueConfig{
|
|
Cfg: cfg,
|
|
Network: network,
|
|
})
|
|
defer qcleanup()
|
|
doccleanurl := test.CreateQueue(t, ctx, cfg, "docclean")
|
|
|
|
net, cleanup := test.CreateRunnersAndServicesNetwork(t, ctx, &test.EcosystemNetworkConfig{
|
|
Cfg: cfg,
|
|
Network: network,
|
|
Runners: []*test.RunnerNetworkConfig{
|
|
{
|
|
Name: test.DocInitRunner,
|
|
Env: map[string]string{
|
|
"DOCUMENT_CLEAN_URL": doccleanurl,
|
|
},
|
|
},
|
|
},
|
|
Services: []*test.ServiceNetworkConfig{
|
|
{
|
|
Name: test.QueryService,
|
|
},
|
|
},
|
|
})
|
|
defer cleanup()
|
|
|
|
qService, err := queryservice.NewClientWithResponses(net.Services[test.QueryService].URI)
|
|
assert.NoError(t, err)
|
|
|
|
clientRes, err := qService.CreateClientWithResponse(ctx, queryservice.ClientCreate{
|
|
Name: "example_name",
|
|
})
|
|
assert.NoError(t, err)
|
|
jobRes, err := qService.CreateJobWithResponse(ctx, queryservice.JobCreate{
|
|
ClientId: clientRes.JSON201.Id,
|
|
})
|
|
assert.NoError(t, err)
|
|
|
|
canSync := true
|
|
_, err = qService.UpdateClientWithResponse(ctx, clientRes.JSON201.Id, queryservice.ClientUpdate{
|
|
CanSync: &canSync,
|
|
})
|
|
assert.NoError(t, err)
|
|
_, err = qService.UpdateJobWithResponse(ctx, jobRes.JSON201.Id, queryservice.JobUpdate{
|
|
CanSync: &canSync,
|
|
})
|
|
assert.NoError(t, err)
|
|
|
|
document := documentinit.Create{
|
|
JobID: jobRes.JSON201.Id,
|
|
Location: "/I/am/here", // TODO
|
|
}
|
|
|
|
err = cfg.SendToQueue(ctx, &queue.SendParams{
|
|
QueueURL: net.Runners[test.DocInitRunner].URI,
|
|
Body: document,
|
|
})
|
|
assert.NoError(t, err)
|
|
|
|
_ = test.AssertMessageWait(t, ctx, cfg, &queue.ReceiveParams{
|
|
QueueURL: doccleanurl,
|
|
})
|
|
}
|