예제 #1
0
func TestInitForeman(t *testing.T) {
	fm := startTestWithRole(pb.MinionConfig_WORKER)
	fm.conn.Transact(func(view db.Database) error {
		m := view.InsertMachine()
		m.PublicIP = "2.2.2.2"
		m.PrivateIP = "2.2.2.2"
		m.CloudID = "ID2"
		view.Commit(m)
		return nil
	})

	fm.init()
	for _, m := range fm.minions {
		if m.machine.Role != db.Worker {
			t.Error("Minion machine not set to worker.")
		}
	}

	fm = startTestWithRole(pb.MinionConfig_Role(-7))
	for _, m := range fm.minions {
		if m.machine.Role != db.None {
			t.Error("Minion machine set to invalid role.")
		}
	}
}
예제 #2
0
func TestInitForeman(t *testing.T) {
	conn := startTestWithRole(pb.MinionConfig_WORKER)
	conn.Transact(func(view db.Database) error {
		m := view.InsertMachine()
		m.PublicIP = "2.2.2.2"
		m.PrivateIP = "2.2.2.2"
		m.CloudID = "ID2"
		view.Commit(m)
		return nil
	})

	Init(conn)
	for _, m := range minions {
		assert.Equal(t, db.Role(db.Worker), m.machine.Role)
	}

	conn = startTestWithRole(pb.MinionConfig_Role(-7))
	Init(conn)
	for _, m := range minions {
		assert.Equal(t, db.None, m.machine.Role)
	}
}