Repository: k3s-io/k3s
File: tests/e2e/startup/startup_test.go (Go)

Code before:
			}, "480s", "10s").Should(Succeed())
			e2e.DumpPods(tc.KubeconfigFile)
		})

		It("Creates test resources before migration", func() {
			createCmd := "kubectl create configmap migration-test --from-literal=test=before-migration"
			_, err := tc.Servers[0].RunCmdOnNode(createCmd)
			Expect(err).NotTo(HaveOccurred())

			getCmd := "kubectl get configmap migration-test -o jsonpath='{.data.test}'"
			result, err := tc.Servers[0].RunCmdOnNode(getCmd)
			Expect(err).NotTo(HaveOccurred())
			Expect(result).To(ContainSubstring("before-migration"))
		})

		It("Migrates from SQLite to etcd", func() {
			configCmd := "echo 'cluster-init: true' >> /etc/rancher/k3s/config.yaml"
			_, err := tc.Servers[0].RunCmdOnNode(configCmd)
			Expect(err).NotTo(HaveOccurred())

			Expect(e2e.RestartCluster(tc.Servers)).To(Succeed())
			Expect(e2e.RestartCluster(tc.Agents)).To(Succeed())

			Eventually(func() (string, error) {
				return tc.Servers[0].RunCmdOnNode("journalctl -u k3s --no-pager | grep -i 'datastore-etcd'")
			}, "120s", "5s").Should(ContainSubstring("datastore-etcd"))
		})

		It("Checks node and pod status after migration", func() {
			By("Fetching node status after migration")
			Eventually(func() error {
				return tests.NodesReady(tc.KubeconfigFile, e2e.VagrantSlice(tc.AllNodes()))
			}, "600s", "5s").Should(Succeed())
			Eventually(func() error {
				return tests.AllPodsUp(tc.KubeconfigFile)
			}, "600s", "5s").Should(Succeed())
			Eventually(func() error {
				return tests.CheckDefaultDeployments(tc.KubeconfigFile)
			}, "480s", "10s").Should(Succeed())
			e2e.DumpPods(tc.KubeconfigFile)
		})

		It("Verifies data persistence after migration", func() {
			getCmd := "kubectl get configmap migration-test -o jsonpath='{.data.test}'"
			result, err := tc.Servers[0].RunCmdOnNode(getCmd)
			Expect(err).NotTo(HaveOccurred())
			Expect(result).To(ContainSubstring("before-migration"))
		})

		It("Kills the cluster", func() {
			err := e2e.KillK3sCluster(tc.AllNodes())

Review comment (suggestion):
I'm not familiar with the string you're checking for here is, but I think that rather than searching logs, the correct thing to do would be to confirm that the server nodes now have the `etcd` node-role label.

Code after:
		})

		It("Creates test resources before migration", func() {
			createCmd := "kubectl create configmap migration-test --from-literal=test=before-migration"
			_, err := tc.Servers[0].RunCmdOnNode(createCmd)
			Expect(err).NotTo(HaveOccurred())

			getCmd := "kubectl get configmap migration-test -o jsonpath='{.data.test}'"
			result, err := tc.Servers[0].RunCmdOnNode(getCmd)
			Expect(err).NotTo(HaveOccurred())
			Expect(result).To(ContainSubstring("before-migration"))
		})

		It("Migrates from SQLite to etcd", func() {
			configCmd := "echo 'cluster-init: true' >> /etc/rancher/k3s/config.yaml"
			_, err := tc.Servers[0].RunCmdOnNode(configCmd)
			Expect(err).NotTo(HaveOccurred())

			Expect(e2e.RestartCluster(tc.Servers)).To(Succeed())
			Expect(e2e.RestartCluster(tc.Agents)).To(Succeed())

			Eventually(func() (string, error) {
				cmd := "kubectl get nodes -l node-role.kubernetes.io/etcd=true"
				return tc.Servers[0].RunCmdOnNode(cmd)
			}, "120s", "5s").Should(ContainSubstring(tc.Servers[0].String()))
		})

		It("Checks node and pod status after migration", func() {
			By("Fetching node status after migration")
			Eventually(func() error {
				return tests.NodesReady(tc.KubeconfigFile, e2e.VagrantSlice(tc.AllNodes()))
			}, "600s", "5s").Should(Succeed())
			Eventually(func() error {
				return tests.AllPodsUp(tc.KubeconfigFile)
			}, "600s", "5s").Should(Succeed())
			Eventually(func() error {
				return tests.CheckDefaultDeployments(tc.KubeconfigFile)
			}, "480s", "10s").Should(Succeed())
			e2e.DumpPods(tc.KubeconfigFile)
		})

		It("Verifies data persistence after migration", func() {
			getCmd := "kubectl get configmap migration-test -o jsonpath='{.data.test}'"
			result, err := tc.Servers[0].RunCmdOnNode(getCmd)
			Expect(err).NotTo(HaveOccurred())
			Expect(result).To(ContainSubstring("before-migration"))
		})

		It("Kills the cluster", func() {
			err := e2e.KillK3sCluster(tc.AllNodes())
			Expect(err).NotTo(HaveOccurred())