|
@@ -28,7 +28,7 @@
|
|
|
#include <sys/stat.h>
|
|
|
#include <sys/wait.h>
|
|
|
|
|
|
-#define TEST_ROOT "/tmp/test-task-controller"
|
|
|
+#define TEST_ROOT "/tmp/test-container-controller"
|
|
|
#define DONT_TOUCH_FILE "dont-touch-me"
|
|
|
|
|
|
static char* username = NULL;
|
|
@@ -84,46 +84,40 @@ void run(const char *cmd) {
|
|
|
|
|
|
int write_config_file(char *file_name) {
|
|
|
FILE *file;
|
|
|
+ int i = 0;
|
|
|
file = fopen(file_name, "w");
|
|
|
if (file == NULL) {
|
|
|
printf("Failed to open %s.\n", file_name);
|
|
|
return EXIT_FAILURE;
|
|
|
}
|
|
|
- fprintf(file, "mapred.local.dir=" TEST_ROOT "/local-1");
|
|
|
- int i;
|
|
|
+ fprintf(file, "yarn.nodemanager.local-dirs=" TEST_ROOT "/local-1");
|
|
|
for(i=2; i < 5; ++i) {
|
|
|
fprintf(file, "," TEST_ROOT "/local-%d", i);
|
|
|
}
|
|
|
fprintf(file, "\n");
|
|
|
- fprintf(file, "mapreduce.cluster.local.dir=" TEST_ROOT "/local-1");
|
|
|
- for(i=2; i < 5; ++i) {
|
|
|
- fprintf(file, "," TEST_ROOT "/local-%d", i);
|
|
|
- }
|
|
|
- fprintf(file, "\n");
|
|
|
-
|
|
|
- fprintf(file, "hadoop.log.dir=" TEST_ROOT "/logs\n");
|
|
|
+ fprintf(file, "yarn.nodemanager.log-dirs=" TEST_ROOT "/logs\n");
|
|
|
fclose(file);
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-void create_tt_roots() {
|
|
|
- char** tt_roots = get_values("mapred.local.dir");
|
|
|
- char** tt_root;
|
|
|
- for(tt_root=tt_roots; *tt_root != NULL; ++tt_root) {
|
|
|
- if (mkdir(*tt_root, 0755) != 0) {
|
|
|
- printf("FAIL: Can't create directory %s - %s\n", *tt_root,
|
|
|
+void create_nm_roots() {
|
|
|
+ char** nm_roots = get_values(NM_SYS_DIR_KEY);
|
|
|
+ char** nm_root;
|
|
|
+ for(nm_root=nm_roots; *nm_root != NULL; ++nm_root) {
|
|
|
+ if (mkdir(*nm_root, 0755) != 0) {
|
|
|
+ printf("FAIL: Can't create directory %s - %s\n", *nm_root,
|
|
|
strerror(errno));
|
|
|
exit(1);
|
|
|
}
|
|
|
char buffer[100000];
|
|
|
- sprintf(buffer, "%s/usercache", *tt_root);
|
|
|
+ sprintf(buffer, "%s/usercache", *nm_root);
|
|
|
if (mkdir(buffer, 0755) != 0) {
|
|
|
printf("FAIL: Can't create directory %s - %s\n", buffer,
|
|
|
strerror(errno));
|
|
|
exit(1);
|
|
|
}
|
|
|
}
|
|
|
- free_values(tt_roots);
|
|
|
+ free_values(nm_roots);
|
|
|
}
|
|
|
|
|
|
void test_get_user_directory() {
|
|
@@ -136,49 +130,49 @@ void test_get_user_directory() {
|
|
|
free(user_dir);
|
|
|
}
|
|
|
|
|
|
-void test_get_job_directory() {
|
|
|
- char *expected = "/tmp/usercache/user/appcache/job_200906101234_0001";
|
|
|
- char *job_dir = (char *) get_job_directory("/tmp", "user",
|
|
|
- "job_200906101234_0001");
|
|
|
- if (strcmp(job_dir, expected) != 0) {
|
|
|
- printf("test_get_job_directory expected %s got %s\n", expected, job_dir);
|
|
|
+void test_get_app_directory() {
|
|
|
+ char *expected = "/tmp/usercache/user/appcache/app_200906101234_0001";
|
|
|
+ char *app_dir = (char *) get_app_directory("/tmp", "user",
|
|
|
+ "app_200906101234_0001");
|
|
|
+ if (strcmp(app_dir, expected) != 0) {
|
|
|
+ printf("test_get_app_directory expected %s got %s\n", expected, app_dir);
|
|
|
exit(1);
|
|
|
}
|
|
|
- free(job_dir);
|
|
|
+ free(app_dir);
|
|
|
}
|
|
|
|
|
|
-void test_get_attempt_directory() {
|
|
|
- char *attempt_dir = get_attempt_work_directory("/tmp", "owen", "job_1",
|
|
|
- "attempt_1");
|
|
|
- char *expected = "/tmp/usercache/owen/appcache/job_1/attempt_1";
|
|
|
- if (strcmp(attempt_dir, expected) != 0) {
|
|
|
- printf("Fail get_attempt_work_directory got %s expected %s\n",
|
|
|
- attempt_dir, expected);
|
|
|
+void test_get_container_directory() {
|
|
|
+ char *container_dir = get_container_work_directory("/tmp", "owen", "app_1",
|
|
|
+ "container_1");
|
|
|
+ char *expected = "/tmp/usercache/owen/appcache/app_1/container_1";
|
|
|
+ if (strcmp(container_dir, expected) != 0) {
|
|
|
+ printf("Fail get_container_work_directory got %s expected %s\n",
|
|
|
+ container_dir, expected);
|
|
|
exit(1);
|
|
|
}
|
|
|
- free(attempt_dir);
|
|
|
+ free(container_dir);
|
|
|
}
|
|
|
|
|
|
-void test_get_task_launcher_file() {
|
|
|
- char *expected_file = ("/tmp/usercache/user/appcache/job_200906101234_0001"
|
|
|
- "/task.sh");
|
|
|
- char *job_dir = get_job_directory("/tmp", "user",
|
|
|
- "job_200906101234_0001");
|
|
|
- char *task_file = get_task_launcher_file(job_dir);
|
|
|
- if (strcmp(task_file, expected_file) != 0) {
|
|
|
- printf("failure to match expected task file %s vs %s\n", task_file,
|
|
|
+void test_get_container_launcher_file() {
|
|
|
+ char *expected_file = ("/tmp/usercache/user/appcache/app_200906101234_0001"
|
|
|
+ "/launch_container.sh");
|
|
|
+ char *app_dir = get_app_directory("/tmp", "user",
|
|
|
+ "app_200906101234_0001");
|
|
|
+ char *container_file = get_container_launcher_file(app_dir);
|
|
|
+ if (strcmp(container_file, expected_file) != 0) {
|
|
|
+ printf("failure to match expected container file %s vs %s\n", container_file,
|
|
|
expected_file);
|
|
|
exit(1);
|
|
|
}
|
|
|
- free(job_dir);
|
|
|
- free(task_file);
|
|
|
+ free(app_dir);
|
|
|
+ free(container_file);
|
|
|
}
|
|
|
|
|
|
-void test_get_job_log_dir() {
|
|
|
- char *expected = TEST_ROOT "/logs/userlogs/job_200906101234_0001";
|
|
|
- char *logdir = get_job_log_directory(TEST_ROOT "/logs/userlogs","job_200906101234_0001");
|
|
|
+void test_get_app_log_dir() {
|
|
|
+ char *expected = TEST_ROOT "/logs/userlogs/app_200906101234_0001";
|
|
|
+ char *logdir = get_app_log_directory(TEST_ROOT "/logs/userlogs","app_200906101234_0001");
|
|
|
if (strcmp(logdir, expected) != 0) {
|
|
|
- printf("Fail get_job_log_dir got %s expected %s\n", logdir, expected);
|
|
|
+ printf("Fail get_app_log_dir got %s expected %s\n", logdir, expected);
|
|
|
exit(1);
|
|
|
}
|
|
|
free(logdir);
|
|
@@ -200,10 +194,6 @@ void test_check_user() {
|
|
|
printf("FAIL: failed check for system user root\n");
|
|
|
exit(1);
|
|
|
}
|
|
|
- if (check_user("mapred") != NULL) {
|
|
|
- printf("FAIL: failed check for hadoop user mapred\n");
|
|
|
- exit(1);
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
void test_check_configuration_permissions() {
|
|
@@ -218,56 +208,56 @@ void test_check_configuration_permissions() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void test_delete_task() {
|
|
|
+void test_delete_container() {
|
|
|
if (initialize_user(username)) {
|
|
|
printf("FAIL: failed to initialize user %s\n", username);
|
|
|
exit(1);
|
|
|
}
|
|
|
- char* job_dir = get_job_directory(TEST_ROOT "/local-2", username, "job_1");
|
|
|
- char* dont_touch = get_job_directory(TEST_ROOT "/local-2", username,
|
|
|
+ char* app_dir = get_app_directory(TEST_ROOT "/local-2", username, "app_1");
|
|
|
+ char* dont_touch = get_app_directory(TEST_ROOT "/local-2", username,
|
|
|
DONT_TOUCH_FILE);
|
|
|
- char* task_dir = get_attempt_work_directory(TEST_ROOT "/local-2",
|
|
|
- username, "job_1", "task_1");
|
|
|
+ char* container_dir = get_container_work_directory(TEST_ROOT "/local-2",
|
|
|
+ username, "app_1", "container_1");
|
|
|
char buffer[100000];
|
|
|
- sprintf(buffer, "mkdir -p %s/who/let/the/dogs/out/who/who", task_dir);
|
|
|
+ sprintf(buffer, "mkdir -p %s/who/let/the/dogs/out/who/who", container_dir);
|
|
|
run(buffer);
|
|
|
sprintf(buffer, "touch %s", dont_touch);
|
|
|
run(buffer);
|
|
|
|
|
|
- // soft link to the canary file from the task directory
|
|
|
- sprintf(buffer, "ln -s %s %s/who/softlink", dont_touch, task_dir);
|
|
|
+ // soft link to the canary file from the container directory
|
|
|
+ sprintf(buffer, "ln -s %s %s/who/softlink", dont_touch, container_dir);
|
|
|
run(buffer);
|
|
|
- // hard link to the canary file from the task directory
|
|
|
- sprintf(buffer, "ln %s %s/who/hardlink", dont_touch, task_dir);
|
|
|
+ // hard link to the canary file from the container directory
|
|
|
+ sprintf(buffer, "ln %s %s/who/hardlink", dont_touch, container_dir);
|
|
|
run(buffer);
|
|
|
- // create a dot file in the task directory
|
|
|
- sprintf(buffer, "touch %s/who/let/.dotfile", task_dir);
|
|
|
+ // create a dot file in the container directory
|
|
|
+ sprintf(buffer, "touch %s/who/let/.dotfile", container_dir);
|
|
|
run(buffer);
|
|
|
// create a no permission file
|
|
|
- sprintf(buffer, "touch %s/who/let/protect", task_dir);
|
|
|
+ sprintf(buffer, "touch %s/who/let/protect", container_dir);
|
|
|
run(buffer);
|
|
|
- sprintf(buffer, "chmod 000 %s/who/let/protect", task_dir);
|
|
|
+ sprintf(buffer, "chmod 000 %s/who/let/protect", container_dir);
|
|
|
run(buffer);
|
|
|
// create a no permission directory
|
|
|
- sprintf(buffer, "chmod 000 %s/who/let", task_dir);
|
|
|
+ sprintf(buffer, "chmod 000 %s/who/let", container_dir);
|
|
|
run(buffer);
|
|
|
|
|
|
- // delete task directory
|
|
|
- char * dirs[] = {job_dir, 0};
|
|
|
- int ret = delete_as_user(username, "task_1" , dirs);
|
|
|
+ // delete container directory
|
|
|
+ char * dirs[] = {app_dir, 0};
|
|
|
+ int ret = delete_as_user(username, "container_1" , dirs);
|
|
|
if (ret != 0) {
|
|
|
printf("FAIL: return code from delete_as_user is %d\n", ret);
|
|
|
exit(1);
|
|
|
}
|
|
|
|
|
|
- // check to make sure the task directory is gone
|
|
|
- if (access(task_dir, R_OK) == 0) {
|
|
|
- printf("FAIL: failed to delete the directory - %s\n", task_dir);
|
|
|
+ // check to make sure the container directory is gone
|
|
|
+ if (access(container_dir, R_OK) == 0) {
|
|
|
+ printf("FAIL: failed to delete the directory - %s\n", container_dir);
|
|
|
exit(1);
|
|
|
}
|
|
|
- // check to make sure the job directory is not gone
|
|
|
- if (access(job_dir, R_OK) != 0) {
|
|
|
- printf("FAIL: accidently deleted the directory - %s\n", job_dir);
|
|
|
+ // check to make sure the app directory is not gone
|
|
|
+ if (access(app_dir, R_OK) != 0) {
|
|
|
+ printf("FAIL: accidently deleted the directory - %s\n", app_dir);
|
|
|
exit(1);
|
|
|
}
|
|
|
// but that the canary is not gone
|
|
@@ -275,60 +265,60 @@ void test_delete_task() {
|
|
|
printf("FAIL: accidently deleted file %s\n", dont_touch);
|
|
|
exit(1);
|
|
|
}
|
|
|
- sprintf(buffer, "chmod -R 700 %s", job_dir);
|
|
|
+ sprintf(buffer, "chmod -R 700 %s", app_dir);
|
|
|
run(buffer);
|
|
|
- sprintf(buffer, "rm -fr %s", job_dir);
|
|
|
+ sprintf(buffer, "rm -fr %s", app_dir);
|
|
|
run(buffer);
|
|
|
- free(job_dir);
|
|
|
- free(task_dir);
|
|
|
+ free(app_dir);
|
|
|
+ free(container_dir);
|
|
|
free(dont_touch);
|
|
|
}
|
|
|
|
|
|
-void test_delete_job() {
|
|
|
- char* job_dir = get_job_directory(TEST_ROOT "/local-2", username, "job_2");
|
|
|
- char* dont_touch = get_job_directory(TEST_ROOT "/local-2", username,
|
|
|
+void test_delete_app() {
|
|
|
+ char* app_dir = get_app_directory(TEST_ROOT "/local-2", username, "app_2");
|
|
|
+ char* dont_touch = get_app_directory(TEST_ROOT "/local-2", username,
|
|
|
DONT_TOUCH_FILE);
|
|
|
- char* task_dir = get_attempt_work_directory(TEST_ROOT "/local-2",
|
|
|
- username, "job_2", "task_1");
|
|
|
+ char* container_dir = get_container_work_directory(TEST_ROOT "/local-2",
|
|
|
+ username, "app_2", "container_1");
|
|
|
char buffer[100000];
|
|
|
- sprintf(buffer, "mkdir -p %s/who/let/the/dogs/out/who/who", task_dir);
|
|
|
+ sprintf(buffer, "mkdir -p %s/who/let/the/dogs/out/who/who", container_dir);
|
|
|
run(buffer);
|
|
|
sprintf(buffer, "touch %s", dont_touch);
|
|
|
run(buffer);
|
|
|
|
|
|
- // soft link to the canary file from the task directory
|
|
|
- sprintf(buffer, "ln -s %s %s/who/softlink", dont_touch, task_dir);
|
|
|
+ // soft link to the canary file from the container directory
|
|
|
+ sprintf(buffer, "ln -s %s %s/who/softlink", dont_touch, container_dir);
|
|
|
run(buffer);
|
|
|
- // hard link to the canary file from the task directory
|
|
|
- sprintf(buffer, "ln %s %s/who/hardlink", dont_touch, task_dir);
|
|
|
+ // hard link to the canary file from the container directory
|
|
|
+ sprintf(buffer, "ln %s %s/who/hardlink", dont_touch, container_dir);
|
|
|
run(buffer);
|
|
|
- // create a dot file in the task directory
|
|
|
- sprintf(buffer, "touch %s/who/let/.dotfile", task_dir);
|
|
|
+ // create a dot file in the container directory
|
|
|
+ sprintf(buffer, "touch %s/who/let/.dotfile", container_dir);
|
|
|
run(buffer);
|
|
|
// create a no permission file
|
|
|
- sprintf(buffer, "touch %s/who/let/protect", task_dir);
|
|
|
+ sprintf(buffer, "touch %s/who/let/protect", container_dir);
|
|
|
run(buffer);
|
|
|
- sprintf(buffer, "chmod 000 %s/who/let/protect", task_dir);
|
|
|
+ sprintf(buffer, "chmod 000 %s/who/let/protect", container_dir);
|
|
|
run(buffer);
|
|
|
// create a no permission directory
|
|
|
- sprintf(buffer, "chmod 000 %s/who/let", task_dir);
|
|
|
+ sprintf(buffer, "chmod 000 %s/who/let", container_dir);
|
|
|
run(buffer);
|
|
|
|
|
|
- // delete task directory
|
|
|
- int ret = delete_as_user(username, job_dir, NULL);
|
|
|
+ // delete container directory
|
|
|
+ int ret = delete_as_user(username, app_dir, NULL);
|
|
|
if (ret != 0) {
|
|
|
printf("FAIL: return code from delete_as_user is %d\n", ret);
|
|
|
exit(1);
|
|
|
}
|
|
|
|
|
|
- // check to make sure the task directory is gone
|
|
|
- if (access(task_dir, R_OK) == 0) {
|
|
|
- printf("FAIL: failed to delete the directory - %s\n", task_dir);
|
|
|
+ // check to make sure the container directory is gone
|
|
|
+ if (access(container_dir, R_OK) == 0) {
|
|
|
+ printf("FAIL: failed to delete the directory - %s\n", container_dir);
|
|
|
exit(1);
|
|
|
}
|
|
|
- // check to make sure the job directory is gone
|
|
|
- if (access(job_dir, R_OK) == 0) {
|
|
|
- printf("FAIL: didn't delete the directory - %s\n", job_dir);
|
|
|
+ // check to make sure the app directory is gone
|
|
|
+ if (access(app_dir, R_OK) == 0) {
|
|
|
+ printf("FAIL: didn't delete the directory - %s\n", app_dir);
|
|
|
exit(1);
|
|
|
}
|
|
|
// but that the canary is not gone
|
|
@@ -336,16 +326,16 @@ void test_delete_job() {
|
|
|
printf("FAIL: accidently deleted file %s\n", dont_touch);
|
|
|
exit(1);
|
|
|
}
|
|
|
- free(job_dir);
|
|
|
- free(task_dir);
|
|
|
+ free(app_dir);
|
|
|
+ free(container_dir);
|
|
|
free(dont_touch);
|
|
|
}
|
|
|
|
|
|
|
|
|
void test_delete_user() {
|
|
|
printf("\nTesting delete_user\n");
|
|
|
- char* job_dir = get_job_directory(TEST_ROOT "/local-1", username, "job_3");
|
|
|
- if (mkdirs(job_dir, 0700) != 0) {
|
|
|
+ char* app_dir = get_app_directory(TEST_ROOT "/local-1", username, "app_3");
|
|
|
+ if (mkdirs(app_dir, 0700) != 0) {
|
|
|
exit(1);
|
|
|
}
|
|
|
char buffer[100000];
|
|
@@ -365,7 +355,7 @@ void test_delete_user() {
|
|
|
printf("FAIL: local-1 directory does not exist\n");
|
|
|
exit(1);
|
|
|
}
|
|
|
- free(job_dir);
|
|
|
+ free(app_dir);
|
|
|
}
|
|
|
|
|
|
void run_test_in_child(const char* test_name, void (*func)()) {
|
|
@@ -397,8 +387,8 @@ void run_test_in_child(const char* test_name, void (*func)()) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void test_signal_task() {
|
|
|
- printf("\nTesting signal_task\n");
|
|
|
+void test_signal_container() {
|
|
|
+ printf("\nTesting signal_container\n");
|
|
|
fflush(stdout);
|
|
|
fflush(stderr);
|
|
|
pid_t child = fork();
|
|
@@ -412,8 +402,8 @@ void test_signal_task() {
|
|
|
sleep(3600);
|
|
|
exit(0);
|
|
|
} else {
|
|
|
- printf("Child task launched as %d\n", child);
|
|
|
- if (signal_user_task(username, child, SIGQUIT) != 0) {
|
|
|
+ printf("Child container launched as %d\n", child);
|
|
|
+ if (signal_container_as_user(username, child, SIGQUIT) != 0) {
|
|
|
exit(1);
|
|
|
}
|
|
|
int status = 0;
|
|
@@ -433,8 +423,8 @@ void test_signal_task() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void test_signal_task_group() {
|
|
|
- printf("\nTesting group signal_task\n");
|
|
|
+void test_signal_container_group() {
|
|
|
+ printf("\nTesting group signal_container\n");
|
|
|
fflush(stdout);
|
|
|
fflush(stderr);
|
|
|
pid_t child = fork();
|
|
@@ -449,8 +439,8 @@ void test_signal_task_group() {
|
|
|
sleep(3600);
|
|
|
exit(0);
|
|
|
}
|
|
|
- printf("Child task launched as %d\n", child);
|
|
|
- if (signal_user_task(username, child, SIGKILL) != 0) {
|
|
|
+ printf("Child container launched as %d\n", child);
|
|
|
+ if (signal_container_as_user(username, child, SIGKILL) != 0) {
|
|
|
exit(1);
|
|
|
}
|
|
|
int status = 0;
|
|
@@ -469,8 +459,8 @@ void test_signal_task_group() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void test_init_job() {
|
|
|
- printf("\nTesting init job\n");
|
|
|
+void test_init_app() {
|
|
|
+ printf("\nTesting init app\n");
|
|
|
if (seteuid(0) != 0) {
|
|
|
printf("FAIL: seteuid to root failed - %s\n", strerror(errno));
|
|
|
exit(1);
|
|
@@ -509,12 +499,12 @@ void test_init_job() {
|
|
|
fflush(stderr);
|
|
|
pid_t child = fork();
|
|
|
if (child == -1) {
|
|
|
- printf("FAIL: failed to fork process for init_job - %s\n",
|
|
|
+ printf("FAIL: failed to fork process for init_app - %s\n",
|
|
|
strerror(errno));
|
|
|
exit(1);
|
|
|
} else if (child == 0) {
|
|
|
char *final_pgm[] = {"touch", "my-touch-file", 0};
|
|
|
- if (initialize_job(username, "job_4", TEST_ROOT "/creds.txt", final_pgm) != 0) {
|
|
|
+ if (initialize_app(username, "app_4", TEST_ROOT "/creds.txt", final_pgm) != 0) {
|
|
|
printf("FAIL: failed in child\n");
|
|
|
exit(42);
|
|
|
}
|
|
@@ -527,37 +517,37 @@ void test_init_job() {
|
|
|
strerror(errno));
|
|
|
exit(1);
|
|
|
}
|
|
|
- if (access(TEST_ROOT "/logs/userlogs/job_4", R_OK) != 0) {
|
|
|
- printf("FAIL: failed to create job log directory\n");
|
|
|
+ if (access(TEST_ROOT "/logs/userlogs/app_4", R_OK) != 0) {
|
|
|
+ printf("FAIL: failed to create app log directory\n");
|
|
|
exit(1);
|
|
|
}
|
|
|
- char* job_dir = get_job_directory(TEST_ROOT "/local-1", username, "job_4");
|
|
|
- if (access(job_dir, R_OK) != 0) {
|
|
|
- printf("FAIL: failed to create job directory %s\n", job_dir);
|
|
|
+ char* app_dir = get_app_directory(TEST_ROOT "/local-1", username, "app_4");
|
|
|
+ if (access(app_dir, R_OK) != 0) {
|
|
|
+ printf("FAIL: failed to create app directory %s\n", app_dir);
|
|
|
exit(1);
|
|
|
}
|
|
|
char buffer[100000];
|
|
|
- sprintf(buffer, "%s/jobToken", job_dir);
|
|
|
+ sprintf(buffer, "%s/jobToken", app_dir);
|
|
|
if (access(buffer, R_OK) != 0) {
|
|
|
printf("FAIL: failed to create credentials %s\n", buffer);
|
|
|
exit(1);
|
|
|
}
|
|
|
- sprintf(buffer, "%s/my-touch-file", job_dir);
|
|
|
+ sprintf(buffer, "%s/my-touch-file", app_dir);
|
|
|
if (access(buffer, R_OK) != 0) {
|
|
|
printf("FAIL: failed to create touch file %s\n", buffer);
|
|
|
exit(1);
|
|
|
}
|
|
|
- free(job_dir);
|
|
|
- job_dir = get_job_log_directory("logs","job_4");
|
|
|
- if (access(job_dir, R_OK) != 0) {
|
|
|
- printf("FAIL: failed to create job log directory %s\n", job_dir);
|
|
|
+ free(app_dir);
|
|
|
+ app_dir = get_app_log_directory("logs","app_4");
|
|
|
+ if (access(app_dir, R_OK) != 0) {
|
|
|
+ printf("FAIL: failed to create app log directory %s\n", app_dir);
|
|
|
exit(1);
|
|
|
}
|
|
|
- free(job_dir);
|
|
|
+ free(app_dir);
|
|
|
}
|
|
|
|
|
|
-void test_run_task() {
|
|
|
- printf("\nTesting run task\n");
|
|
|
+void test_run_container() {
|
|
|
+ printf("\nTesting run container\n");
|
|
|
if (seteuid(0) != 0) {
|
|
|
printf("FAIL: seteuid to root failed - %s\n", strerror(errno));
|
|
|
exit(1);
|
|
@@ -576,7 +566,7 @@ void test_run_task() {
|
|
|
exit(1);
|
|
|
}
|
|
|
|
|
|
- const char* script_name = TEST_ROOT "/task-script";
|
|
|
+ const char* script_name = TEST_ROOT "/container-script";
|
|
|
FILE* script = fopen(script_name, "w");
|
|
|
if (script == NULL) {
|
|
|
printf("FAIL: failed to create script file - %s\n", strerror(errno));
|
|
@@ -598,16 +588,16 @@ void test_run_task() {
|
|
|
}
|
|
|
fflush(stdout);
|
|
|
fflush(stderr);
|
|
|
- char* task_dir = get_attempt_work_directory(TEST_ROOT "/local-1",
|
|
|
- username, "job_4", "task_1");
|
|
|
+ char* container_dir = get_container_work_directory(TEST_ROOT "/local-1",
|
|
|
+ username, "app_4", "container_1");
|
|
|
pid_t child = fork();
|
|
|
if (child == -1) {
|
|
|
- printf("FAIL: failed to fork process for init_job - %s\n",
|
|
|
+ printf("FAIL: failed to fork process for init_app - %s\n",
|
|
|
strerror(errno));
|
|
|
exit(1);
|
|
|
} else if (child == 0) {
|
|
|
- if (run_task_as_user(username, "job_4", "task_1",
|
|
|
- task_dir, script_name, TEST_ROOT "creds.txt") != 0) {
|
|
|
+ if (launch_container_as_user(username, "app_4", "container_1",
|
|
|
+ container_dir, script_name, TEST_ROOT "creds.txt") != 0) {
|
|
|
printf("FAIL: failed in child\n");
|
|
|
exit(42);
|
|
|
}
|
|
@@ -620,31 +610,32 @@ void test_run_task() {
|
|
|
strerror(errno));
|
|
|
exit(1);
|
|
|
}
|
|
|
- if (access(TEST_ROOT "/logs/userlogs/job_4/task_1", R_OK) != 0) {
|
|
|
- printf("FAIL: failed to create task log directory\n");
|
|
|
+ if (access(TEST_ROOT "/logs/userlogs/app_4/container_1", R_OK) != 0) {
|
|
|
+ printf("FAIL: failed to create container log directory\n");
|
|
|
exit(1);
|
|
|
}
|
|
|
- if (access(task_dir, R_OK) != 0) {
|
|
|
- printf("FAIL: failed to create task directory %s\n", task_dir);
|
|
|
+ if (access(container_dir, R_OK) != 0) {
|
|
|
+ printf("FAIL: failed to create container directory %s\n", container_dir);
|
|
|
exit(1);
|
|
|
}
|
|
|
char buffer[100000];
|
|
|
- sprintf(buffer, "%s/foobar", task_dir);
|
|
|
+ sprintf(buffer, "%s/foobar", container_dir);
|
|
|
if (access(buffer, R_OK) != 0) {
|
|
|
printf("FAIL: failed to create touch file %s\n", buffer);
|
|
|
exit(1);
|
|
|
}
|
|
|
- free(task_dir);
|
|
|
- task_dir = get_job_log_directory("logs", "job_4/task_1");
|
|
|
- if (access(task_dir, R_OK) != 0) {
|
|
|
- printf("FAIL: failed to create job log directory %s\n", task_dir);
|
|
|
+ free(container_dir);
|
|
|
+ container_dir = get_app_log_directory("logs", "app_4/container_1");
|
|
|
+ if (access(container_dir, R_OK) != 0) {
|
|
|
+ printf("FAIL: failed to create app log directory %s\n", container_dir);
|
|
|
exit(1);
|
|
|
}
|
|
|
- free(task_dir);
|
|
|
+ free(container_dir);
|
|
|
}
|
|
|
|
|
|
int main(int argc, char **argv) {
|
|
|
LOGFILE = stdout;
|
|
|
+ ERRORFILE = stderr;
|
|
|
int my_username = 0;
|
|
|
|
|
|
// clean up any junk from previous run
|
|
@@ -659,7 +650,7 @@ int main(int argc, char **argv) {
|
|
|
}
|
|
|
read_config(TEST_ROOT "/test.cfg");
|
|
|
|
|
|
- create_tt_roots();
|
|
|
+ create_nm_roots();
|
|
|
|
|
|
if (getuid() == 0 && argc == 2) {
|
|
|
username = argv[1];
|
|
@@ -667,7 +658,7 @@ int main(int argc, char **argv) {
|
|
|
username = strdup(getpwuid(getuid())->pw_name);
|
|
|
my_username = 1;
|
|
|
}
|
|
|
- set_tasktracker_uid(geteuid(), getegid());
|
|
|
+ set_nm_uid(geteuid(), getegid());
|
|
|
|
|
|
if (set_user(username)) {
|
|
|
exit(1);
|
|
@@ -678,25 +669,25 @@ int main(int argc, char **argv) {
|
|
|
printf("\nTesting get_user_directory()\n");
|
|
|
test_get_user_directory();
|
|
|
|
|
|
- printf("\nTesting get_job_directory()\n");
|
|
|
- test_get_job_directory();
|
|
|
+ printf("\nTesting get_app_directory()\n");
|
|
|
+ test_get_app_directory();
|
|
|
|
|
|
- printf("\nTesting get_attempt_directory()\n");
|
|
|
- test_get_attempt_directory();
|
|
|
+ printf("\nTesting get_container_directory()\n");
|
|
|
+ test_get_container_directory();
|
|
|
|
|
|
- printf("\nTesting get_task_launcher_file()\n");
|
|
|
- test_get_task_launcher_file();
|
|
|
+ printf("\nTesting get_container_launcher_file()\n");
|
|
|
+ test_get_container_launcher_file();
|
|
|
|
|
|
- printf("\nTesting get_job_log_dir()\n");
|
|
|
- test_get_job_log_dir();
|
|
|
+ printf("\nTesting get_app_log_dir()\n");
|
|
|
+ test_get_app_log_dir();
|
|
|
|
|
|
test_check_configuration_permissions();
|
|
|
|
|
|
- printf("\nTesting delete_task()\n");
|
|
|
- test_delete_task();
|
|
|
+ printf("\nTesting delete_container()\n");
|
|
|
+ test_delete_container();
|
|
|
|
|
|
- printf("\nTesting delete_job()\n");
|
|
|
- test_delete_job();
|
|
|
+ printf("\nTesting delete_app()\n");
|
|
|
+ test_delete_app();
|
|
|
|
|
|
test_delete_user();
|
|
|
|
|
@@ -704,15 +695,15 @@ int main(int argc, char **argv) {
|
|
|
|
|
|
// the tests that change user need to be run in a subshell, so that
|
|
|
// when they change user they don't give up our privs
|
|
|
- run_test_in_child("test_signal_task", test_signal_task);
|
|
|
- run_test_in_child("test_signal_task_group", test_signal_task_group);
|
|
|
+ run_test_in_child("test_signal_container", test_signal_container);
|
|
|
+ run_test_in_child("test_signal_container_group", test_signal_container_group);
|
|
|
|
|
|
- // init job and run task can't be run if you aren't testing as root
|
|
|
+ // init app and run container can't be run if you aren't testing as root
|
|
|
if (getuid() == 0) {
|
|
|
// these tests do internal forks so that the change_owner and execs
|
|
|
// don't mess up our process.
|
|
|
- test_init_job();
|
|
|
- test_run_task();
|
|
|
+ test_init_app();
|
|
|
+ test_run_container();
|
|
|
}
|
|
|
|
|
|
seteuid(0);
|