2014-04-17 17:43:01 -04:00
|
|
|
package daemon
|
2014-03-24 03:16:40 -04:00
|
|
|
|
|
|
|
import (
|
2014-04-01 03:07:42 -04:00
|
|
|
"testing"
|
|
|
|
|
2014-07-24 18:19:50 -04:00
|
|
|
"github.com/docker/docker/runconfig"
|
|
|
|
"github.com/docker/docker/utils"
|
2014-03-24 03:16:40 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestMergeLxcConfig(t *testing.T) {
|
2014-09-29 18:40:26 -04:00
|
|
|
hostConfig := &runconfig.HostConfig{
|
|
|
|
LxcConf: []utils.KeyValuePair{
|
|
|
|
{Key: "lxc.cgroups.cpuset", Value: "1,2"},
|
|
|
|
},
|
2014-03-24 03:16:40 -04:00
|
|
|
}
|
|
|
|
|
2014-12-08 19:45:42 -05:00
|
|
|
out, err := mergeLxcConfIntoOptions(hostConfig)
|
|
|
|
if err != nil {
|
2014-12-12 13:58:56 -05:00
|
|
|
t.Fatalf("Failed to merge Lxc Config: %s", err)
|
2014-12-08 19:45:42 -05:00
|
|
|
}
|
2014-09-29 18:40:26 -04:00
|
|
|
|
|
|
|
cpuset := out[0]
|
2014-03-24 03:16:40 -04:00
|
|
|
if expected := "cgroups.cpuset=1,2"; cpuset != expected {
|
|
|
|
t.Fatalf("expected %s got %s", expected, cpuset)
|
|
|
|
}
|
|
|
|
}
|
2014-09-15 15:43:21 -04:00
|
|
|
|
|
|
|
func TestRemoveLocalDns(t *testing.T) {
|
|
|
|
ns0 := "nameserver 10.16.60.14\nnameserver 10.16.60.21\n"
|
|
|
|
|
|
|
|
if result := utils.RemoveLocalDns([]byte(ns0)); result != nil {
|
|
|
|
if ns0 != string(result) {
|
|
|
|
t.Fatalf("Failed No Localhost: expected \n<%s> got \n<%s>", ns0, string(result))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ns1 := "nameserver 10.16.60.14\nnameserver 10.16.60.21\nnameserver 127.0.0.1\n"
|
|
|
|
if result := utils.RemoveLocalDns([]byte(ns1)); result != nil {
|
|
|
|
if ns0 != string(result) {
|
|
|
|
t.Fatalf("Failed Localhost: expected \n<%s> got \n<%s>", ns0, string(result))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ns1 = "nameserver 10.16.60.14\nnameserver 127.0.0.1\nnameserver 10.16.60.21\n"
|
|
|
|
if result := utils.RemoveLocalDns([]byte(ns1)); result != nil {
|
|
|
|
if ns0 != string(result) {
|
|
|
|
t.Fatalf("Failed Localhost: expected \n<%s> got \n<%s>", ns0, string(result))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ns1 = "nameserver 127.0.1.1\nnameserver 10.16.60.14\nnameserver 10.16.60.21\n"
|
|
|
|
if result := utils.RemoveLocalDns([]byte(ns1)); result != nil {
|
|
|
|
if ns0 != string(result) {
|
|
|
|
t.Fatalf("Failed Localhost: expected \n<%s> got \n<%s>", ns0, string(result))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|