32 host =
host_init(
"local",
"localhost",
"directory", 10);
33 FO_ASSERT_PTR_NOT_NULL(host);
34 FO_ASSERT_STRING_EQUAL(host->
name,
"local");
35 FO_ASSERT_STRING_EQUAL(host->
address,
"localhost");
36 FO_ASSERT_STRING_EQUAL(host->
agent_dir,
"directory");
37 FO_ASSERT_EQUAL(host->
max, 10);
38 FO_ASSERT_EQUAL(host->
running, 0);
60 gchar* name = g_strdup(
" _local");
65 for(i = 0; i < 9; i++)
67 name[0] = (char)(
'1' + i);
70 list_size = g_tree_nnodes(scheduler->
host_list);
71 queue_size = g_list_length(scheduler->
host_queue);
72 FO_ASSERT_EQUAL(list_size, i + 1);
73 FO_ASSERT_EQUAL(queue_size, i + 1);
76 list_size = g_tree_nnodes(scheduler->
host_list);
77 queue_size = g_list_length(scheduler->
host_queue);
78 FO_ASSERT_EQUAL(list_size, 9);
79 FO_ASSERT_EQUAL(queue_size, 9);
82 for(iter = scheduler->
host_queue, i = 0; iter != NULL; iter = iter->next, i++)
83 FO_ASSERT_EQUAL(((
host_t*)iter->data)->max, i);
101 FO_ASSERT_EQUAL(host->
running, 0);
103 FO_ASSERT_EQUAL(host->
running, 1);
105 FO_ASSERT_EQUAL(host->
running, 2);
123 FO_ASSERT_EQUAL(host->
running, 2);
125 FO_ASSERT_EQUAL(host->
running, 1);
127 FO_ASSERT_EQUAL(host->
running, 0);
145 char* name = g_strdup(
" _local");
149 for(i = 0; i < 9; i++)
151 name[0] = (char)(
'1' + i);
155 for(i = 0; i < 9; i++)
158 name[0] = (char)(
'1' + i);
160 FO_ASSERT_PTR_EQUAL(host, g_tree_lookup(scheduler->
host_list, name));
161 FO_ASSERT_EQUAL(host->
max, i + 1);
165 FO_ASSERT_STRING_EQUAL(host->
name,
"3_local");
166 FO_ASSERT_EQUAL(host->
max, 3);
168 FO_ASSERT_STRING_EQUAL(host->
name,
"1_local");
169 FO_ASSERT_EQUAL(host->
max, 1);
171 FO_ASSERT_STRING_EQUAL(host->
name,
"9_local");
172 FO_ASSERT_EQUAL(host->
max, 9);
174 FO_ASSERT_STRING_EQUAL(host->
name,
"4_local");
175 FO_ASSERT_EQUAL(host->
max, 4);
185 CU_TestInfo tests_host[] =
void host_insert(host_t *host, scheduler_t *scheduler)
Inserts a new host into the scheduler structure.
host_t * host_init(char *name, char *address, char *agent_dir, int max)
Creates a new host, and adds it to the host list.
void host_decrease_load(host_t *host)
Decrease the number of running agents on a host by 1.
void host_destroy(host_t *host)
Frees and uninitializes any memory associated with the host struct.
host_t * get_host(GList **queue, uint8_t num)
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.
void scheduler_destroy(scheduler_t *scheduler)
Free any memory associated with a scheduler_t.
char * agent_dir
The location on the host machine where the executables are.
int running
The number of agents currently running on this host.
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.
int max
The max number of agents that can run on this host.
GList * host_queue
Round-robin queue for choosing which host use next.
GTree * host_list
List of all hosts available to the scheduler.
void test_host_increase_load()
Test for host_increase_load()
void test_host_init()
Test for host_init()
void test_host_insert()
Test for host_insert()
void test_host_decrease_load()
Test for host_decrease_load()
void test_get_host()
Test for get_host()