16 #include <scheduler.h>
22 char sqltmp[1024] = {0};
46 FO_ASSERT_PTR_NOT_NULL(scheduler->
db_conn);
49 sql = g_string_new(sqltmp);
50 g_string_append(sql,
"'users';");
57 if(PQresultStatus(db_result) == PGRES_TUPLES_OK && PQntuples(db_result) != 0)
60 FO_ASSERT_STRING_EQUAL(g_strdup(PQgetvalue(db_result, 0, 0)),
"user_pk");
61 FO_ASSERT_STRING_EQUAL(g_strdup(PQgetvalue(db_result, 1, 0)),
"user_name");
62 FO_ASSERT_STRING_EQUAL(g_strdup(PQgetvalue(db_result, 2, 0)),
"root_folder_fk");
63 FO_ASSERT_STRING_EQUAL(g_strdup(PQgetvalue(db_result, 3, 0)),
"user_desc");
64 FO_ASSERT_STRING_EQUAL(g_strdup(PQgetvalue(db_result, 4, 0)),
"user_seed");
68 g_string_free(sql, TRUE);
84 FO_ASSERT_PTR_NULL(scheduler->
db_conn);
86 FO_ASSERT_PTR_NOT_NULL(scheduler->
db_conn);
110 FO_ASSERT_PTR_NULL(scheduler->
db_conn);
112 FO_ASSERT_PTR_NOT_NULL(scheduler->
db_conn);
117 sprintf(sql,
"SELECT * FROM job;");
120 if(PQresultStatus(db_result) == PGRES_TUPLES_OK && PQntuples(db_result) != 0)
122 FO_ASSERT_STRING_EQUAL(PQget(db_result, 0,
"job_name"),
"testing file");
123 FO_ASSERT_EQUAL(atoi(PQget(db_result, 0,
"job_user_fk")), 1);
151 FO_ASSERT_PTR_NULL(scheduler->
db_conn);
153 FO_ASSERT_PTR_NOT_NULL(scheduler->
db_conn);
158 params->second = jq_pk;
159 params->first = g_tree_lookup(scheduler->
job_list, ¶ms->second);
161 if(params->first == NULL)
163 tmp_job.
id = params->second;
164 tmp_job.
status = JB_NOT_AVAILABLE;
171 FO_ASSERT_STRING_EQUAL(job_status_strings[job->
status],
"JOB_NOT_AVAILABLE");
174 FO_ASSERT_STRING_EQUAL(job_status_strings[job->
status],
"JOB_NOT_AVAILABLE");
200 FO_ASSERT_PTR_NULL(scheduler->
db_conn);
202 FO_ASSERT_PTR_NOT_NULL(scheduler->
db_conn);
207 params->second = jq_pk;
208 params->first = g_tree_lookup(scheduler->
job_list, ¶ms->second);
210 if(params->first == NULL)
212 tmp_job.
id = params->second;
213 tmp_job.
status = JB_NOT_AVAILABLE;
220 FO_ASSERT_STRING_EQUAL(job_status_strings[job->
status],
"JOB_NOT_AVAILABLE");
245 FO_ASSERT_PTR_NULL(scheduler->
db_conn);
248 FO_ASSERT_PTR_NOT_NULL(scheduler->
db_conn);
255 FO_ASSERT_STRING_EQUAL(job_status_strings[job->
status],
"JOB_CHECKEDOUT");
263 CU_TestInfo tests_database[] =
273 CU_TestInfo tests_email[] =
job_t * job_init(GTree *job_list, GSequence *job_queue, char *type, char *host, int id, int parent_id, int user_id, int group_id, int priority, char *jq_cmd_args)
Create a new job.
PGresult * database_exec(scheduler_t *scheduler, const char *sql)
Executes an sql statement for the scheduler.
void database_reset_queue(scheduler_t *scheduler)
Resets any jobs in the job queue that are not completed.
void database_init(scheduler_t *scheduler)
void database_job_priority(scheduler_t *scheduler, job_t *job, int priority)
Changes the priority of a job queue entry in the database.
void database_update_job(scheduler_t *scheduler, job_t *job, job_status status)
Change the status of a job in the database.
void database_update_event(scheduler_t *scheduler, void *unused)
Checks the job queue for any new entries.
void database_job_log(int j_id, char *log_name)
Enters the name of the log file for a job into the database.
void database_exec_event(scheduler_t *scheduler, char *sql)
void email_init(scheduler_t *scheduler)
Loads information about the email that will be sent for job notifications.
void database_job_processed(int j_id, int num)
Updates the number of items that a job queue entry has processed.
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.
int Prepare_Testing_Data(scheduler_t *scheduler)
int32_t id
The identifier for this job.
job_status status
The current status for the job.
gchar * message
Message that will be sent with job notification email.
GList * running_agents
The list of agents assigned to this job that are still working.
GTree * job_list
List of jobs that have been created.
PGconn * db_conn
The database connection.
GSequence * job_queue
heap of jobs that still need to be started
void test_database_init()
Test for database_init()
char * check_scheduler_tables
void test_database_update_job()
Test for database_update_job()
void test_email_notify()
Test for email_notification()
void test_database_update_event()
Test for database_update_event()
void test_database_job()
Test for database_job_processed(),database_job_log(),database_job_priority()
void test_database_exec_event()
Test for database_exec_event()