43 host =
host_init(
"local",
"localhost",
"directory", 10);
44 FO_ASSERT_PTR_NOT_NULL(host);
45 FO_ASSERT_STRING_EQUAL(host->
name,
"local");
46 FO_ASSERT_STRING_EQUAL(host->
address,
"localhost");
47 FO_ASSERT_STRING_EQUAL(host->
agent_dir,
"directory");
48 FO_ASSERT_EQUAL(host->
max, 10);
49 FO_ASSERT_EQUAL(host->
running, 0);
71 gchar* name = g_strdup(
" _local");
76 for(i = 0; i < 9; i++)
78 name[0] = (char)(
'1' + i);
81 list_size = g_tree_nnodes(scheduler->
host_list);
82 queue_size = g_list_length(scheduler->
host_queue);
83 FO_ASSERT_EQUAL(list_size, i + 1);
84 FO_ASSERT_EQUAL(queue_size, i + 1);
87 list_size = g_tree_nnodes(scheduler->
host_list);
88 queue_size = g_list_length(scheduler->
host_queue);
89 FO_ASSERT_EQUAL(list_size, 9);
90 FO_ASSERT_EQUAL(queue_size, 9);
93 for(iter = scheduler->
host_queue, i = 0; iter != NULL; iter = iter->next, i++)
94 FO_ASSERT_EQUAL(((
host_t*)iter->data)->max, i);
112 FO_ASSERT_EQUAL(host->
running, 0);
114 FO_ASSERT_EQUAL(host->
running, 1);
116 FO_ASSERT_EQUAL(host->
running, 2);
134 FO_ASSERT_EQUAL(host->
running, 2);
136 FO_ASSERT_EQUAL(host->
running, 1);
138 FO_ASSERT_EQUAL(host->
running, 0);
156 char* name = g_strdup(
" _local");
160 for(i = 0; i < 9; i++)
162 name[0] = (char)(
'1' + i);
166 for(i = 0; i < 9; i++)
169 name[0] = (char)(
'1' + i);
171 FO_ASSERT_PTR_EQUAL(host, g_tree_lookup(scheduler->
host_list, name));
172 FO_ASSERT_EQUAL(host->
max, i + 1);
176 FO_ASSERT_STRING_EQUAL(host->
name,
"3_local");
177 FO_ASSERT_EQUAL(host->
max, 3);
179 FO_ASSERT_STRING_EQUAL(host->
name,
"1_local");
180 FO_ASSERT_EQUAL(host->
max, 1);
182 FO_ASSERT_STRING_EQUAL(host->
name,
"9_local");
183 FO_ASSERT_EQUAL(host->
max, 9);
185 FO_ASSERT_STRING_EQUAL(host->
name,
"4_local");
186 FO_ASSERT_EQUAL(host->
max, 4);
196 CU_TestInfo tests_host[] =
GTree * host_list
List of all hosts available to the scheduler.
void test_get_host()
Test for get_host()
void test_host_increase_load()
Test for host_increase_load()
void scheduler_destroy(scheduler_t *scheduler)
Free any memory associated with a scheduler_t.
void host_destroy(host_t *host)
Frees and uninitializes any memory associated with the host struct.
void test_host_init()
Test for host_init()
GList * host_queue
Round-robin queue for choosing which host use next.
int max
The max number of agents that can run on this host.
host_t * host_init(char *name, char *address, char *agent_dir, int max)
Creates a new host, and adds it to the host list.
char * address
The address of the host, used by ssh when starting a new agent.
char * name
The name of the host, used to store host internally to scheduler.
void host_insert(host_t *host, scheduler_t *scheduler)
Inserts a new host into the scheduler structure.
void test_host_decrease_load()
Test for host_decrease_load()
void host_increase_load(host_t *host)
Increase the number of running agents on a host by 1.
scheduler_t * scheduler_init(gchar *sysconfigdir, log_t *log)
Create a new scheduler object.
host_t * get_host(GList **queue, uint8_t num)
char * agent_dir
The location on the host machine where the executables are.
void test_host_insert()
Test for host_insert()
void host_decrease_load(host_t *host)
Decrease the number of running agents on a host by 1.
int running
The number of agents currently running on this host.