Пример #1
0
func TestDockerInitScheduler(t *testing.T) {
	tests := []struct {
		pullImages bool
	}{
		{
			pullImages: true,
		},
		{
			pullImages: false,
		},
	}

	for _, test := range tests {
		d := NewScheduler(test.pullImages, "unix:///var/run/docker.sock")
		log.Infof("Should I pull images? %v", test.pullImages)
		server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
			log.Infof("Received something %v", r)

			// TODO!! Check that we're receiving what we expect
		}))

		log.Infof("Test server at %s", server.URL)
		d.client, _ = docker.NewClient(server.URL)
		log.Debugf("Docker client %v", d.client)

		var task demand.Task
		task.Demand = 5
		task.Image = "microscaling/priority-1:latest"

		d.InitScheduler(&task)
		d.startTask(&task)
	}
}
Пример #2
0
func TestDockerScheduler(t *testing.T) {
	d := NewScheduler(true, "unix:///var/run/docker.sock")
	server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
	}))

	d.client, _ = docker.NewClient(server.URL)

	var task demand.Task
	task.Demand = 5
	task.Image = "microscaling/priority-1:latest"

	d.InitScheduler(&task)

	d.startTask(&task)
	// TODO! Some Docker tests that mock out the Docker client

	var tasks demand.Tasks
	tasks.Tasks = make([]*demand.Task, 1)
	tasks.Tasks = append(tasks.Tasks, &task)
	d.CountAllTasks(&tasks)
}