1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 * Ceph - scalable distributed file system
6 * Copyright (C) 2011 New Dream Network
8 * This is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License version 2.1, as published by the Free Software
11 * Foundation. See file COPYING.
15 #include "cross_process_sem.h"
16 #include "include/rados/librados.h"
17 #include "st_rados_create_pool.h"
18 #include "st_rados_delete_pool.h"
19 #include "st_rados_list_objects.h"
20 #include "systest_runnable.h"
21 #include "systest_settings.h"
25 #include <semaphore.h>
34 using std::ostringstream;
38 static int g_num_objects = 50;
41 * rados_delete_pools_parallel
43 * This tests creation and deletion races.
45 * EXPECT: * can delete a pool while another user is using it
46 * * operations on pools return error codes after the pools
49 * DO NOT EXPECT * hangs, crashes
52 const char *get_id_str()
57 int main(int argc, const char **argv)
59 const char *num_objects = getenv("NUM_OBJECTS");
60 const std::string pool = get_temp_pool_name(argv[0]);
62 g_num_objects = atoi(num_objects);
63 if (g_num_objects == 0)
67 CrossProcessSem *pool_setup_sem = NULL;
68 RETURN1_IF_NONZERO(CrossProcessSem::create(0, &pool_setup_sem));
69 CrossProcessSem *delete_pool_sem = NULL;
70 RETURN1_IF_NONZERO(CrossProcessSem::create(0, &delete_pool_sem));
72 // first test: create a pool, then delete that pool
74 StRadosCreatePool r1(argc, argv, NULL, pool_setup_sem, NULL,
76 StRadosDeletePool r2(argc, argv, pool_setup_sem, NULL, pool);
77 vector < SysTestRunnable* > vec;
80 std::string error = SysTestRunnable::run_until_finished(vec);
82 printf("test1: got error: %s\n", error.c_str());
87 // second test: create a pool, the list objects in that pool while it's
89 RETURN1_IF_NONZERO(pool_setup_sem->reinit(0));
90 RETURN1_IF_NONZERO(delete_pool_sem->reinit(0));
92 StRadosCreatePool r1(argc, argv, NULL, pool_setup_sem, NULL,
93 pool, g_num_objects, ".obj");
94 StRadosDeletePool r2(argc, argv, delete_pool_sem, NULL, pool);
95 StRadosListObjects r3(argc, argv, pool, true, g_num_objects / 2,
96 pool_setup_sem, NULL, delete_pool_sem);
97 vector < SysTestRunnable* > vec;
101 std::string error = SysTestRunnable::run_until_finished(vec);
102 if (!error.empty()) {
103 printf("test2: got error: %s\n", error.c_str());
108 printf("******* SUCCESS **********\n");