mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-12 01:37:31 +00:00
add github action for integration tests
This commit is contained in:
10
internal/integration/config/cockroach.yaml
Normal file
10
internal/integration/config/cockroach.yaml
Normal file
@@ -0,0 +1,10 @@
|
||||
Database:
|
||||
cockroach:
|
||||
Host: localhost
|
||||
Port: 26257
|
||||
Database: zitadel
|
||||
Options: ""
|
||||
User:
|
||||
Username: zitadel
|
||||
Admin:
|
||||
Username: root
|
15
internal/integration/config/postgres.yaml
Normal file
15
internal/integration/config/postgres.yaml
Normal file
@@ -0,0 +1,15 @@
|
||||
Database:
|
||||
postgres:
|
||||
Host: localhost
|
||||
Port: 5432
|
||||
Database: zitadel
|
||||
MaxOpenConns: 20
|
||||
MaxIdleConns: 10
|
||||
User:
|
||||
Username: zitadel
|
||||
SSL:
|
||||
Mode: disable
|
||||
Admin:
|
||||
Username: zitadel
|
||||
SSL:
|
||||
Mode: disable
|
38
internal/integration/config/zitadel.yaml
Normal file
38
internal/integration/config/zitadel.yaml
Normal file
@@ -0,0 +1,38 @@
|
||||
Log:
|
||||
Level: debug
|
||||
|
||||
TLS:
|
||||
Enabled: false
|
||||
|
||||
FirstInstance:
|
||||
Org:
|
||||
Human:
|
||||
PasswordChangeRequired: false
|
||||
|
||||
LogStore:
|
||||
Access:
|
||||
Database:
|
||||
Enabled: true
|
||||
Debounce:
|
||||
MinFrequency: 0s
|
||||
MaxBulkSize: 0
|
||||
Execution:
|
||||
Database:
|
||||
Enabled: true
|
||||
Stdout:
|
||||
Enabled: true
|
||||
|
||||
Quotas:
|
||||
Access:
|
||||
ExhaustedCookieKey: "zitadel.quota.limiting"
|
||||
ExhaustedCookieMaxAge: "60s"
|
||||
|
||||
Projections:
|
||||
Customizations:
|
||||
NotificationsQuotas:
|
||||
RequeueEvery: 1s
|
||||
|
||||
DefaultInstance:
|
||||
LoginPolicy:
|
||||
MfaInitSkipLifetime: "0"
|
||||
|
@@ -2,11 +2,15 @@
|
||||
package integration
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
_ "embed"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/spf13/viper"
|
||||
"github.com/zitadel/logging"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
@@ -15,6 +19,15 @@ import (
|
||||
"github.com/zitadel/zitadel/cmd/start"
|
||||
)
|
||||
|
||||
var (
|
||||
//go:embed config/zitadel.yaml
|
||||
zitadelYAML []byte
|
||||
//go:embed config/cockroach.yaml
|
||||
cockroachYAML []byte
|
||||
//go:embed config/postgres.yaml
|
||||
postgresYAML []byte
|
||||
)
|
||||
|
||||
type Tester struct {
|
||||
*start.Server
|
||||
ClientConn *grpc.ClientConn
|
||||
@@ -22,6 +35,8 @@ type Tester struct {
|
||||
wg sync.WaitGroup // used for shutdown
|
||||
}
|
||||
|
||||
const commandLine = `start-from-init --masterkey MasterkeyNeedsToHave32Characters --tlsMode disabled`
|
||||
|
||||
func (s *Tester) createClientConn(ctx context.Context) {
|
||||
target := fmt.Sprintf("localhost:%d", s.Config.Port)
|
||||
cc, err := grpc.DialContext(ctx, target,
|
||||
@@ -45,16 +60,31 @@ func (s *Tester) Done() {
|
||||
s.wg.Wait()
|
||||
}
|
||||
|
||||
func NewTester(ctx context.Context, args []string) *Tester {
|
||||
tester := new(Tester)
|
||||
func NewTester(ctx context.Context) *Tester {
|
||||
args := strings.Split(commandLine, " ")
|
||||
|
||||
sc := make(chan *start.Server)
|
||||
cmd := cmd.New(os.Stdout, os.Stdin, args, sc)
|
||||
cmd.SetArgs(args)
|
||||
err := viper.MergeConfig(bytes.NewBuffer(zitadelYAML))
|
||||
logging.OnError(err).Fatal()
|
||||
|
||||
flavor := os.Getenv("INTEGRATION_DB_FLAVOR")
|
||||
switch flavor {
|
||||
case "cockroach":
|
||||
err = viper.MergeConfig(bytes.NewBuffer(cockroachYAML))
|
||||
case "postgres":
|
||||
err = viper.MergeConfig(bytes.NewBuffer(postgresYAML))
|
||||
default:
|
||||
logging.New().WithField("flavor", flavor).Fatal("unknown db flavor set in INTEGRATION_DB_FLAVOR")
|
||||
}
|
||||
logging.OnError(err).Fatal()
|
||||
|
||||
tester := new(Tester)
|
||||
tester.wg.Add(1)
|
||||
go func(wg *sync.WaitGroup) {
|
||||
defer wg.Done()
|
||||
|
||||
cmd := cmd.New(os.Stdout, os.Stdin, args, sc)
|
||||
cmd.SetArgs(args)
|
||||
logging.OnError(cmd.Execute()).Fatal()
|
||||
wg.Done()
|
||||
}(&tester.wg)
|
||||
|
||||
select {
|
||||
|
@@ -1,18 +1,17 @@
|
||||
//go:build integration
|
||||
|
||||
package integration
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
const commandLine = `start-from-init --masterkey MasterkeyNeedsToHave32Characters --tlsMode disabled --config ../../e2e/config/localhost/zitadel.yaml --steps ../../e2e/config/localhost/zitadel.yaml`
|
||||
|
||||
func TestNewTester(t *testing.T) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
|
||||
s := NewTester(ctx, strings.Split(commandLine, " "))
|
||||
s := NewTester(ctx)
|
||||
defer s.Done()
|
||||
}
|
||||
|
Reference in New Issue
Block a user