Skip to content
Closed
Show file tree
Hide file tree
Changes from 131 commits
Commits
Show all changes
152 commits
Select commit Hold shift + click to select a range
ab10720
squash all commits
shreyas-goenka Jan 20, 2025
3964d8d
[WIP] In process telemetry logger
shreyas-goenka Jan 22, 2025
01d63dd
Merge remote-tracking branch 'origin' into implement-async-logger
shreyas-goenka Jan 23, 2025
155fe7b
-
shreyas-goenka Jan 29, 2025
acd64fa
merge
shreyas-goenka Jan 29, 2025
ee3568c
-'
shreyas-goenka Jan 29, 2025
8f8463f
-
shreyas-goenka Jan 29, 2025
f092e21
add back worker input
shreyas-goenka Jan 29, 2025
5d75c3f
Merge remote-tracking branch 'origin' into implement-async-logger
shreyas-goenka Feb 2, 2025
427c755
major cleanup
shreyas-goenka Feb 3, 2025
b83e576
-
shreyas-goenka Feb 3, 2025
f09a780
fix panic
shreyas-goenka Feb 3, 2025
90148d8
replace os
shreyas-goenka Feb 3, 2025
259a21a
-
shreyas-goenka Feb 3, 2025
e4a1f42
-
shreyas-goenka Feb 3, 2025
d7bf1dc
add test for upload
shreyas-goenka Feb 3, 2025
382efe4
-
shreyas-goenka Feb 3, 2025
c412eb7
-
shreyas-goenka Feb 3, 2025
da0cf95
-
shreyas-goenka Feb 3, 2025
8801587
pass test
shreyas-goenka Feb 3, 2025
5385faf
fix test
shreyas-goenka Feb 3, 2025
c1a3225
fx test
shreyas-goenka Feb 3, 2025
4f97900
-
shreyas-goenka Feb 3, 2025
a8b366e
-
shreyas-goenka Feb 3, 2025
5c2205a
-
shreyas-goenka Feb 3, 2025
dc0ab30
-
shreyas-goenka Feb 3, 2025
2cd25e3
-
shreyas-goenka Feb 3, 2025
2cbc39f
-
shreyas-goenka Feb 3, 2025
f3e7594
fx test
shreyas-goenka Feb 3, 2025
403f612
address comments
shreyas-goenka Feb 3, 2025
0423b09
add filtering for auth
shreyas-goenka Feb 3, 2025
981dbf7
add bash script for waiting
shreyas-goenka Feb 4, 2025
918af62
remove eventually files
shreyas-goenka Feb 4, 2025
39ff290
pass test
shreyas-goenka Feb 4, 2025
33ff865
cleaner output
shreyas-goenka Feb 4, 2025
17698a5
-
shreyas-goenka Feb 4, 2025
5b6ffd5
-
shreyas-goenka Feb 4, 2025
963022a
-
shreyas-goenka Feb 4, 2025
9e2a689
-
shreyas-goenka Feb 4, 2025
0abba86
=
shreyas-goenka Feb 4, 2025
407e9e0
-
shreyas-goenka Feb 4, 2025
414a94d
-
shreyas-goenka Feb 4, 2025
d5e03f0
-
shreyas-goenka Feb 4, 2025
8c90ad0
clean
shreyas-goenka Feb 4, 2025
1bb4537
Merge remote-tracking branch 'origin' into async-logger-clean
shreyas-goenka Feb 5, 2025
c9ebc82
add error test case'
shreyas-goenka Feb 5, 2025
fd6b129
make test generic
shreyas-goenka Feb 5, 2025
73fac82
remove pid file
shreyas-goenka Feb 5, 2025
5e2e03a
fix test
shreyas-goenka Feb 5, 2025
0253039
-
shreyas-goenka Feb 5, 2025
369faff
return 501
shreyas-goenka Feb 5, 2025
e43a0a0
skip end to end integration tests
shreyas-goenka Feb 6, 2025
f88db77
-
shreyas-goenka Feb 10, 2025
a6e8e92
Merge remote-tracking branch 'origin' into async-logger-clean
shreyas-goenka Feb 10, 2025
23b42e9
Merge remote-tracking branch 'origin' into async-logger-clean
shreyas-goenka Feb 10, 2025
9d65761
pretty print
shreyas-goenka Feb 10, 2025
c8ac08c
consolidate test.toml
shreyas-goenka Feb 10, 2025
58bf931
comment
shreyas-goenka Feb 10, 2025
79fad7a
pass test
shreyas-goenka Feb 10, 2025
4cdcbd6
Merge remote-tracking branch 'origin' into async-logger-clean
shreyas-goenka Feb 11, 2025
f98369d
-
shreyas-goenka Feb 11, 2025
d86ccf6
Add library for spawning a daemon
shreyas-goenka Feb 13, 2025
6148681
implement
shreyas-goenka Feb 17, 2025
533e7be
-
shreyas-goenka Feb 17, 2025
de6ebdb
Merge remote-tracking branch 'origin' into daemon-library
shreyas-goenka Feb 17, 2025
d15ff75
-
shreyas-goenka Feb 17, 2025
e970a12
-
shreyas-goenka Feb 17, 2025
3c4443c
cleanup
shreyas-goenka Feb 17, 2025
42c526f
-
shreyas-goenka Feb 17, 2025
ecbbee1
more test
shreyas-goenka Feb 17, 2025
2c71269
-
shreyas-goenka Feb 17, 2025
a9ccc32
-'
shreyas-goenka Feb 17, 2025
403c1b2
-
shreyas-goenka Feb 17, 2025
07141ba
skip wait test on windows
shreyas-goenka Feb 18, 2025
a4009ed
use script to wait
shreyas-goenka Feb 18, 2025
b130787
-
shreyas-goenka Feb 18, 2025
50308f2
-
shreyas-goenka Feb 18, 2025
f6a0223
extend timeout to 1 minute
shreyas-goenka Feb 18, 2025
6f63e14
-
shreyas-goenka Feb 18, 2025
11af4ba
delay closing output log file
shreyas-goenka Feb 18, 2025
75f3008
-
shreyas-goenka Feb 18, 2025
e649fc0
-
shreyas-goenka Feb 18, 2025
f6bd82d
add readme
shreyas-goenka Feb 18, 2025
8eb454d
-
shreyas-goenka Feb 18, 2025
608f0ad
-
shreyas-goenka Feb 18, 2025
c59b11f
-
shreyas-goenka Feb 18, 2025
dfd26e3
-
shreyas-goenka Feb 18, 2025
f504343
-
shreyas-goenka Feb 18, 2025
86428da
-
shreyas-goenka Feb 18, 2025
12f1fbd
-
shreyas-goenka Feb 18, 2025
8a0b359
Merge remote-tracking branch 'origin' into async-logger-clean
shreyas-goenka Feb 18, 2025
f48fbb9
merge daemon
shreyas-goenka Feb 18, 2025
520f069
use daemon
shreyas-goenka Feb 18, 2025
a98993a
-
shreyas-goenka Feb 18, 2025
3cfeb64
add skip functionality
shreyas-goenka Feb 18, 2025
18748f7
rename
shreyas-goenka Feb 18, 2025
96ade4e
merge
shreyas-goenka Feb 21, 2025
d7abb3b
remove daemon acceptance tests
shreyas-goenka Feb 21, 2025
5ee52ac
remove parent child selftest commands
shreyas-goenka Feb 21, 2025
5056070
remove user agent from telemetry tests
shreyas-goenka Feb 21, 2025
ae8ebaa
add acc test for oauth'
shreyas-goenka Feb 21, 2025
68646a5
remove leaking logs
shreyas-goenka Feb 21, 2025
69f5b03
remove log line
shreyas-goenka Feb 21, 2025
f11f589
toml files
shreyas-goenka Feb 24, 2025
0d37654
add test for timeout
shreyas-goenka Feb 24, 2025
8cfbb33
Merge remote-tracking branch 'origin' into async-logger-clean
shreyas-goenka Feb 24, 2025
a0e6f8f
pull latest
shreyas-goenka Feb 24, 2025
5939616
rename env var
shreyas-goenka Feb 24, 2025
9e3aa59
-
shreyas-goenka Feb 24, 2025
00ebbb9
add integration test
shreyas-goenka Feb 24, 2025
6acb6f1
consolidate repl
shreyas-goenka Feb 24, 2025
63ad316
fx
shreyas-goenka Feb 24, 2025
32a600a
cleanip
shreyas-goenka Feb 24, 2025
3f48d1f
-
shreyas-goenka Feb 24, 2025
549e49e
cancel test
shreyas-goenka Feb 24, 2025
71643ab
-
shreyas-goenka Feb 24, 2025
6dc73d7
-
shreyas-goenka Feb 24, 2025
0f98570
Revert "-"
shreyas-goenka Feb 24, 2025
33a7f71
-
shreyas-goenka Feb 24, 2025
a556d51
Merge remote-tracking branch 'origin' into async-logger-clean
shreyas-goenka Feb 27, 2025
a407a54
fix test toml
shreyas-goenka Feb 27, 2025
da0e08d
log to stdout / stderr
shreyas-goenka Feb 27, 2025
bddbc5d
-
shreyas-goenka Feb 27, 2025
5da92e9
raise to warn
shreyas-goenka Feb 27, 2025
8b3d942
-
shreyas-goenka Feb 27, 2025
c1272b3
use Getenv
shreyas-goenka Feb 27, 2025
fd271d3
add max retries
shreyas-goenka Feb 28, 2025
fec9c4e
move wait_pid to python
shreyas-goenka Feb 28, 2025
362a93b
remove todo
shreyas-goenka Feb 28, 2025
c898aaf
-
shreyas-goenka Feb 28, 2025
eb2b187
lint
shreyas-goenka Feb 28, 2025
476b8bb
address comments
shreyas-goenka Feb 28, 2025
e500bcb
remove the -f flag
shreyas-goenka Feb 28, 2025
0ff0877
add more test cases for retry on status code
shreyas-goenka Mar 1, 2025
7f71651
better retrying logic
shreyas-goenka Mar 2, 2025
db4fc69
rename environment variables
shreyas-goenka Mar 2, 2025
f249a1a
consolidate test configuration
shreyas-goenka Mar 2, 2025
8213c4f
make wait script more robust
shreyas-goenka Mar 2, 2025
0e300c6
lint
shreyas-goenka Mar 2, 2025
da7e9e2
add debug logs
shreyas-goenka Mar 2, 2025
6492404
-
shreyas-goenka Mar 2, 2025
5a2dcbb
incremental improvements
shreyas-goenka Mar 2, 2025
30a582a
-
shreyas-goenka Mar 2, 2025
efdb977
better debug logs
shreyas-goenka Mar 2, 2025
fbc657d
Merge remote-tracking branch 'origin' into async-logger-clean
shreyas-goenka Mar 5, 2025
217d4e7
add comment for failure
shreyas-goenka Mar 5, 2025
bd35ac9
implement the command in cobra
shreyas-goenka Mar 5, 2025
d854660
added debug log test
shreyas-goenka Mar 5, 2025
116c513
remove envvars functino
shreyas-goenka Mar 5, 2025
9e29462
use proper loggers
shreyas-goenka Mar 5, 2025
dab957d
-
shreyas-goenka Mar 5, 2025
2664028
lint'
shreyas-goenka Mar 5, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions acceptance/bin/wait_pid.py
Comment thread
shreyas-goenka marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/usr/bin/env python3
import sys
import os
import time
import platform
import subprocess


def wait_pid(pid):
max_attempts = 600 # 600 * 0.1 seconds = 1 minute
sleep_time = 0.1

for i in range(max_attempts):
# Check if we are on Windows or a Unix system.
if platform.system().lower() == "windows":
# Windows approach: use tasklist to check for the existence of the process.
try:
# Get the output of 'tasklist'
output = subprocess.check_output(["tasklist"], text=True)
except subprocess.CalledProcessError:
print("[wait_pid] Error retrieving tasklist. Assuming process has ended.")
return 0

# if the PID is not found in the list then assume the process ended.
if str(pid) not in output:
Comment thread
shreyas-goenka marked this conversation as resolved.
Outdated
print("[wait_pid] process has ended")
return 0
else:
# Linux/macOS approach: using os.kill with signal 0 to check if the process exists.
try:
os.kill(pid, 0)
except OSError:
print("[wait_pid] process has ended")
return 0

time.sleep(sleep_time)

print(f"Timeout: Process {pid} did not end within 1 minute")
return 1


try:
pid = int(sys.argv[1])
except ValueError:
print("Error: PID must be an integer.")
sys.exit(1)
Comment thread
shreyas-goenka marked this conversation as resolved.
Outdated

exit_code = wait_pid(pid)
sys.exit(exit_code)
15 changes: 15 additions & 0 deletions acceptance/telemetry/test.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
IncludeRequestHeaders = ["Authorization"]
Local = true
Cloud = false

[[Repls]]
Old = '17\d{11}'
New = '"UNIX_TIME_MILLIS"'

[[Repls]]
Old = 'darwin|linux|windows'
New = 'OS'
Comment thread
shreyas-goenka marked this conversation as resolved.
Outdated

[[Repls]]
Old = 'execution_time_ms\\\":\d{1,5},'
New = 'execution_time_ms\":\"SMALL_INT\",'
17 changes: 17 additions & 0 deletions acceptance/telemetry/upload-command/out.requests.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"headers": {
"Authorization": [
"Bearer [DATABRICKS_TOKEN]"
]
},
"method": "POST",
"path": "/telemetry-ext",
"body": {
"uploadTime": "UNIX_TIME_MILLIS",
"items": [],
"protoLogs": [
"{\"frontend_log_event_id\":\"[UUID]\",\"entry\":{\"databricks_cli_log\":{\"cli_test_event\":{\"name\":\"VALUE1\"}}}}",
"{\"frontend_log_event_id\":\"[UUID]\",\"entry\":{\"databricks_cli_log\":{\"cli_test_event\":{\"name\":\"VALUE2\"}}}}"
]
}
}
5 changes: 5 additions & 0 deletions acceptance/telemetry/upload-command/output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

>>> [CLI] telemetry upload
Telemetry logs uploaded successfully
Response:
{"errors":[],"numProtoSuccess":2}
5 changes: 5 additions & 0 deletions acceptance/telemetry/upload-command/script
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export DATABRICKS_CLI_TELEMETRY_UPLOAD_LOGS_FILE=./out.upload.txt

# This command / test cannot be run in inprocess / debug mode. This is because
# it does not go through the [root.Execute] function.
trace $CLI telemetry upload < stdin
24 changes: 24 additions & 0 deletions acceptance/telemetry/upload-command/stdin
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"logs": [
{
"frontend_log_event_id": "AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA",
"entry": {
"databricks_cli_log": {
"cli_test_event": {
"name": "VALUE1"
}
}
}
},
{
"frontend_log_event_id": "BBBBBBBB-BBBB-BBBB-BBBB-BBBBBBBBBBBB",
"entry": {
"databricks_cli_log": {
"cli_test_event": {
"name": "VALUE2"
}
}
}
}
]
}
10 changes: 10 additions & 0 deletions acceptance/telemetry/upload-command/test.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
RecordRequests = true

[[Server]]
Pattern = "POST /telemetry-ext"
Response.Body = '''
{
"errors": [],
"numProtoSuccess": 2
}
'''
17 changes: 17 additions & 0 deletions acceptance/telemetry/upload-fails/out.requests.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"headers": {
"Authorization": [
"Bearer [DATABRICKS_TOKEN]"
]
},
"method": "POST",
"path": "/telemetry-ext",
"body": {
"uploadTime": "UNIX_TIME_MILLIS",
"items": [],
"protoLogs": [
"{\"frontend_log_event_id\":\"[UUID]\",\"entry\":{\"databricks_cli_log\":{\"execution_context\":{\"cmd_exec_id\":\"[UUID]\",\"version\":\"[DEV_VERSION]\",\"command\":\"selftest_send-telemetry\",\"operating_system\":\"OS\",\"execution_time_ms\":\"SMALL_INT\",\"exit_code\":0},\"cli_test_event\":{\"name\":\"VALUE1\"}}}}",
"{\"frontend_log_event_id\":\"[UUID]\",\"entry\":{\"databricks_cli_log\":{\"execution_context\":{\"cmd_exec_id\":\"[UUID]\",\"version\":\"[DEV_VERSION]\",\"command\":\"selftest_send-telemetry\",\"operating_system\":\"OS\",\"execution_time_ms\":\"SMALL_INT\",\"exit_code\":0},\"cli_test_event\":{\"name\":\"VALUE2\"}}}}"
]
}
}
2 changes: 2 additions & 0 deletions acceptance/telemetry/upload-fails/out.upload_process.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
error: Failed to upload telemetry logs: Endpoint not implemented.

3 changes: 3 additions & 0 deletions acceptance/telemetry/upload-fails/output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

>>> [CLI] selftest send-telemetry
[wait_pid] process has ended
12 changes: 12 additions & 0 deletions acceptance/telemetry/upload-fails/script
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export DATABRICKS_CLI_TELEMETRY_PID_FILE=./telemetry.pid
export DATABRICKS_CLI_TELEMETRY_UPLOAD_LOGS_FILE=./out.upload_process.txt
Comment thread
shreyas-goenka marked this conversation as resolved.
Outdated

# This test ensures that the main CLI command does not error even if
# telemetry upload fails.
trace $CLI selftest send-telemetry

# Wait for the child telemetry process to finish
wait_pid.py $(cat ./telemetry.pid)
Comment thread
shreyas-goenka marked this conversation as resolved.

# cleanup the pid file
rm -f ./telemetry.pid
Comment thread
shreyas-goenka marked this conversation as resolved.
Outdated
11 changes: 11 additions & 0 deletions acceptance/telemetry/upload-fails/test.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
RecordRequests = true

[[Server]]
Pattern = "POST /telemetry-ext"
Response.Body = '''
{
"error_code": "ERROR_CODE",
"message": "Endpoint not implemented."
}
'''
Response.StatusCode = 501
3 changes: 3 additions & 0 deletions acceptance/telemetry/upload-skipped/output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

>>> [CLI] selftest send-telemetry
telemetry process not started. No pid file found
12 changes: 12 additions & 0 deletions acceptance/telemetry/upload-skipped/script
Original file line number Diff line number Diff line change
@@ -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"
Comment thread
shreyas-goenka marked this conversation as resolved.
fi
10 changes: 10 additions & 0 deletions acceptance/telemetry/upload-skipped/test.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
RecordRequests = true

[[Server]]
Pattern = "POST /telemetry-ext"
Response.Body = '''
{
"errors": [],
"numProtoSuccess": 2
}
'''
Comment thread
shreyas-goenka marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Telemetry logs uploaded successfully
Response:
{"errors":[],"numProtoSuccess":2}
4 changes: 4 additions & 0 deletions acceptance/telemetry/upload-succeeds-integration/output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

>>> [CLI] selftest send-telemetry
waiting for telemetry process to finish
[wait_pid] process has ended
12 changes: 12 additions & 0 deletions acceptance/telemetry/upload-succeeds-integration/script
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export DATABRICKS_CLI_TELEMETRY_PID_FILE=./telemetry.pid
export DATABRICKS_CLI_TELEMETRY_UPLOAD_LOGS_FILE=./out.upload_process.txt

trace $CLI selftest send-telemetry

echo "waiting for telemetry process to finish"

# Wait for the child telemetry process to finish
wait_pid.py $(cat ./telemetry.pid)

# cleanup the pid file
rm -f ./telemetry.pid
14 changes: 14 additions & 0 deletions acceptance/telemetry/upload-succeeds-integration/test.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# RecordRequests is not supported for integration tests yet. Once we have support
# for running integration tests with record requests we can remove this test since
# it's a copy of acceptance/telemetry/upload-succeeds.
Local = true
Cloud = true

[[Server]]
Pattern = "POST /telemetry-ext"
Response.Body = '''
{
"errors": [],
"numProtoSuccess": 2
}
'''
45 changes: 45 additions & 0 deletions acceptance/telemetry/upload-succeeds-oauth/out.requests.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"method": "GET",
"path": "/oidc/.well-known/oauth-authorization-server"
}
{
"headers": {
"Authorization": [
"Basic [ENCODED_AUTH]"
]
},
"method": "POST",
"path": "/oidc/v1/token",
"raw_body": "grant_type=client_credentials\u0026scope=all-apis"
}
{
"method": "GET",
"path": "/oidc/.well-known/oauth-authorization-server"
}
{
"headers": {
"Authorization": [
"Basic [ENCODED_AUTH]"
]
},
"method": "POST",
"path": "/oidc/v1/token",
"raw_body": "grant_type=client_credentials\u0026scope=all-apis"
}
{
"headers": {
"Authorization": [
"Bearer oauth-token"
]
},
"method": "POST",
"path": "/telemetry-ext",
"body": {
"uploadTime": "UNIX_TIME_MILLIS",
"items": [],
"protoLogs": [
"{\"frontend_log_event_id\":\"[UUID]\",\"entry\":{\"databricks_cli_log\":{\"execution_context\":{\"cmd_exec_id\":\"[UUID]\",\"version\":\"[DEV_VERSION]\",\"command\":\"selftest_send-telemetry\",\"operating_system\":\"OS\",\"execution_time_ms\":\"SMALL_INT\",\"exit_code\":0},\"cli_test_event\":{\"name\":\"VALUE1\"}}}}",
"{\"frontend_log_event_id\":\"[UUID]\",\"entry\":{\"databricks_cli_log\":{\"execution_context\":{\"cmd_exec_id\":\"[UUID]\",\"version\":\"[DEV_VERSION]\",\"command\":\"selftest_send-telemetry\",\"operating_system\":\"OS\",\"execution_time_ms\":\"SMALL_INT\",\"exit_code\":0},\"cli_test_event\":{\"name\":\"VALUE2\"}}}}"
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Telemetry logs uploaded successfully
Response:
{"errors":[],"numProtoSuccess":2}
4 changes: 4 additions & 0 deletions acceptance/telemetry/upload-succeeds-oauth/output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

>>> [CLI] selftest send-telemetry
waiting for telemetry process to finish
[wait_pid] process has ended
19 changes: 19 additions & 0 deletions acceptance/telemetry/upload-succeeds-oauth/script
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
export DATABRICKS_CLI_TELEMETRY_PID_FILE=./telemetry.pid
export DATABRICKS_CLI_TELEMETRY_UPLOAD_LOGS_FILE=./out.upload_process.txt

# Unset the token which is configured by default
# in acceptance tests
export DATABRICKS_TOKEN=""

export DATABRICKS_CLIENT_ID=client_id
export DATABRICKS_CLIENT_SECRET=client_secret

trace $CLI selftest send-telemetry

echo "waiting for telemetry process to finish"

# Wait for the child telemetry process to finish
wait_pid.py $(cat ./telemetry.pid)

# cleanup the pid file
rm -f ./telemetry.pid
17 changes: 17 additions & 0 deletions acceptance/telemetry/upload-succeeds-oauth/test.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
RecordRequests = true

[[Server]]
Pattern = "POST /telemetry-ext"
Response.Body = '''
{
"errors": [],
"numProtoSuccess": 2
}
'''


# "client_id:client_secret" in base64 is Y2xpZW50X2lkOmNsaWVudF9zZWNyZXQ=, expect to
# see this in Authorization header
[[Repls]]
Old = "Y2xpZW50X2lkOmNsaWVudF9zZWNyZXQ="
New = "[ENCODED_AUTH]"
17 changes: 17 additions & 0 deletions acceptance/telemetry/upload-succeeds/out.requests.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"headers": {
"Authorization": [
"Bearer [DATABRICKS_TOKEN]"
]
},
"method": "POST",
"path": "/telemetry-ext",
"body": {
"uploadTime": "UNIX_TIME_MILLIS",
"items": [],
"protoLogs": [
"{\"frontend_log_event_id\":\"[UUID]\",\"entry\":{\"databricks_cli_log\":{\"execution_context\":{\"cmd_exec_id\":\"[UUID]\",\"version\":\"[DEV_VERSION]\",\"command\":\"selftest_send-telemetry\",\"operating_system\":\"OS\",\"execution_time_ms\":\"SMALL_INT\",\"exit_code\":0},\"cli_test_event\":{\"name\":\"VALUE1\"}}}}",
"{\"frontend_log_event_id\":\"[UUID]\",\"entry\":{\"databricks_cli_log\":{\"execution_context\":{\"cmd_exec_id\":\"[UUID]\",\"version\":\"[DEV_VERSION]\",\"command\":\"selftest_send-telemetry\",\"operating_system\":\"OS\",\"execution_time_ms\":\"SMALL_INT\",\"exit_code\":0},\"cli_test_event\":{\"name\":\"VALUE2\"}}}}"
]
}
}
3 changes: 3 additions & 0 deletions acceptance/telemetry/upload-succeeds/out.upload_process.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Telemetry logs uploaded successfully
Response:
{"errors":[],"numProtoSuccess":2}
4 changes: 4 additions & 0 deletions acceptance/telemetry/upload-succeeds/output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

>>> [CLI] selftest send-telemetry
waiting for telemetry process to finish
[wait_pid] process has ended
12 changes: 12 additions & 0 deletions acceptance/telemetry/upload-succeeds/script
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export DATABRICKS_CLI_TELEMETRY_PID_FILE=./telemetry.pid
export DATABRICKS_CLI_TELEMETRY_UPLOAD_LOGS_FILE=./out.upload_process.txt

trace $CLI selftest send-telemetry

echo "waiting for telemetry process to finish"

# Wait for the child telemetry process to finish
wait_pid.py $(cat ./telemetry.pid)

# cleanup the pid file
rm -f ./telemetry.pid
10 changes: 10 additions & 0 deletions acceptance/telemetry/upload-succeeds/test.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
RecordRequests = true

[[Server]]
Pattern = "POST /telemetry-ext"
Response.Body = '''
{
"errors": [],
"numProtoSuccess": 2
}
'''
1 change: 1 addition & 0 deletions acceptance/telemetry/upload-timeout/out.upload_process.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
error: Failed to flush telemetry log due to timeout
4 changes: 4 additions & 0 deletions acceptance/telemetry/upload-timeout/output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

>>> [CLI] selftest send-telemetry
waiting for telemetry process to finish
[wait_pid] process has ended
Loading