mirror of
https://github.com/pomerium/pomerium.git
synced 2025-05-10 07:37:33 +02:00
integration: add cluster setup and configuration and a few tests
This commit is contained in:
parent
9860c3ce9f
commit
8fd716e1d8
24 changed files with 1689 additions and 2 deletions
52
integration/main_test.go
Normal file
52
integration/main_test.go
Normal file
|
@ -0,0 +1,52 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/onsi/gocleanup"
|
||||
"github.com/pomerium/pomerium/integration/internal/cluster"
|
||||
"github.com/rs/zerolog"
|
||||
"github.com/rs/zerolog/log"
|
||||
)
|
||||
|
||||
const localHTTPSPort = 9443
|
||||
|
||||
var (
|
||||
mainCtx context.Context
|
||||
testcluster *cluster.Cluster
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr})
|
||||
|
||||
flag.Parse()
|
||||
if testing.Verbose() {
|
||||
log.Logger = log.Logger.Level(zerolog.DebugLevel)
|
||||
} else {
|
||||
log.Logger = log.Logger.Level(zerolog.InfoLevel)
|
||||
}
|
||||
|
||||
mainCtx = context.Background()
|
||||
var cancel func()
|
||||
mainCtx, cancel = context.WithCancel(mainCtx)
|
||||
var clearTimeout func()
|
||||
mainCtx, clearTimeout = context.WithTimeout(mainCtx, time.Minute*10)
|
||||
defer clearTimeout()
|
||||
|
||||
_, mainTestFilePath, _, _ := runtime.Caller(0)
|
||||
testcluster = cluster.New(filepath.Dir(mainTestFilePath))
|
||||
if err := testcluster.Setup(mainCtx); err != nil {
|
||||
log.Fatal().Err(err).Send()
|
||||
}
|
||||
|
||||
status := m.Run()
|
||||
cancel()
|
||||
gocleanup.Cleanup()
|
||||
os.Exit(status)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue