Merged in feature/import (pull request #157)

Feature/import

* importstart

* pp

* tests

* importtests

* 100GB

* lint

* passtests

* utc

* awsprofile

* doublequotes

* host
This commit is contained in:
Michael McGuinness
2025-05-27 15:28:46 +00:00
parent 46882da5f5
commit cc2278086f
74 changed files with 992 additions and 4753 deletions
+13 -78
View File
@@ -5,17 +5,12 @@ import (
"context"
"fmt"
"log/slog"
"os"
"path/filepath"
"strconv"
"sync"
"testing"
"queryorchestration/internal/serviceconfig"
"queryorchestration/internal/serviceconfig/objectstore"
"github.com/docker/docker/api/types"
"github.com/docker/docker/client"
"github.com/docker/docker/pkg/archive"
"github.com/docker/go-connections/nat"
"github.com/stretchr/testify/require"
"github.com/testcontainers/testcontainers-go"
@@ -27,9 +22,14 @@ type Container struct {
URI string
}
type ContainerConfigProvider interface {
serviceconfig.ConfigProvider
objectstore.ConfigProvider
}
type containerConfig struct {
Name string
Cfg serviceconfig.ConfigProvider
Cfg ContainerConfigProvider
DownstreamQueues []RunnerName
Env map[string]string
WaitForMsg string
@@ -42,77 +42,14 @@ const (
dockerfilePath = "build/Dockerfile"
)
var imageBuild sync.Once
func buildImage(t testing.TB, ctx context.Context) {
imageBuild.Do(func() {
dockerContextPath, err := os.Getwd()
require.NoError(t, err, "Failed to get current directory")
for {
candidatePath := filepath.Join(dockerContextPath, dockerfilePath)
t.Logf("Checking for Dockerfile at: %s", dockerContextPath)
_, err := os.Stat(candidatePath)
if err == nil {
break
}
dockerContextPath = filepath.Join(dockerContextPath, "..")
}
cli, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation())
require.NoError(t, err)
excludePatterns := []string{
"LICENSE",
"README.md",
"**/*_test.go",
"cmd/*_test/",
".bitbucket/",
".devbox/",
".vscode/",
"deployments/",
"mocks/",
"out/",
"serviceAPIs/",
"test/",
"docs/",
"assets/",
"pkg/",
"internal/test/",
"Taskfile.yml",
"scripts/",
".gitattributes",
".gitignore",
"devbox.*",
"sqlc.yml",
"vaccum.conf.yaml",
".*.yml",
"**/*.cast",
"**/*.http",
}
buildContext, err := archive.TarWithOptions(dockerContextPath, &archive.TarOptions{
ExcludePatterns: excludePatterns,
})
require.NoError(t, err)
defer buildContext.Close()
out, err := cli.ImageBuild(ctx, buildContext, types.ImageBuildOptions{
Dockerfile: dockerfilePath,
Tags: []string{imageTag},
})
require.NoError(t, err)
defer func() {
err := out.Body.Close()
require.NoError(t, err)
}()
})
}
func createContainer(t testing.TB, ctx context.Context, network string, cfg *containerConfig) (testcontainers.Container, func()) {
bucket := cfg.Cfg.GetBucket()
if bucket == "" {
bucket = "invalid-example"
}
env := map[string]string{
"BUCKET": bucket,
"PGUSER": cfg.Cfg.GetDBUser(),
"PGPASSWORD": cfg.Cfg.GetDBSecret(),
"PGHOST": dbAlias,
@@ -145,8 +82,6 @@ func createContainer(t testing.TB, ctx context.Context, network string, cfg *con
env[string(GetRunnerEnvFromName(e))] = GetQueueURL(t, cfg.Cfg, e)
}
buildImage(t, ctx)
req := testcontainers.ContainerRequest{
Image: imageTag,
Env: env,