-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add integration test for the /telemetry-ext endpoint #2259
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
535d556
Add protos for bundle telemetry
shreyas-goenka 34d3ccc
-
shreyas-goenka cbd3a48
add bundle deploy event
shreyas-goenka 57ca88c
Update libs/telemetry/api.go
shreyas-goenka bc51673
Update libs/telemetry/protos/bundle_deploy.go
shreyas-goenka 6423fbb
add comments
shreyas-goenka d08cff4
address comments
shreyas-goenka e3be64e
-
shreyas-goenka 9d2286f
fmt
shreyas-goenka 809423d
Merge remote-tracking branch 'origin' into test-protos
shreyas-goenka 7c003f2
Add integration test for the /telemetry-ext endpoint
shreyas-goenka 41e8cb6
Merge remote-tracking branch 'origin' into test-protos
shreyas-goenka File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package telemetry | ||
|
||
import ( | ||
"encoding/json" | ||
"testing" | ||
"time" | ||
|
||
"github.com/databricks/cli/integration/internal/acc" | ||
"github.com/databricks/cli/libs/telemetry" | ||
"github.com/databricks/cli/libs/telemetry/protos" | ||
"github.com/databricks/databricks-sdk-go/client" | ||
"github.com/google/uuid" | ||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestTelemetryEndpoint(t *testing.T) { | ||
ctx, wt := acc.WorkspaceTest(t) | ||
w := wt.W | ||
|
||
apiClient, err := client.New(w.Config) | ||
require.NoError(t, err) | ||
|
||
logs := []protos.FrontendLog{ | ||
{ | ||
FrontendLogEventID: uuid.New().String(), | ||
Entry: protos.FrontendLogEntry{ | ||
DatabricksCliLog: protos.DatabricksCliLog{ | ||
CliTestEvent: &protos.CliTestEvent{Name: protos.DummyCliEnumValue1}, | ||
}, | ||
}, | ||
}, | ||
{ | ||
FrontendLogEventID: uuid.New().String(), | ||
Entry: protos.FrontendLogEntry{ | ||
DatabricksCliLog: protos.DatabricksCliLog{ | ||
CliTestEvent: &protos.CliTestEvent{Name: protos.DummyCliEnumValue2}, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
protoLogs := make([]string, len(logs)) | ||
for i, log := range logs { | ||
b, err := json.Marshal(log) | ||
require.NoError(t, err) | ||
protoLogs[i] = string(b) | ||
} | ||
|
||
reqB := telemetry.RequestBody{ | ||
UploadTime: time.Now().UnixMilli(), | ||
Items: []string{}, | ||
ProtoLogs: protoLogs, | ||
} | ||
|
||
respB := telemetry.ResponseBody{} | ||
|
||
err = apiClient.Do(ctx, "POST", "/telemetry-ext", nil, nil, reqB, &respB) | ||
require.NoError(t, err) | ||
|
||
assert.Equal(t, telemetry.ResponseBody{ | ||
Errors: []telemetry.LogError{}, | ||
NumProtoSuccess: int64(2), | ||
}, respB) | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you're building a client for this that performs the marshalling, make sure to update the call site here as well.