1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Lustre Light user test program
6 * Copyright (c) 2002, 2003 Cluster File Systems, Inc.
8 * This file is part of Lustre, http://www.lustre.org.
10 * Lustre is free software; you can redistribute it and/or
11 * modify it under the terms of version 2 of the GNU General Public
12 * License as published by the Free Software Foundation.
14 * Lustre is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with Lustre; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
31 #include <sys/types.h>
34 #include <sys/queue.h>
40 #include "test_common.h"
42 #define MAX_STRING_SIZE 2048
44 static char mds_server[MAX_STRING_SIZE] = {0,};
45 static char barrier_script[MAX_STRING_SIZE] = {0,};
46 static char failover_script[MAX_STRING_SIZE] = {0,};
47 static char barrier_cmd[MAX_STRING_SIZE] = {0,};
48 static char failover_cmd[MAX_STRING_SIZE] = {0,};
49 static char ssh_cmd[MAX_STRING_SIZE] = {0,};
51 static void replay_barrier()
55 if ((rc = system(barrier_cmd))) {
56 printf("excute barrier error: %d\n", rc);
61 static void mds_failover()
65 if ((rc = system(failover_cmd))) {
66 printf("excute failover error: %d\n", rc);
76 sprintf(buf, "===== START: %s ", (str)); \
79 memset(buf+len, '=', 100-len); \
88 printf("----- END TEST successfully ---"); \
89 printf("-----------------------------"); \
90 printf("-------------------\n"); \
95 ENTRY("empty replay");
103 char *path="/mnt/lustre/f1";
104 ENTRY("simple create");
109 t_check_stat(path, NULL);
116 char *path="/mnt/lustre/f2a";
122 t_check_stat(path, NULL);
129 char *path="/mnt/lustre/f2b";
130 ENTRY("mcreate+touch");
136 t_check_stat(path, NULL);
142 void n_create_delete(int nfiles)
144 char *base="/mnt/lustre/f3_";
150 for (i = 0; i < nfiles; i++) {
151 sprintf(path, "%s%d\n", base, i);
152 sprintf(str, "TEST#%d CONTENT\n", i);
153 t_echo_create(path, str);
156 for (i = 0; i < nfiles; i++) {
157 sprintf(path, "%s%d\n", base, i);
158 sprintf(str, "TEST#%d CONTENT\n", i);
162 for (i = 0; i < nfiles; i++) {
163 sprintf(path, "%s%d\n", base, i);
167 for (i = 0; i < nfiles; i++) {
168 sprintf(path, "%s%d\n", base, i);
169 t_check_stat_fail(path);
176 ENTRY("10 create/delete");
183 ENTRY("30 create/delete(>1'st block precreated)");
190 char *dir="/mnt/lustre/d4";
191 char *path="/mnt/lustre/d4/f1";
192 ENTRY("mkdir + contained create");
198 t_check_stat(dir, NULL);
199 t_check_stat(path, NULL);
200 sleep(2); /* wait for log process thread */
206 t_check_stat_fail(dir);
207 t_check_stat_fail(path);
213 char *dir="/mnt/lustre/d5";
214 char *path="/mnt/lustre/d5/f1";
215 ENTRY("mkdir |X| contained create");
221 t_check_stat(dir, NULL);
222 t_check_stat(path, NULL);
230 char *path="/mnt/lustre/f6";
232 ENTRY("open |X| close");
239 t_check_stat(path, NULL);
247 char *path="/mnt/lustre/f7";
248 char *path2="/mnt/lustre/f7-2";
249 ENTRY("create |X| rename unlink");
253 t_rename(path, path2);
255 t_check_stat_fail(path);
256 t_check_stat(path2, NULL);
262 char *path="/mnt/lustre/f8";
263 char *path2="/mnt/lustre/f8-2";
264 ENTRY("create open write rename |X| create-old-name read");
267 t_echo_create(path, "old");
268 t_rename(path, path2);
270 t_echo_create(path, "new");
273 t_grep(path2, "old");
280 char *path="/mnt/lustre/f9";
281 char *path2="/mnt/lustre/f9-2";
282 ENTRY("|X| open(O_CREAT), unlink, touch new, unlink new");
289 t_check_stat_fail(path);
290 t_check_stat(path2, NULL);
296 char *path="/mnt/lustre/f10";
297 char *path2="/mnt/lustre/f10-2";
298 ENTRY("|X| mcreate, open write, rename");
302 t_echo_create(path, "old");
303 t_rename(path, path2);
304 t_grep(path2, "old");
306 t_grep(path2, "old");
310 extern int portal_debug;
311 extern int portal_subsystem_debug;
313 extern void __liblustre_setup_(void);
314 extern void __liblustre_cleanup_(void);
316 void usage(const char *cmd)
318 printf("Usage: \t%s --target mdsnid:/mdsname/profile -s mds_hostname "
319 "-b \"barrier cmd\" -f \"failover cmd\" --ssh \"ssh_cmd\"\n", cmd);
320 printf(" \t%s --dumpfile dumpfile -s mds_hostname -b \"barrier cmd\" "
321 "-f \"failover cmd\" --ssh \"ssh_cmd\"\n", cmd);
327 char cmd[MAX_STRING_SIZE];
329 sprintf(cmd, "%s %s cat /dev/null", ssh_cmd, mds_server);
331 printf("Can't access server node: %s using method: %s\n", mds_server, ssh_cmd);
336 int main(int argc, char * const argv[])
339 static struct option long_opts[] = {
341 {"dumpfile", 1, 0, 0},
349 while ((c = getopt_long(argc, argv, "s:b:f:", long_opts, &opt_index)) != -1) {
355 if (!strcmp(long_opts[opt_index].name, "target")) {
356 setenv(ENV_LUSTRE_MNTTGT, optarg, 1);
357 } else if (!strcmp(long_opts[opt_index].name, "dumpfile")) {
358 setenv(ENV_LUSTRE_DUMPFILE, optarg, 1);
359 } else if (!strcmp(long_opts[opt_index].name, "ssh")) {
360 safe_strncpy(ssh_cmd, optarg, MAX_STRING_SIZE);
366 safe_strncpy(mds_server, optarg, MAX_STRING_SIZE);
369 safe_strncpy(barrier_script, optarg, MAX_STRING_SIZE);
372 safe_strncpy(failover_script, optarg, MAX_STRING_SIZE);
381 if (!strlen(mds_server) || !strlen(barrier_script) ||
382 !strlen(failover_script))
385 /* default to using ssh */
386 if (!strlen(ssh_cmd)) {
387 safe_strncpy(ssh_cmd, "ssh", MAX_STRING_SIZE);
392 /* prepare remote command */
393 sprintf(barrier_cmd, "%s %s \"%s\"",
394 ssh_cmd, mds_server, barrier_script);
395 sprintf(failover_cmd, "%s %s \"%s\"",
396 ssh_cmd, mds_server, failover_script);
398 setenv(ENV_LUSTRE_TIMEOUT, "10", 1);
400 __liblustre_setup_();
416 printf("liblustre is about shutdown\n");
417 __liblustre_cleanup_();
419 printf("complete successfully\n");