-
Notifications
You must be signed in to change notification settings - Fork 146
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 action store -> state store migration tests #4235
Fix action store -> state store migration tests #4235
Conversation
Pinging @elastic/elastic-agent (Team:Elastic-Agent) |
…-state-store-migration-tests
…ersonQ/elastic-agent into 3912-add-state-store-migration-tests
…e-migration-tests
…-state-store-migration-tests
…ersonQ/elastic-agent into 3912-add-state-store-migration-tests
8d69a4e
to
ea73ae9
Compare
It's needed so we can set the encrypted store vault's path
Quality Gate failedFailed conditions0.0% Coverage on New Code (required ≥ 40%) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks reasonable, I am a bit surprised by the 0% new code coverage... are the tests actually running?
Moreover, I think that there's a bit of overlap with a bugfix I merged last year where I was moving unencrypted config to the new encrypted diskstores (as the agent was "forgetting" fleet config because fleet.enc
was not found), so maybe we need to clean up a bit. Here's where the bugfix is located
elastic-agent/internal/pkg/agent/cmd/run.go
Lines 194 to 206 in bdefb2c
// Migrate .yml files if the corresponding .enc does not exist | |
// the encrypted config does not exist but the unencrypted file does | |
err = migration.MigrateToEncryptedConfig(ctx, l, paths.AgentConfigYmlFile(), paths.AgentConfigFile()) | |
if err != nil { | |
return errors.New(err, "error migrating fleet config") | |
} | |
// the encrypted state does not exist but the unencrypted file does | |
err = migration.MigrateToEncryptedConfig(ctx, l, paths.AgentStateStoreYmlFile(), paths.AgentStateStoreFile()) | |
if err != nil { | |
return errors.New(err, "error migrating agent state") | |
} |
the new code is test code, which isn't covered by tests. I don't think it's calculating the overall coverage. |
As Sonarqube looks for coverage only on NEW code and all the new code is test code, it isn't calculating the overall code coverage increase. Here it's:
@pchila here it is, a 14% increase in code coverage |
@pchila, good point, it might be messing the store migration. I added a TODO on my currently WIP PR: 4926df0 |
db6c7a6
into
elastic:bugfix/3912-borken-stat-store
Fix action store -> state store migration tests (#4235) * use golden file for store migration test * remove withFile function * migrate take in a storage.Store instead of the storage's path. It's needed so we can set the encrypted store vault's path refactor state store (#4253) It modifies the state store API to match the current needs. update action model to match fleet-server schema (#4240) * simplify fleetapi.Actions.UnmarshalJSON * add test to ensure the state store is correctly loaded from disk * skip state store migration tests, they will be fixes on a follow-up PR as part of #3912 add migrations for action and state stores (#4305)
What does this PR do?
Fixes the state store migration tests so they actually run and skip them for darwin.
It also changes the migration test to use a golden file when testing the migration from the old action store to the new state store.
Finally, it removes the
withFile
function as its miss usage caused the store migration tests to not actually run.Why is it important?
error parsing version ""
if agent restarts before the upgrade starts #3912, the test would still pass. However the actual migration would not work as expected.Checklist
[ ] I have commented my code, particularly in hard-to-understand areas[ ] I have made corresponding changes to the documentation[ ] I have made corresponding change to the default configuration files[ ] I have added an entry in./changelog/fragments
using the changelog tool[ ] I have added an integration test or an E2E testRelated issues
error parsing version ""
if agent restarts before the upgrade starts #3912Questions to ask yourself