예제 #1
0
파일: config.go 프로젝트: IRCody/snap
// get the default snapd configuration
func GetDefaultConfig() *Config {
	mlCfg := memberlist.DefaultLANConfig()
	mlCfg.PushPullInterval = defaultPushPullInterval
	mlCfg.GossipNodes = mlCfg.GossipNodes * 2
	return &Config{
		Name:                      getHostname(),
		Enable:                    defaultEnable,
		BindAddr:                  netutil.GetIP(),
		BindPort:                  defaultBindPort,
		Seed:                      defaultSeed,
		MemberlistConfig:          mlCfg,
		RestAPIProto:              defaultRestAPIProto,
		RestAPIPassword:           defaultRestAPIPassword,
		RestAPIPort:               defaultRestAPIPort,
		RestAPIInsecureSkipVerify: defaultRestAPIInsecureSkipVerify,
	}
}
예제 #2
0
파일: config_test.go 프로젝트: IRCody/snap
func TestTribeDefaultConfig(t *testing.T) {
	cfg := GetDefaultConfig()
	Convey("Provided a default tribe config", t, func() {
		Convey("Name should be the hostname of the system", func() {
			So(cfg.Name, ShouldEqual, getHostname())
		})
		Convey("Enable should be false", func() {
			So(cfg.Enable, ShouldEqual, false)
		})
		Convey("BindAddr should be not empty", func() {
			So(cfg.BindAddr, ShouldEqual, netutil.GetIP())
		})
		Convey("BindPort should be 6000", func() {
			So(cfg.BindPort, ShouldEqual, 6000)
		})
		Convey("Seed should be empty", func() {
			So(cfg.Seed, ShouldEqual, "")
		})
		Convey("MemberlistConfig.PushPullInterval should be 300s", func() {
			So(cfg.MemberlistConfig.PushPullInterval, ShouldEqual, 300*time.Second)
		})
		Convey("MemberlistConfig.GossipNodes should be 6", func() {
			So(cfg.MemberlistConfig.GossipNodes, ShouldEqual, 6)
		})
		Convey("RestAPIProto should be http", func() {
			So(cfg.RestAPIProto, ShouldEqual, "http")
		})
		Convey("RestAPIPassword should be empty", func() {
			So(cfg.RestAPIPassword, ShouldEqual, "")
		})
		Convey("RestAPIPort should be 8181", func() {
			So(cfg.RestAPIPort, ShouldEqual, 8181)
		})
		Convey("RestAPIInsecureSkipVerify should be true", func() {
			So(cfg.RestAPIInsecureSkipVerify, ShouldEqual, "true")
		})
	})
}