tests: No need to run onnode in parallel for single node
[ctdb.git] / tests / simple / 71_ctdb_wipedb.sh
1 #!/bin/bash
2
3 test_info()
4 {
5     cat <<EOF
6 The command 'ctdb wipedb' is used to clear a database across the whole
7 cluster.
8
9 Prerequisites:
10
11 * An active CTDB cluster with at least 2 active nodes.
12
13 Steps:
14
15 1. Verify that the status on all of the ctdb nodes is 'OK'.
16 2. create a persistent test database
17 3, add some records to node #0 and node #1
18 4, perform wipedb on node #0 and verify the database is empty on both node 0 and 1
19
20 Expected results:
21
22 * that 4 will result in empty database
23
24 EOF
25 }
26
27 . "${TEST_SCRIPTS_DIR}/integration.bash"
28
29 ctdb_test_init "$@"
30
31 set -e
32
33 cluster_is_healthy
34
35 try_command_on_node 0 "$CTDB listnodes"
36 num_nodes=$(echo "$out" | wc -l)
37
38 # create a temporary persistent database to test with
39 echo create persistent test database persistent_test.tdb
40 try_command_on_node 0 $CTDB_TEST_WRAPPER ctdb attach persistent_test.tdb persistent
41
42
43 # 3,
44 # add one record to node 0   key==ABC  data==ABC
45 TDB=`try_command_on_node -v 0 $CTDB_TEST_WRAPPER ctdb getdbmap | grep persistent_test.tdb | sed -e "s/.*path://" -e "s/ .*//"`
46 echo "store key(ABC) data(ABC) on node 0"
47 try_command_on_node 0 $CTDB_TEST_WRAPPER ctdb tstore $TDB 0x414243 0x070000000000000000000000000000000000000000000000414243
48 #
49 # add one record to node 1   key==DEF  data==DEF
50 TDB=`try_command_on_node -v 1 $CTDB_TEST_WRAPPER ctdb getdbmap | grep persistent_test.tdb | sed -e "s/.*path://" -e "s/ .*//"`
51 echo "store key(DEF) data(DEF) on node 1"
52 try_command_on_node 1 $CTDB_TEST_WRAPPER ctdb tstore $TDB 0x444546 0x070000000000000000000000000000000000000000000000444546
53
54
55 # 4,
56 echo wipe the persistent test database
57 try_command_on_node 0 $CTDB_TEST_WRAPPER ctdb wipedb persistent_test.tdb
58 echo force a recovery
59 try_command_on_node 0 $CTDB_TEST_WRAPPER ctdb recover
60
61 # check that the database is wiped
62 num_records=$(try_command_on_node -v 1 $CTDB_TEST_WRAPPER ctdb cattdb persistent_test.tdb | grep key | wc -l)
63 [ $num_records != "0" ] && {
64     echo "BAD: we did not end up with an empty database"
65     exit 1
66 }
67 echo "OK. database was wiped"
68