Debian Codegraph @

tools/ocft/db2

raw
1 # db2
2 #
3 # This test assumes a db2 ESE instance with two partitions and a database.
4 # Default is instance=db2inst1, database=ocft
5 # adapt this in set_testenv below
6 #
7 # Simple steps to generate a test environment (if you don't have one):
8 #
9 # A virtual machine with 1200MB RAM is sufficient
10 #
11 # - download an eval version of DB2 server from IBM
12 # - create an user "db2inst1" in group "db2inst1"
13 #
14 # As root
15 # - install DB2 software in some location
16 # - create instance
17 # cd <this_location>/instance
18 # ./db2icrt -s ese -u db2inst1 db2inst1
19 # - adapt profile of db2inst1 as instructed by db2icrt
20 #
21 # As db2inst1
22 # # allow to run with small memory footprint
23 # db2set DB2_FCM_SETTINGS=FCM_MAXIMIZE_SET_SIZE:FALSE
24 # db2start
25 # db2start dbpartitionnum 1 add dbpartitionnum hostname $(uname -n) port 1 without tablespaces
26 # db2stop
27 # db2start
28 # db2 create database ocft
29 # Done
30 # In order to install a real cluster refer to http://www.linux-ha.org/wiki/db2_(resource_agent)
31
32 CONFIG
33 Agent db2
34 AgentRoot /usr/lib/ocf/resource.d/heartbeat
35 HangTimeout 40
36
37 SETUP-AGENT
38 # nothing
39
40 CASE-BLOCK set_testenv
41 Env OCFT_instance=db2inst1
42 Env OCFT_db=ocft
43
44 CASE-BLOCK crm_setting
45 Env OCF_RESKEY_instance=$OCFT_instance
46 Env OCF_RESKEY_CRM_meta_timeout=30000
47
48 CASE-BLOCK default_status
49 AgentRun stop
50
51 CASE-BLOCK prepare
52 Include set_testenv
53 Include crm_setting
54 Include default_status
55
56 CASE "check base env"
57 Include prepare
58 AgentRun start OCF_SUCCESS
59
60 CASE "check base env: invalid 'OCF_RESKEY_instance'"
61 Include prepare
62 Env OCF_RESKEY_instance=no_such
63 AgentRun start OCF_ERR_INSTALLED
64
65 CASE "invalid instance config"
66 Include prepare
67 Bash eval mv ~$OCFT_instance/sqllib ~$OCFT_instance/sqllib-
68 BashAtExit eval mv ~$OCFT_instance/sqllib- ~$OCFT_instance/sqllib
69 AgentRun start OCF_ERR_INSTALLED
70
71 CASE "unimplemented command"
72 Include prepare
73 AgentRun no_cmd OCF_ERR_UNIMPLEMENTED
74
75 CASE "normal start"
76 Include prepare
77 AgentRun start OCF_SUCCESS
78
79 CASE "normal stop"
80 Include prepare
81 AgentRun start
82 AgentRun stop OCF_SUCCESS
83
84 CASE "double start"
85 Include prepare
86 AgentRun start
87 AgentRun start OCF_SUCCESS
88
89 CASE "double stop"
90 Include prepare
91 AgentRun stop OCF_SUCCESS
92
93 CASE "started: monitor"
94 Include prepare
95 AgentRun start
96 AgentRun monitor OCF_SUCCESS
97
98 CASE "not started: monitor"
99 Include prepare
100 AgentRun monitor OCF_NOT_RUNNING
101
102 CASE "killed instance: monitor"
103 Include prepare
104 AgentRun start OCF_SUCCESS
105 AgentRun monitor OCF_SUCCESS
106 BashAtExit rm /tmp/ocft-helper1
107 Bash echo "su $OCFT_instance -c '. ~$OCFT_instance/sqllib/db2profile; db2nkill 0 >/dev/null 2>&1'" > /tmp/ocft-helper1
108 Bash sh -x /tmp/ocft-helper1
109 AgentRun monitor OCF_NOT_RUNNING
110
111 CASE "overload param instance by admin"
112 Include prepare
113 Env OCF_RESKEY_instance=no_such
114 Env OCF_RESKEY_admin=$OCFT_instance
115 AgentRun start OCF_SUCCESS
116
117 CASE "check start really activates db"
118 Include prepare
119 AgentRun start OCF_SUCCESS
120
121 BashAtExit rm /tmp/ocft-helper2
122 Bash echo "su $OCFT_instance -c '. ~$OCFT_instance/sqllib/db2profile; db2 get snapshot for database on $OCFT_db>/dev/null'" > /tmp/ocft-helper2
123 Bash sh -x /tmp/ocft-helper2
124
125 CASE "multipartion test"
126 Include prepare
127 AgentRun start OCF_SUCCESS
128 AgentRun monitor OCF_SUCCESS
129
130 # start does not start partion 1
131 Env OCF_RESKEY_dbpartitionnum=1
132 AgentRun monitor OCF_NOT_RUNNING
133
134 # now start 1
135 AgentRun start OCF_SUCCESS
136 AgentRun monitor OCF_SUCCESS
137
138 # now stop 1
139 AgentRun stop OCF_SUCCESS
140 AgentRun monitor OCF_NOT_RUNNING
141
142 # does not affect 0
143 Env OCF_RESKEY_dbpartitionnum=0
144 AgentRun monitor OCF_SUCCESS
145
146 # fault injection does not work on the 1.0.4 client due to a hardcoded path
147 CASE "simulate hanging db2stop (not meaningful for 1.0.4 agent)"
148 Include prepare
149 AgentRun start OCF_SUCCESS
150 Bash [ ! -f /usr/local/bin/db2stop ]
151 BashAtExit rm /usr/local/bin/db2stop
152 Bash echo -e "#!/bin/sh\necho fake db2stop\nsleep 10000" > /usr/local/bin/db2stop
153 Bash chmod +x /usr/local/bin/db2stop
154 AgentRun stop OCF_SUCCESS
155
156 # fault injection does not work on the 1.0.4 client due to a hardcoded path
157 CASE "simulate not stopping db2stop (not meaningful for 1.0.4 agent)"
158 Include prepare
159 AgentRun start OCF_SUCCESS
160 Bash [ ! -f /usr/local/bin/db2stop ]
161 BashAtExit rm /usr/local/bin/db2stop
162 Bash echo -e "#!/bin/sh\necho fake db2stop\nexit 0" > /usr/local/bin/db2stop
163 Bash chmod +x /usr/local/bin/db2stop
164 AgentRun stop OCF_SUCCESS