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"
44 static char mds_server[1024] = {0,};
45 static char barrier_script[1024] = {0,};
46 static char failover_script[1024] = {0,};
47 static char barrier_cmd[1024] = {0,};
48 static char failover_cmd[1024] = {0,};
50 static void replay_barrier()
54 if ((rc = system(barrier_cmd))) {
55 printf("excute barrier error: %d\n", rc);
60 static void mds_failover()
64 if ((rc = system(failover_cmd))) {
65 printf("excute failover error: %d\n", rc);
75 sprintf(buf, "===== START: %s ", (str)); \
78 memset(buf+len, '=', 100-len); \
87 printf("----- END TEST successfully ---"); \
88 printf("-----------------------------"); \
89 printf("-------------------\n"); \
94 ENTRY("empty replay");
102 char *path="/mnt/lustre/f1";
103 ENTRY("simple create");
108 t_check_stat(path, NULL);
115 char *path="/mnt/lustre/f2a";
121 t_check_stat(path, NULL);
128 char *path="/mnt/lustre/f2b";
129 ENTRY("mcreate+touch");
135 t_check_stat(path, NULL);
141 void n_create_delete(int nfiles)
143 char *base="/mnt/lustre/f3_";
149 for (i = 0; i < nfiles; i++) {
150 sprintf(path, "%s%d\n", base, i);
151 sprintf(str, "TEST#%d CONTENT\n", i);
152 t_echo_create(path, str);
155 for (i = 0; i < nfiles; i++) {
156 sprintf(path, "%s%d\n", base, i);
157 sprintf(str, "TEST#%d CONTENT\n", i);
161 for (i = 0; i < nfiles; i++) {
162 sprintf(path, "%s%d\n", base, i);
166 for (i = 0; i < nfiles; i++) {
167 sprintf(path, "%s%d\n", base, i);
168 t_check_stat_fail(path);
175 ENTRY("10 create/delete");
182 ENTRY("30 create/delete(>1'st block precreated)");
189 char *dir="/mnt/lustre/d4";
190 char *path="/mnt/lustre/d4/f1";
191 ENTRY("mkdir + contained create");
197 t_check_stat(dir, NULL);
198 t_check_stat(path, NULL);
199 sleep(2); /* wait for log process thread */
205 t_check_stat_fail(dir);
206 t_check_stat_fail(path);
212 char *dir="/mnt/lustre/d5";
213 char *path="/mnt/lustre/d5/f1";
214 ENTRY("mkdir |X| contained create");
220 t_check_stat(dir, NULL);
221 t_check_stat(path, NULL);
229 char *path="/mnt/lustre/f6";
231 ENTRY("open |X| close");
238 t_check_stat(path, NULL);
246 char *path="/mnt/lustre/f7";
247 char *path2="/mnt/lustre/f7-2";
248 ENTRY("create |X| rename unlink");
252 t_rename(path, path2);
254 t_check_stat_fail(path);
255 t_check_stat(path2, NULL);
261 char *path="/mnt/lustre/f8";
262 char *path2="/mnt/lustre/f8-2";
263 ENTRY("create open write rename |X| create-old-name read");
266 t_echo_create(path, "old");
267 t_rename(path, path2);
269 t_echo_create(path, "new");
272 t_grep(path2, "old");
279 char *path="/mnt/lustre/f9";
280 char *path2="/mnt/lustre/f9-2";
281 ENTRY("|X| open(O_CREAT), unlink, touch new, unlink new");
288 t_check_stat_fail(path);
289 t_check_stat(path2, NULL);
295 char *path="/mnt/lustre/f10";
296 char *path2="/mnt/lustre/f10-2";
297 ENTRY("|X| mcreate, open write, rename");
301 t_echo_create(path, "old");
302 t_rename(path, path2);
303 t_grep(path2, "old");
305 t_grep(path2, "old");
309 extern int portal_debug;
310 extern int portal_subsystem_debug;
312 extern void __liblustre_setup_(void);
313 extern void __liblustre_cleanup_(void);
315 void usage(const char *cmd)
317 printf("Usage: \t%s --target mdsnid:/mdsname/profile -s mds_hostname "
318 "-b \"barrier cmd\" -f \"failover cmd\"\n", cmd);
319 printf(" \t%s --dumpfile dumpfile -s mds_hostname -b \"barrier cmd\" "
320 "-f \"failover cmd\"\n", cmd);
328 sprintf(cmd, "ssh %s cat /dev/null", mds_server);
330 printf("ssh can't access server node: %s\n", mds_server);
335 int main(int argc, char * const argv[])
338 static struct option long_opts[] = {
340 {"dumpfile", 1, 0, 0},
347 while ((c = getopt_long(argc, argv, "s:b:f:", long_opts, &opt_index)) != -1) {
353 if (!strcmp(long_opts[opt_index].name, "target")) {
354 setenv(ENV_LUSTRE_MNTTGT, optarg, 1);
355 } else if (!strcmp(long_opts[opt_index].name, "dumpfile")) {
356 setenv(ENV_LUSTRE_DUMPFILE, optarg, 1);
362 strcpy(mds_server, optarg);
365 strcpy(barrier_script, optarg);
368 strcpy(failover_script, optarg);
377 if (!strlen(mds_server) || !strlen(barrier_script) ||
378 !strlen(failover_script))
383 /* prepare remote command */
384 sprintf(barrier_cmd, "ssh %s \"%s\"", mds_server, barrier_script);
385 sprintf(failover_cmd, "ssh %s \"%s\"", mds_server, failover_script);
387 setenv(ENV_LUSTRE_TIMEOUT, "10", 1);
389 __liblustre_setup_();
405 printf("liblustre is about shutdown\n");
406 __liblustre_cleanup_();
408 printf("complete successfully\n");