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

Fix: test time #586

Merged
merged 11 commits into from
May 30, 2022
Merged

Fix: test time #586

merged 11 commits into from
May 30, 2022

Conversation

mathnogueira
Copy link
Member

This PR fixes CompletedAt value. Now it is populated at the end of the run or when it fails.

I also added a few more time variables so we can know know much time each step took.

Changes

  • CompletedAt is filled at the end of the execution
  • New time fields added to TestRun

Fixes

  • Time difference between Created and Completed was always 1s

Checklist

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

@mathnogueira mathnogueira requested a review from schoren May 27, 2022 19:30
@@ -53,8 +53,6 @@ func TestPersistentRunner(t *testing.T) {

run2 := f.mockDB.runs[test2.ID.String()]
require.NotNil(t, run2)

assert.True(t, run1.CompletedAt.UnixNano() > run2.CompletedAt.UnixNano(), "test1 did not complete after test2")
Copy link
Member Author

@mathnogueira mathnogueira May 27, 2022

Choose a reason for hiding this comment

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

Does this test still make sense? I feel that having a runner test mocking everything doesn't provide great value right now that we have integration tests.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, this test that the runner is actually async, that was why the comparison was by dates. This needs to be kept. Maybe we could add a runCompletedAt field or similar, so we keep track of all the timestmaps of the process

@@ -53,8 +53,6 @@ func TestPersistentRunner(t *testing.T) {

run2 := f.mockDB.runs[test2.ID.String()]
require.NotNil(t, run2)

assert.True(t, run1.CompletedAt.UnixNano() > run2.CompletedAt.UnixNano(), "test1 did not complete after test2")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, this test that the runner is actually async, that was why the comparison was by dates. This needs to be kept. Maybe we could add a runCompletedAt field or similar, so we keep track of all the timestmaps of the process

@@ -70,6 +70,7 @@ func (r persistentRunner) Start(workers int) {
fmt.Println("persistentRunner exit goroutine")
return
case job := <-r.executeQueue:
job.run.StartedAt = time.Now()
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would put this either at the processExecQueue func, or remove the field, since it's almost the same value as ServiceTriggeredAt

@@ -201,7 +202,7 @@ func (tp tracePoller) donePollingTraces(job tracePollReq, trace traces.Trace) bo
func (tp tracePoller) handleTraceDBError(job tracePollReq, err error) {
run := job.run
if errors.Is(err, tracedb.ErrTraceNotFound) {
if time.Since(run.CompletedAt) < tp.maxWaitTimeForTrace {
if time.Since(run.CreatedAt) < tp.maxWaitTimeForTrace {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This feels weird. This time now includes the time elapsed since the trigger started, so we need to either change the config name, or change the checked field. I'd incline for the latter, so we can have different timeouts for execution and trace polling

@mathnogueira mathnogueira requested a review from schoren May 30, 2022 15:08
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.

LGTM, I think you can also regenerate the cli client as part of this pr too

SpanID: r.idGen.SpanID(),
State: model.RunStateCreated,
CreatedAt: time.Now(),
ServiceTriggeredAt: time.Time{},
Copy link
Collaborator

Choose a reason for hiding this comment

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

you don't need to do this. If you just leave them empty, they will be zero valued

@mathnogueira mathnogueira merged commit c457ba7 into main May 30, 2022
@mathnogueira mathnogueira deleted the fix/test-time branch May 30, 2022 15:14
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.

2 participants