mirror of https://github.com/databricks/cli.git
add skip functionality
This commit is contained in:
parent
a98993abfc
commit
3cfeb640e1
|
@ -1,5 +1,5 @@
|
|||
export DATABRICKS_CLI_TELEMETRY_PID_FILE=./telemetry.pid
|
||||
export DATABRICKS_CLI_TELEMETRY_UPLOAD_LOGS_FILE=./out.upload.txt
|
||||
export DATABRICKS_CLI_TELEMETRY_UPLOAD_LOGS_FILE=./out.upload_process.txt
|
||||
|
||||
# This test ensures that the main CLI command does not error even if
|
||||
# telemetry upload fails.
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
|
||||
>>> [CLI] selftest send-telemetry
|
||||
telemetry process not started. No pid file found
|
|
@ -0,0 +1,12 @@
|
|||
export DATABRICKS_CLI_TELEMETRY_PID_FILE=./telemetry.pid
|
||||
export DATABRICKS_CLI_TELEMETRY_UPLOAD_LOGS_FILE=./out.upload_process.txt
|
||||
export DATABRICKS_CLI_DISABLE_TELEMETRY="true"
|
||||
|
||||
trace $CLI selftest send-telemetry
|
||||
|
||||
if [ -f ./telemetry.pid ]; then
|
||||
echo "telemetry process was started"
|
||||
exit 1
|
||||
else
|
||||
echo "telemetry process not started. No pid file found"
|
||||
fi
|
|
@ -0,0 +1,11 @@
|
|||
[[Server]]
|
||||
Pattern = "POST /telemetry-ext"
|
||||
Response.Body = '''
|
||||
{
|
||||
"numProtoSuccess": 2
|
||||
}
|
||||
'''
|
||||
|
||||
[[Repls]]
|
||||
Old = 'execution_time_ms\\\":\d{1,5},'
|
||||
New = 'execution_time_ms\":\"SMALL_INT\",'
|
|
@ -1,5 +1,5 @@
|
|||
export DATABRICKS_CLI_TELEMETRY_PID_FILE=./telemetry.pid
|
||||
export DATABRICKS_CLI_TELEMETRY_UPLOAD_LOGS_FILE=./out.send_telemetry.txt
|
||||
export DATABRICKS_CLI_TELEMETRY_UPLOAD_LOGS_FILE=./out.upload_process.txt
|
||||
|
||||
trace $CLI selftest send-telemetry
|
||||
|
||||
|
|
|
@ -181,6 +181,11 @@ func uploadTelemetry(ctx context.Context, cmdStr string, start, end time.Time, e
|
|||
return
|
||||
}
|
||||
|
||||
// Telemetry is disabled. We don't upload logs.
|
||||
if _, ok := os.LookupEnv(telemetry.DisableEnvVar); ok {
|
||||
return
|
||||
}
|
||||
|
||||
telemetry.SetExecutionContext(ctx, protos.ExecutionContext{
|
||||
CmdExecID: cmdExecId,
|
||||
Version: build.GetInfo().Version,
|
||||
|
|
|
@ -21,6 +21,10 @@ const (
|
|||
|
||||
// File containing the PID of the telemetry upload process.
|
||||
PidFileEnvVar = "DATABRICKS_CLI_TELEMETRY_PID_FILE"
|
||||
|
||||
// Environment variable to disable telemetry. If this is set to any value, telemetry
|
||||
// will be disabled.
|
||||
DisableEnvVar = "DATABRICKS_CLI_DISABLE_TELEMETRY"
|
||||
)
|
||||
|
||||
type UploadConfig struct {
|
||||
|
|
|
@ -14,6 +14,10 @@ import (
|
|||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
// TODO: Add flag to allow skipping telemetry.
|
||||
// TODO: Add verification that the telemetry process uses the correct authentication
|
||||
// credentials.
|
||||
|
||||
func TestTelemetryUploadRetries(t *testing.T) {
|
||||
server := testserver.New(t)
|
||||
t.Cleanup(server.Close)
|
||||
|
|
Loading…
Reference in New Issue