1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2011 New Dream Network
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#include "cross_process_sem.h"
#include "include/rados/librados.h"
#include "st_rados_create_pool.h"
#include "st_rados_delete_pool.h"
#include "st_rados_list_objects.h"
#include "systest_runnable.h"
#include "systest_settings.h"
#include <errno.h>
#include <pthread.h>
#include <semaphore.h>
#include <sstream>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <time.h>
#include <vector>
using std::ostringstream;
using std::string;
using std::vector;
static int g_num_objects = 50;
/*
* rados_delete_pools_parallel
*
* This tests creation and deletion races.
*
* EXPECT: * can delete a pool while another user is using it
* * operations on pools return error codes after the pools
* are deleted
*
* DO NOT EXPECT * hangs, crashes
*/
const char *get_id_str()
{
return "main";
}
int main(int argc, const char **argv)
{
const char *num_objects = getenv("NUM_OBJECTS");
const std::string pool = get_temp_pool_name(argv[0]);
if (num_objects) {
g_num_objects = atoi(num_objects);
if (g_num_objects == 0)
return 100;
}
CrossProcessSem *pool_setup_sem = NULL;
RETURN1_IF_NONZERO(CrossProcessSem::create(0, &pool_setup_sem));
CrossProcessSem *delete_pool_sem = NULL;
RETURN1_IF_NONZERO(CrossProcessSem::create(0, &delete_pool_sem));
CrossProcessSem *deleted_pool_sem = NULL;
RETURN1_IF_NONZERO(CrossProcessSem::create(0, &deleted_pool_sem));
// first test: create a pool, then delete that pool
{
StRadosCreatePool r1(argc, argv, NULL, pool_setup_sem, NULL,
pool, 50, ".obj");
StRadosDeletePool r2(argc, argv, pool_setup_sem, deleted_pool_sem, pool);
vector < SysTestRunnable* > vec;
vec.push_back(&r1);
vec.push_back(&r2);
std::string error = SysTestRunnable::run_until_finished(vec);
if (!error.empty()) {
printf("test1: got error: %s\n", error.c_str());
return EXIT_FAILURE;
}
}
// second test: create a pool, the list objects in that pool while it's
// being deleted.
RETURN1_IF_NONZERO(pool_setup_sem->reinit(0));
RETURN1_IF_NONZERO(delete_pool_sem->reinit(0));
{
StRadosCreatePool r1(argc, argv, deleted_pool_sem, pool_setup_sem, NULL,
pool, g_num_objects, ".obj");
StRadosDeletePool r2(argc, argv, delete_pool_sem, NULL, pool);
StRadosListObjects r3(argc, argv, pool, true, g_num_objects / 2,
pool_setup_sem, NULL, delete_pool_sem);
vector < SysTestRunnable* > vec;
vec.push_back(&r1);
vec.push_back(&r2);
vec.push_back(&r3);
std::string error = SysTestRunnable::run_until_finished(vec);
if (!error.empty()) {
printf("test2: got error: %s\n", error.c_str());
return EXIT_FAILURE;
}
}
printf("******* SUCCESS **********\n");
return EXIT_SUCCESS;
}
|