2025-01-10 19:17:20 +00:00
|
|
|
package test
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
"testing"
|
|
|
|
|
|
2025-03-05 12:05:46 +00:00
|
|
|
"queryorchestration/internal/serviceconfig"
|
2025-05-03 01:16:53 +00:00
|
|
|
"queryorchestration/internal/serviceconfig/objectstore"
|
2025-03-05 12:05:46 +00:00
|
|
|
|
2025-03-12 12:36:44 +00:00
|
|
|
"github.com/docker/go-connections/nat"
|
2025-05-03 01:16:53 +00:00
|
|
|
"github.com/gruntwork-io/terratest/modules/docker"
|
2025-01-10 19:17:20 +00:00
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
|
)
|
|
|
|
|
|
2025-05-03 01:16:53 +00:00
|
|
|
func TestBuildImage(t *testing.T) {
|
|
|
|
|
if testing.Short() {
|
|
|
|
|
t.SkipNow()
|
|
|
|
|
}
|
2025-05-03 11:29:10 +00:00
|
|
|
buildImage(t, t.Context())
|
2025-05-03 01:16:53 +00:00
|
|
|
|
|
|
|
|
exists := docker.DoesImageExist(t, imageTag, nil)
|
|
|
|
|
assert.True(t, exists)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type Cfg struct {
|
|
|
|
|
serviceconfig.BaseConfig
|
|
|
|
|
objectstore.ObjectStoreConfig
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-10 19:17:20 +00:00
|
|
|
func TestCreateContainer(t *testing.T) {
|
2025-04-25 17:02:50 +00:00
|
|
|
t.Parallel()
|
2025-01-17 12:00:32 +00:00
|
|
|
if testing.Short() {
|
2025-05-03 01:16:53 +00:00
|
|
|
t.SkipNow()
|
2025-01-17 12:00:32 +00:00
|
|
|
}
|
2025-01-10 19:17:20 +00:00
|
|
|
ctx := context.Background()
|
|
|
|
|
|
2025-05-03 01:16:53 +00:00
|
|
|
cfg := &Cfg{}
|
2025-04-22 14:40:16 +00:00
|
|
|
|
2025-05-03 01:16:53 +00:00
|
|
|
deps, clean := CreateFullDependencies(t, ctx, cfg)
|
|
|
|
|
defer clean()
|
2025-01-10 19:17:20 +00:00
|
|
|
|
2025-01-31 13:43:55 +00:00
|
|
|
ccfg := &containerConfig{
|
2025-04-02 18:50:03 +00:00
|
|
|
Name: string(QueryAPIName),
|
2025-03-17 18:14:15 +00:00
|
|
|
DownstreamQueues: QueryAPI.DownstreamQueues,
|
|
|
|
|
Cfg: cfg,
|
2025-03-12 12:36:44 +00:00
|
|
|
ExposedPorts: []nat.Port{
|
|
|
|
|
nat.Port("8080/tcp"),
|
|
|
|
|
},
|
2025-01-10 19:17:20 +00:00
|
|
|
}
|
|
|
|
|
|
2025-05-03 01:16:53 +00:00
|
|
|
container, cleanup := createContainer(t, ctx, deps.Network, ccfg)
|
2025-01-10 19:17:20 +00:00
|
|
|
assert.NotNil(t, container)
|
|
|
|
|
assert.NotNil(t, cleanup)
|
|
|
|
|
|
2025-03-19 11:54:14 +00:00
|
|
|
PrintContainerLogs(t, ctx, container)
|
|
|
|
|
|
2025-01-10 19:17:20 +00:00
|
|
|
cleanup()
|
|
|
|
|
}
|