MCPcopy
hub / github.com/containerd/containerd / TestIssue10467

Function TestIssue10467

integration/issue10467_linux_test.go:34–121  ·  view source on GitHub ↗

TestIssue10467 tests the migration of sandboxes into the proper bucket. Prior to v1.7.21, the sandboxes were stored incorrectly in the root bucket. In order to verify the migration, a v1.7.20 must run and create a sandbox, then check the migration after upgrading to a newer version.

(t *testing.T)

Source from the content-addressed store, hash-verified

32// sandboxes were stored incorrectly in the root bucket. In order to verify the migration, a v1.7.20
33// must run and create a sandbox, then check the migration after upgrading to a newer version.
34func TestIssue10467(t *testing.T) {
35 latestVersion := "v1.7.20"
36
37 releaseBinDir := t.TempDir()
38
39 downloadReleaseBinary(t, releaseBinDir, latestVersion)
40
41 t.Logf("Install config for release %s", latestVersion)
42 workDir := t.TempDir()
43 oneSevenCtrdConfig(t, releaseBinDir, workDir)
44
45 t.Log("Starting the previous release's containerd")
46 previousCtrdBinPath := filepath.Join(releaseBinDir, "bin", "containerd")
47 previousProc := newCtrdProc(t, previousCtrdBinPath, workDir, []string{"ENABLE_CRI_SANDBOXES=yes"})
48
49 boltdbPath := filepath.Join(workDir, "root", "io.containerd.metadata.v1.bolt", "meta.db")
50
51 ctrdLogPath := previousProc.logPath()
52 t.Cleanup(func() {
53 if t.Failed() {
54 dumpFileContent(t, ctrdLogPath)
55 }
56 })
57
58 require.NoError(t, previousProc.isReady())
59
60 needToCleanup := true
61 t.Cleanup(func() {
62 if t.Failed() && needToCleanup {
63 t.Logf("Try to cleanup leaky pods")
64 cleanupPods(t, previousProc.criRuntimeService(t))
65 }
66 })
67
68 t.Log("Prepare pods for current release")
69 upgradeCaseFuncs, hookFunc := shouldManipulateContainersInPodAfterUpgrade("")(t, 2, previousProc.criRuntimeService(t), previousProc.criImageService(t))
70 upgradeCaseFunc := upgradeCaseFuncs[0]
71 needToCleanup = false
72 require.Nil(t, hookFunc)
73
74 t.Log("Gracefully stop previous release's containerd process")
75 require.NoError(t, previousProc.kill(syscall.SIGTERM))
76 require.NoError(t, previousProc.wait(5*time.Minute))
77
78 t.Logf("%s should have bucket k8s.io in root", boltdbPath)
79 db, err := bbolt.Open(boltdbPath, 0600, &bbolt.Options{ReadOnly: true})
80 require.NoError(t, err)
81 require.NoError(t, db.View(func(tx *bbolt.Tx) error {
82 if tx.Bucket([]byte("k8s.io")) == nil {
83 return fmt.Errorf("expected k8s.io bucket")
84 }
85 return nil
86 }))
87 require.NoError(t, db.Close())
88
89 t.Log("Install default config for current release")
90 currentReleaseCtrdDefaultConfig(t, workDir)
91

Callers

nothing calls this directly

Calls 15

downloadReleaseBinaryFunction · 0.85
oneSevenCtrdConfigFunction · 0.85
newCtrdProcFunction · 0.85
dumpFileContentFunction · 0.85
cleanupPodsFunction · 0.85
LogMethod · 0.80
logPathMethod · 0.80
isReadyMethod · 0.80
criRuntimeServiceMethod · 0.80
criImageServiceMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…