mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-29 12:14:48 +00:00
agent: Add env var tests
Add some tests for the existing `KATA_AGENT_SERVER_ADDR` environment variable feature. Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
This commit is contained in:
parent
705e995589
commit
b9c6db4bb8
@ -319,297 +319,440 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_parse_cmdline() {
|
fn test_parse_cmdline() {
|
||||||
|
const TEST_SERVER_ADDR: &str = "vsock://-1:1024";
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
struct TestData<'a> {
|
struct TestData<'a> {
|
||||||
contents: &'a str,
|
contents: &'a str,
|
||||||
|
env_vars: Vec<&'a str>,
|
||||||
debug_console: bool,
|
debug_console: bool,
|
||||||
dev_mode: bool,
|
dev_mode: bool,
|
||||||
log_level: slog::Level,
|
log_level: slog::Level,
|
||||||
hotplug_timeout: time::Duration,
|
hotplug_timeout: time::Duration,
|
||||||
container_pipe_size: i32,
|
container_pipe_size: i32,
|
||||||
|
server_addr: &'a str,
|
||||||
unified_cgroup_hierarchy: bool,
|
unified_cgroup_hierarchy: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
let tests = &[
|
let tests = &[
|
||||||
TestData {
|
TestData {
|
||||||
contents: "agent.debug_consolex agent.devmode",
|
contents: "agent.debug_consolex agent.devmode",
|
||||||
|
env_vars: Vec::new(),
|
||||||
debug_console: false,
|
debug_console: false,
|
||||||
dev_mode: true,
|
dev_mode: true,
|
||||||
log_level: DEFAULT_LOG_LEVEL,
|
log_level: DEFAULT_LOG_LEVEL,
|
||||||
hotplug_timeout: DEFAULT_HOTPLUG_TIMEOUT,
|
hotplug_timeout: DEFAULT_HOTPLUG_TIMEOUT,
|
||||||
container_pipe_size: DEFAULT_CONTAINER_PIPE_SIZE,
|
container_pipe_size: DEFAULT_CONTAINER_PIPE_SIZE,
|
||||||
|
server_addr: TEST_SERVER_ADDR,
|
||||||
unified_cgroup_hierarchy: false,
|
unified_cgroup_hierarchy: false,
|
||||||
},
|
},
|
||||||
TestData {
|
TestData {
|
||||||
contents: "agent.debug_console agent.devmodex",
|
contents: "agent.debug_console agent.devmodex",
|
||||||
|
env_vars: Vec::new(),
|
||||||
debug_console: true,
|
debug_console: true,
|
||||||
dev_mode: false,
|
dev_mode: false,
|
||||||
log_level: DEFAULT_LOG_LEVEL,
|
log_level: DEFAULT_LOG_LEVEL,
|
||||||
hotplug_timeout: DEFAULT_HOTPLUG_TIMEOUT,
|
hotplug_timeout: DEFAULT_HOTPLUG_TIMEOUT,
|
||||||
container_pipe_size: DEFAULT_CONTAINER_PIPE_SIZE,
|
container_pipe_size: DEFAULT_CONTAINER_PIPE_SIZE,
|
||||||
|
server_addr: TEST_SERVER_ADDR,
|
||||||
unified_cgroup_hierarchy: false,
|
unified_cgroup_hierarchy: false,
|
||||||
},
|
},
|
||||||
TestData {
|
TestData {
|
||||||
contents: "agent.logx=debug",
|
contents: "agent.logx=debug",
|
||||||
|
env_vars: Vec::new(),
|
||||||
debug_console: false,
|
debug_console: false,
|
||||||
dev_mode: false,
|
dev_mode: false,
|
||||||
log_level: DEFAULT_LOG_LEVEL,
|
log_level: DEFAULT_LOG_LEVEL,
|
||||||
hotplug_timeout: DEFAULT_HOTPLUG_TIMEOUT,
|
hotplug_timeout: DEFAULT_HOTPLUG_TIMEOUT,
|
||||||
container_pipe_size: DEFAULT_CONTAINER_PIPE_SIZE,
|
container_pipe_size: DEFAULT_CONTAINER_PIPE_SIZE,
|
||||||
|
server_addr: TEST_SERVER_ADDR,
|
||||||
unified_cgroup_hierarchy: false,
|
unified_cgroup_hierarchy: false,
|
||||||
},
|
},
|
||||||
TestData {
|
TestData {
|
||||||
contents: "agent.log=debug",
|
contents: "agent.log=debug",
|
||||||
|
env_vars: Vec::new(),
|
||||||
debug_console: false,
|
debug_console: false,
|
||||||
dev_mode: false,
|
dev_mode: false,
|
||||||
log_level: slog::Level::Debug,
|
log_level: slog::Level::Debug,
|
||||||
hotplug_timeout: DEFAULT_HOTPLUG_TIMEOUT,
|
hotplug_timeout: DEFAULT_HOTPLUG_TIMEOUT,
|
||||||
container_pipe_size: DEFAULT_CONTAINER_PIPE_SIZE,
|
container_pipe_size: DEFAULT_CONTAINER_PIPE_SIZE,
|
||||||
|
server_addr: TEST_SERVER_ADDR,
|
||||||
unified_cgroup_hierarchy: false,
|
unified_cgroup_hierarchy: false,
|
||||||
},
|
},
|
||||||
TestData {
|
TestData {
|
||||||
contents: "",
|
contents: "",
|
||||||
|
env_vars: Vec::new(),
|
||||||
debug_console: false,
|
debug_console: false,
|
||||||
dev_mode: false,
|
dev_mode: false,
|
||||||
log_level: DEFAULT_LOG_LEVEL,
|
log_level: DEFAULT_LOG_LEVEL,
|
||||||
hotplug_timeout: DEFAULT_HOTPLUG_TIMEOUT,
|
hotplug_timeout: DEFAULT_HOTPLUG_TIMEOUT,
|
||||||
container_pipe_size: DEFAULT_CONTAINER_PIPE_SIZE,
|
container_pipe_size: DEFAULT_CONTAINER_PIPE_SIZE,
|
||||||
|
server_addr: TEST_SERVER_ADDR,
|
||||||
unified_cgroup_hierarchy: false,
|
unified_cgroup_hierarchy: false,
|
||||||
},
|
},
|
||||||
TestData {
|
TestData {
|
||||||
contents: "foo",
|
contents: "foo",
|
||||||
|
env_vars: Vec::new(),
|
||||||
debug_console: false,
|
debug_console: false,
|
||||||
dev_mode: false,
|
dev_mode: false,
|
||||||
log_level: DEFAULT_LOG_LEVEL,
|
log_level: DEFAULT_LOG_LEVEL,
|
||||||
hotplug_timeout: DEFAULT_HOTPLUG_TIMEOUT,
|
hotplug_timeout: DEFAULT_HOTPLUG_TIMEOUT,
|
||||||
container_pipe_size: DEFAULT_CONTAINER_PIPE_SIZE,
|
container_pipe_size: DEFAULT_CONTAINER_PIPE_SIZE,
|
||||||
|
server_addr: TEST_SERVER_ADDR,
|
||||||
unified_cgroup_hierarchy: false,
|
unified_cgroup_hierarchy: false,
|
||||||
},
|
},
|
||||||
TestData {
|
TestData {
|
||||||
contents: "foo bar",
|
contents: "foo bar",
|
||||||
|
env_vars: Vec::new(),
|
||||||
debug_console: false,
|
debug_console: false,
|
||||||
dev_mode: false,
|
dev_mode: false,
|
||||||
log_level: DEFAULT_LOG_LEVEL,
|
log_level: DEFAULT_LOG_LEVEL,
|
||||||
hotplug_timeout: DEFAULT_HOTPLUG_TIMEOUT,
|
hotplug_timeout: DEFAULT_HOTPLUG_TIMEOUT,
|
||||||
container_pipe_size: DEFAULT_CONTAINER_PIPE_SIZE,
|
container_pipe_size: DEFAULT_CONTAINER_PIPE_SIZE,
|
||||||
|
server_addr: TEST_SERVER_ADDR,
|
||||||
unified_cgroup_hierarchy: false,
|
unified_cgroup_hierarchy: false,
|
||||||
},
|
},
|
||||||
TestData {
|
TestData {
|
||||||
contents: "foo bar",
|
contents: "foo bar",
|
||||||
|
env_vars: Vec::new(),
|
||||||
debug_console: false,
|
debug_console: false,
|
||||||
dev_mode: false,
|
dev_mode: false,
|
||||||
log_level: DEFAULT_LOG_LEVEL,
|
log_level: DEFAULT_LOG_LEVEL,
|
||||||
hotplug_timeout: DEFAULT_HOTPLUG_TIMEOUT,
|
hotplug_timeout: DEFAULT_HOTPLUG_TIMEOUT,
|
||||||
container_pipe_size: DEFAULT_CONTAINER_PIPE_SIZE,
|
container_pipe_size: DEFAULT_CONTAINER_PIPE_SIZE,
|
||||||
|
server_addr: TEST_SERVER_ADDR,
|
||||||
unified_cgroup_hierarchy: false,
|
unified_cgroup_hierarchy: false,
|
||||||
},
|
},
|
||||||
TestData {
|
TestData {
|
||||||
contents: "foo agent bar",
|
contents: "foo agent bar",
|
||||||
|
env_vars: Vec::new(),
|
||||||
debug_console: false,
|
debug_console: false,
|
||||||
dev_mode: false,
|
dev_mode: false,
|
||||||
log_level: DEFAULT_LOG_LEVEL,
|
log_level: DEFAULT_LOG_LEVEL,
|
||||||
hotplug_timeout: DEFAULT_HOTPLUG_TIMEOUT,
|
hotplug_timeout: DEFAULT_HOTPLUG_TIMEOUT,
|
||||||
container_pipe_size: DEFAULT_CONTAINER_PIPE_SIZE,
|
container_pipe_size: DEFAULT_CONTAINER_PIPE_SIZE,
|
||||||
|
server_addr: TEST_SERVER_ADDR,
|
||||||
unified_cgroup_hierarchy: false,
|
unified_cgroup_hierarchy: false,
|
||||||
},
|
},
|
||||||
TestData {
|
TestData {
|
||||||
contents: "foo debug_console agent bar devmode",
|
contents: "foo debug_console agent bar devmode",
|
||||||
|
env_vars: Vec::new(),
|
||||||
debug_console: false,
|
debug_console: false,
|
||||||
dev_mode: false,
|
dev_mode: false,
|
||||||
log_level: DEFAULT_LOG_LEVEL,
|
log_level: DEFAULT_LOG_LEVEL,
|
||||||
hotplug_timeout: DEFAULT_HOTPLUG_TIMEOUT,
|
hotplug_timeout: DEFAULT_HOTPLUG_TIMEOUT,
|
||||||
container_pipe_size: DEFAULT_CONTAINER_PIPE_SIZE,
|
container_pipe_size: DEFAULT_CONTAINER_PIPE_SIZE,
|
||||||
|
server_addr: TEST_SERVER_ADDR,
|
||||||
unified_cgroup_hierarchy: false,
|
unified_cgroup_hierarchy: false,
|
||||||
},
|
},
|
||||||
TestData {
|
TestData {
|
||||||
contents: "agent.debug_console",
|
contents: "agent.debug_console",
|
||||||
|
env_vars: Vec::new(),
|
||||||
debug_console: true,
|
debug_console: true,
|
||||||
dev_mode: false,
|
dev_mode: false,
|
||||||
log_level: DEFAULT_LOG_LEVEL,
|
log_level: DEFAULT_LOG_LEVEL,
|
||||||
hotplug_timeout: DEFAULT_HOTPLUG_TIMEOUT,
|
hotplug_timeout: DEFAULT_HOTPLUG_TIMEOUT,
|
||||||
container_pipe_size: DEFAULT_CONTAINER_PIPE_SIZE,
|
container_pipe_size: DEFAULT_CONTAINER_PIPE_SIZE,
|
||||||
|
server_addr: TEST_SERVER_ADDR,
|
||||||
unified_cgroup_hierarchy: false,
|
unified_cgroup_hierarchy: false,
|
||||||
},
|
},
|
||||||
TestData {
|
TestData {
|
||||||
contents: " agent.debug_console ",
|
contents: " agent.debug_console ",
|
||||||
|
env_vars: Vec::new(),
|
||||||
debug_console: true,
|
debug_console: true,
|
||||||
dev_mode: false,
|
dev_mode: false,
|
||||||
log_level: DEFAULT_LOG_LEVEL,
|
log_level: DEFAULT_LOG_LEVEL,
|
||||||
hotplug_timeout: DEFAULT_HOTPLUG_TIMEOUT,
|
hotplug_timeout: DEFAULT_HOTPLUG_TIMEOUT,
|
||||||
container_pipe_size: DEFAULT_CONTAINER_PIPE_SIZE,
|
container_pipe_size: DEFAULT_CONTAINER_PIPE_SIZE,
|
||||||
|
server_addr: TEST_SERVER_ADDR,
|
||||||
unified_cgroup_hierarchy: false,
|
unified_cgroup_hierarchy: false,
|
||||||
},
|
},
|
||||||
TestData {
|
TestData {
|
||||||
contents: "agent.debug_console foo",
|
contents: "agent.debug_console foo",
|
||||||
|
env_vars: Vec::new(),
|
||||||
debug_console: true,
|
debug_console: true,
|
||||||
dev_mode: false,
|
dev_mode: false,
|
||||||
log_level: DEFAULT_LOG_LEVEL,
|
log_level: DEFAULT_LOG_LEVEL,
|
||||||
hotplug_timeout: DEFAULT_HOTPLUG_TIMEOUT,
|
hotplug_timeout: DEFAULT_HOTPLUG_TIMEOUT,
|
||||||
container_pipe_size: DEFAULT_CONTAINER_PIPE_SIZE,
|
container_pipe_size: DEFAULT_CONTAINER_PIPE_SIZE,
|
||||||
|
server_addr: TEST_SERVER_ADDR,
|
||||||
unified_cgroup_hierarchy: false,
|
unified_cgroup_hierarchy: false,
|
||||||
},
|
},
|
||||||
TestData {
|
TestData {
|
||||||
contents: " agent.debug_console foo",
|
contents: " agent.debug_console foo",
|
||||||
|
env_vars: Vec::new(),
|
||||||
debug_console: true,
|
debug_console: true,
|
||||||
dev_mode: false,
|
dev_mode: false,
|
||||||
log_level: DEFAULT_LOG_LEVEL,
|
log_level: DEFAULT_LOG_LEVEL,
|
||||||
hotplug_timeout: DEFAULT_HOTPLUG_TIMEOUT,
|
hotplug_timeout: DEFAULT_HOTPLUG_TIMEOUT,
|
||||||
container_pipe_size: DEFAULT_CONTAINER_PIPE_SIZE,
|
container_pipe_size: DEFAULT_CONTAINER_PIPE_SIZE,
|
||||||
|
server_addr: TEST_SERVER_ADDR,
|
||||||
unified_cgroup_hierarchy: false,
|
unified_cgroup_hierarchy: false,
|
||||||
},
|
},
|
||||||
TestData {
|
TestData {
|
||||||
contents: "foo agent.debug_console bar",
|
contents: "foo agent.debug_console bar",
|
||||||
|
env_vars: Vec::new(),
|
||||||
debug_console: true,
|
debug_console: true,
|
||||||
dev_mode: false,
|
dev_mode: false,
|
||||||
log_level: DEFAULT_LOG_LEVEL,
|
log_level: DEFAULT_LOG_LEVEL,
|
||||||
hotplug_timeout: DEFAULT_HOTPLUG_TIMEOUT,
|
hotplug_timeout: DEFAULT_HOTPLUG_TIMEOUT,
|
||||||
container_pipe_size: DEFAULT_CONTAINER_PIPE_SIZE,
|
container_pipe_size: DEFAULT_CONTAINER_PIPE_SIZE,
|
||||||
|
server_addr: TEST_SERVER_ADDR,
|
||||||
unified_cgroup_hierarchy: false,
|
unified_cgroup_hierarchy: false,
|
||||||
},
|
},
|
||||||
TestData {
|
TestData {
|
||||||
contents: "foo agent.debug_console",
|
contents: "foo agent.debug_console",
|
||||||
|
env_vars: Vec::new(),
|
||||||
debug_console: true,
|
debug_console: true,
|
||||||
dev_mode: false,
|
dev_mode: false,
|
||||||
log_level: DEFAULT_LOG_LEVEL,
|
log_level: DEFAULT_LOG_LEVEL,
|
||||||
hotplug_timeout: DEFAULT_HOTPLUG_TIMEOUT,
|
hotplug_timeout: DEFAULT_HOTPLUG_TIMEOUT,
|
||||||
container_pipe_size: DEFAULT_CONTAINER_PIPE_SIZE,
|
container_pipe_size: DEFAULT_CONTAINER_PIPE_SIZE,
|
||||||
|
server_addr: TEST_SERVER_ADDR,
|
||||||
unified_cgroup_hierarchy: false,
|
unified_cgroup_hierarchy: false,
|
||||||
},
|
},
|
||||||
TestData {
|
TestData {
|
||||||
contents: "foo agent.debug_console ",
|
contents: "foo agent.debug_console ",
|
||||||
|
env_vars: Vec::new(),
|
||||||
debug_console: true,
|
debug_console: true,
|
||||||
dev_mode: false,
|
dev_mode: false,
|
||||||
log_level: DEFAULT_LOG_LEVEL,
|
log_level: DEFAULT_LOG_LEVEL,
|
||||||
hotplug_timeout: DEFAULT_HOTPLUG_TIMEOUT,
|
hotplug_timeout: DEFAULT_HOTPLUG_TIMEOUT,
|
||||||
container_pipe_size: DEFAULT_CONTAINER_PIPE_SIZE,
|
container_pipe_size: DEFAULT_CONTAINER_PIPE_SIZE,
|
||||||
|
server_addr: TEST_SERVER_ADDR,
|
||||||
unified_cgroup_hierarchy: false,
|
unified_cgroup_hierarchy: false,
|
||||||
},
|
},
|
||||||
TestData {
|
TestData {
|
||||||
contents: "agent.devmode",
|
contents: "agent.devmode",
|
||||||
|
env_vars: Vec::new(),
|
||||||
debug_console: false,
|
debug_console: false,
|
||||||
dev_mode: true,
|
dev_mode: true,
|
||||||
log_level: DEFAULT_LOG_LEVEL,
|
log_level: DEFAULT_LOG_LEVEL,
|
||||||
hotplug_timeout: DEFAULT_HOTPLUG_TIMEOUT,
|
hotplug_timeout: DEFAULT_HOTPLUG_TIMEOUT,
|
||||||
container_pipe_size: DEFAULT_CONTAINER_PIPE_SIZE,
|
container_pipe_size: DEFAULT_CONTAINER_PIPE_SIZE,
|
||||||
|
server_addr: TEST_SERVER_ADDR,
|
||||||
unified_cgroup_hierarchy: false,
|
unified_cgroup_hierarchy: false,
|
||||||
},
|
},
|
||||||
TestData {
|
TestData {
|
||||||
contents: " agent.devmode ",
|
contents: " agent.devmode ",
|
||||||
|
env_vars: Vec::new(),
|
||||||
debug_console: false,
|
debug_console: false,
|
||||||
dev_mode: true,
|
dev_mode: true,
|
||||||
log_level: DEFAULT_LOG_LEVEL,
|
log_level: DEFAULT_LOG_LEVEL,
|
||||||
hotplug_timeout: DEFAULT_HOTPLUG_TIMEOUT,
|
hotplug_timeout: DEFAULT_HOTPLUG_TIMEOUT,
|
||||||
container_pipe_size: DEFAULT_CONTAINER_PIPE_SIZE,
|
container_pipe_size: DEFAULT_CONTAINER_PIPE_SIZE,
|
||||||
|
server_addr: TEST_SERVER_ADDR,
|
||||||
unified_cgroup_hierarchy: false,
|
unified_cgroup_hierarchy: false,
|
||||||
},
|
},
|
||||||
TestData {
|
TestData {
|
||||||
contents: "agent.devmode foo",
|
contents: "agent.devmode foo",
|
||||||
|
env_vars: Vec::new(),
|
||||||
debug_console: false,
|
debug_console: false,
|
||||||
dev_mode: true,
|
dev_mode: true,
|
||||||
log_level: DEFAULT_LOG_LEVEL,
|
log_level: DEFAULT_LOG_LEVEL,
|
||||||
hotplug_timeout: DEFAULT_HOTPLUG_TIMEOUT,
|
hotplug_timeout: DEFAULT_HOTPLUG_TIMEOUT,
|
||||||
container_pipe_size: DEFAULT_CONTAINER_PIPE_SIZE,
|
container_pipe_size: DEFAULT_CONTAINER_PIPE_SIZE,
|
||||||
|
server_addr: TEST_SERVER_ADDR,
|
||||||
unified_cgroup_hierarchy: false,
|
unified_cgroup_hierarchy: false,
|
||||||
},
|
},
|
||||||
TestData {
|
TestData {
|
||||||
contents: " agent.devmode foo",
|
contents: " agent.devmode foo",
|
||||||
|
env_vars: Vec::new(),
|
||||||
debug_console: false,
|
debug_console: false,
|
||||||
dev_mode: true,
|
dev_mode: true,
|
||||||
log_level: DEFAULT_LOG_LEVEL,
|
log_level: DEFAULT_LOG_LEVEL,
|
||||||
hotplug_timeout: DEFAULT_HOTPLUG_TIMEOUT,
|
hotplug_timeout: DEFAULT_HOTPLUG_TIMEOUT,
|
||||||
container_pipe_size: DEFAULT_CONTAINER_PIPE_SIZE,
|
container_pipe_size: DEFAULT_CONTAINER_PIPE_SIZE,
|
||||||
|
server_addr: TEST_SERVER_ADDR,
|
||||||
unified_cgroup_hierarchy: false,
|
unified_cgroup_hierarchy: false,
|
||||||
},
|
},
|
||||||
TestData {
|
TestData {
|
||||||
contents: "foo agent.devmode bar",
|
contents: "foo agent.devmode bar",
|
||||||
|
env_vars: Vec::new(),
|
||||||
debug_console: false,
|
debug_console: false,
|
||||||
dev_mode: true,
|
dev_mode: true,
|
||||||
log_level: DEFAULT_LOG_LEVEL,
|
log_level: DEFAULT_LOG_LEVEL,
|
||||||
hotplug_timeout: DEFAULT_HOTPLUG_TIMEOUT,
|
hotplug_timeout: DEFAULT_HOTPLUG_TIMEOUT,
|
||||||
container_pipe_size: DEFAULT_CONTAINER_PIPE_SIZE,
|
container_pipe_size: DEFAULT_CONTAINER_PIPE_SIZE,
|
||||||
|
server_addr: TEST_SERVER_ADDR,
|
||||||
unified_cgroup_hierarchy: false,
|
unified_cgroup_hierarchy: false,
|
||||||
},
|
},
|
||||||
TestData {
|
TestData {
|
||||||
contents: "foo agent.devmode",
|
contents: "foo agent.devmode",
|
||||||
|
env_vars: Vec::new(),
|
||||||
debug_console: false,
|
debug_console: false,
|
||||||
dev_mode: true,
|
dev_mode: true,
|
||||||
log_level: DEFAULT_LOG_LEVEL,
|
log_level: DEFAULT_LOG_LEVEL,
|
||||||
hotplug_timeout: DEFAULT_HOTPLUG_TIMEOUT,
|
hotplug_timeout: DEFAULT_HOTPLUG_TIMEOUT,
|
||||||
container_pipe_size: DEFAULT_CONTAINER_PIPE_SIZE,
|
container_pipe_size: DEFAULT_CONTAINER_PIPE_SIZE,
|
||||||
|
server_addr: TEST_SERVER_ADDR,
|
||||||
unified_cgroup_hierarchy: false,
|
unified_cgroup_hierarchy: false,
|
||||||
},
|
},
|
||||||
TestData {
|
TestData {
|
||||||
contents: "foo agent.devmode ",
|
contents: "foo agent.devmode ",
|
||||||
|
env_vars: Vec::new(),
|
||||||
debug_console: false,
|
debug_console: false,
|
||||||
dev_mode: true,
|
dev_mode: true,
|
||||||
log_level: DEFAULT_LOG_LEVEL,
|
log_level: DEFAULT_LOG_LEVEL,
|
||||||
hotplug_timeout: DEFAULT_HOTPLUG_TIMEOUT,
|
hotplug_timeout: DEFAULT_HOTPLUG_TIMEOUT,
|
||||||
container_pipe_size: DEFAULT_CONTAINER_PIPE_SIZE,
|
container_pipe_size: DEFAULT_CONTAINER_PIPE_SIZE,
|
||||||
|
server_addr: TEST_SERVER_ADDR,
|
||||||
unified_cgroup_hierarchy: false,
|
unified_cgroup_hierarchy: false,
|
||||||
},
|
},
|
||||||
TestData {
|
TestData {
|
||||||
contents: "agent.devmode agent.debug_console",
|
contents: "agent.devmode agent.debug_console",
|
||||||
|
env_vars: Vec::new(),
|
||||||
debug_console: true,
|
debug_console: true,
|
||||||
dev_mode: true,
|
dev_mode: true,
|
||||||
log_level: DEFAULT_LOG_LEVEL,
|
log_level: DEFAULT_LOG_LEVEL,
|
||||||
hotplug_timeout: DEFAULT_HOTPLUG_TIMEOUT,
|
hotplug_timeout: DEFAULT_HOTPLUG_TIMEOUT,
|
||||||
container_pipe_size: DEFAULT_CONTAINER_PIPE_SIZE,
|
container_pipe_size: DEFAULT_CONTAINER_PIPE_SIZE,
|
||||||
|
server_addr: TEST_SERVER_ADDR,
|
||||||
unified_cgroup_hierarchy: false,
|
unified_cgroup_hierarchy: false,
|
||||||
},
|
},
|
||||||
TestData {
|
TestData {
|
||||||
contents: "agent.devmode agent.debug_console agent.hotplug_timeout=100 agent.unified_cgroup_hierarchy=a",
|
contents: "agent.devmode agent.debug_console agent.hotplug_timeout=100 agent.unified_cgroup_hierarchy=a",
|
||||||
|
env_vars: Vec::new(),
|
||||||
debug_console: true,
|
debug_console: true,
|
||||||
dev_mode: true,
|
dev_mode: true,
|
||||||
log_level: DEFAULT_LOG_LEVEL,
|
log_level: DEFAULT_LOG_LEVEL,
|
||||||
hotplug_timeout: time::Duration::from_secs(100),
|
hotplug_timeout: time::Duration::from_secs(100),
|
||||||
container_pipe_size: DEFAULT_CONTAINER_PIPE_SIZE,
|
container_pipe_size: DEFAULT_CONTAINER_PIPE_SIZE,
|
||||||
|
server_addr: TEST_SERVER_ADDR,
|
||||||
unified_cgroup_hierarchy: false,
|
unified_cgroup_hierarchy: false,
|
||||||
},
|
},
|
||||||
TestData {
|
TestData {
|
||||||
contents: "agent.devmode agent.debug_console agent.hotplug_timeout=0 agent.unified_cgroup_hierarchy=11",
|
contents: "agent.devmode agent.debug_console agent.hotplug_timeout=0 agent.unified_cgroup_hierarchy=11",
|
||||||
|
env_vars: Vec::new(),
|
||||||
debug_console: true,
|
debug_console: true,
|
||||||
dev_mode: true,
|
dev_mode: true,
|
||||||
log_level: DEFAULT_LOG_LEVEL,
|
log_level: DEFAULT_LOG_LEVEL,
|
||||||
hotplug_timeout: DEFAULT_HOTPLUG_TIMEOUT,
|
hotplug_timeout: DEFAULT_HOTPLUG_TIMEOUT,
|
||||||
container_pipe_size: DEFAULT_CONTAINER_PIPE_SIZE,
|
container_pipe_size: DEFAULT_CONTAINER_PIPE_SIZE,
|
||||||
|
server_addr: TEST_SERVER_ADDR,
|
||||||
unified_cgroup_hierarchy: true,
|
unified_cgroup_hierarchy: true,
|
||||||
},
|
},
|
||||||
TestData {
|
TestData {
|
||||||
contents: "agent.devmode agent.debug_console agent.container_pipe_size=2097152 agent.unified_cgroup_hierarchy=false",
|
contents: "agent.devmode agent.debug_console agent.container_pipe_size=2097152 agent.unified_cgroup_hierarchy=false",
|
||||||
|
env_vars: Vec::new(),
|
||||||
debug_console: true,
|
debug_console: true,
|
||||||
dev_mode: true,
|
dev_mode: true,
|
||||||
log_level: DEFAULT_LOG_LEVEL,
|
log_level: DEFAULT_LOG_LEVEL,
|
||||||
hotplug_timeout: DEFAULT_HOTPLUG_TIMEOUT,
|
hotplug_timeout: DEFAULT_HOTPLUG_TIMEOUT,
|
||||||
container_pipe_size: 2097152,
|
container_pipe_size: 2097152,
|
||||||
|
server_addr: TEST_SERVER_ADDR,
|
||||||
unified_cgroup_hierarchy: false,
|
unified_cgroup_hierarchy: false,
|
||||||
},
|
},
|
||||||
TestData {
|
TestData {
|
||||||
contents: "agent.devmode agent.debug_console agent.container_pipe_size=100 agent.unified_cgroup_hierarchy=true",
|
contents: "agent.devmode agent.debug_console agent.container_pipe_size=100 agent.unified_cgroup_hierarchy=true",
|
||||||
|
env_vars: Vec::new(),
|
||||||
debug_console: true,
|
debug_console: true,
|
||||||
dev_mode: true,
|
dev_mode: true,
|
||||||
log_level: DEFAULT_LOG_LEVEL,
|
log_level: DEFAULT_LOG_LEVEL,
|
||||||
hotplug_timeout: DEFAULT_HOTPLUG_TIMEOUT,
|
hotplug_timeout: DEFAULT_HOTPLUG_TIMEOUT,
|
||||||
container_pipe_size: 100,
|
container_pipe_size: 100,
|
||||||
|
server_addr: TEST_SERVER_ADDR,
|
||||||
unified_cgroup_hierarchy: true,
|
unified_cgroup_hierarchy: true,
|
||||||
},
|
},
|
||||||
TestData {
|
TestData {
|
||||||
contents: "agent.devmode agent.debug_console agent.container_pipe_size=0 agent.unified_cgroup_hierarchy=0",
|
contents: "agent.devmode agent.debug_console agent.container_pipe_size=0 agent.unified_cgroup_hierarchy=0",
|
||||||
|
env_vars: Vec::new(),
|
||||||
debug_console: true,
|
debug_console: true,
|
||||||
dev_mode: true,
|
dev_mode: true,
|
||||||
log_level: DEFAULT_LOG_LEVEL,
|
log_level: DEFAULT_LOG_LEVEL,
|
||||||
hotplug_timeout: DEFAULT_HOTPLUG_TIMEOUT,
|
hotplug_timeout: DEFAULT_HOTPLUG_TIMEOUT,
|
||||||
container_pipe_size: DEFAULT_CONTAINER_PIPE_SIZE,
|
container_pipe_size: DEFAULT_CONTAINER_PIPE_SIZE,
|
||||||
|
server_addr: TEST_SERVER_ADDR,
|
||||||
unified_cgroup_hierarchy: false,
|
unified_cgroup_hierarchy: false,
|
||||||
},
|
},
|
||||||
TestData {
|
TestData {
|
||||||
contents: "agent.devmode agent.debug_console agent.container_pip_siz=100 agent.unified_cgroup_hierarchy=1",
|
contents: "agent.devmode agent.debug_console agent.container_pip_siz=100 agent.unified_cgroup_hierarchy=1",
|
||||||
|
env_vars: Vec::new(),
|
||||||
debug_console: true,
|
debug_console: true,
|
||||||
dev_mode: true,
|
dev_mode: true,
|
||||||
log_level: DEFAULT_LOG_LEVEL,
|
log_level: DEFAULT_LOG_LEVEL,
|
||||||
hotplug_timeout: DEFAULT_HOTPLUG_TIMEOUT,
|
hotplug_timeout: DEFAULT_HOTPLUG_TIMEOUT,
|
||||||
container_pipe_size: DEFAULT_CONTAINER_PIPE_SIZE,
|
container_pipe_size: DEFAULT_CONTAINER_PIPE_SIZE,
|
||||||
|
server_addr: TEST_SERVER_ADDR,
|
||||||
unified_cgroup_hierarchy: true,
|
unified_cgroup_hierarchy: true,
|
||||||
},
|
},
|
||||||
|
TestData {
|
||||||
|
contents: "",
|
||||||
|
env_vars: Vec::new(),
|
||||||
|
debug_console: false,
|
||||||
|
dev_mode: false,
|
||||||
|
log_level: DEFAULT_LOG_LEVEL,
|
||||||
|
hotplug_timeout: DEFAULT_HOTPLUG_TIMEOUT,
|
||||||
|
container_pipe_size: DEFAULT_CONTAINER_PIPE_SIZE,
|
||||||
|
server_addr: TEST_SERVER_ADDR,
|
||||||
|
unified_cgroup_hierarchy: false,
|
||||||
|
},
|
||||||
|
TestData {
|
||||||
|
contents: "",
|
||||||
|
env_vars: vec!["KATA_AGENT_SERVER_ADDR=foo"],
|
||||||
|
debug_console: false,
|
||||||
|
dev_mode: false,
|
||||||
|
log_level: DEFAULT_LOG_LEVEL,
|
||||||
|
hotplug_timeout: DEFAULT_HOTPLUG_TIMEOUT,
|
||||||
|
container_pipe_size: DEFAULT_CONTAINER_PIPE_SIZE,
|
||||||
|
server_addr: "foo",
|
||||||
|
unified_cgroup_hierarchy: false,
|
||||||
|
},
|
||||||
|
TestData {
|
||||||
|
contents: "",
|
||||||
|
env_vars: vec!["KATA_AGENT_SERVER_ADDR=="],
|
||||||
|
debug_console: false,
|
||||||
|
dev_mode: false,
|
||||||
|
log_level: DEFAULT_LOG_LEVEL,
|
||||||
|
hotplug_timeout: DEFAULT_HOTPLUG_TIMEOUT,
|
||||||
|
container_pipe_size: DEFAULT_CONTAINER_PIPE_SIZE,
|
||||||
|
server_addr: "=",
|
||||||
|
unified_cgroup_hierarchy: false,
|
||||||
|
},
|
||||||
|
TestData {
|
||||||
|
contents: "",
|
||||||
|
env_vars: vec!["KATA_AGENT_SERVER_ADDR==foo"],
|
||||||
|
debug_console: false,
|
||||||
|
dev_mode: false,
|
||||||
|
log_level: DEFAULT_LOG_LEVEL,
|
||||||
|
hotplug_timeout: DEFAULT_HOTPLUG_TIMEOUT,
|
||||||
|
container_pipe_size: DEFAULT_CONTAINER_PIPE_SIZE,
|
||||||
|
server_addr: "=foo",
|
||||||
|
unified_cgroup_hierarchy: false,
|
||||||
|
},
|
||||||
|
TestData {
|
||||||
|
contents: "",
|
||||||
|
env_vars: vec!["KATA_AGENT_SERVER_ADDR=foo=bar=baz="],
|
||||||
|
debug_console: false,
|
||||||
|
dev_mode: false,
|
||||||
|
log_level: DEFAULT_LOG_LEVEL,
|
||||||
|
hotplug_timeout: DEFAULT_HOTPLUG_TIMEOUT,
|
||||||
|
container_pipe_size: DEFAULT_CONTAINER_PIPE_SIZE,
|
||||||
|
server_addr: "foo=bar=baz=",
|
||||||
|
unified_cgroup_hierarchy: false,
|
||||||
|
},
|
||||||
|
TestData {
|
||||||
|
contents: "",
|
||||||
|
env_vars: vec!["KATA_AGENT_SERVER_ADDR=unix:///tmp/foo.socket"],
|
||||||
|
debug_console: false,
|
||||||
|
dev_mode: false,
|
||||||
|
log_level: DEFAULT_LOG_LEVEL,
|
||||||
|
hotplug_timeout: DEFAULT_HOTPLUG_TIMEOUT,
|
||||||
|
container_pipe_size: DEFAULT_CONTAINER_PIPE_SIZE,
|
||||||
|
server_addr: "unix:///tmp/foo.socket",
|
||||||
|
unified_cgroup_hierarchy: false,
|
||||||
|
},
|
||||||
|
TestData {
|
||||||
|
contents: "",
|
||||||
|
env_vars: vec!["KATA_AGENT_SERVER_ADDR=unix://@/tmp/foo.socket"],
|
||||||
|
debug_console: false,
|
||||||
|
dev_mode: false,
|
||||||
|
log_level: DEFAULT_LOG_LEVEL,
|
||||||
|
hotplug_timeout: DEFAULT_HOTPLUG_TIMEOUT,
|
||||||
|
container_pipe_size: DEFAULT_CONTAINER_PIPE_SIZE,
|
||||||
|
server_addr: "unix://@/tmp/foo.socket",
|
||||||
|
unified_cgroup_hierarchy: false,
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
let dir = tempdir().expect("failed to create tmpdir");
|
let dir = tempdir().expect("failed to create tmpdir");
|
||||||
@ -623,7 +766,8 @@ mod tests {
|
|||||||
let result = config.parse_cmdline(&filename.to_owned());
|
let result = config.parse_cmdline(&filename.to_owned());
|
||||||
assert!(result.is_err());
|
assert!(result.is_err());
|
||||||
|
|
||||||
// Now, test various combinations of file contents
|
// Now, test various combinations of file contents and environment
|
||||||
|
// variables.
|
||||||
for (i, d) in tests.iter().enumerate() {
|
for (i, d) in tests.iter().enumerate() {
|
||||||
let msg = format!("test[{}]: {:?}", i, d);
|
let msg = format!("test[{}]: {:?}", i, d);
|
||||||
|
|
||||||
@ -637,6 +781,19 @@ mod tests {
|
|||||||
file.write_all(d.contents.as_bytes())
|
file.write_all(d.contents.as_bytes())
|
||||||
.unwrap_or_else(|_| panic!("{}: failed to write file contents", msg));
|
.unwrap_or_else(|_| panic!("{}: failed to write file contents", msg));
|
||||||
|
|
||||||
|
let mut vars_to_unset = Vec::new();
|
||||||
|
|
||||||
|
for v in &d.env_vars {
|
||||||
|
let fields: Vec<&str> = v.split('=').collect();
|
||||||
|
|
||||||
|
let name = fields[0];
|
||||||
|
let value = fields[1..].join("=");
|
||||||
|
|
||||||
|
env::set_var(name, value);
|
||||||
|
|
||||||
|
vars_to_unset.push(name);
|
||||||
|
}
|
||||||
|
|
||||||
let mut config = agentConfig::new();
|
let mut config = agentConfig::new();
|
||||||
assert_eq!(config.debug_console, false, "{}", msg);
|
assert_eq!(config.debug_console, false, "{}", msg);
|
||||||
assert_eq!(config.dev_mode, false, "{}", msg);
|
assert_eq!(config.dev_mode, false, "{}", msg);
|
||||||
@ -648,6 +805,7 @@ mod tests {
|
|||||||
msg
|
msg
|
||||||
);
|
);
|
||||||
assert_eq!(config.container_pipe_size, 0, "{}", msg);
|
assert_eq!(config.container_pipe_size, 0, "{}", msg);
|
||||||
|
assert_eq!(config.server_addr, TEST_SERVER_ADDR, "{}", msg);
|
||||||
|
|
||||||
let result = config.parse_cmdline(filename);
|
let result = config.parse_cmdline(filename);
|
||||||
assert!(result.is_ok(), "{}", msg);
|
assert!(result.is_ok(), "{}", msg);
|
||||||
@ -662,6 +820,11 @@ mod tests {
|
|||||||
assert_eq!(d.log_level, config.log_level, "{}", msg);
|
assert_eq!(d.log_level, config.log_level, "{}", msg);
|
||||||
assert_eq!(d.hotplug_timeout, config.hotplug_timeout, "{}", msg);
|
assert_eq!(d.hotplug_timeout, config.hotplug_timeout, "{}", msg);
|
||||||
assert_eq!(d.container_pipe_size, config.container_pipe_size, "{}", msg);
|
assert_eq!(d.container_pipe_size, config.container_pipe_size, "{}", msg);
|
||||||
|
assert_eq!(d.server_addr, config.server_addr, "{}", msg);
|
||||||
|
|
||||||
|
for v in vars_to_unset {
|
||||||
|
env::remove_var(v);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user