From 5ee52acacf5c8fb1f88ef0ff9cb32f46fb49edb3 Mon Sep 17 00:00:00 2001 From: Shreyas Goenka Date: Fri, 21 Feb 2025 15:57:30 +0100 Subject: [PATCH] remove parent child selftest commands --- cmd/selftest/child.go | 41 ------------------------------------- cmd/selftest/parent.go | 44 ---------------------------------------- cmd/selftest/selftest.go | 2 -- 3 files changed, 87 deletions(-) delete mode 100644 cmd/selftest/child.go delete mode 100644 cmd/selftest/parent.go diff --git a/cmd/selftest/child.go b/cmd/selftest/child.go deleted file mode 100644 index 55c696e16..000000000 --- a/cmd/selftest/child.go +++ /dev/null @@ -1,41 +0,0 @@ -package selftest - -import ( - "fmt" - "io" - "os" - "os/exec" - - "github.com/databricks/cli/libs/daemon" - "github.com/spf13/cobra" -) - -func newChildCommand() *cobra.Command { - return &cobra.Command{ - Use: "child", - RunE: func(cmd *cobra.Command, args []string) error { - // wait_pid lives in acceptance/bin. We expect this command to only be called - // from acceptance tests. - // - // Note: The golang standard library only provides a way to wait on - // processes that are children of the current process. While it's possible to - // rely on os native syscalls to wait on arbitrary processes, it's hard - // to get right and test. - waitCmd := exec.Command("bash", "-euo", "pipefail", "wait_pid", os.Getenv(daemon.DatabricksCliParentPid)) - b, err := waitCmd.Output() - if err != nil { - return fmt.Errorf("failed to wait for parent process: %w", err) - } - fmt.Print("[child]" + string(b)) - fmt.Println("[child] Parent process has exited") - - in, err := io.ReadAll(os.Stdin) - if err != nil { - return fmt.Errorf("failed to read from stdin: %w", err) - } - - fmt.Println("[child] input from parent: " + string(in)) - return nil - }, - } -} diff --git a/cmd/selftest/parent.go b/cmd/selftest/parent.go deleted file mode 100644 index 77d1cfe64..000000000 --- a/cmd/selftest/parent.go +++ /dev/null @@ -1,44 +0,0 @@ -package selftest - -import ( - "fmt" - "os" - - "github.com/databricks/cli/libs/daemon" - "github.com/spf13/cobra" -) - -const OutputFile = "DATABRICKS_CLI_SELFTEST_CHILD_OUTPUT_FILE" - -func newParentCommand() *cobra.Command { - return &cobra.Command{ - Use: "parent", - RunE: func(cmd *cobra.Command, args []string) error { - d := daemon.Daemon{ - Env: os.Environ(), - Args: []string{"selftest", "child"}, - LogFile: os.Getenv(OutputFile), - PidFilePath: "child.pid", - } - - err := d.Start() - if err != nil { - return fmt.Errorf("failed to start child process: %w", err) - } - fmt.Println("[parent] started child") - - err = d.WriteInput([]byte("Hello from the other side\n")) - if err != nil { - return fmt.Errorf("failed to write to child process: %w", err) - } - fmt.Println("[parent] input sent to child: Hello from the other side") - - err = d.Release() - if err != nil { - return fmt.Errorf("failed to release child process: %w", err) - } - fmt.Println("[parent] exiting") - return nil - }, - } -} diff --git a/cmd/selftest/selftest.go b/cmd/selftest/selftest.go index 145909fb8..64cc562d5 100644 --- a/cmd/selftest/selftest.go +++ b/cmd/selftest/selftest.go @@ -11,8 +11,6 @@ func New() *cobra.Command { Hidden: true, } - cmd.AddCommand(newChildCommand()) - cmd.AddCommand(newParentCommand()) cmd.AddCommand(newSendTelemetry()) return cmd }