27 #include <scheduler.h> 33 char sqltmp[1024] = {0};
57 FO_ASSERT_PTR_NOT_NULL(scheduler->
db_conn);
60 sql = g_string_new(sqltmp);
61 g_string_append(sql,
"'users';");
68 if(PQresultStatus(db_result) == PGRES_TUPLES_OK && PQntuples(db_result) != 0)
71 FO_ASSERT_STRING_EQUAL(g_strdup(PQgetvalue(db_result, 0, 0)),
"user_pk");
72 FO_ASSERT_STRING_EQUAL(g_strdup(PQgetvalue(db_result, 1, 0)),
"user_name");
73 FO_ASSERT_STRING_EQUAL(g_strdup(PQgetvalue(db_result, 2, 0)),
"root_folder_fk");
74 FO_ASSERT_STRING_EQUAL(g_strdup(PQgetvalue(db_result, 3, 0)),
"user_desc");
75 FO_ASSERT_STRING_EQUAL(g_strdup(PQgetvalue(db_result, 4, 0)),
"user_seed");
79 g_string_free(sql, TRUE);
95 FO_ASSERT_PTR_NULL(scheduler->
db_conn);
97 FO_ASSERT_PTR_NOT_NULL(scheduler->
db_conn);
121 FO_ASSERT_PTR_NULL(scheduler->
db_conn);
123 FO_ASSERT_PTR_NOT_NULL(scheduler->
db_conn);
128 sprintf(sql,
"SELECT * FROM job;");
131 if(PQresultStatus(db_result) == PGRES_TUPLES_OK && PQntuples(db_result) != 0)
133 FO_ASSERT_STRING_EQUAL(PQget(db_result, 0,
"job_name"),
"testing file");
134 FO_ASSERT_EQUAL(atoi(PQget(db_result, 0,
"job_user_fk")), 1);
162 FO_ASSERT_PTR_NULL(scheduler->
db_conn);
164 FO_ASSERT_PTR_NOT_NULL(scheduler->
db_conn);
169 params->second = jq_pk;
170 params->first = g_tree_lookup(scheduler->
job_list, ¶ms->second);
172 if(params->first == NULL)
174 tmp_job.
id = params->second;
175 tmp_job.
status = JB_NOT_AVAILABLE;
182 FO_ASSERT_STRING_EQUAL(job_status_strings[job->
status],
"JOB_NOT_AVAILABLE");
185 FO_ASSERT_STRING_EQUAL(job_status_strings[job->
status],
"JOB_NOT_AVAILABLE");
211 FO_ASSERT_PTR_NULL(scheduler->
db_conn);
213 FO_ASSERT_PTR_NOT_NULL(scheduler->
db_conn);
218 params->second = jq_pk;
219 params->first = g_tree_lookup(scheduler->
job_list, ¶ms->second);
221 if(params->first == NULL)
223 tmp_job.
id = params->second;
224 tmp_job.
status = JB_NOT_AVAILABLE;
231 FO_ASSERT_STRING_EQUAL(job_status_strings[job->
status],
"JOB_NOT_AVAILABLE");
256 FO_ASSERT_PTR_NULL(scheduler->
db_conn);
259 FO_ASSERT_PTR_NOT_NULL(scheduler->
db_conn);
266 FO_ASSERT_STRING_EQUAL(job_status_strings[job->
status],
"JOB_CHECKEDOUT");
274 CU_TestInfo tests_database[] =
284 CU_TestInfo tests_email[] =
PGconn * db_conn
The database connection.
int Prepare_Testing_Data(scheduler_t *scheduler)
void database_reset_queue(scheduler_t *scheduler)
Resets any jobs in the job queue that are not completed.
void test_database_exec_event()
Test for database_exec_event()
void scheduler_destroy(scheduler_t *scheduler)
Free any memory associated with a scheduler_t.
void email_init(scheduler_t *scheduler)
Loads information about the email that will be sent for job notifications.
void database_init(scheduler_t *scheduler)
void database_update_event(scheduler_t *scheduler, void *unused)
Checks the job queue for any new entries.
char * check_scheduler_tables
void database_update_job(scheduler_t *scheduler, job_t *job, job_status status)
Change the status of a job in the database.
void database_job_log(int j_id, char *log_name)
Enters the name of the log file for a job into the database.
GSequence * job_queue
heap of jobs that still need to be started
PGresult * database_exec(scheduler_t *scheduler, const char *sql)
Executes an sql statement for the scheduler.
void test_email_notify()
Test for email_notification()
GTree * job_list
List of jobs that have been created.
void test_database_update_job()
Test for database_update_job()
GList * running_agents
The list of agents assigned to this job that are still working.
scheduler_t * scheduler_init(gchar *sysconfigdir, log_t *log)
Create a new scheduler object.
void database_exec_event(scheduler_t *scheduler, char *sql)
void test_database_update_event()
Test for database_update_event()
void database_job_processed(int j_id, int num)
Updates the number of items that a job queue entry has processed.
gchar * message
Message that will be sent with job notification 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.
void database_job_priority(scheduler_t *scheduler, job_t *job, int priority)
Changes the priority of a job queue entry in the database.
void test_database_job()
Test for database_job_processed(),database_job_log(),database_job_priority()
job_status status
The current status for the job.
void test_database_init()
Test for database_init()
int32_t id
The identifier for this job.