Skip to content

add integration server tests for resources version checks #17312

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

Draft
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

endorama
Copy link
Member

Motivation/summary

Add additional integrationservertest for a recent bug affecting some upgrade paths in APM Server.

Checklist

For functional changes, consider:

  • Is it observable through the addition of either logging or metrics?
  • Is its use being published in telemetry to enable product improvement?
  • Have system tests been added to avoid regression?

How to test these changes

Related issues

endorama added 7 commits June 19, 2025 13:33
This is useful when you want to manually inspect the results even on success
This aid troubleshooting as you don't need to look into the upgrade-config.yaml
file but the indications are printed with the test
Copy link
Contributor

🤖 GitHub comments

Expand to view the GitHub comments

Just comment with:

  • run docs-build : Re-trigger the docs validation. (use unformatted text in the comment!)

Copy link
Contributor

mergify bot commented Jun 19, 2025

This pull request does not have a backport label. Could you fix it @endorama? 🙏
To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-7.17 is the label to automatically backport to the 7.17 branch.
  • backport-8./d is the label to automatically backport to the 8./d branch. /d is the digit.
  • backport-9./d is the label to automatically backport to the 9./d branch. /d is the digit.
  • backport-active-all is the label that automatically backports to all active branches.
  • backport-active-8 is the label that automatically backports to all active minor branches for the 8 major.
  • backport-active-9 is the label that automatically backports to all active minor branches for the 9 major.

Copy link
Contributor

mergify bot commented Jun 20, 2025

This pull request is now in conflicts. Could you fix it @endorama? 🙏
To fixup this pull request, you can check out it locally. See documentation: https://help.github.com/articles/checking-out-pull-requests-locally/

git fetch upstream
git checkout -b integrationserver-tests-for-bug upstream/integrationserver-tests-for-bug
git merge upstream/main
git push upstream integrationserver-tests-for-bug

endorama added 2 commits June 20, 2025 11:58
Add support for specifying patch versions in upgrade-config.yaml.
If a patch version is present will take precedence over it's own
minor version, if both are specified.

Patch version use is supported in both keys and values. This allows
to specify, for example, specific patch versions not triggering a
lazy rollover when upgrading to another patch version.

Overhauled the comments in upgrade-config.yaml to reflect this new
possibilities and clarify how to write the configuration with examples.
Other than usual bug checks we need one more to
check for event.success_count
Comment on lines 63 to 88
if len(versions) == 2 { // if 2 versions we expect the first to be bugged and the second to be not
return []testStep{
steps[0], // create
steps[1], // ingest
zeroEventIngestedDocs,
noEventIngestedInMappings,
steps[2], // upgrade
steps[3], // ingest
someEventIngestedDocs,
eventIngestedHasMappings,
}

} else if len(versions) == 3 { // if 3 versions we expect the first to be bugged on create, the second on upgrade, the third to be not
return []testStep{
steps[0], // create
steps[1], // ingest
steps[2], // upgrade
steps[3], // ingest
zeroEventIngestedDocs,
noEventIngestedInMappings,
steps[4], // upgrade
steps[5], // upgrade
someEventIngestedDocs,
eventIngestedHasMappings,
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This is definitely quite flimsy, I think having a way to tell when 1 "cycle" (create / upgrade -> ingest -> others) is done would be best. Perhaps having the cycles manually defined e.g.

[]testCycle{
    {
        createStep,
        ingestStep,
    },
    {
        upgradeStep,
        ingestStep,
     },
     ...
}

Or some other way to detect it.

Copy link
Member Author

Choose a reason for hiding this comment

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

You are suggesting to not use the buildTestStep function but create them manually so it's easier to follow the various cycles?

Copy link
Contributor

Choose a reason for hiding this comment

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

My bad I wasn't clear enough. Creating them manually works, but we can also change how steps are defined in the runner. In the example above, testCycle is essentially just: type testCycle []testStep, and demarcates where one version ends and the other starts.

In your case, since you are inserting the steps in between each "cycle", it would be much less flimsy since you can inject the steps at the end of each cycle.

Just an idea, not sure if it would work well.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah I see, I refactored it in a way that I think removes some of the ifs, but did not address this issue directly in 9874d2d (#17312)

I think there is value in doing something you propose if we decide is something we want to introduce but we should take some time to think the feature through, here I'm only interested in a quick way to have additional steps (we could also extract createStep and upgradeStep "builder" functions from the current one, so they are easier to compose, but I considered it out of scope here)


// this wraps the usual steps build to add additional checks in between.
// Is a bit brittle, maybe we should consider allowing this as a first class citizen.
buildteststepsForBug := func(t *testing.T, versions ech.Versions, config upgradeTestConfig) []testStep {
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
buildteststepsForBug := func(t *testing.T, versions ech.Versions, config upgradeTestConfig) []testStep {
buildTestStepsForBug := func(t *testing.T, versions ech.Versions, config upgradeTestConfig) []testStep {

runner.Run(t)
})

t.Run("8.18.2 to 8.18.3", func(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

If this includes start, shouldn't it be "8.16.2 to 8.17.x to 8.18.x"? Also vsCache.GetLatestSnapshot gets the latest patch for the minor if you specify x.y, so the description will be inaccurate when new patches come out.

Copy link
Member Author

Choose a reason for hiding this comment

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

I named this after our test cases for this bug. I don't think we want to merge this PR as it is, with all these test cases for all these versions. This is now useful to ensure our fixes are working but I would make it more general if we want to include it as our regular testing.

I think a necessary test case to add is an upgrade test: from the "previous previous" minor (ie in this case 8.16.2) to the previous minor and than to the current minor. Such a test could find issues that only appears with an upgrade, a scenario we don't yet cover.

}

type checkMappingStep struct {
datastreamname string
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
datastreamname string
dataStreamName string

t.Log("test failed and cleanup-on-failure is false, skipping cleanup")
}
})
if *doCleanup {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this works. The doCleanup is defined in main_test.go and so is only accessible in test files.

Copy link
Member Author

Choose a reason for hiding this comment

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

It does if you run the tests 😅 It's a quick hack for my use case.

Do you think there is value in bringing this to main? If yes I'll do a proper implementation.

Copy link
Contributor

Choose a reason for hiding this comment

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

TIL, my IDE complains that doCleanup doesn't exist 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

It's correct I'd say, mine too. I'd expect it's because it doesn't exist if you're running/compiling the go module 😅 it exists if you run the tests because _tests.go files are included in the compilation.

endorama added 3 commits June 23, 2025 12:05
Finding event.ingested in 8.17.7 already after upgrade from 8.16.2
is expected due to the changes to apm-data between the versions.
@endorama endorama mentioned this pull request Jun 23, 2025
4 tasks
endorama added 2 commits June 23, 2025 17:30
Refactor version selection to ease the move to BCs.
Don't use vsCache.GetLatestSnapshot as that will change
version as we release new ones. These tests are version specific
at the moment, so use fixed SNAPSHOT versions
Replace SNAPSHOT versions with BC or released versions.

Use SNAPSHOTS for 8.19.0 test as there is no BC version for it yet
and we cannot mix releases/BCs and SNAPSHOT versions.
version8190 := ech.NewVersion(8, 19, 0, "SNAPSHOT") // latest 8.19
version8162 := vsCache.GetLatestVersionOrSkip(t, "8.16.2")
version8177 := vsCache.GetLatestVersionOrSkip(t, "8.17.7")
version8178 := vsCache.GetLatestBCOrSkip(t, "8.17.8") // latest 8.17 as of today
Copy link
Contributor

Choose a reason for hiding this comment

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

This will skip the whole test entirely if the BC does not exist. Since both GetLatestVersionOrSkip and GetLatestBCOrSkip are not used currently, you can update them to achieve what you need instead.

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