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

Enhance ES index cleaner e2e test to verify indices have been removed #378

Merged
merged 10 commits into from
Apr 26, 2019
Merged

Conversation

objectiser
Copy link
Contributor

Existing test only verifies that the cronjob completes successfully.

This PR extends the test to verify that the job has correctly triggered the es-index-cleaner image and that the task has been performed correctly (i.e. the indices have been removed).

Signed-off-by: Gary Brown [email protected]

@objectiser objectiser requested a review from pavolloffay April 25, 2019 16:13
if err != nil {
return err
}

err = WaitForCronJob(t, f.KubeClient, namespace, fmt.Sprintf("%s-es-index-cleaner", name), retryInterval, timeout)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Currently removed the intermediate checks of whether the cronjob completed - as was focusing on the result. But wondering whether this should be added back in - just to check that the job also reports success.

Copy link
Member

Choose a reason for hiding this comment

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

I would leave it there to see that the job run successfully.

bodyBytes, err := ioutil.ReadAll(resp.Body)
bodyString := string(bodyBytes)

return strings.Contains(bodyString, "jaeger-span-"), nil
Copy link
Member

Choose a reason for hiding this comment

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

a minor thing but could you also check the service names index or just do jaeger- in a case we add new indices..

if err != nil {
return err
}

err = WaitForCronJob(t, f.KubeClient, namespace, fmt.Sprintf("%s-es-index-cleaner", name), retryInterval, timeout)
Copy link
Member

Choose a reason for hiding this comment

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

I would leave it there to see that the job run successfully.

if err != nil {
return err
}

err = WaitForCronJob(t, f.KubeClient, namespace, fmt.Sprintf("%s-es-index-cleaner", name), retryInterval, timeout)
portForwES, closeChanES, err := CreatePortForward(esPod.Namespace, esPod.Name, []string{"9200"}, f.KubeConfig)
Copy link
Member

Choose a reason for hiding this comment

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

nit move es port forward closer to has-index.

})
}

func hasIndex(t *testing.T) (bool, error) {
Copy link
Member

Choose a reason for hiding this comment

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

why passing t? maybe it's better to change the signature to bool containsIndex(string) bool, error

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, t no longer necessary so will remove. Will also update the signature and check for jaeger- for now.

return nil

return wait.Poll(retryInterval, timeout, func() (done bool, err error) {
flag, err := hasIndexWithPrefix("jaeger-")
Copy link
Member

Choose a reason for hiding this comment

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

Is this needed hasIndexWithPrefix is also called on line 97.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Line 97 is checking the indices exist, this part of checking they no longer exist.

Copy link
Member

Choose a reason for hiding this comment

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

oh my bad, it looks good.

@objectiser
Copy link
Contributor Author

Still investigating the build failure in travis - the problem is not lint, but the gosec command performed in the lint target. I've not been able to reproduce the behaviour locally yet, but found odd behaviour with gosec - produces a different return status depending upon whether the -quiet option is provided (which should only affect what is output).

@codecov
Copy link

codecov bot commented Apr 26, 2019

Codecov Report

Merging #378 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #378      +/-   ##
==========================================
+ Coverage   89.71%   89.72%   +<.01%     
==========================================
  Files          64       64              
  Lines        3093     3094       +1     
==========================================
+ Hits         2775     2776       +1     
  Misses        216      216              
  Partials      102      102
Impacted Files Coverage Δ
pkg/apis/jaegertracing/v1/jaeger_types.go 100% <ø> (ø) ⬆️
pkg/cronjob/es_index_cleaner.go 100% <100%> (ø) ⬆️
pkg/strategy/controller.go 97.52% <100%> (+0.02%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ed370cf...e12c9a8. Read the comment docs.

@objectiser
Copy link
Contributor Author

I have created a separate issue #379 for the gosec problem and currently disabled it, as it was not a direct result of this PR (out of memory problem). So will merge this PR.

@objectiser objectiser merged commit 9ff5bb7 into jaegertracing:master Apr 26, 2019
@objectiser objectiser deleted the esclean branch April 26, 2019 15:04
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