mirror of
https://github.com/pomerium/pomerium.git
synced 2025-06-26 06:28:18 +02:00
Initial test environment implementation
This commit is contained in:
parent
dc427a4078
commit
f1d2799a9f
24 changed files with 2917 additions and 20 deletions
36
internal/testenv/snippets/wait.go
Normal file
36
internal/testenv/snippets/wait.go
Normal file
|
@ -0,0 +1,36 @@
|
|||
package snippets
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/pomerium/pomerium/internal/testenv"
|
||||
"github.com/pomerium/pomerium/pkg/grpcutil"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/connectivity"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
)
|
||||
|
||||
func WaitStartupComplete(t testing.TB, env testenv.Environment, timeout ...time.Duration) time.Duration {
|
||||
start := time.Now()
|
||||
recorder := env.NewLogRecorder()
|
||||
if len(timeout) == 0 {
|
||||
timeout = append(timeout, 1*time.Minute)
|
||||
}
|
||||
ctx, ca := context.WithTimeout(env.Context(), timeout[0])
|
||||
defer ca()
|
||||
recorder.WaitForMatch(map[string]any{
|
||||
"syncer_id": "databroker",
|
||||
"syncer_type": "type.googleapis.com/pomerium.config.Config",
|
||||
"message": "listening for updates",
|
||||
}, timeout...)
|
||||
cc, err := grpc.Dial(env.DatabrokerURL().Value(),
|
||||
grpc.WithTransportCredentials(insecure.NewCredentials()),
|
||||
grpc.WithChainUnaryInterceptor(grpcutil.WithUnarySignedJWT(env.SharedSecret)),
|
||||
grpc.WithChainStreamInterceptor(grpcutil.WithStreamSignedJWT(env.SharedSecret)),
|
||||
)
|
||||
env.Require().NoError(err)
|
||||
env.Require().True(cc.WaitForStateChange(ctx, connectivity.Ready))
|
||||
return time.Since(start)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue