mirror of
https://github.com/containers/podman.git
synced 2025-12-05 12:52:12 +08:00
Merge pull request #15437 from mheon/default_volume_timeout
Add support for containers.conf volume timeouts
This commit is contained in:
@@ -61,6 +61,8 @@ no_hosts=true
|
||||
network_cmd_options=["allow_host_loopback=true"]
|
||||
service_timeout=1234
|
||||
|
||||
volume_plugin_timeout = 15
|
||||
|
||||
# We need to ensure each test runs on a separate plugin instance...
|
||||
# For now, let's just make a bunch of plugin paths and have each test use one.
|
||||
[engine.volume_plugins]
|
||||
|
||||
@@ -162,19 +162,4 @@ var _ = Describe("Podman volume create", func() {
|
||||
Expect(inspectOpts).Should(Exit(0))
|
||||
Expect(inspectOpts.OutputToString()).To(Equal(optionStrFormatExpect))
|
||||
})
|
||||
|
||||
It("podman create volume with o=timeout", func() {
|
||||
volName := "testVol"
|
||||
timeout := 10
|
||||
timeoutStr := "10"
|
||||
session := podmanTest.Podman([]string{"volume", "create", "--opt", fmt.Sprintf("o=timeout=%d", timeout), volName})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(Exit(0))
|
||||
|
||||
inspectTimeout := podmanTest.Podman([]string{"volume", "inspect", "--format", "{{ .Timeout }}", volName})
|
||||
inspectTimeout.WaitWithDefaultTimeout()
|
||||
Expect(inspectTimeout).Should(Exit(0))
|
||||
Expect(inspectTimeout.OutputToString()).To(Equal(timeoutStr))
|
||||
|
||||
})
|
||||
})
|
||||
|
||||
@@ -256,4 +256,38 @@ Removed:
|
||||
Expect(session.OutputToStringArray()).To(ContainElements(localvol, vol2))
|
||||
Expect(session.ErrorToString()).To(Equal("")) // make no errors are shown
|
||||
})
|
||||
|
||||
It("volume driver timeouts test", func() {
|
||||
podmanTest.AddImageToRWStore(volumeTest)
|
||||
|
||||
pluginStatePath := filepath.Join(podmanTest.TempDir, "volumes")
|
||||
err := os.Mkdir(pluginStatePath, 0755)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
||||
// Keep this distinct within tests to avoid multiple tests using the same plugin.
|
||||
pluginName := "testvol6"
|
||||
plugin := podmanTest.Podman([]string{"run", "--security-opt", "label=disable", "-v", "/run/docker/plugins:/run/docker/plugins", "-v", fmt.Sprintf("%v:%v", pluginStatePath, pluginStatePath), "-d", volumeTest, "--sock-name", pluginName, "--path", pluginStatePath})
|
||||
plugin.WaitWithDefaultTimeout()
|
||||
Expect(plugin).Should(Exit(0))
|
||||
|
||||
volName := "testVolume1"
|
||||
create := podmanTest.Podman([]string{"volume", "create", "--driver", pluginName, volName})
|
||||
create.WaitWithDefaultTimeout()
|
||||
Expect(create).Should(Exit(0))
|
||||
|
||||
volInspect := podmanTest.Podman([]string{"volume", "inspect", "--format", "{{ .Timeout }}", volName})
|
||||
volInspect.WaitWithDefaultTimeout()
|
||||
Expect(volInspect).Should(Exit(0))
|
||||
Expect(volInspect.OutputToString()).To(ContainSubstring("15"))
|
||||
|
||||
volName2 := "testVolume2"
|
||||
create2 := podmanTest.Podman([]string{"volume", "create", "--driver", pluginName, "--opt", "o=timeout=3", volName2})
|
||||
create2.WaitWithDefaultTimeout()
|
||||
Expect(create2).Should(Exit(0))
|
||||
|
||||
volInspect2 := podmanTest.Podman([]string{"volume", "inspect", "--format", "{{ .Timeout }}", volName2})
|
||||
volInspect2.WaitWithDefaultTimeout()
|
||||
Expect(volInspect2).Should(Exit(0))
|
||||
Expect(volInspect2.OutputToString()).To(ContainSubstring("3"))
|
||||
})
|
||||
})
|
||||
|
||||
@@ -25,5 +25,5 @@ func getPluginName(pathOrName string) string {
|
||||
func getPlugin(sockNameOrPath string) (*plugin.VolumePlugin, error) {
|
||||
path := getSocketPath(sockNameOrPath)
|
||||
name := getPluginName(sockNameOrPath)
|
||||
return plugin.GetVolumePlugin(name, path, 0)
|
||||
return plugin.GetVolumePlugin(name, path, nil, nil)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user