Skip to content
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

chore(server): Updating data store test to use queues #3166

Merged
merged 8 commits into from
Sep 20, 2023

Conversation

xoscar
Copy link
Collaborator

@xoscar xoscar commented Sep 18, 2023

This PR updates the data test connection logic to use queues

Changes

  • Implements ds test connection pipeline
  • Updates logic to be async

Checklist

  • tested locally
  • added new dependencies
  • updated the docs
  • added a test

@xoscar xoscar self-assigned this Sep 18, 2023
@xoscar xoscar marked this pull request as ready for review September 18, 2023 22:56
@danielbdias danielbdias self-requested a review September 18, 2023 23:30
@@ -170,6 +176,32 @@ message TraceIdResponse {
string id = 1;
}

message DataStoreConnectionTestRequest {
string requestID = 1;
DataStore datastore = 5;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
DataStore datastore = 5;
DataStore datastore = 2;

??

@@ -78,6 +83,13 @@ type transactionRunner interface {
Run(context.Context, testsuite.TestSuite, test.RunMetadata, variableset.VariableSet, *[]testrunner.RequiredGate) testsuite.TestSuiteRun
}

type dataStoreTestRunner interface {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

name suggestion

Suggested change
type dataStoreTestRunner interface {
type dataStoreTester interface {

}

func (p *DataStoreTestPipeline) Run(ctx context.Context, job Job) {
spew.Dump(job)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
spew.Dump(job)

Comment on lines 51 to 58
job := Job{
Headers: make(map[string]string),
}
job.ID = uuid.New().String()
job.DataStore = datastore
job.Headers[string(middleware.TenantIDKey)] = middleware.TenantIDFromContext(ctx)

return job
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
job := Job{
Headers: make(map[string]string),
}
job.ID = uuid.New().String()
job.DataStore = datastore
job.Headers[string(middleware.TenantIDKey)] = middleware.TenantIDFromContext(ctx)
return job
return Job{
ID: uuid.New().String()
DataStore: datastore
Headers:= map[string]string{
string(middleware.TenantIDKey): middleware.TenantIDFromContext(ctx)
}
}

)

type Job struct {
Headers map[string]string `json:"headers"`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are the headers used for anything other than passing the tenant ID? if so, it might be simpler to just have a TenantID string field

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to keep using the same approach we have for the rest, but yeah we can just change it for a new field, let me check..

ctx, pollingSpan := w.tracer.Start(ctx, "dsTestConnectionRequest.ProcessItem")
defer pollingSpan.End()

traceDB, err := getTraceDB(job.DataStore, w.newTraceDBFn)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If i understand this correctly, this function's only effect is to wrap the error with a message. I'd recommend to just have this behavior inlined here so it's easier to follow

Comment on lines 34 to 38
func (m *Listener) Notify(job Job) {
for _, sub := range m.subscriptions[job.ID] {
sub(job)
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If not using locks for reading there can still be race conditions

Suggested change
func (m *Listener) Notify(job Job) {
for _, sub := range m.subscriptions[job.ID] {
sub(job)
}
}
func (m *Listener) Notify(job Job) {
m.mutex.Lock()
defer m.mutex.Unlock()
for _, sub := range m.subscriptions[job.ID] {
sub(job)
}
}

Copy link
Collaborator

@schoren schoren left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My comments are mostly optiona, except for the one about the race conditoin. that needs to be fixed or it might cause panics on prod

@xoscar xoscar merged commit 6e64d9c into main Sep 20, 2023
38 checks passed
@xoscar xoscar deleted the chore/ds-test-connection-pipelines branch September 20, 2023 20:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants