tests: Refactors PodSandbox creation
Most of the tests creating and using Pod Sandboxes in the same way. We can create a common function that will do that for us, so we can have less duplicated code, and make it easier to add new tests in the future. Signed-off-by: Claudiu Belu <cbelu@cloudbasesolutions.com>
This commit is contained in:
@@ -28,19 +28,12 @@ import (
|
||||
)
|
||||
|
||||
func TestImageFSInfo(t *testing.T) {
|
||||
config := PodSandboxConfig("running-pod", "imagefs")
|
||||
t.Logf("Create a sandbox to make sure there is an active snapshot")
|
||||
PodSandboxConfigWithCleanup(t, "running-pod", "imagefs")
|
||||
|
||||
t.Logf("Pull an image to make sure image fs is not empty")
|
||||
EnsureImageExists(t, GetImage(BusyBox))
|
||||
|
||||
t.Logf("Create a sandbox to make sure there is an active snapshot")
|
||||
sb, err := runtimeService.RunPodSandbox(config, *runtimeHandler)
|
||||
require.NoError(t, err)
|
||||
defer func() {
|
||||
assert.NoError(t, runtimeService.StopPodSandbox(sb))
|
||||
assert.NoError(t, runtimeService.RemovePodSandbox(sb))
|
||||
}()
|
||||
|
||||
// It takes time to populate imagefs stats. Use eventually
|
||||
// to check for a period of time.
|
||||
t.Logf("Check imagefs info")
|
||||
@@ -66,6 +59,6 @@ func TestImageFSInfo(t *testing.T) {
|
||||
}, time.Second, 30*time.Second))
|
||||
|
||||
t.Logf("Image filesystem mountpath should exist")
|
||||
_, err = os.Stat(info.GetFsId().GetMountpoint())
|
||||
_, err := os.Stat(info.GetFsId().GetMountpoint())
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
|
Reference in New Issue
Block a user