summaryrefslogtreecommitdiff
path: root/internal/cli/cli.go
diff options
context:
space:
mode:
authorJames O'Doherty <james@theodohertyfamily.com>2026-05-29 21:16:13 -0400
committerJames O'Doherty <james@theodohertyfamily.com>2026-05-29 21:16:13 -0400
commit0f3806f77164af99466bfc8c0d7d5f85f9ec078f (patch)
tree034b3c7d2688345a01b2d7fa26575944242e6b8c /internal/cli/cli.go
parentd2173cdbc03884ecd9534e9369f8ebe1634f7e9c (diff)
perf: optimize test suite execution and reduce polling
- Added `test-lifecycle` CLI command to verify active session state. - Replaced manual filesystem polling and `time.Sleep` in E2E tests with `waitForLifecycle` synchronization. - Optimized `TestConfigHotSwap` by reducing artificial sleep durations. - Fixed linting issue (ST1023) in `internal/cli/cli.go`. These changes reduce total test execution time to under 15 seconds and improve the determinism of lifecycle verification.
Diffstat (limited to 'internal/cli/cli.go')
-rw-r--r--internal/cli/cli.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/internal/cli/cli.go b/internal/cli/cli.go
index 076d46b..7d5a05c 100644
--- a/internal/cli/cli.go
+++ b/internal/cli/cli.go
@@ -74,6 +74,9 @@ func (a *App) Run() error {
}
}
return namespace.VerifyArguments(a.Args)
+ case "test-lifecycle":
+ pm := a.getPathManager()
+ return a.verifyLifecycle(pm)
}
}
@@ -447,6 +450,24 @@ func (a *App) handleProfileDelete(name string) error {
return nil
}
+func (a *App) verifyLifecycle(pm *paths.PathManager) error {
+ profile := "default"
+ for i := 0; i < len(a.Args)-1; i++ {
+ if a.Args[i] == "--profile" && i+1 < len(a.Args) {
+ profile = a.Args[i+1]
+ break
+ }
+ }
+
+ activePid, err := namespace.FindActiveProfilePid(pm, profile)
+ if err != nil || activePid <= 0 {
+ return fmt.Errorf("no active session found for profile %s", profile)
+ }
+
+ fmt.Printf("Active session found for profile %s (PID: %d)\n", profile, activePid)
+ return nil
+}
+
func (a *App) showConfig() error {
cfg := &config.Config{}
fs := flag.NewFlagSet("wg-wrap", flag.ExitOnError)