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

e2e index cleaner tests improvements #1331

Merged
merged 6 commits into from
Dec 10, 2020

Conversation

jkandasa
Copy link
Member

@jkandasa jkandasa commented Dec 4, 2020

Changes summary:

  • Generates spans/services data for 45 days, generates 45 days indices
  • runs index cleaner tests with different day limits (numberOfDays), 45, 30, 7, 1, 0 days
  • Verifies the indices were removed
  • Verifies there are no past indices
  • Verifies index prefix
  • all the tests on production environment

Signed-off-by: Jeeva Kandasamy <jkandasa@gmail.com>
Signed-off-by: Jeeva Kandasamy <jkandasa@gmail.com>
@jkandasa
Copy link
Member Author

jkandasa commented Dec 4, 2020

@kevinearls @jpkrohling @objectiser kindly review the changes

@codecov
Copy link

codecov bot commented Dec 4, 2020

Codecov Report

Merging #1331 (abd1f0e) into master (3160523) will decrease coverage by 1.38%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1331      +/-   ##
==========================================
- Coverage   87.41%   86.02%   -1.39%     
==========================================
  Files          89       90       +1     
  Lines        5021     5125     +104     
==========================================
+ Hits         4389     4409      +20     
- Misses        467      548      +81     
- Partials      165      168       +3     
Impacted Files Coverage Δ
pkg/apis/jaegertracing/v1/logger.go 0.00% <0.00%> (ø)
pkg/controller/deployment/deployment_controller.go 19.04% <0.00%> (ø)

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 3160523...abd1f0e. Read the comment docs.

Signed-off-by: Jeeva Kandasamy <jkandasa@gmail.com>
@kevinearls
Copy link
Contributor

@jkandasa Is this something we need to do on a per PR basis? If not it might be better to move this to its own test suite (like elasticsearch_index_tests.go) and only run it on an as needed basis.

Copy link
Contributor

@kevinearls kevinearls left a comment

Choose a reason for hiding this comment

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

I've added a bunch of comments, but they're mostly nits or some refactoring which I think could make the code easier to follow.

// Run the smoke test so indices will be created
AllInOneSmokeTest(jaegerInstanceName)
// executes index cleaner tests
func (suite *ElasticSearchTestSuite) runIndexCleaner(esIndexPrefix string, daysRange []int) {
Copy link
Contributor

Choose a reason for hiding this comment

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

At 175 lines this function is really long. I don't think we have a rule, but it would be good to keep things short enough to fit on a screen. I will recommend some changes below.

AllInOneSmokeTest(jaegerInstanceName)
// function to get indices
// returns in order: serviceIndices, spansIndices
getIndices := func() ([]esIndexData, []esIndexData) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I would recommend defining this as func getIndices() outside of this test function.

// Once we've created a span with the smoke test, enable the index cleaner
turnOnEsIndexCleaner(jaegerInstance)
// function to validate indices
assertIndex := func(indices []esIndexData, verifyDateAfter time.Time, count int) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be a good idea to extract this too.

// generate spans and service for last 45 days
currentDate := time.Now()
indexDateLayout := "2006-01-02"
// enable port forward for collector port
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: the comment isn't necessary as the log message says the same thing.

stringDate := spanDate.Format(indexDateLayout)
// get tracing client
serviceName := fmt.Sprintf("%s_%s", jaegerInstanceName, stringDate)
tracer, closer, err := getTracerClientWithCollectorEndpoint(serviceName, fmt.Sprintf("http://localhost:%d/api/traces", localPortColl))
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this is a tracing client and not a tracer, I would call it tracingClient.

// Now make sure indices have been deleted
indexWithPrefixExists("jaeger-", false, esNamespace)
// trigger the index cleaner for multiple day range and verify indices
for _, verifyDays := range daysRange {
Copy link
Contributor

Choose a reason for hiding this comment

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

Finally this block (i.e. the for loop) could be extracted to its own method.

localPortColl := colPorts[0].Local

logrus.Infof("Generating spans and services for the last %d days", indexHistoryDays)
for day := 0; day < indexHistoryDays; day++ {
Copy link
Contributor

Choose a reason for hiding this comment

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

This for loop could be put in its own function

// update and trigger index cleaner job
turnOnEsIndexCleaner(jaegerInstance, verifyDays)

// get servies and spans indices
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: get services and spans indices

func (suite *ElasticSearchTestSuite) TestEsIndexCleaner() {
// update jaeger CR with index cleaner specifications
indexHistoryDays := 45 // maximum number of days to generate spans and services
numberOfDays = indexHistoryDays
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't this redundant?

updateOptions := make(map[string]interface{})
for key, value := range options {
updateOptions[key] = value
// update es node namespace and es node url into jaeger CR for external es deployment
Copy link
Contributor

Choose a reason for hiding this comment

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

This comment doesn't really make it clear what your doing here. I think something like this might be better:
// If there is an external es deployment use it instead of creating a self prov one

Signed-off-by: Jeeva Kandasamy <jkandasa@gmail.com>
@jkandasa
Copy link
Member Author

jkandasa commented Dec 9, 2020

@kevinearls Thanks for the review comments. I am working on the required changes.

Signed-off-by: Jeeva Kandasamy <jkandasa@gmail.com>
Signed-off-by: Jeeva Kandasamy <jkandasa@gmail.com>
@jkandasa
Copy link
Member Author

jkandasa commented Dec 9, 2020

@kevinearls can you review the changes? Looks like a delay abd1f0e fixes the e2e test failure in github ci environment

Copy link
Contributor

@kevinearls kevinearls left a comment

Choose a reason for hiding this comment

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

LGTM

@objectiser
Copy link
Contributor

@jpkrohling Will merge this, as hasn't contributed to the project codecov drop, but looks like the deployment_controller test coverage needs to be improved.

@objectiser objectiser merged commit 9cf7150 into jaegertracing:master Dec 10, 2020
@jkandasa jkandasa deleted the index-cleaner-e2e branch December 10, 2020 10:30
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.

3 participants