2022-02-05 01:22:53 +00:00
|
|
|
package containers
|
2022-02-03 00:31:47 +00:00
|
|
|
|
|
|
|
import (
|
2022-02-07 16:00:16 +00:00
|
|
|
"os"
|
2022-02-03 00:31:47 +00:00
|
|
|
"testing"
|
2022-02-06 00:40:04 +00:00
|
|
|
"time"
|
2022-02-03 00:31:47 +00:00
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
2022-02-07 16:00:16 +00:00
|
|
|
func getTestDockerSock() string {
|
|
|
|
dockerSocket := os.Getenv("DOCKER_SOCKET")
|
|
|
|
if dockerSocket == "" {
|
|
|
|
return "unix:///run/user/1000/podman/podman.sock"
|
|
|
|
}
|
|
|
|
return dockerSocket
|
|
|
|
}
|
|
|
|
|
2022-02-03 00:31:47 +00:00
|
|
|
func TestGetProcesses(t *testing.T) {
|
|
|
|
driver := Driver{
|
2022-02-07 16:00:16 +00:00
|
|
|
DockerSock: getTestDockerSock(),
|
2022-02-03 00:31:47 +00:00
|
|
|
BindIPHTTP: "127.0.0.1",
|
|
|
|
BindIPSSH: "127.0.0.1",
|
|
|
|
}
|
|
|
|
|
|
|
|
driver.Remove("test")
|
|
|
|
|
|
|
|
_, err := driver.Create("test", "docker.io/library/busybox", "/tmp", 8990, 8922, 1, 128, []string{"sleep", "3600"})
|
|
|
|
assert.Nil(t, err)
|
|
|
|
|
|
|
|
err = driver.Start("test")
|
|
|
|
assert.Nil(t, err)
|
|
|
|
|
2022-02-06 00:40:04 +00:00
|
|
|
time.Sleep(5 * time.Second)
|
|
|
|
|
2022-02-03 00:31:47 +00:00
|
|
|
processes, err := driver.GetProcesses("test")
|
|
|
|
assert.Nil(t, err)
|
|
|
|
assert.Contains(t, processes, "sleep 3600")
|
|
|
|
|
|
|
|
driver.Remove("test")
|
|
|
|
}
|