mirror of https://github.com/databricks/cli.git
more test
This commit is contained in:
parent
42c526f40f
commit
ecbbee1bb3
|
@ -72,7 +72,7 @@
|
||||||
10:07:59 Debug: Apply pid=12345 mutator=initialize mutator=seq mutator=metadata.AnnotatePipelines
|
10:07:59 Debug: Apply pid=12345 mutator=initialize mutator=seq mutator=metadata.AnnotatePipelines
|
||||||
10:07:59 Debug: Apply pid=12345 mutator=initialize mutator=seq mutator=terraform.Initialize
|
10:07:59 Debug: Apply pid=12345 mutator=initialize mutator=seq mutator=terraform.Initialize
|
||||||
10:07:59 Debug: Using Terraform from DATABRICKS_TF_EXEC_PATH at [TERRAFORM] pid=12345 mutator=initialize mutator=seq mutator=terraform.Initialize
|
10:07:59 Debug: Using Terraform from DATABRICKS_TF_EXEC_PATH at [TERRAFORM] pid=12345 mutator=initialize mutator=seq mutator=terraform.Initialize
|
||||||
10:07:59 Debug: Using Terraform CLI config from DATABRICKS_TF_CLI_CONFIG_FILE at [DATABRICKS_TF_CLI_CONFIG_FILE] pid=12345 mutator=initialize mutator=seq mutator=terraform.Initialize
|
10:07:59 Debug: DATABRICKS_TF_PROVIDER_VERSION as 1.62.0 does not match the current version 1.65.1, ignoring DATABRICKS_TF_CLI_CONFIG_FILE pid=12345 mutator=initialize mutator=seq mutator=terraform.Initialize
|
||||||
10:07:59 Debug: Environment variables for Terraform: ...redacted... pid=12345 mutator=initialize mutator=seq mutator=terraform.Initialize
|
10:07:59 Debug: Environment variables for Terraform: ...redacted... pid=12345 mutator=initialize mutator=seq mutator=terraform.Initialize
|
||||||
10:07:59 Debug: Apply pid=12345 mutator=initialize mutator=seq mutator=scripts.postinit
|
10:07:59 Debug: Apply pid=12345 mutator=initialize mutator=seq mutator=scripts.postinit
|
||||||
10:07:59 Debug: No script defined for postinit, skipping pid=12345 mutator=initialize mutator=seq mutator=scripts.postinit
|
10:07:59 Debug: No script defined for postinit, skipping pid=12345 mutator=initialize mutator=seq mutator=scripts.postinit
|
||||||
|
|
|
@ -4,3 +4,5 @@ $CLI selftest parent &> out.parentchild.txt
|
||||||
|
|
||||||
echo "waiting for child process to finish"
|
echo "waiting for child process to finish"
|
||||||
wait_pid $(cat ./child.pid)
|
wait_pid $(cat ./child.pid)
|
||||||
|
|
||||||
|
rm ./child.pid
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
Parent process has started
|
||||||
|
Started the child process
|
||||||
|
Provided input: Hello from the other side
|
||||||
|
Released the child process
|
||||||
|
Parent process is exiting
|
||||||
|
|
||||||
|
wait for child process to finish
|
||||||
|
Process has ended
|
||||||
|
the child process should not have written any output.
|
|
@ -0,0 +1,9 @@
|
||||||
|
$CLI selftest parent
|
||||||
|
|
||||||
|
echo "
|
||||||
|
wait for child process to finish"
|
||||||
|
wait_pid $(cat ./child.pid)
|
||||||
|
|
||||||
|
echo "the child process should not have written any output."
|
||||||
|
|
||||||
|
rm ./child.pid
|
|
@ -1,7 +1,6 @@
|
||||||
package daemon
|
package daemon
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
|
@ -12,11 +11,7 @@ import (
|
||||||
const DatabricksCliParentPid = "DATABRICKS_CLI_PARENT_PID"
|
const DatabricksCliParentPid = "DATABRICKS_CLI_PARENT_PID"
|
||||||
|
|
||||||
type Daemon struct {
|
type Daemon struct {
|
||||||
// TODO: remove this.
|
|
||||||
ctx context.Context
|
|
||||||
|
|
||||||
// If provided, the child process will create a pid file at this path.
|
// If provided, the child process will create a pid file at this path.
|
||||||
// TODO: Can we remove this?
|
|
||||||
PidFilePath string
|
PidFilePath string
|
||||||
|
|
||||||
// Environment variables to set in the child process.
|
// Environment variables to set in the child process.
|
||||||
|
@ -48,7 +43,6 @@ func (d *Daemon) Start() error {
|
||||||
d.cmd.SysProcAttr = sysProcAttr()
|
d.cmd.SysProcAttr = sysProcAttr()
|
||||||
|
|
||||||
// By default redirect stdout and stderr to /dev/null.
|
// By default redirect stdout and stderr to /dev/null.
|
||||||
// TODO: Test that by default stdout and stderr do not leak to the parent process.
|
|
||||||
d.cmd.Stdout = nil
|
d.cmd.Stdout = nil
|
||||||
d.cmd.Stderr = nil
|
d.cmd.Stderr = nil
|
||||||
|
|
||||||
|
@ -101,7 +95,8 @@ func (d *Daemon) Release() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// This does not seem to be strictly necessary, but the docs recommend
|
// The docs recommend calling Release if Wait is not called. This does not
|
||||||
// adding it if Wait is not called. Thus we add it here to be safe.
|
// seem to be necessary since the functionality works without it. However, we
|
||||||
|
// we add it just to be safe.
|
||||||
return d.cmd.Process.Release()
|
return d.cmd.Process.Release()
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,6 @@ import (
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TODO: Test this in windows. Setup an IDE.
|
|
||||||
func TestWait(t *testing.T) {
|
func TestWait(t *testing.T) {
|
||||||
err := Wait(1000000)
|
err := Wait(1000000)
|
||||||
assert.EqualError(t, err, "process with pid 1000000 does not exist")
|
assert.EqualError(t, err, "process with pid 1000000 does not exist")
|
||||||
|
|
|
@ -17,7 +17,7 @@ func waitForPid(pid int) error {
|
||||||
uint32(pid),
|
uint32(pid),
|
||||||
)
|
)
|
||||||
if errors.Is(err, windows.ERROR_INVALID_PARAMETER) {
|
if errors.Is(err, windows.ERROR_INVALID_PARAMETER) {
|
||||||
return ErrProcessDoesNotExist{Pid: pid}
|
return ErrProcessNotFound{Pid: pid}
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("OpenProcess failed: %v", err)
|
return fmt.Errorf("OpenProcess failed: %v", err)
|
||||||
|
|
Loading…
Reference in New Issue