mirror of
https://github.com/containers/podman.git
synced 2026-07-11 15:55:22 -04:00
test/e2e: use Ginkgo Setenv in info tests
Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
@@ -66,10 +66,7 @@ var _ = Describe("Podman Info", func() {
|
||||
SkipIfNotRootless("test of rootless_storage_path is only meaningful as rootless")
|
||||
SkipIfRemote("Only tests storage on local client")
|
||||
configPath := filepath.Join(podmanTest.TempDir, ".config", "containers", "storage.conf")
|
||||
os.Setenv("CONTAINERS_STORAGE_CONF", configPath)
|
||||
defer func() {
|
||||
os.Unsetenv("CONTAINERS_STORAGE_CONF")
|
||||
}()
|
||||
GinkgoT().Setenv("CONTAINERS_STORAGE_CONF", configPath)
|
||||
err := os.RemoveAll(filepath.Dir(configPath))
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
||||
@@ -150,7 +147,7 @@ var _ = Describe("Podman Info", func() {
|
||||
It("Podman info: check default network from configuration", func() {
|
||||
configPath := filepath.Join(podmanTest.TempDir, "containers.conf")
|
||||
|
||||
os.Setenv("CONTAINERS_CONF_OVERRIDE", configPath)
|
||||
GinkgoT().Setenv("CONTAINERS_CONF_OVERRIDE", configPath)
|
||||
|
||||
customNetName := "my-custom-test-network"
|
||||
configContent := fmt.Sprintf("[network]\ndefault_network=%q\n", customNetName)
|
||||
@@ -165,8 +162,7 @@ var _ = Describe("Podman Info", func() {
|
||||
|
||||
It("Podman info: check CDI spec dirs and devices from configuration", func() {
|
||||
cdiDir := filepath.Join(podmanTest.TempDir, "cdi")
|
||||
err := os.MkdirAll(cdiDir, os.ModePerm)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(os.MkdirAll(cdiDir, os.ModePerm)).To(Succeed())
|
||||
|
||||
cdiSpec := []byte(`{
|
||||
"cdiVersion": "0.3.0",
|
||||
@@ -180,12 +176,11 @@ var _ = Describe("Podman Info", func() {
|
||||
}
|
||||
]
|
||||
}`)
|
||||
err = os.WriteFile(filepath.Join(cdiDir, "device.json"), cdiSpec, os.ModePerm)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(os.WriteFile(filepath.Join(cdiDir, "device.json"), cdiSpec, os.ModePerm)).To(Succeed())
|
||||
|
||||
configPath := filepath.Join(podmanTest.TempDir, "containers.conf")
|
||||
configContent := fmt.Sprintf("[engine]\ncdi_spec_dirs = [%q]\n", cdiDir)
|
||||
err = os.WriteFile(configPath, []byte(configContent), os.ModePerm)
|
||||
err := os.WriteFile(configPath, []byte(configContent), os.ModePerm)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
||||
GinkgoT().Setenv("CONTAINERS_CONF_OVERRIDE", configPath)
|
||||
@@ -197,6 +192,35 @@ var _ = Describe("Podman Info", func() {
|
||||
Expect(session.OutputToString()).To(ContainSubstring("vendor.com/device=myKmsg"))
|
||||
})
|
||||
|
||||
It("Podman info: check CDI spec dirs and devices with --cdi-spec-dir", func() {
|
||||
SkipIfRemote("The --cdi-spec-dir flag is not supported for remote")
|
||||
|
||||
cdiDir := filepath.Join(podmanTest.TempDir, "cdi")
|
||||
Expect(os.MkdirAll(cdiDir, os.ModePerm)).To(Succeed())
|
||||
|
||||
cdiSpec := []byte(`{
|
||||
"cdiVersion": "0.3.0",
|
||||
"kind": "vendor.com/device",
|
||||
"devices": [
|
||||
{
|
||||
"name": "myKmsg",
|
||||
"containerEdits": {
|
||||
"env": ["PODMAN_CDI_INFO_TEST=1"]
|
||||
}
|
||||
}
|
||||
]
|
||||
}`)
|
||||
Expect(os.WriteFile(filepath.Join(cdiDir, "device.json"), cdiSpec, os.ModePerm)).To(Succeed())
|
||||
|
||||
session := podmanTest.PodmanExitCleanly("--cdi-spec-dir", cdiDir, "info", "--format", "{{.Host.CDISpecDirs}} {{.Host.DiscoveredDevices}}")
|
||||
Expect(session.OutputToString()).To(ContainSubstring(cdiDir))
|
||||
Expect(session.OutputToString()).To(ContainSubstring("vendor.com/device=myKmsg"))
|
||||
|
||||
session = podmanTest.PodmanExitCleanly("--cdi-spec-dir", cdiDir, "system", "info", "--format", "{{.Host.CDISpecDirs}} {{.Host.DiscoveredDevices}}")
|
||||
Expect(session.OutputToString()).To(ContainSubstring(cdiDir))
|
||||
Expect(session.OutputToString()).To(ContainSubstring("vendor.com/device=myKmsg"))
|
||||
})
|
||||
|
||||
It("Podman info: check desired storage driver", func() {
|
||||
// defined in .cirrus.yml
|
||||
want := os.Getenv("CI_DESIRED_STORAGE")
|
||||
|
||||
@@ -62,37 +62,6 @@ store.imageStore.number | 1
|
||||
done < <(parse_table "$tests")
|
||||
}
|
||||
|
||||
@test "podman info - CDI spec dirs and devices" {
|
||||
skip_if_remote "--cdi-spec-dir flag is not supported for remote"
|
||||
|
||||
cdi_dir=$PODMAN_TMPDIR/cdi
|
||||
mkdir -p "$cdi_dir"
|
||||
cat >"$cdi_dir/device.json" <<EOF
|
||||
{
|
||||
"cdiVersion": "0.3.0",
|
||||
"kind": "vendor.com/device",
|
||||
"devices": [
|
||||
{
|
||||
"name": "myKmsg",
|
||||
"containerEdits": {
|
||||
"env": ["PODMAN_CDI_INFO_TEST=1"]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
EOF
|
||||
|
||||
run_podman --cdi-spec-dir "$cdi_dir" info --format=json
|
||||
cdi_spec_dirs=$(echo "$output" | jq -r '.host.cdiSpecDirs[]')
|
||||
cdi_devices=$(echo "$output" | jq -r '.host.discoveredDevices[] | select(.source == "cdi") | .id')
|
||||
assert "$cdi_spec_dirs" =~ "$cdi_dir" "info includes configured CDI spec dir"
|
||||
assert "$cdi_devices" =~ "vendor.com/device=myKmsg" "info includes resolved CDI device"
|
||||
|
||||
run_podman --cdi-spec-dir "$cdi_dir" system info --format '{{.Host.CDISpecDirs}} {{.Host.DiscoveredDevices}}'
|
||||
assert "$output" =~ "$cdi_dir" "system info includes configured CDI spec dir"
|
||||
assert "$output" =~ "vendor.com/device=myKmsg" "system info includes resolved CDI device"
|
||||
}
|
||||
|
||||
@test "podman info - confirm desired runtime" {
|
||||
if [[ -z "$CI_DESIRED_RUNTIME" ]]; then
|
||||
# When running in Cirrus, CI_DESIRED_RUNTIME *must* be defined
|
||||
|
||||
Reference in New Issue
Block a user