virtcontainers/sandbox: support new persist API

Fix sandbox implementation and unit tests to support the new persist API

Signed-off-by: Julio Montes <julio.montes@intel.com>
This commit is contained in:
Julio Montes 2020-01-31 20:41:56 +00:00
parent 4b9ab557c8
commit 00307a70ee
4 changed files with 8 additions and 8 deletions

View File

@ -451,7 +451,7 @@ func (c *Container) Restore() error {
}
func loadSandboxConfig(id string) (*SandboxConfig, error) {
store, err := persist.GetDriver("fs")
store, err := persist.GetDriver()
if err != nil || store == nil {
return nil, errors.New("failed to get fs persist driver")
}

View File

@ -37,7 +37,7 @@ func TestSandboxRestore(t *testing.T) {
config: &sconfig,
}
sandbox.newStore, err = persist.GetDriver("fs")
sandbox.newStore, err = persist.GetDriver()
assert.NoError(err)
assert.NotNil(sandbox.newStore)

View File

@ -538,7 +538,7 @@ func newSandbox(ctx context.Context, sandboxConfig SandboxConfig, factory Factor
ctx: ctx,
}
if s.newStore, err = persist.GetDriver("fs"); err != nil || s.newStore == nil {
if s.newStore, err = persist.GetDriver(); err != nil || s.newStore == nil {
return nil, fmt.Errorf("failed to get fs persist driver: %v", err)
}
@ -622,7 +622,7 @@ func (s *Sandbox) storeSandbox() error {
}
func rLockSandbox(sandboxID string) (func() error, error) {
store, err := persist.GetDriver("fs")
store, err := persist.GetDriver()
if err != nil {
return nil, fmt.Errorf("failed to get fs persist driver: %v", err)
}
@ -631,7 +631,7 @@ func rLockSandbox(sandboxID string) (func() error, error) {
}
func rwLockSandbox(sandboxID string) (func() error, error) {
store, err := persist.GetDriver("fs")
store, err := persist.GetDriver()
if err != nil {
return nil, fmt.Errorf("failed to get fs persist driver: %v", err)
}

View File

@ -990,7 +990,7 @@ func TestDeleteStoreWhenNewContainerFail(t *testing.T) {
}
_, err = newContainer(p, &contConfig)
assert.NotNil(t, err, "New container with invalid device info should fail")
storePath := filepath.Join(fs.RunStoragePath(), testSandboxID, contID)
storePath := filepath.Join(p.newStore.RunStoragePath(), testSandboxID, contID)
_, err = os.Stat(storePath)
assert.NotNil(t, err, "Should delete configuration root after failed to create a container")
}
@ -1160,7 +1160,7 @@ func TestAttachBlockDevice(t *testing.T) {
}
// create state file
path := filepath.Join(fs.RunStoragePath(), testSandboxID, container.ID())
path := filepath.Join(fs.MockRunStoragePath(), testSandboxID, container.ID())
err := os.MkdirAll(path, DirMode)
assert.NoError(t, err)
@ -1238,7 +1238,7 @@ func TestPreAddDevice(t *testing.T) {
container.state.State = types.StateReady
// create state file
path := filepath.Join(fs.RunStoragePath(), testSandboxID, container.ID())
path := filepath.Join(fs.MockRunStoragePath(), testSandboxID, container.ID())
err := os.MkdirAll(path, DirMode)
assert.NoError(t, err)