-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Add etcdmigration e2e test #12528
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
Add etcdmigration e2e test #12528
Conversation
f105544
to
7ad28bf
Compare
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.
Looks good, just needs some function swaps.
// StartK3sWithSQLite starts K3s with SQLite as the datastore | ||
func StartK3sWithSQLite(nodes []e2e.VagrantNode) error { | ||
for _, node := range nodes { | ||
var startCmd string | ||
if strings.Contains(node.String(), "server") { | ||
startCmd = "systemctl start k3s" | ||
} else { | ||
startCmd = "systemctl start k3s-agent" | ||
} | ||
if _, err := node.RunCmdOnNode(startCmd); err != nil { | ||
return &e2e.NodeError{Node: node, Cmd: startCmd, Err: err} | ||
} | ||
} | ||
return nil | ||
} |
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.
You don't need to do this, the startup test you copied this from is special. The regular create cluster functions can handle starting k3s.
See https://github.com/k3s-io/k3s/blob/master/tests/e2e/embeddedmirror/embeddedmirror_test.go#L40-L53 for a better example of what you should use.
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.
Thanks for your advice.
func MigrateToEtcd(server e2e.VagrantNode) error { | ||
// Stop K3s service | ||
stopCmd := "systemctl stop k3s" | ||
if _, err := server.RunCmdOnNode(stopCmd); err != nil { | ||
return &e2e.NodeError{Node: server, Cmd: stopCmd, Err: err} | ||
} | ||
|
||
// Update config to use etcd | ||
configCmd := "echo 'cluster-init: true' >> /etc/rancher/k3s/config.yaml" | ||
if _, err := server.RunCmdOnNode(configCmd); err != nil { | ||
return &e2e.NodeError{Node: server, Cmd: configCmd, Err: err} | ||
} | ||
|
||
// Start K3s with etcd | ||
startCmd := "systemctl start k3s" | ||
if _, err := server.RunCmdOnNode(startCmd); err != nil { | ||
return &e2e.NodeError{Node: server, Cmd: startCmd, Err: err} | ||
} |
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.
Since the config.yaml is not hot loaded, you can just append to the config, then restart k3s on each node using the buildin e2e.RestartCluster. See https://github.com/k3s-io/k3s/blob/master/tests/e2e/rotateca/rotateca_test.go#L82-L88 as an example.
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.
This is indeed better.
} | ||
|
||
// KillK3sCluster kills the K3s cluster | ||
func KillK3sCluster(nodes []e2e.VagrantNode) error { |
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.
We should move this function inside the e2e testutils.go file and call that for both startup and this new test function. Probably before this function.
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.
done
Expect(result).To(ContainSubstring("before-migration")) | ||
}) | ||
|
||
It("Kills the cluster", func() { |
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.
Nit: no need to kill the cluster, the next step is to cleanup and destroy everything in AfterSuite.
Could this just go in with the rest of the startup tests? |
7ad28bf
to
32db248
Compare
I've integrated the etcd migration-related e2e tests into the startup tests. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #12528 +/- ##
===========================================
- Coverage 40.52% 19.91% -20.62%
===========================================
Files 187 184 -3
Lines 19330 19265 -65
===========================================
- Hits 7834 3836 -3998
- Misses 10307 14997 +4690
+ Partials 1189 432 -757
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
53a5eda
to
40159a9
Compare
40159a9
to
9fedc75
Compare
Signed-off-by: bo.jiang <[email protected]>
9fedc75
to
f059a99
Compare
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.
thanks!
Proposed Changes
This PR adds a new e2e test to verify SQLite to etcd datastore migration functionality. The test:
Types of Changes
New Feature
Linked Issues
#12507
User-Facing Change