diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index ae3acf5b7a..0ea1505420 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -4,28 +4,14 @@ permissions: contents: read id-token: write -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - on: pull_request: jobs: - lint: - uses: ./.github/workflows/lint.yml - generated-code-check: - uses: ./.github/workflows/pr-no-generated-changes.yml - out-of-order-migrations: - uses: ./.github/workflows/out-of-order-migrations.yml - unit-tests: - uses: ./.github/workflows/pr-tests.yml integration-tests: - needs: [ lint, out-of-order-migrations ] uses: ./.github/workflows/integration_tests.yml publish-test-results: needs: - - unit-tests - integration-tests runs-on: ubuntu-latest permissions: diff --git a/packages/api/internal/analytics_collector/client.go b/packages/api/internal/analytics_collector/client.go index b1c0cf6387..67d1ac6ace 100644 --- a/packages/api/internal/analytics_collector/client.go +++ b/packages/api/internal/analytics_collector/client.go @@ -12,6 +12,8 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/credentials" "google.golang.org/protobuf/types/known/emptypb" + + "github.com/e2b-dev/infra/packages/api/internal/testhacks" ) var host = strings.TrimSpace(os.Getenv("ANALYTICS_COLLECTOR_HOST")) @@ -40,12 +42,20 @@ func NewAnalytics() (*Analytics, error) { MinVersion: tls.VersionTLS13, }) - conn, err := grpc.NewClient( - fmt.Sprintf("%s:443", host), + grpcOptions := []grpc.DialOption{ grpc.WithPerRPCCredentials(&gRPCApiKey{}), grpc.WithAuthority(host), grpc.WithTransportCredentials(cred), - ) + } + + if testhacks.IsTesting() { + grpcOptions = append(grpcOptions, + grpc.WithUnaryInterceptor(testhacks.GRPCUnaryInterceptor), + grpc.WithStreamInterceptor(testhacks.GRPCStreamInterceptor), + ) + } + + conn, err := grpc.NewClient(fmt.Sprintf("%s:443", host), grpcOptions...) if err != nil { return nil, fmt.Errorf("failed to create GRPC client: %w", err) } diff --git a/packages/api/internal/edge/client.go b/packages/api/internal/edge/client.go index 0177707198..8c4a07e974 100644 --- a/packages/api/internal/edge/client.go +++ b/packages/api/internal/edge/client.go @@ -13,6 +13,7 @@ import ( "google.golang.org/grpc/keepalive" grpclient "github.com/e2b-dev/infra/packages/api/internal/grpc" + "github.com/e2b-dev/infra/packages/api/internal/testhacks" "github.com/e2b-dev/infra/packages/shared/pkg/consts" orchestratorgrpc "github.com/e2b-dev/infra/packages/shared/pkg/grpc/orchestrator" infogrpc "github.com/e2b-dev/infra/packages/shared/pkg/grpc/orchestrator-info" @@ -59,6 +60,13 @@ func createClusterClient(tel *telemetry.Client, auth clientAuthorization, endpoi grpcOptions = append(grpcOptions, grpc.WithTransportCredentials(insecure.NewCredentials())) } + if testhacks.IsTesting() { + grpcOptions = append(grpcOptions, + grpc.WithUnaryInterceptor(testhacks.GRPCUnaryInterceptor), + grpc.WithStreamInterceptor(testhacks.GRPCStreamInterceptor), + ) + } + conn, err := grpc.NewClient(endpoint, grpcOptions...) if err != nil { return nil, fmt.Errorf("failed to create grpc client: %w", err) diff --git a/packages/api/internal/orchestrator/nodemanager/client.go b/packages/api/internal/orchestrator/nodemanager/client.go index 468c52d102..4c42b69645 100644 --- a/packages/api/internal/orchestrator/nodemanager/client.go +++ b/packages/api/internal/orchestrator/nodemanager/client.go @@ -11,6 +11,7 @@ import ( "github.com/e2b-dev/infra/packages/api/internal/api" grpclient "github.com/e2b-dev/infra/packages/api/internal/grpc" + "github.com/e2b-dev/infra/packages/api/internal/testhacks" "github.com/e2b-dev/infra/packages/shared/pkg/grpc/orchestrator" orchestratorinfo "github.com/e2b-dev/infra/packages/shared/pkg/grpc/orchestrator-info" ) @@ -22,7 +23,7 @@ var OrchestratorToApiNodeStateMapper = map[orchestratorinfo.ServiceInfoStatus]ap } func NewClient(tracerProvider trace.TracerProvider, meterProvider metric.MeterProvider, host string) (*grpclient.GRPCClient, error) { - conn, err := grpc.NewClient(host, + grpcOptions := []grpc.DialOption{ grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithStatsHandler( otelgrpc.NewClientHandler( @@ -30,7 +31,16 @@ func NewClient(tracerProvider trace.TracerProvider, meterProvider metric.MeterPr otelgrpc.WithMeterProvider(meterProvider), ), ), - ) + } + + if testhacks.IsTesting() { + grpcOptions = append(grpcOptions, + grpc.WithUnaryInterceptor(testhacks.GRPCUnaryInterceptor), + grpc.WithStreamInterceptor(testhacks.GRPCStreamInterceptor), + ) + } + + conn, err := grpc.NewClient(host, grpcOptions...) if err != nil { return nil, fmt.Errorf("failed to establish GRPC connection: %w", err) } diff --git a/packages/api/internal/template-manager/client.go b/packages/api/internal/template-manager/client.go index 2a1749a5b7..87f3a5d9f5 100644 --- a/packages/api/internal/template-manager/client.go +++ b/packages/api/internal/template-manager/client.go @@ -12,6 +12,7 @@ import ( "google.golang.org/grpc/keepalive" grpclient "github.com/e2b-dev/infra/packages/api/internal/grpc" + "github.com/e2b-dev/infra/packages/api/internal/testhacks" infogrpc "github.com/e2b-dev/infra/packages/shared/pkg/grpc/orchestrator-info" templatemanagergrpc "github.com/e2b-dev/infra/packages/shared/pkg/grpc/template-manager" ) @@ -19,7 +20,7 @@ import ( var templateManagerHost = os.Getenv("TEMPLATE_MANAGER_HOST") func createClient(tracerProvider trace.TracerProvider, meterProvider metric.MeterProvider) (*grpclient.GRPCClient, error) { - conn, err := grpc.NewClient(templateManagerHost, + grpcOptions := []grpc.DialOption{ grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithStatsHandler( otelgrpc.NewClientHandler( @@ -32,7 +33,16 @@ func createClient(tracerProvider trace.TracerProvider, meterProvider metric.Mete Timeout: 2 * time.Second, // Wait 2s for response PermitWithoutStream: true, }), - ) + } + + if testhacks.IsTesting() { + grpcOptions = append(grpcOptions, + grpc.WithUnaryInterceptor(testhacks.GRPCUnaryInterceptor), + grpc.WithStreamInterceptor(testhacks.GRPCStreamInterceptor), + ) + } + + conn, err := grpc.NewClient(templateManagerHost, grpcOptions...) if err != nil { return nil, err } diff --git a/packages/api/internal/testhacks/context.go b/packages/api/internal/testhacks/context.go new file mode 100644 index 0000000000..cbcd876099 --- /dev/null +++ b/packages/api/internal/testhacks/context.go @@ -0,0 +1,14 @@ +package testhacks + +import "context" + +type testNameContextKey struct{} + +func addTestName(ctx context.Context, testName string) context.Context { + return context.WithValue(ctx, testNameContextKey{}, testName) +} + +func GetTestName(ctx context.Context) string { + val, _ := ctx.Value(testNameContextKey{}).(string) + return val +} diff --git a/packages/api/internal/testhacks/gin.go b/packages/api/internal/testhacks/gin.go new file mode 100644 index 0000000000..3a88d5b7dd --- /dev/null +++ b/packages/api/internal/testhacks/gin.go @@ -0,0 +1,22 @@ +package testhacks + +import ( + "fmt" + + "github.com/gin-gonic/gin" +) + +func PrintTestName(c *gin.Context) { + testName := c.GetHeader("x-test-name") + if testName != "" { + ctx := addTestName(c.Request.Context(), testName) + c.Request = c.Request.WithContext(ctx) + fmt.Printf("====================== START api request for %s ========================\n", testName) + } + + c.Next() + + if testName != "" { + fmt.Printf("====================== FINISH api request for %s ========================\n", testName) + } +} diff --git a/packages/api/internal/testhacks/grpc.go b/packages/api/internal/testhacks/grpc.go new file mode 100644 index 0000000000..f80477c79b --- /dev/null +++ b/packages/api/internal/testhacks/grpc.go @@ -0,0 +1,24 @@ +package testhacks + +import ( + "context" + + "google.golang.org/grpc" + "google.golang.org/grpc/metadata" +) + +func GRPCUnaryInterceptor(ctx context.Context, method string, req any, reply any, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error { + if testName := GetTestName(ctx); testName != "" { + ctx = metadata.AppendToOutgoingContext(ctx, "x-test-name", testName) + } + + return invoker(ctx, method, req, reply, cc, opts...) +} + +func GRPCStreamInterceptor(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, streamer grpc.Streamer, opts ...grpc.CallOption) (grpc.ClientStream, error) { + if testName := GetTestName(ctx); testName != "" { + ctx = metadata.AppendToOutgoingContext(ctx, "x-test-name", testName) + } + + return streamer(ctx, desc, cc, method, opts...) +} diff --git a/packages/api/internal/testhacks/switch.go b/packages/api/internal/testhacks/switch.go new file mode 100644 index 0000000000..1049410f2a --- /dev/null +++ b/packages/api/internal/testhacks/switch.go @@ -0,0 +1,7 @@ +package testhacks + +import "os" + +func IsTesting() bool { + return os.Getenv("CI") == "true" +} diff --git a/packages/api/main.go b/packages/api/main.go index 03139797e5..5c40a78328 100644 --- a/packages/api/main.go +++ b/packages/api/main.go @@ -33,6 +33,7 @@ import ( customMiddleware "github.com/e2b-dev/infra/packages/api/internal/middleware" metricsMiddleware "github.com/e2b-dev/infra/packages/api/internal/middleware/otel/metrics" tracingMiddleware "github.com/e2b-dev/infra/packages/api/internal/middleware/otel/tracing" + "github.com/e2b-dev/infra/packages/api/internal/testhacks" "github.com/e2b-dev/infra/packages/api/internal/utils" "github.com/e2b-dev/infra/packages/shared/pkg/env" l "github.com/e2b-dev/infra/packages/shared/pkg/logger" @@ -67,6 +68,10 @@ func NewGinServer(ctx context.Context, tel *telemetry.Client, logger *zap.Logger r := gin.New() + if testhacks.IsTesting() { + r.Use(testhacks.PrintTestName) + } + r.Use( // We use custom otel gin middleware because we want to log 4xx errors in the otel customMiddleware.ExcludeRoutes( diff --git a/packages/client-proxy/internal/edge-pass-through/proxy.go b/packages/client-proxy/internal/edge-pass-through/proxy.go index 96493aeb44..7d193e31c5 100644 --- a/packages/client-proxy/internal/edge-pass-through/proxy.go +++ b/packages/client-proxy/internal/edge-pass-through/proxy.go @@ -15,6 +15,7 @@ import ( e2binfo "github.com/e2b-dev/infra/packages/proxy/internal/edge/info" e2borchestrators "github.com/e2b-dev/infra/packages/proxy/internal/edge/pool" "github.com/e2b-dev/infra/packages/proxy/internal/edge/sandboxes" + "github.com/e2b-dev/infra/packages/proxy/internal/testhacks" "github.com/e2b-dev/infra/packages/shared/pkg/consts" api "github.com/e2b-dev/infra/packages/shared/pkg/http/edge" ) @@ -48,10 +49,19 @@ func NewNodePassThroughServer( info: info, } - return grpc.NewServer( + serverOpts := []grpc.ServerOption{ grpc.UnknownServiceHandler(nodePassThrough.handler), grpc.MaxRecvMsgSize(grpcMaxMsgSize), - ) + } + + if testhacks.IsTesting() { + serverOpts = append(serverOpts, + grpc.ChainUnaryInterceptor(testhacks.UnaryTestNamePrinter), + grpc.ChainStreamInterceptor(testhacks.StreamingTestNamePrinter), + ) + } + + return grpc.NewServer(serverOpts...) } func (s *NodePassThroughServer) director(ctx context.Context) (*grpc.ClientConn, metadata.MD, error) { diff --git a/packages/client-proxy/internal/edge/http.go b/packages/client-proxy/internal/edge/http.go index 7d1b2b20f7..fc37121a32 100644 --- a/packages/client-proxy/internal/edge/http.go +++ b/packages/client-proxy/internal/edge/http.go @@ -19,6 +19,7 @@ import ( "github.com/e2b-dev/infra/packages/proxy/internal/edge/authorization" "github.com/e2b-dev/infra/packages/proxy/internal/edge/handlers" + "github.com/e2b-dev/infra/packages/proxy/internal/testhacks" "github.com/e2b-dev/infra/packages/shared/pkg/consts" "github.com/e2b-dev/infra/packages/shared/pkg/http/edge" "github.com/e2b-dev/infra/packages/shared/pkg/telemetry" @@ -51,6 +52,10 @@ func NewGinServer(logger *zap.Logger, store *handlers.APIStore, swagger *openapi handler := gin.New() handler.MaxMultipartMemory = maxMultipartMemory + if testhacks.IsTesting() { + handler.Use(testhacks.ProcessGinRequest) + } + // Use our validation middleware to check all requests against the // OpenAPI schema. handler.Use( diff --git a/packages/client-proxy/internal/edge/pool/orchestrator.go b/packages/client-proxy/internal/edge/pool/orchestrator.go index e1aa775a6d..7e83aa69e7 100644 --- a/packages/client-proxy/internal/edge/pool/orchestrator.go +++ b/packages/client-proxy/internal/edge/pool/orchestrator.go @@ -16,6 +16,7 @@ import ( "google.golang.org/grpc/credentials/insecure" "google.golang.org/protobuf/types/known/emptypb" + "github.com/e2b-dev/infra/packages/proxy/internal/testhacks" e2bgrpcorchestratorinfo "github.com/e2b-dev/infra/packages/shared/pkg/grpc/orchestrator-info" l "github.com/e2b-dev/infra/packages/shared/pkg/logger" ) @@ -161,7 +162,7 @@ func getMappedStatus(s e2bgrpcorchestratorinfo.ServiceInfoStatus) OrchestratorSt } func newClient(tracerProvider trace.TracerProvider, meterProvider metric.MeterProvider, host string) (*OrchestratorGRPCClient, error) { - conn, err := grpc.NewClient(host, + grpcOptions := []grpc.DialOption{ grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithStatsHandler( otelgrpc.NewClientHandler( @@ -169,7 +170,16 @@ func newClient(tracerProvider trace.TracerProvider, meterProvider metric.MeterPr otelgrpc.WithMeterProvider(meterProvider), ), ), - ) + } + + if testhacks.IsTesting() { + grpcOptions = append(grpcOptions, + grpc.WithUnaryInterceptor(testhacks.GRPCUnaryInterceptor), + grpc.WithStreamInterceptor(testhacks.GRPCStreamInterceptor), + ) + } + + conn, err := grpc.NewClient(host, grpcOptions...) if err != nil { return nil, fmt.Errorf("failed to create GRPC client: %w", err) } diff --git a/packages/client-proxy/internal/proxy/proxy.go b/packages/client-proxy/internal/proxy/proxy.go index 2b1afb4b0d..6265c8e1c3 100644 --- a/packages/client-proxy/internal/proxy/proxy.go +++ b/packages/client-proxy/internal/proxy/proxy.go @@ -15,6 +15,7 @@ import ( orchestratorspool "github.com/e2b-dev/infra/packages/proxy/internal/edge/pool" "github.com/e2b-dev/infra/packages/proxy/internal/edge/sandboxes" + "github.com/e2b-dev/infra/packages/proxy/internal/testhacks" l "github.com/e2b-dev/infra/packages/shared/pkg/logger" reverseproxy "github.com/e2b-dev/infra/packages/shared/pkg/proxy" "github.com/e2b-dev/infra/packages/shared/pkg/proxy/pool" @@ -109,6 +110,8 @@ func NewClientProxy(meterProvider metric.MeterProvider, serviceName string, port port, idleTimeout, func(r *http.Request) (*pool.Destination, error) { + r = testhacks.ProcessHTTPRequest(r) + sandboxId, port, err := reverseproxy.ParseHost(r.Host) if err != nil { return nil, err diff --git a/packages/client-proxy/internal/testhacks/context.go b/packages/client-proxy/internal/testhacks/context.go new file mode 100644 index 0000000000..cbcd876099 --- /dev/null +++ b/packages/client-proxy/internal/testhacks/context.go @@ -0,0 +1,14 @@ +package testhacks + +import "context" + +type testNameContextKey struct{} + +func addTestName(ctx context.Context, testName string) context.Context { + return context.WithValue(ctx, testNameContextKey{}, testName) +} + +func GetTestName(ctx context.Context) string { + val, _ := ctx.Value(testNameContextKey{}).(string) + return val +} diff --git a/packages/client-proxy/internal/testhacks/gin.go b/packages/client-proxy/internal/testhacks/gin.go new file mode 100644 index 0000000000..bb5e5c6e92 --- /dev/null +++ b/packages/client-proxy/internal/testhacks/gin.go @@ -0,0 +1,23 @@ +package testhacks + +import ( + "fmt" + + "github.com/gin-gonic/gin" +) + +func ProcessGinRequest(c *gin.Context) { + testName := c.GetHeader("x-test-name") + if testName == "" { + c.Next() + return + } + + ctx := addTestName(c.Request.Context(), testName) + c.Request = c.Request.WithContext(ctx) + fmt.Printf("====================== START client-proxy request for %s ========================\n", testName) + + c.Next() + + fmt.Printf("====================== FINISH client-proxy call for %s ========================\n", testName) +} diff --git a/packages/client-proxy/internal/testhacks/grpc.go b/packages/client-proxy/internal/testhacks/grpc.go new file mode 100644 index 0000000000..fbaab4a1cf --- /dev/null +++ b/packages/client-proxy/internal/testhacks/grpc.go @@ -0,0 +1,68 @@ +package testhacks + +import ( + "context" + "fmt" + + "google.golang.org/grpc" + "google.golang.org/grpc/metadata" +) + +func GRPCUnaryInterceptor(ctx context.Context, method string, req any, reply any, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error { + if testName := GetTestName(ctx); testName != "" { + ctx = metadata.AppendToOutgoingContext(ctx, "x-test-name", testName) + } + + return invoker(ctx, method, req, reply, cc, opts...) +} + +func GRPCStreamInterceptor(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, streamer grpc.Streamer, opts ...grpc.CallOption) (grpc.ClientStream, error) { + if testName := GetTestName(ctx); testName != "" { + ctx = metadata.AppendToOutgoingContext(ctx, "x-test-name", testName) + } + + return streamer(ctx, desc, cc, method, opts...) +} + +func getTestName(ctx context.Context) string { + md, ok := metadata.FromIncomingContext(ctx) + if !ok { + return "" + } + + testName := md.Get("x-test-name") + if len(testName) == 0 { + return "" + } + + return testName[0] +} + +func UnaryTestNamePrinter(ctx context.Context, req any, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp any, err error) { + testName := getTestName(ctx) + if testName != "" { + fmt.Printf("====================== START client-proxy unary for %s ========================\n", testName) + } + + resp, err = handler(ctx, req) + if testName != "" { + fmt.Printf("====================== FINISH client-proxy unary for %s ========================\n", testName) + } + + return resp, err +} + +func StreamingTestNamePrinter(srv any, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error { + testName := getTestName(ss.Context()) + if testName != "" { + fmt.Printf("====================== START client-proxy streaming for %s ========================\n", testName) + } + + err := handler(srv, ss) + + if testName != "" { + fmt.Printf("====================== FINISH client-proxy streaming for %s ========================\n", testName) + } + + return err +} diff --git a/packages/client-proxy/internal/testhacks/http.go b/packages/client-proxy/internal/testhacks/http.go new file mode 100644 index 0000000000..2cad59a815 --- /dev/null +++ b/packages/client-proxy/internal/testhacks/http.go @@ -0,0 +1,20 @@ +package testhacks + +import "net/http" + +func ProcessHTTPRequest(r *http.Request) *http.Request { + if !IsTesting() { + return r + } + + testName := r.Header.Get("X-Test-Name") + if testName == "" { + return r + } + + ctx := r.Context() + ctx = addTestName(ctx, testName) + r = r.WithContext(ctx) + + return r +} diff --git a/packages/client-proxy/internal/testhacks/switch.go b/packages/client-proxy/internal/testhacks/switch.go new file mode 100644 index 0000000000..1049410f2a --- /dev/null +++ b/packages/client-proxy/internal/testhacks/switch.go @@ -0,0 +1,7 @@ +package testhacks + +import "os" + +func IsTesting() bool { + return os.Getenv("CI") == "true" +} diff --git a/packages/client-proxy/main.go b/packages/client-proxy/main.go index 7ec5b025ac..e4fd8b9890 100644 --- a/packages/client-proxy/main.go +++ b/packages/client-proxy/main.go @@ -275,7 +275,7 @@ func run() int { proxyRunLogger := logger.With(zap.Int("proxy_port", proxyPort)) proxyRunLogger.Info("Http proxy starting") - err := trafficProxy.ListenAndServe() + err := trafficProxy.ListenAndServe(ctx) // Add different handling for the error switch { case errors.Is(err, http.ErrServerClosed): diff --git a/packages/envd/internal/port/forward.go b/packages/envd/internal/port/forward.go index 91219bbedd..f2e25f64c6 100644 --- a/packages/envd/internal/port/forward.go +++ b/packages/envd/internal/port/forward.go @@ -7,6 +7,7 @@ package port import ( + "context" "fmt" "net" "os/exec" @@ -64,7 +65,7 @@ func NewForwarder( } } -func (f *Forwarder) StartForwarding() { +func (f *Forwarder) StartForwarding(ctx context.Context) { if f.scannerSubscriber == nil { f.logger.Error().Msg("Cannot start forwarding because scanner subscriber is nil") @@ -110,7 +111,7 @@ func (f *Forwarder) StartForwarding() { family: familyToIPVersion(p.Family), } f.ports[key] = ptf - f.starPortForwarding(ptf) + f.startPortForwarding(ctx, ptf) } } @@ -125,11 +126,11 @@ func (f *Forwarder) StartForwarding() { } } -func (f *Forwarder) starPortForwarding(p *PortToForward) { +func (f *Forwarder) startPortForwarding(ctx context.Context, p *PortToForward) { // https://unix.stackexchange.com/questions/311492/redirect-application-listening-on-localhost-to-listening-on-external-interface // socat -d -d TCP4-LISTEN:4000,bind=169.254.0.21,fork TCP4:localhost:4000 // reuseaddr is used to fix the "Address already in use" error when restarting socat quickly. - cmd := exec.Command( + cmd := exec.CommandContext(ctx, "socat", "-d", "-d", "-d", fmt.Sprintf("TCP4-LISTEN:%v,bind=%s,reuseaddr,fork", p.port, f.sourceIP.To4()), fmt.Sprintf("TCP%d:localhost:%v", p.family, p.port), diff --git a/packages/envd/main.go b/packages/envd/main.go index d5e85b362e..ef58b275c0 100644 --- a/packages/envd/main.go +++ b/packages/envd/main.go @@ -199,7 +199,7 @@ func main() { portLogger := l.With().Str("logger", "port-forwarder").Logger() portForwarder := publicport.NewForwarder(&portLogger, portScanner) - go portForwarder.StartForwarding() + go portForwarder.StartForwarding(ctx) go portScanner.ScanAndBroadcast() diff --git a/packages/orchestrator/cmd/build-template/main.go b/packages/orchestrator/cmd/build-template/main.go index eb0c8b4047..3772fb1952 100644 --- a/packages/orchestrator/cmd/build-template/main.go +++ b/packages/orchestrator/cmd/build-template/main.go @@ -87,7 +87,7 @@ func buildTemplate( logger.Fatal("failed to create sandbox proxy", zap.Error(err)) } go func() { - err := sandboxProxy.Start() + err := sandboxProxy.Start(parentCtx) if err != nil && !errors.Is(err, http.ErrServerClosed) { logger.Error("failed to start sandbox proxy", zap.Error(err)) } diff --git a/packages/orchestrator/internal/grpcserver/server.go b/packages/orchestrator/internal/grpcserver/server.go index 66ea73194b..57a6fdeaa5 100644 --- a/packages/orchestrator/internal/grpcserver/server.go +++ b/packages/orchestrator/internal/grpcserver/server.go @@ -22,6 +22,7 @@ import ( e2bhealthcheck "github.com/e2b-dev/infra/packages/orchestrator/internal/healthcheck" "github.com/e2b-dev/infra/packages/orchestrator/internal/service" + "github.com/e2b-dev/infra/packages/orchestrator/internal/testhacks" e2bgrpc "github.com/e2b-dev/infra/packages/shared/pkg/grpc" "github.com/e2b-dev/infra/packages/shared/pkg/logger" ) @@ -52,6 +53,27 @@ func New(tracerProvider trace.TracerProvider, meterProvider metric.MeterProvider "/TemplateService/HealthStatus", "/InfoService/ServiceInfo", ) + + unaryInterceptors := []grpc.UnaryServerInterceptor{ + recovery.UnaryServerInterceptor(), + selector.UnaryServerInterceptor( + logging.UnaryServerInterceptor(logger.GRPCLogger(zap.L()), opts...), + ignoredLoggingRoutes, + ), + } + + streamingInterceptors := []grpc.StreamServerInterceptor{ + selector.StreamServerInterceptor( + logging.StreamServerInterceptor(logger.GRPCLogger(zap.L()), opts...), + ignoredLoggingRoutes, + ), + } + + if testhacks.IsTesting() { + unaryInterceptors = append(unaryInterceptors, testhacks.UnaryTestNamePrinter) + streamingInterceptors = append(streamingInterceptors, testhacks.StreamingTestNamePrinter) + } + srv := grpc.NewServer( grpc.KeepaliveEnforcementPolicy(keepalive.EnforcementPolicy{ MinTime: 5 * time.Second, // Minimum time between pings from client @@ -65,19 +87,8 @@ func New(tracerProvider trace.TracerProvider, meterProvider metric.MeterProvider otelgrpc.WithTracerProvider(tracerProvider), otelgrpc.WithMeterProvider(meterProvider), ))), - grpc.ChainUnaryInterceptor( - recovery.UnaryServerInterceptor(), - selector.UnaryServerInterceptor( - logging.UnaryServerInterceptor(logger.GRPCLogger(zap.L()), opts...), - ignoredLoggingRoutes, - ), - ), - grpc.ChainStreamInterceptor( - selector.StreamServerInterceptor( - logging.StreamServerInterceptor(logger.GRPCLogger(zap.L()), opts...), - ignoredLoggingRoutes, - ), - ), + grpc.ChainUnaryInterceptor(unaryInterceptors...), + grpc.ChainStreamInterceptor(streamingInterceptors...), ) grpcHealth := health.NewServer() diff --git a/packages/orchestrator/internal/proxy/proxy.go b/packages/orchestrator/internal/proxy/proxy.go index 6bea825aad..6e35731b15 100644 --- a/packages/orchestrator/internal/proxy/proxy.go +++ b/packages/orchestrator/internal/proxy/proxy.go @@ -101,8 +101,8 @@ func NewSandboxProxy(meterProvider metric.MeterProvider, port uint, sandboxes *s return &SandboxProxy{proxy}, nil } -func (p *SandboxProxy) Start() error { - return p.proxy.ListenAndServe() +func (p *SandboxProxy) Start(ctx context.Context) error { + return p.proxy.ListenAndServe(ctx) } func (p *SandboxProxy) Close(ctx context.Context) error { diff --git a/packages/orchestrator/internal/testhacks/config.go b/packages/orchestrator/internal/testhacks/config.go new file mode 100644 index 0000000000..1049410f2a --- /dev/null +++ b/packages/orchestrator/internal/testhacks/config.go @@ -0,0 +1,7 @@ +package testhacks + +import "os" + +func IsTesting() bool { + return os.Getenv("CI") == "true" +} diff --git a/packages/orchestrator/internal/testhacks/grpc.go b/packages/orchestrator/internal/testhacks/grpc.go new file mode 100644 index 0000000000..4c2928bff0 --- /dev/null +++ b/packages/orchestrator/internal/testhacks/grpc.go @@ -0,0 +1,52 @@ +package testhacks + +import ( + "context" + "fmt" + + "google.golang.org/grpc" + "google.golang.org/grpc/metadata" +) + +func getTestName(ctx context.Context) string { + md, ok := metadata.FromIncomingContext(ctx) + if !ok { + return "" + } + + testName := md.Get("x-test-name") + if len(testName) == 0 { + return "" + } + + return testName[0] +} + +func UnaryTestNamePrinter(ctx context.Context, req any, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp any, err error) { + testName := getTestName(ctx) + if testName != "" { + fmt.Printf("====================== START orchestrator unary for %s ========================\n", testName) + } + + resp, err = handler(ctx, req) + if testName != "" { + fmt.Printf("====================== FINISH orchestrator unary for %s ========================\n", testName) + } + + return resp, err +} + +func StreamingTestNamePrinter(srv any, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error { + testName := getTestName(ss.Context()) + if testName != "" { + fmt.Printf("====================== START orchestrator streaming for %s ========================\n", testName) + } + + err := handler(srv, ss) + + if testName != "" { + fmt.Printf("====================== FINISH orchestrator streaming for %s ========================\n", testName) + } + + return err +} diff --git a/packages/orchestrator/main.go b/packages/orchestrator/main.go index 2c84016db5..241485ffa4 100644 --- a/packages/orchestrator/main.go +++ b/packages/orchestrator/main.go @@ -439,7 +439,7 @@ func run(port, proxyPort, hyperloopPort uint) (success bool) { g.Go(func() error { zap.L().Info("Starting session proxy") - proxyErr := sandboxProxy.Start() + proxyErr := sandboxProxy.Start(ctx) if proxyErr != nil && !errors.Is(proxyErr, http.ErrServerClosed) { proxyErr = fmt.Errorf("proxy server: %w", proxyErr) zap.L().Error("error starting proxy server", zap.Error(proxyErr)) diff --git a/packages/shared/pkg/proxy/proxy.go b/packages/shared/pkg/proxy/proxy.go index 98e236f236..6e39fc8913 100644 --- a/packages/shared/pkg/proxy/proxy.go +++ b/packages/shared/pkg/proxy/proxy.go @@ -1,6 +1,7 @@ package proxy import ( + "context" "fmt" "net" "net/http" @@ -68,8 +69,9 @@ func (p *Proxy) RemoveFromPool(connectionKey string) { p.pool.Close(connectionKey) } -func (p *Proxy) ListenAndServe() error { - l, err := net.Listen("tcp", p.Addr) +func (p *Proxy) ListenAndServe(ctx context.Context) error { + var lisCfg net.ListenConfig + l, err := lisCfg.Listen(ctx, "tcp", p.Addr) if err != nil { return err } diff --git a/tests/integration/internal/main_test.go b/tests/integration/internal/main_test.go index 41c60fc3d8..f2dd0640de 100644 --- a/tests/integration/internal/main_test.go +++ b/tests/integration/internal/main_test.go @@ -25,7 +25,7 @@ func TestCacheTemplate(t *testing.T) { ctx, cancel := context.WithCancel(t.Context()) defer cancel() - c := setup.GetAPIClient() + c := setup.GetAPIClient(t) sbxTimeout := int32(60) sbx, err := c.PostSandboxesWithResponse(ctx, api.NewSandbox{ TemplateID: setup.SandboxTemplateID, diff --git a/tests/integration/internal/setup/api_client.go b/tests/integration/internal/setup/api_client.go index 00f280620a..245049e1a9 100644 --- a/tests/integration/internal/setup/api_client.go +++ b/tests/integration/internal/setup/api_client.go @@ -10,9 +10,32 @@ import ( "github.com/e2b-dev/infra/tests/integration/internal/api" ) -func GetAPIClient() *api.ClientWithResponses { +type addHeaders struct { + headers map[string]string + rt http.RoundTripper +} + +func (a addHeaders) RoundTrip(request *http.Request) (*http.Response, error) { + for key, val := range a.headers { + request.Header.Add(key, val) + } + + return a.rt.RoundTrip(request) +} + +var _ http.RoundTripper = (*addHeaders)(nil) + +func GetAPIClient(tb testing.TB) *api.ClientWithResponses { + tb.Helper() + hc := http.Client{ Timeout: apiTimeout, + Transport: addHeaders{ + headers: map[string]string{ + "x-test-name": tb.Name(), + }, + rt: http.DefaultTransport, + }, } c, err := api.NewClientWithResponses(APIServerURL, api.WithHTTPClient(&hc)) diff --git a/tests/integration/internal/setup/orchestrator_client.go b/tests/integration/internal/setup/orchestrator_client.go index bfd0f10c7e..8850d8e838 100644 --- a/tests/integration/internal/setup/orchestrator_client.go +++ b/tests/integration/internal/setup/orchestrator_client.go @@ -5,16 +5,22 @@ import ( "fmt" "testing" + "github.com/stretchr/testify/assert" "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" "github.com/e2b-dev/infra/packages/shared/pkg/grpc/orchestrator" + "github.com/e2b-dev/infra/tests/integration/internal/testhacks" ) func GetOrchestratorClient(tb testing.TB, ctx context.Context) orchestrator.SandboxServiceClient { tb.Helper() - conn, err := grpc.NewClient(OrchestratorHost, grpc.WithTransportCredentials(insecure.NewCredentials())) + conn, err := grpc.NewClient(OrchestratorHost, + grpc.WithTransportCredentials(insecure.NewCredentials()), + grpc.WithUnaryInterceptor(testhacks.GRPCUnaryInterceptor(tb)), + grpc.WithStreamInterceptor(testhacks.GRPCStreamInterceptor(tb)), + ) if err != nil { tb.Fatal(fmt.Errorf("failed to establish GRPC connection: %w", err)) @@ -23,7 +29,8 @@ func GetOrchestratorClient(tb testing.TB, ctx context.Context) orchestrator.Sand go func() { <-ctx.Done() - conn.Close() + err = conn.Close() + assert.NoError(tb, err) }() return orchestrator.NewSandboxServiceClient(conn) diff --git a/tests/integration/internal/testhacks/config.go b/tests/integration/internal/testhacks/config.go new file mode 100644 index 0000000000..1049410f2a --- /dev/null +++ b/tests/integration/internal/testhacks/config.go @@ -0,0 +1,7 @@ +package testhacks + +import "os" + +func IsTesting() bool { + return os.Getenv("CI") == "true" +} diff --git a/tests/integration/internal/testhacks/interceptors.go b/tests/integration/internal/testhacks/interceptors.go new file mode 100644 index 0000000000..c7bdb03faf --- /dev/null +++ b/tests/integration/internal/testhacks/interceptors.go @@ -0,0 +1,27 @@ +package testhacks + +import ( + "context" + "testing" + + "google.golang.org/grpc" + "google.golang.org/grpc/metadata" +) + +func GRPCUnaryInterceptor(tb testing.TB) grpc.UnaryClientInterceptor { + tb.Helper() + + return func(ctx context.Context, method string, req, reply any, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error { + ctx = metadata.AppendToOutgoingContext(ctx, "x-test-name", tb.Name()) + return invoker(ctx, method, req, reply, cc, opts...) + } +} + +func GRPCStreamInterceptor(tb testing.TB) grpc.StreamClientInterceptor { + tb.Helper() + + return func(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, streamer grpc.Streamer, opts ...grpc.CallOption) (grpc.ClientStream, error) { + ctx = metadata.AppendToOutgoingContext(ctx, "x-test-name", tb.Name()) + return streamer(ctx, desc, cc, method, opts...) + } +} diff --git a/tests/integration/internal/tests/api/access_token_test.go b/tests/integration/internal/tests/api/access_token_test.go index 882a35813e..9e395b051c 100644 --- a/tests/integration/internal/tests/api/access_token_test.go +++ b/tests/integration/internal/tests/api/access_token_test.go @@ -18,7 +18,7 @@ func TestCreateAccessToken(t *testing.T) { ctx, cancel := context.WithCancel(t.Context()) defer cancel() - c := setup.GetAPIClient() + c := setup.GetAPIClient(t) resp, err := c.PostAccessTokensWithResponse(ctx, api.PostAccessTokensJSONRequestBody{ Name: "test", @@ -37,7 +37,7 @@ func TestDeleteAccessToken(t *testing.T) { ctx, cancel := context.WithCancel(t.Context()) defer cancel() - c := setup.GetAPIClient() + c := setup.GetAPIClient(t) t.Run("succeeds", func(t *testing.T) { respC, err := c.PostAccessTokensWithResponse(ctx, api.PostAccessTokensJSONRequestBody{ diff --git a/tests/integration/internal/tests/api/apikey_test.go b/tests/integration/internal/tests/api/apikey_test.go index a0fd1883ab..0346cecfe4 100644 --- a/tests/integration/internal/tests/api/apikey_test.go +++ b/tests/integration/internal/tests/api/apikey_test.go @@ -22,7 +22,7 @@ func TestCreateAPIKey(t *testing.T) { ctx, cancel := context.WithCancel(t.Context()) defer cancel() - c := setup.GetAPIClient() + c := setup.GetAPIClient(t) // Create the API key resp, err := c.PostApiKeysWithResponse(ctx, api.PostApiKeysJSONRequestBody{ @@ -40,7 +40,7 @@ func TestCreateAPIKeyForeignTeam(t *testing.T) { ctx := t.Context() db := setup.GetTestDBClient(t) - c := setup.GetAPIClient() + c := setup.GetAPIClient(t) // Create first team and API key foreignTeamID := utils.CreateTeam(t, c, db, "test-team-apikey-foreign") @@ -57,7 +57,7 @@ func TestCreateAPIKeyForeignTeamWithCache(t *testing.T) { ctx := t.Context() db := setup.GetTestDBClient(t) - c := setup.GetAPIClient() + c := setup.GetAPIClient(t) // Create first team foreignUserID := utils.CreateUser(t, db) @@ -78,7 +78,7 @@ func TestDeleteAPIKey(t *testing.T) { ctx, cancel := context.WithCancel(t.Context()) defer cancel() - c := setup.GetAPIClient() + c := setup.GetAPIClient(t) t.Run("succeeds", func(t *testing.T) { // Create the API key @@ -109,7 +109,7 @@ func TestDeleteAPIKey(t *testing.T) { t.Run("cant delete other teams api key", func(t *testing.T) { ctx := t.Context() db := setup.GetTestDBClient(t) - c := setup.GetAPIClient() + c := setup.GetAPIClient(t) // Create first team and API key teamID1 := utils.CreateTeamWithUser(t, c, db, "test-team-apikey-delete-1", setup.UserID) @@ -169,7 +169,7 @@ func TestListAPIKeys(t *testing.T) { ctx, cancel := context.WithCancel(t.Context()) defer cancel() - c := setup.GetAPIClient() + c := setup.GetAPIClient(t) resp, err := c.GetApiKeysWithResponse(ctx, setup.WithSupabaseToken(t), setup.WithSupabaseTeam(t)) if err != nil { @@ -184,7 +184,7 @@ func TestPatchAPIKey(t *testing.T) { ctx, cancel := context.WithCancel(t.Context()) defer cancel() - c := setup.GetAPIClient() + c := setup.GetAPIClient(t) // Create the first API key respC, err := c.PostApiKeysWithResponse(ctx, api.PostApiKeysJSONRequestBody{ @@ -245,7 +245,7 @@ func TestPatchAPIKey(t *testing.T) { t.Run("cant patch other teams api keys", func(t *testing.T) { ctx := t.Context() db := setup.GetTestDBClient(t) - c := setup.GetAPIClient() + c := setup.GetAPIClient(t) // Create first team and API key teamID1 := utils.CreateTeamWithUser(t, c, db, "test-team-apikey-patch-1", setup.UserID) @@ -301,7 +301,7 @@ func TestPatchAPIKey(t *testing.T) { } func TestAPIKeyLastUsedUpdated(t *testing.T) { - c := setup.GetAPIClient() + c := setup.GetAPIClient(t) // The last used is updated only once a minute expectedLastUsed := time.Now().Add(-2 * time.Minute) diff --git a/tests/integration/internal/tests/api/auth/supabase_test.go b/tests/integration/internal/tests/api/auth/supabase_test.go index 01af217a45..ad66d863a7 100644 --- a/tests/integration/internal/tests/api/auth/supabase_test.go +++ b/tests/integration/internal/tests/api/auth/supabase_test.go @@ -19,7 +19,7 @@ func createSandbox(t *testing.T, reqEditors ...api.RequestEditorFn) int { ctx, cancel := context.WithCancel(t.Context()) defer cancel() - c := setup.GetAPIClient() + c := setup.GetAPIClient(t) sbxTimeout := int32(10) resp, err := c.PostSandboxesWithResponse(ctx, api.NewSandbox{ @@ -74,7 +74,7 @@ func TestSandboxCreateWithSupabaseToken(t *testing.T) { func TestSandboxCreateWithForeignTeamAccess(t *testing.T) { db := setup.GetTestDBClient(t) - c := setup.GetAPIClient() + c := setup.GetAPIClient(t) userID2 := utils.CreateUser(t, db) teamID2 := utils.CreateTeamWithUser(t, c, db, "test-team-2", userID2.String()) diff --git a/tests/integration/internal/tests/api/health_test.go b/tests/integration/internal/tests/api/health_test.go index dd967de613..a7622335f3 100644 --- a/tests/integration/internal/tests/api/health_test.go +++ b/tests/integration/internal/tests/api/health_test.go @@ -14,7 +14,7 @@ func TestHealth(t *testing.T) { ctx, cancel := context.WithCancel(t.Context()) defer cancel() - c := setup.GetAPIClient() + c := setup.GetAPIClient(t) resp, err := c.GetHealthWithResponse(ctx) if err != nil { diff --git a/tests/integration/internal/tests/api/metrics/sandbox_list_metrics_test.go b/tests/integration/internal/tests/api/metrics/sandbox_list_metrics_test.go index e0477f7cc6..967e8893d2 100644 --- a/tests/integration/internal/tests/api/metrics/sandbox_list_metrics_test.go +++ b/tests/integration/internal/tests/api/metrics/sandbox_list_metrics_test.go @@ -14,7 +14,7 @@ import ( ) func TestSandboxListMetrics(t *testing.T) { - c := setup.GetAPIClient() + c := setup.GetAPIClient(t) // Create a sandbox for testing sbx1 := utils.SetupSandboxWithCleanup(t, c) diff --git a/tests/integration/internal/tests/api/metrics/sandbox_metrics_test.go b/tests/integration/internal/tests/api/metrics/sandbox_metrics_test.go index 6358d340f1..33d8013da5 100644 --- a/tests/integration/internal/tests/api/metrics/sandbox_metrics_test.go +++ b/tests/integration/internal/tests/api/metrics/sandbox_metrics_test.go @@ -13,7 +13,7 @@ import ( ) func TestSandboxMetrics(t *testing.T) { - c := setup.GetAPIClient() + c := setup.GetAPIClient(t) // Create a sandbox for testing sbx := utils.SetupSandboxWithCleanup(t, c) diff --git a/tests/integration/internal/tests/api/metrics/team_metrics_max_test.go b/tests/integration/internal/tests/api/metrics/team_metrics_max_test.go index 4e94b1703e..2d1fcf9265 100644 --- a/tests/integration/internal/tests/api/metrics/team_metrics_max_test.go +++ b/tests/integration/internal/tests/api/metrics/team_metrics_max_test.go @@ -13,7 +13,7 @@ import ( ) func TestTeamMetricsMaxConcurrentSandboxes(t *testing.T) { - c := setup.GetAPIClient() + c := setup.GetAPIClient(t) // Create multiple sandboxes to generate team metrics utils.SetupSandboxWithCleanup(t, c) @@ -52,7 +52,7 @@ func TestTeamMetricsMaxConcurrentSandboxes(t *testing.T) { } func TestTeamMetricsMaxSandboxStartRate(t *testing.T) { - c := setup.GetAPIClient() + c := setup.GetAPIClient(t) // Create sandboxes to generate start rate metrics utils.SetupSandboxWithCleanup(t, c) @@ -91,7 +91,7 @@ func TestTeamMetricsMaxSandboxStartRate(t *testing.T) { } func TestTeamMetricsMaxEmpty(t *testing.T) { - c := setup.GetAPIClient() + c := setup.GetAPIClient(t) db := setup.GetTestDBClient(t) diff --git a/tests/integration/internal/tests/api/metrics/team_metrics_test.go b/tests/integration/internal/tests/api/metrics/team_metrics_test.go index aaf8077e88..b865aab738 100644 --- a/tests/integration/internal/tests/api/metrics/team_metrics_test.go +++ b/tests/integration/internal/tests/api/metrics/team_metrics_test.go @@ -14,7 +14,7 @@ import ( ) func TestTeamMetrics(t *testing.T) { - c := setup.GetAPIClient() + c := setup.GetAPIClient(t) // Create multiple sandboxes to generate team metrics utils.SetupSandboxWithCleanup(t, c) @@ -61,7 +61,7 @@ func TestTeamMetrics(t *testing.T) { } func TestTeamMetricsWithTimeRange(t *testing.T) { - c := setup.GetAPIClient() + c := setup.GetAPIClient(t) // Create a sandbox to generate metrics utils.SetupSandboxWithCleanup(t, c) @@ -102,7 +102,7 @@ func TestTeamMetricsWithTimeRange(t *testing.T) { } func TestTeamMetricsEmpty(t *testing.T) { - c := setup.GetAPIClient() + c := setup.GetAPIClient(t) db := setup.GetTestDBClient(t) teamID := utils.CreateTeamWithUser(t, c, db, "test-team-no-metrics", setup.UserID) @@ -122,7 +122,7 @@ func TestTeamMetricsEmpty(t *testing.T) { } func TestTeamMetricsInvalidDate(t *testing.T) { - c := setup.GetAPIClient() + c := setup.GetAPIClient(t) // Test getting metrics for a time range where no sandboxes existed now := time.Now().Unix() diff --git a/tests/integration/internal/tests/api/sandboxes/sandbox_auto_pause_test.go b/tests/integration/internal/tests/api/sandboxes/sandbox_auto_pause_test.go index 9a9b650154..ed7ac71eaa 100644 --- a/tests/integration/internal/tests/api/sandboxes/sandbox_auto_pause_test.go +++ b/tests/integration/internal/tests/api/sandboxes/sandbox_auto_pause_test.go @@ -15,7 +15,7 @@ import ( ) func TestSandboxAutoPausePauseResume(t *testing.T) { - c := setup.GetAPIClient() + c := setup.GetAPIClient(t) sbx := utils.SetupSandboxWithCleanup(t, c, utils.WithAutoPause(true)) sbxId := sbx.SandboxID @@ -52,7 +52,7 @@ func TestSandboxAutoPausePauseResume(t *testing.T) { } func TestSandboxAutoPauseResumePersisted(t *testing.T) { - c := setup.GetAPIClient() + c := setup.GetAPIClient(t) // Create a sandbox with auto-pause disabled sbx := utils.SetupSandboxWithCleanup(t, c, utils.WithAutoPause(true)) @@ -136,7 +136,7 @@ func TestSandboxAutoPauseResumePersisted(t *testing.T) { } func TestSandboxNotAutoPause(t *testing.T) { - c := setup.GetAPIClient() + c := setup.GetAPIClient(t) // Create a sandbox with auto-pause disabled sbx := utils.SetupSandboxWithCleanup(t, c, utils.WithAutoPause(false)) diff --git a/tests/integration/internal/tests/api/sandboxes/sandbox_detail_test.go b/tests/integration/internal/tests/api/sandboxes/sandbox_detail_test.go index 9f9f3b3b10..a2d7fbcdd9 100644 --- a/tests/integration/internal/tests/api/sandboxes/sandbox_detail_test.go +++ b/tests/integration/internal/tests/api/sandboxes/sandbox_detail_test.go @@ -16,7 +16,7 @@ import ( ) func TestSandboxDetailRunning(t *testing.T) { - c := setup.GetAPIClient() + c := setup.GetAPIClient(t) // Create a sandbox for testing sbx := utils.SetupSandboxWithCleanup(t, c) @@ -32,7 +32,7 @@ func TestSandboxDetailRunning(t *testing.T) { } func TestSandboxDetailPaused(t *testing.T) { - c := setup.GetAPIClient() + c := setup.GetAPIClient(t) sbx := utils.SetupSandboxWithCleanup(t, c) sandboxID := sbx.SandboxID @@ -47,7 +47,7 @@ func TestSandboxDetailPaused(t *testing.T) { } func TestSandboxDetailPausingSandbox(t *testing.T) { - c := setup.GetAPIClient() + c := setup.GetAPIClient(t) sbx := utils.SetupSandboxWithCleanup(t, c) sandboxID := sbx.SandboxID diff --git a/tests/integration/internal/tests/api/sandboxes/sandbox_internet_test.go b/tests/integration/internal/tests/api/sandboxes/sandbox_internet_test.go index 97af51b10a..a3f4c1d13f 100644 --- a/tests/integration/internal/tests/api/sandboxes/sandbox_internet_test.go +++ b/tests/integration/internal/tests/api/sandboxes/sandbox_internet_test.go @@ -15,7 +15,7 @@ func TestInternetAccess(t *testing.T) { ctx := t.Context() sbxTimeout := int32(30) - client := setup.GetAPIClient() + client := setup.GetAPIClient(t) testCases := []struct { name string @@ -59,7 +59,7 @@ func TestInternetAccessResumedSbx(t *testing.T) { ctx := t.Context() sbxTimeout := int32(30) - client := setup.GetAPIClient() + client := setup.GetAPIClient(t) testCases := []struct { name string diff --git a/tests/integration/internal/tests/api/sandboxes/sandbox_kill_test.go b/tests/integration/internal/tests/api/sandboxes/sandbox_kill_test.go index 9341190b59..881fcac499 100644 --- a/tests/integration/internal/tests/api/sandboxes/sandbox_kill_test.go +++ b/tests/integration/internal/tests/api/sandboxes/sandbox_kill_test.go @@ -12,7 +12,7 @@ import ( ) func TestSandboxKill(t *testing.T) { - c := setup.GetAPIClient() + c := setup.GetAPIClient(t) t.Run("kill a non-existing sandbox", func(t *testing.T) { killSandboxResponse, err := c.DeleteSandboxesSandboxIDWithResponse(t.Context(), "non-existing", setup.WithAPIKey()) diff --git a/tests/integration/internal/tests/api/sandboxes/sandbox_list_test.go b/tests/integration/internal/tests/api/sandboxes/sandbox_list_test.go index db502e58f6..5b79af9e49 100644 --- a/tests/integration/internal/tests/api/sandboxes/sandbox_list_test.go +++ b/tests/integration/internal/tests/api/sandboxes/sandbox_list_test.go @@ -28,7 +28,7 @@ func pauseSandbox(t *testing.T, c *api.ClientWithResponses, sandboxID string) { } func TestSandboxList(t *testing.T) { - c := setup.GetAPIClient() + c := setup.GetAPIClient(t) // Create a sandbox for testing sbx := utils.SetupSandboxWithCleanup(t, c) @@ -52,7 +52,7 @@ func TestSandboxList(t *testing.T) { } func TestSandboxListWithFilter(t *testing.T) { - c := setup.GetAPIClient() + c := setup.GetAPIClient(t) // standard sandbox _ = utils.SetupSandboxWithCleanup(t, c) @@ -75,7 +75,7 @@ func TestSandboxListWithFilter(t *testing.T) { } func TestSandboxListRunning(t *testing.T) { - c := setup.GetAPIClient() + c := setup.GetAPIClient(t) uniqueString := id.Generate() metadataString := fmt.Sprintf("sandboxType=%s", uniqueString) @@ -104,7 +104,7 @@ func TestSandboxListRunning(t *testing.T) { } func TestSandboxListRunning_NoMetadata(t *testing.T) { - c := setup.GetAPIClient() + c := setup.GetAPIClient(t) sbx := utils.SetupSandboxWithCleanup(t, c, utils.WithoutAnyMetadata()) sandboxID := sbx.SandboxID @@ -122,7 +122,7 @@ func TestSandboxListRunning_NoMetadata(t *testing.T) { } func TestSandboxListPaused(t *testing.T) { - c := setup.GetAPIClient() + c := setup.GetAPIClient(t) metadataKey := "uniqueIdentifier" metadataValue := id.Generate() @@ -155,7 +155,7 @@ func TestSandboxListPaused(t *testing.T) { } func TestSandboxListPausing(t *testing.T) { - c := setup.GetAPIClient() + c := setup.GetAPIClient(t) metadataKey := "uniqueIdentifier" metadataValue := id.Generate() @@ -209,7 +209,7 @@ func TestSandboxListPausing(t *testing.T) { } func TestSandboxListPaused_NoMetadata(t *testing.T) { - c := setup.GetAPIClient() + c := setup.GetAPIClient(t) sbx := utils.SetupSandboxWithCleanup(t, c, utils.WithoutAnyMetadata()) sandboxID := sbx.SandboxID @@ -230,7 +230,7 @@ func TestSandboxListPaused_NoMetadata(t *testing.T) { } func TestSandboxListPaginationRunning(t *testing.T) { - c := setup.GetAPIClient() + c := setup.GetAPIClient(t) metadataKey := "uniqueIdentifier" metadataValue := id.Generate() @@ -300,7 +300,7 @@ func TestSandboxListPaginationRunning(t *testing.T) { } func TestSandboxListPaginationRunningLargerLimit(t *testing.T) { - c := setup.GetAPIClient() + c := setup.GetAPIClient(t) metadataKey := "uniqueIdentifier" metadataValue := id.Generate() @@ -365,7 +365,7 @@ func TestSandboxListPaginationRunningLargerLimit(t *testing.T) { } func TestSandboxListPaginationPaused(t *testing.T) { - c := setup.GetAPIClient() + c := setup.GetAPIClient(t) metadataKey := "uniqueIdentifier" metadataValue := id.Generate() @@ -414,7 +414,7 @@ func TestSandboxListPaginationPaused(t *testing.T) { } func TestSandboxListPaginationRunningAndPaused(t *testing.T) { - c := setup.GetAPIClient() + c := setup.GetAPIClient(t) metadataKey := "uniqueIdentifier" metadataValue := id.Generate() @@ -465,7 +465,7 @@ func TestSandboxListPaginationRunningAndPaused(t *testing.T) { // legacy tests func TestSandboxListRunningV1(t *testing.T) { - c := setup.GetAPIClient() + c := setup.GetAPIClient(t) metadataKey := "uniqueIdentifier" metadataValue := id.Generate() @@ -494,7 +494,7 @@ func TestSandboxListRunningV1(t *testing.T) { } func TestSandboxListWithFilterV1(t *testing.T) { - c := setup.GetAPIClient() + c := setup.GetAPIClient(t) metadataKey := "uniqueIdentifier" metadataValue := id.Generate() @@ -513,7 +513,7 @@ func TestSandboxListWithFilterV1(t *testing.T) { } func TestSandboxListSortedV1(t *testing.T) { - c := setup.GetAPIClient() + c := setup.GetAPIClient(t) // Create three sandboxes sbx1 := utils.SetupSandboxWithCleanup(t, c) diff --git a/tests/integration/internal/tests/api/sandboxes/sandbox_pause_test.go b/tests/integration/internal/tests/api/sandboxes/sandbox_pause_test.go index 6a9822148b..a618cf7653 100644 --- a/tests/integration/internal/tests/api/sandboxes/sandbox_pause_test.go +++ b/tests/integration/internal/tests/api/sandboxes/sandbox_pause_test.go @@ -14,7 +14,7 @@ import ( ) func TestSandboxPause(t *testing.T) { - c := setup.GetAPIClient() + c := setup.GetAPIClient(t) t.Run("regular pause", func(t *testing.T) { // Create a sandbox with auto-pause disabled diff --git a/tests/integration/internal/tests/api/sandboxes/sandbox_resume_test.go b/tests/integration/internal/tests/api/sandboxes/sandbox_resume_test.go index e2ae6492f5..af73e7291f 100644 --- a/tests/integration/internal/tests/api/sandboxes/sandbox_resume_test.go +++ b/tests/integration/internal/tests/api/sandboxes/sandbox_resume_test.go @@ -15,7 +15,7 @@ import ( ) func TestSandboxResume(t *testing.T) { - c := setup.GetAPIClient() + c := setup.GetAPIClient(t) t.Run("regular resume", func(t *testing.T) { // Create a sandbox with auto-pause disabled @@ -93,7 +93,7 @@ func TestSandboxResume(t *testing.T) { }) t.Run("resume killed sandbox", func(t *testing.T) { - c := setup.GetAPIClient() + c := setup.GetAPIClient(t) // Create a sandbox with auto-pause disabled sbx := utils.SetupSandboxWithCleanup(t, c, utils.WithAutoPause(true)) diff --git a/tests/integration/internal/tests/api/sandboxes/sandbox_secure_test.go b/tests/integration/internal/tests/api/sandboxes/sandbox_secure_test.go index 6ef88136c1..d8efd90902 100644 --- a/tests/integration/internal/tests/api/sandboxes/sandbox_secure_test.go +++ b/tests/integration/internal/tests/api/sandboxes/sandbox_secure_test.go @@ -17,7 +17,7 @@ func TestCreateSandboxWithSecuredEnvd(t *testing.T) { ctx, cancel := context.WithCancel(t.Context()) defer cancel() - c := setup.GetAPIClient() + c := setup.GetAPIClient(t) sbxTimeout := int32(60) sbxSecure := true diff --git a/tests/integration/internal/tests/api/sandboxes/sandbox_test.go b/tests/integration/internal/tests/api/sandboxes/sandbox_test.go index 2970333acd..7822e87f8f 100644 --- a/tests/integration/internal/tests/api/sandboxes/sandbox_test.go +++ b/tests/integration/internal/tests/api/sandboxes/sandbox_test.go @@ -17,7 +17,7 @@ func TestSandboxCreate(t *testing.T) { ctx, cancel := context.WithCancel(t.Context()) defer cancel() - c := setup.GetAPIClient() + c := setup.GetAPIClient(t) sbxTimeout := int32(60) resp, err := c.PostSandboxesWithResponse(ctx, api.NewSandbox{ @@ -43,7 +43,7 @@ func TestSandboxResumeUnknownSandbox(t *testing.T) { ctx, cancel := context.WithCancel(t.Context()) defer cancel() - c := setup.GetAPIClient() + c := setup.GetAPIClient(t) sbxCreate, err := c.PostSandboxesWithResponse(ctx, api.NewSandbox{TemplateID: setup.SandboxTemplateID}, setup.WithAPIKey()) require.NoError(t, err) @@ -68,7 +68,7 @@ func TestSandboxResumeWithSecuredEnvd(t *testing.T) { ctx, cancel := context.WithCancel(t.Context()) defer cancel() - c := setup.GetAPIClient() + c := setup.GetAPIClient(t) sbxSecure := true sbxCreate, err := c.PostSandboxesWithResponse(ctx, api.NewSandbox{TemplateID: setup.SandboxTemplateID, Secure: &sbxSecure}, setup.WithAPIKey()) @@ -100,7 +100,7 @@ func TestSandboxPauseNonFound(t *testing.T) { ctx, cancel := context.WithCancel(t.Context()) defer cancel() - c := setup.GetAPIClient() + c := setup.GetAPIClient(t) r, err := c.PostSandboxesSandboxIDPauseWithResponse(ctx, "not-found", setup.WithAPIKey()) require.NoError(t, err) diff --git a/tests/integration/internal/tests/api/templates/build_template_test.go b/tests/integration/internal/tests/api/templates/build_template_test.go index c79e734a6f..afe7f10981 100644 --- a/tests/integration/internal/tests/api/templates/build_template_test.go +++ b/tests/integration/internal/tests/api/templates/build_template_test.go @@ -35,7 +35,7 @@ func buildTemplate( ctx, cancel := context.WithTimeout(tb.Context(), BuildTimeout) defer cancel() - c := setup.GetAPIClient() + c := setup.GetAPIClient(tb) // Request build resp, err := c.PostV2TemplatesWithResponse(ctx, api.TemplateBuildRequestV2{ diff --git a/tests/integration/internal/tests/api/templates/delete_template_test.go b/tests/integration/internal/tests/api/templates/delete_template_test.go index 1ab03fc51b..0c15388010 100644 --- a/tests/integration/internal/tests/api/templates/delete_template_test.go +++ b/tests/integration/internal/tests/api/templates/delete_template_test.go @@ -28,7 +28,7 @@ func TestDeleteTemplate(t *testing.T) { require.True(t, res) - c := setup.GetAPIClient() + c := setup.GetAPIClient(t) deleteRes, err := c.DeleteTemplatesTemplateIDWithResponse( t.Context(), alias, diff --git a/tests/integration/internal/tests/api/templates/request_build_test.go b/tests/integration/internal/tests/api/templates/request_build_test.go index 95525c871a..28bee4437b 100644 --- a/tests/integration/internal/tests/api/templates/request_build_test.go +++ b/tests/integration/internal/tests/api/templates/request_build_test.go @@ -14,7 +14,7 @@ import ( ) func TestRequestTemplateBuild(t *testing.T) { - c := setup.GetAPIClient() + c := setup.GetAPIClient(t) resp, err := c.PostTemplatesWithResponse(t.Context(), api.TemplateBuildRequest{ CpuCount: utils.ToPtr[int32](2), @@ -25,7 +25,7 @@ func TestRequestTemplateBuild(t *testing.T) { } func TestRequestTemplateTooLowCPU(t *testing.T) { - c := setup.GetAPIClient() + c := setup.GetAPIClient(t) resp, err := c.PostTemplatesWithResponse(t.Context(), api.TemplateBuildRequest{ CpuCount: utils.ToPtr[int32](0), @@ -37,7 +37,7 @@ func TestRequestTemplateTooLowCPU(t *testing.T) { } func TestRequestTemplateTooLowRAM(t *testing.T) { - c := setup.GetAPIClient() + c := setup.GetAPIClient(t) resp, err := c.PostTemplatesWithResponse(t.Context(), api.TemplateBuildRequest{ CpuCount: utils.ToPtr[int32](2), @@ -49,7 +49,7 @@ func TestRequestTemplateTooLowRAM(t *testing.T) { } func TestRequestTemplateTooHighCPU(t *testing.T) { - c := setup.GetAPIClient() + c := setup.GetAPIClient(t) resp, err := c.PostTemplatesWithResponse(t.Context(), api.TemplateBuildRequest{ CpuCount: utils.ToPtr[int32](1024), @@ -61,7 +61,7 @@ func TestRequestTemplateTooHighCPU(t *testing.T) { } func TestRequestTemplateTooHighMemory(t *testing.T) { - c := setup.GetAPIClient() + c := setup.GetAPIClient(t) resp, err := c.PostTemplatesWithResponse(t.Context(), api.TemplateBuildRequest{ CpuCount: utils.ToPtr[int32](2), @@ -73,7 +73,7 @@ func TestRequestTemplateTooHighMemory(t *testing.T) { } func TestRequestTemplateMemoryNonDivisibleBy2(t *testing.T) { - c := setup.GetAPIClient() + c := setup.GetAPIClient(t) resp, err := c.PostTemplatesWithResponse(t.Context(), api.TemplateBuildRequest{ CpuCount: utils.ToPtr[int32](2), diff --git a/tests/integration/internal/tests/envd/auth_test.go b/tests/integration/internal/tests/envd/auth_test.go index fcd2478754..5e68dacee5 100644 --- a/tests/integration/internal/tests/envd/auth_test.go +++ b/tests/integration/internal/tests/envd/auth_test.go @@ -25,7 +25,7 @@ func createSandbox(t *testing.T, sbxWithAuth bool, reqEditors ...api.RequestEdit ctx, cancel := context.WithCancel(t.Context()) defer cancel() - c := setup.GetAPIClient() + c := setup.GetAPIClient(t) sbxTimeout := int32(10) resp, err := c.PostSandboxesWithResponse(ctx, api.NewSandbox{ @@ -43,7 +43,7 @@ func createSandbox(t *testing.T, sbxWithAuth bool, reqEditors ...api.RequestEdit } if resp.JSON201 != nil { - utils.TeardownSandbox(t, setup.GetAPIClient(), resp.JSON201.SandboxID) + utils.TeardownSandbox(t, setup.GetAPIClient(t), resp.JSON201.SandboxID) } }) @@ -135,7 +135,7 @@ func TestAccessAuthorizedPathWithResumedSandboxWithValidAccessToken(t *testing.T // create a test file utils.UploadFile(t, ctx, sbxMeta, envdClient, filePath, fileContent) - c := setup.GetAPIClient() + c := setup.GetAPIClient(t) // stop sandbox _, err := c.PostSandboxesSandboxIDPauseWithResponse(ctx, sbxMeta.SandboxID, setup.WithAPIKey()) @@ -191,7 +191,7 @@ func TestAccessAuthorizedPathWithResumedSandboxWithoutAccessToken(t *testing.T) // create a test file utils.UploadFile(t, ctx, sbxMeta, envdClient, filePath, fileContent) - c := setup.GetAPIClient() + c := setup.GetAPIClient(t) // stop sandbox _, err := c.PostSandboxesSandboxIDPauseWithResponse(ctx, sbxMeta.SandboxID, setup.WithAPIKey()) diff --git a/tests/integration/internal/tests/envd/filesystem_test.go b/tests/integration/internal/tests/envd/filesystem_test.go index c02372c9a1..e3ceea3a0e 100644 --- a/tests/integration/internal/tests/envd/filesystem_test.go +++ b/tests/integration/internal/tests/envd/filesystem_test.go @@ -27,7 +27,7 @@ func TestListDir(t *testing.T) { ctx, cancel := context.WithCancel(t.Context()) defer cancel() - c := setup.GetAPIClient() + c := setup.GetAPIClient(t) sbx := utils.SetupSandboxWithCleanup(t, c) envdClient := setup.GetEnvdClient(t, ctx) @@ -106,7 +106,7 @@ func TestFilePermissions(t *testing.T) { ctx, cancel := context.WithCancel(t.Context()) defer cancel() - c := setup.GetAPIClient() + c := setup.GetAPIClient(t) sbx := utils.SetupSandboxWithCleanup(t, c) envdClient := setup.GetEnvdClient(t, ctx) @@ -147,7 +147,7 @@ func TestStat(t *testing.T) { ctx, cancel := context.WithCancel(t.Context()) defer cancel() - c := setup.GetAPIClient() + c := setup.GetAPIClient(t) sbx := utils.SetupSandboxWithCleanup(t, c) envdClient := setup.GetEnvdClient(t, ctx) @@ -189,7 +189,7 @@ func TestListDirFileEntry(t *testing.T) { ctx, cancel := context.WithCancel(t.Context()) defer cancel() - c := setup.GetAPIClient() + c := setup.GetAPIClient(t) sbx := utils.SetupSandboxWithCleanup(t, c) envdClient := setup.GetEnvdClient(t, ctx) @@ -235,7 +235,7 @@ func TestListDirEntry(t *testing.T) { ctx, cancel := context.WithCancel(t.Context()) defer cancel() - c := setup.GetAPIClient() + c := setup.GetAPIClient(t) sbx := utils.SetupSandboxWithCleanup(t, c) envdClient := setup.GetEnvdClient(t, ctx) @@ -278,7 +278,7 @@ func TestListDirMixedEntries(t *testing.T) { ctx, cancel := context.WithCancel(t.Context()) defer cancel() - c := setup.GetAPIClient() + c := setup.GetAPIClient(t) sbx := utils.SetupSandboxWithCleanup(t, c) envdClient := setup.GetEnvdClient(t, ctx) @@ -341,7 +341,7 @@ func TestRelativePath(t *testing.T) { ctx, cancel := context.WithCancel(t.Context()) defer cancel() - c := setup.GetAPIClient() + c := setup.GetAPIClient(t) sbx := utils.SetupSandboxWithCleanup(t, c) envdClient := setup.GetEnvdClient(t, ctx) diff --git a/tests/integration/internal/tests/envd/hyperloop_test.go b/tests/integration/internal/tests/envd/hyperloop_test.go index 1545ad356c..9c88ad8b55 100644 --- a/tests/integration/internal/tests/envd/hyperloop_test.go +++ b/tests/integration/internal/tests/envd/hyperloop_test.go @@ -18,7 +18,7 @@ func TestAccessingHyperloopServerViaIP(t *testing.T) { ctx, cancel := context.WithCancel(t.Context()) defer cancel() - client := setup.GetAPIClient() + client := setup.GetAPIClient(t) sbx := utils.SetupSandboxWithCleanup(t, client, utils.WithTimeout(120)) envdClient := setup.GetEnvdClient(t, ctx) @@ -42,7 +42,7 @@ func TestAccessingHyperloopServerViaDomain(t *testing.T) { ctx, cancel := context.WithCancel(t.Context()) defer cancel() - client := setup.GetAPIClient() + client := setup.GetAPIClient(t) sbx := utils.SetupSandboxWithCleanup(t, client, utils.WithTimeout(120)) envdClient := setup.GetEnvdClient(t, ctx) diff --git a/tests/integration/internal/tests/envd/localhost_bind_test.go b/tests/integration/internal/tests/envd/localhost_bind_test.go index 07f28c7ef3..e134559a53 100644 --- a/tests/integration/internal/tests/envd/localhost_bind_test.go +++ b/tests/integration/internal/tests/envd/localhost_bind_test.go @@ -19,7 +19,7 @@ import ( func TestBindLocalhost(t *testing.T) { ctx := t.Context() - client := setup.GetAPIClient() + client := setup.GetAPIClient(t) testCases := []struct { name string diff --git a/tests/integration/internal/tests/envd/process_test.go b/tests/integration/internal/tests/envd/process_test.go index 3cbd0fa4b2..d81a54cc4e 100644 --- a/tests/integration/internal/tests/envd/process_test.go +++ b/tests/integration/internal/tests/envd/process_test.go @@ -18,7 +18,7 @@ func TestCommandKillNextApp(t *testing.T) { ctx, cancel := context.WithCancel(t.Context()) defer cancel() - client := setup.GetAPIClient() + client := setup.GetAPIClient(t) sbx := utils.SetupSandboxWithCleanup(t, client, utils.WithTimeout(300)) envdClient := setup.GetEnvdClient(t, ctx) @@ -97,7 +97,7 @@ func TestCommandKillWithAnd(t *testing.T) { ctx, cancel := context.WithCancel(t.Context()) defer cancel() - client := setup.GetAPIClient() + client := setup.GetAPIClient(t) sbx := utils.SetupSandboxWithCleanup(t, client, utils.WithTimeout(300)) envdClient := setup.GetEnvdClient(t, ctx) @@ -216,7 +216,7 @@ func TestWorkdirDeletion(t *testing.T) { ctx, cancel := context.WithCancel(t.Context()) defer cancel() - client := setup.GetAPIClient() + client := setup.GetAPIClient(t) sbx := utils.SetupSandboxWithCleanup(t, client, utils.WithTimeout(120)) envdClient := setup.GetEnvdClient(t, ctx) @@ -237,7 +237,7 @@ func TestWorkdirPermissionDenied(t *testing.T) { ctx, cancel := context.WithCancel(t.Context()) defer cancel() - client := setup.GetAPIClient() + client := setup.GetAPIClient(t) sbx := utils.SetupSandboxWithCleanup(t, client, utils.WithTimeout(120)) envdClient := setup.GetEnvdClient(t, ctx) @@ -258,7 +258,7 @@ func TestWorkdirPermissionDenied(t *testing.T) { } func TestStdinCantRead(t *testing.T) { - client := setup.GetAPIClient() + client := setup.GetAPIClient(t) sbx := utils.SetupSandboxWithCleanup(t, client, utils.WithTimeout(120)) envdClient := setup.GetEnvdClient(t, t.Context()) diff --git a/tests/integration/internal/tests/envd/watcher_test.go b/tests/integration/internal/tests/envd/watcher_test.go index bb3cd94cee..4b18629fcd 100644 --- a/tests/integration/internal/tests/envd/watcher_test.go +++ b/tests/integration/internal/tests/envd/watcher_test.go @@ -15,7 +15,7 @@ import ( ) func TestWatcher(t *testing.T) { - c := setup.GetAPIClient() + c := setup.GetAPIClient(t) sbx := utils.SetupSandboxWithCleanup(t, c) envdClient := setup.GetEnvdClient(t, t.Context()) diff --git a/tests/integration/internal/tests/proxies/closed_port_test.go b/tests/integration/internal/tests/proxies/closed_port_test.go index c1ef7ef09b..cd8f33aae2 100644 --- a/tests/integration/internal/tests/proxies/closed_port_test.go +++ b/tests/integration/internal/tests/proxies/closed_port_test.go @@ -53,7 +53,7 @@ func TestSandboxProxyWorkingPort(t *testing.T) { ctx, cancel := context.WithCancel(t.Context()) defer cancel() - c := setup.GetAPIClient() + c := setup.GetAPIClient(t) sbx := utils.SetupSandboxWithCleanup(t, c) envdClient := setup.GetEnvdClient(t, ctx) @@ -95,7 +95,7 @@ func TestSandboxProxyWorkingPort(t *testing.T) { } func TestSandboxProxyClosedPort(t *testing.T) { - c := setup.GetAPIClient() + c := setup.GetAPIClient(t) sbx := utils.SetupSandboxWithCleanup(t, c) url, err := url.Parse(setup.EnvdProxy) diff --git a/tests/integration/internal/tests/team_test.go b/tests/integration/internal/tests/team_test.go index 5a3702564c..53013fdd9b 100644 --- a/tests/integration/internal/tests/team_test.go +++ b/tests/integration/internal/tests/team_test.go @@ -21,7 +21,7 @@ type ForbiddenErrorResponse struct { func TestBannedTeam(t *testing.T) { ctx := t.Context() db := setup.GetTestDBClient(t) - c := setup.GetAPIClient() + c := setup.GetAPIClient(t) teamName := "test-team-banned" teamID := utils.CreateTeamWithUser(t, c, db, teamName, setup.UserID) @@ -50,7 +50,7 @@ func TestBannedTeam(t *testing.T) { func TestBlockedTeam(t *testing.T) { ctx := t.Context() db := setup.GetTestDBClient(t) - c := setup.GetAPIClient() + c := setup.GetAPIClient(t) teamName := "test-team-blocked" blockReason := "test-reason"