remove parent child selftest commands

This commit is contained in:
Shreyas Goenka 2025-02-21 15:57:30 +01:00
parent d7abb3bd97
commit 5ee52acacf
No known key found for this signature in database
GPG Key ID: 92A07DF49CCB0622
3 changed files with 0 additions and 87 deletions

View File

@ -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
},
}
}

View File

@ -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
},
}
}

View File

@ -11,8 +11,6 @@ func New() *cobra.Command {
Hidden: true, Hidden: true,
} }
cmd.AddCommand(newChildCommand())
cmd.AddCommand(newParentCommand())
cmd.AddCommand(newSendTelemetry()) cmd.AddCommand(newSendTelemetry())
return cmd return cmd
} }