package main import ( "context" "fmt" "os" "os/signal" "path/filepath" "syscall" "github.com/QuantumNous/new-api/common" helpers "github.com/QuantumNous/new-api/test/e2e/helpers" ) func main() { if err := run(); err != nil { fmt.Fprintln(os.Stderr, err) os.Exit(1) } } func run() error { repoRoot, err := os.Getwd() if err != nil { return fmt.Errorf("get working directory: %w", err) } artifactRoot := filepath.Join(repoRoot, "test-artifacts", "user-migration-e2e") if err := os.MkdirAll(artifactRoot, 0o755); err != nil { return fmt.Errorf("create artifact root: %w", err) } binaryPath, err := helpers.BuildBinary(repoRoot, artifactRoot) if err != nil { return fmt.Errorf("build api binary: %w", err) } env, err := helpers.PrepareEnvironment(repoRoot, artifactRoot, binaryPath, "playwright-ui") if err != nil { return fmt.Errorf("prepare playwright environment: %w", err) } defer func() { _ = env.Close() }() playwrightArtifactRoot := filepath.Join(artifactRoot, "playwright") if err := os.MkdirAll(playwrightArtifactRoot, 0o755); err != nil { return fmt.Errorf("create playwright artifact root: %w", err) } readyPayload, err := common.Marshal(map[string]any{ "run_dir": env.RunDir, "base_url": env.Cluster.CN.BaseURL, "ov_base_url": env.Cluster.OV.BaseURL, }) if err != nil { return fmt.Errorf("marshal ready payload: %w", err) } if err := os.WriteFile( filepath.Join(playwrightArtifactRoot, "server-ready.json"), readyPayload, 0o644, ); err != nil { return fmt.Errorf("write ready marker: %w", err) } fmt.Printf( "user migration ui e2e ready: cn=%s ov=%s run_dir=%s\n", env.Cluster.CN.BaseURL, env.Cluster.OV.BaseURL, env.RunDir, ) ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM) defer stop() <-ctx.Done() return nil }