Merge lp:~ubuntu-branches/ubuntu/quantal/charm-tools/quantal-201207232113 into lp:ubuntu/quantal/charm-tools

Proposed by Ubuntu Package Importer
Status: Rejected
Rejected by: James Westby
Proposed branch: lp:~ubuntu-branches/ubuntu/quantal/charm-tools/quantal-201207232113
Merge into: lp:ubuntu/quantal/charm-tools
Diff against target: 953 lines (+0/-472)
1 file modified
tests/helpers/disabled_test_peer.sh (+0/-472)
To merge this branch: bzr merge lp:~ubuntu-branches/ubuntu/quantal/charm-tools/quantal-201207232113
Reviewer Review Type Date Requested Status
Ubuntu branches Pending
Review via email: mp+116377@code.launchpad.net

Description of the change

The package importer has detected a possible inconsistency between the package history in the archive and the history in bzr. As the archive is authoritative the importer has made lp:ubuntu/quantal/charm-tools reflect what is in the archive and the old bzr branch has been pushed to lp:~ubuntu-branches/ubuntu/quantal/charm-tools/quantal-201207232113. This merge proposal was created so that an Ubuntu developer can review the situations and perform a merge/upload if necessary. There are three typical cases where this can happen.
  1. Where someone pushes a change to bzr and someone else uploads the package without that change. This is the reason that this check is done by the importer. If this appears to be the case then a merge/upload should be done if the changes that were in bzr are still desirable.
  2. The importer incorrectly detected the above situation when someone made a change in bzr and then uploaded it.
  3. The importer incorrectly detected the above situation when someone just uploaded a package and didn't touch bzr.

If this case doesn't appear to be the first situation then set the status of the merge proposal to "Rejected" and help avoid the problem in future by filing a bug at https://bugs.launchpad.net/udd linking to this merge proposal.

(this is an automatically generated message)

To post a comment you must log in.

Unmerged revisions

18. By Clint Byrum

releasing version 0.3+151-0ubuntu1

17. By Clint Byrum

New upstream release.

16. By Clint Byrum

d/charm-tools.install: Install etc/* to pick up bash completion.

15. By Clint Byrum

buid-dep on python-apt and python-cheetah to enable new upstream
tests.

14. By Clint Byrum

Removing python build until python-shelltoolbox is packaged.

13. By Clint Byrum

build-dep on python-yaml so charm proof tests can be run.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'tests/helpers/disabled_test_peer.sh'
2--- tests/helpers/disabled_test_peer.sh 1970-01-01 00:00:00 +0000
3+++ tests/helpers/disabled_test_peer.sh 2012-07-23 21:21:18 +0000
4@@ -0,0 +1,472 @@
5+#!/bin/sh
6+
7+# debug=1 full
8+# debug=2 client only
9+debug=0
10+
11+if [ -z "$test_home" ] ; then
12+ test_home=`dirname $0`
13+ test_home=`readlink -f $test_home`
14+fi
15+
16+[ "$LIB_SOURCED" = "1" ] || . $test_home/lib.sh
17+
18+set -ue
19+
20+JUJU_UNIT_NAME="EMPTY"
21+
22+#mock relation-list
23+alias relation-list=mock_relation_list
24+mock_relation_list()
25+{
26+ [ -z $CH_MASTER ] && let CH_MASTER=1
27+
28+ case $CH_MASTER in
29+ 4)
30+ echo "TEST/3
31+TEST/2
32+TEST/4"
33+ ;;
34+ 3)
35+ echo "TEST/4
36+TEST/3
37+TEST/1"
38+ ;;
39+ 2)
40+ echo "TEST/3
41+TEST/4"
42+ ;;
43+ 1)
44+ echo "TEST/2
45+TEST/3
46+TEST/4"
47+ ;;
48+ 0)
49+ echo "TEST/1
50+TEST/3
51+TEST/4"
52+ ;;
53+ -1)
54+ echo ""
55+ ;;
56+ esac
57+
58+}
59+
60+#Save juju-log for debugging
61+CH_TEMPLOG="/tmp/$USER-tmp-juju-log"
62+echo "" > $CH_TEMPLOG
63+output "creating test-log in $CH_TEMPLOG"
64+alias juju-log=mock_juju_log
65+mock_juju_log()
66+{
67+ echo "$*" >> $CH_TEMPLOG
68+}
69+
70+#mock unit-get
71+alias unit-get=mock_unit_get
72+mock_unit_get()
73+{
74+ case $1 in
75+ "private-address")
76+ echo "localhost"
77+ ;;
78+ *)
79+ echo "UNDEFINED"
80+ ;;
81+ esac
82+}
83+
84+#mock relation-set/get
85+alias relation-set=mock_relation_set
86+alias relation-get=mock_relation_get
87+CH_scp_hostname=""
88+CH_scp_ssh_key_saved=""
89+CH_scp_ssh_key=""
90+CH_scp_copy_done=""
91+mock_relation_set()
92+{
93+ juju-log "mock_relation_set: $1"
94+ CH_varname=`echo $1 | cut -d= -f1`
95+ CH_value=`echo $1 | sed 's/^[^=]*=//'`
96+ case $CH_varname in
97+ "scp-hostname")
98+ CH_scp_hostname=$CH_value
99+ ;;
100+ "scp-ssh-key-saved")
101+ CH_scp_ssh_key_saved=$CH_value
102+ ;;
103+ "scp-ssh-key")
104+ CH_scp_ssh_key="$CH_value"
105+ ;;
106+ "scp-copy-done")
107+ CH_scp_copy_done=$CH_value
108+ ;;
109+ *)
110+ juju-log "mock_relation_set: unknow var $CH_varname"
111+ ;;
112+ esac
113+}
114+mock_relation_get()
115+{
116+ case $1 in
117+ "scp-hostname")
118+ echo $CH_scp_hostname
119+ juju-log "mock_relation_get: $1 = $CH_scp_hostname"
120+ ;;
121+ "scp-ssh-key-saved")
122+ echo $CH_scp_ssh_key_saved
123+ juju-log "mock_relation_get: $1 = $CH_scp_ssh_key_saved"
124+ ;;
125+ "scp-ssh-key")
126+ echo "$CH_scp_ssh_key"
127+ juju-log "mock_relation_get: $1 = $CH_scp_ssh_key"
128+ ;;
129+ "scp-copy-done")
130+ echo $CH_scp_copy_done
131+ juju-log "mock_relation_get: $1 = $CH_scp_copy_done"
132+ ;;
133+ *)
134+ juju-log "mock_relation_get: unknow var $1"
135+ ;;
136+ esac
137+}
138+
139+CH_TEMPDIR=""
140+
141+created_ssh_home=0
142+
143+cleanup_peer()
144+{
145+ [ $debug = 1 ] && output "====== sshd server log ======" && cat /tmp/juju-sshd-log ; rm -f /tmp/juju-sshd-log
146+ [ $debug -gt 1 ] && output "===== juju debug log ======" && cat $CH_TEMPLOG
147+ output "Cleaning up..."
148+ unalias juju-log
149+ unalias relation-set
150+ unalias relation-get
151+ unalias unit-get
152+ unalias relation-list
153+ [ -n "$CH_TEMPDIR" ] || return 0
154+ [ ! -f $CH_TEMPDIR/sshd.pid ] || kill -9 `cat $CH_TEMPDIR/sshd.pid`
155+ rm -rf $CH_TEMPDIR
156+ if [ $created_ssh_home = 1 ] ; then
157+ backup_dir=`mktemp -d /tmp/backup-charm-helper.ssh.XXXXXXXX`
158+ output "Backing up created $HOME/.ssh to $backup_dir/dot-ssh"
159+ mv $HOME/.ssh $backup_dir/dot-ssh
160+ fi
161+ if [ -e $HOME/ch_test ] ; then
162+ rm -rf $HOME/ch_test
163+ fi
164+}
165+trap cleanup_peer EXIT
166+if [ $debug -gt 0 ] ; then echo "user: $USER, home: $HOME"; fi
167+if [ ! -d $HOME ] ; then
168+ mkdir -p $HOME
169+ chown $USER:$USER $HOME
170+ chmod 700 $HOME
171+fi
172+if [ ! -d $HOME/.ssh ] ; then
173+ mkdir -p $HOME/.ssh
174+ chmod 700 $HOME/.ssh
175+ created_ssh_home=1
176+else
177+ output "ch_peer_scp can be destructive to \$HOME/.ssh, move it out of the way or"
178+ output "run these tests in a clean chroot or with a test user. Skipping."
179+ exit 0
180+fi
181+if [ x"$USER" = x"root" ] ; then
182+ if ! touch /root/.ssh/known_hosts ; then
183+ USER=`basename $HOME`
184+ echo "forcing user to: $USER"
185+ fi
186+fi
187+touch $HOME/.ssh/authorized_keys
188+touch $HOME/.ssh/known_hosts
189+chmod 600 $HOME/.ssh/authorized_keys
190+
191+# mock sshd server
192+CH_TEMPDIR=`mktemp -d "/tmp/juju-helpers-tmp.XXXXXXX"`
193+mkdir -p $CH_TEMPDIR/sourcedir/
194+mkdir -p $CH_TEMPDIR/destdir/
195+mkdir -p $CH_TEMPDIR/$HOME/
196+if ! [ -d /var/run/sshd ] ; then
197+ if ! mkdir -p /var/run/sshd ; then
198+ mkdir -p $HOME/var/run/sshd/
199+ fi
200+fi
201+# Protect user's normal home dir
202+head -c 16384 /dev/urandom > $CH_TEMPDIR/sourcedir/testfile0
203+head -c 32385 /dev/urandom > $CH_TEMPDIR/sourcedir/testfile1
204+head -c 19998 /dev/urandom > $CH_TEMPDIR/sourcedir/testfile
205+CH_portnum=28822
206+# lucid's ssh-keygen does not accept -h, so we check for maverick or
207+# later to add -h
208+ssh_version=`dpkg -l 'openssh-client'|awk '/^ii/ { print $3 }'`
209+if dpkg --compare-versions $ssh_version lt 1:5.5p1-4ubuntu4 ; then
210+ opts=""
211+else
212+ opts="-h"
213+fi
214+ssh-keygen -t rsa -b 1024 -N "" $opts -f $CH_TEMPDIR/my_host_key > /dev/null 2>&1
215+if [ $debug = 1 ] ; then
216+ /usr/sbin/sshd -e -o PidFile=$CH_TEMPDIR/sshd.pid -o UsePrivilegeSeparation=no -o StrictModes=no -d -h $CH_TEMPDIR/my_host_key -p $CH_portnum 2> /tmp/juju-sshd-log &
217+ CH_scpopt="-v"
218+ listening=1
219+else
220+ /usr/sbin/sshd -e -o PidFile=$CH_TEMPDIR/sshd.pid -o UsePrivilegeSeparation=no -o StrictModes=no -h $CH_TEMPDIR/my_host_key -p $CH_portnum
221+ # wait for server
222+ output "waiting for sshd to be available"
223+ listening=0
224+ ch_tmp_result=`mktemp`
225+ for i in 1 2 3 4 5 ; do
226+ sleep 1
227+
228+ ssh -o StrictHostKeyChecking=no -o PasswordAuthentication=no -p $CH_portnum bozo@localhost 2> $ch_tmp_result ||
229+ if grep -q -F "Permission denied" $ch_tmp_result ; then
230+ output Attempt $i succeeded.
231+ listening=1
232+ break
233+ fi
234+ output Attempt $i failed..
235+ done
236+ rm -f $ch_tmp_result
237+ if [ $listening = 0 ] ; then
238+ exit 1
239+ fi
240+ if [ $debug -gt 0 ]; then CH_scpopt="-v" ; else CH_scpopt="-q"; fi;
241+fi
242+
243+. $HELPERS_HOME/peer.sh
244+
245+start_test ch_unit_id...
246+JUJU_UNIT_NAME="TEST/1"
247+[ ! `ch_unit_id $JUJU_UNIT_NAME` -eq 1 ] && return 1
248+CH_bad="badarg"
249+ch_unit_id $CH_bad > /dev/null || return 1
250+echo PASS
251+
252+start_test ch_my_unit_id...
253+[ ! `ch_my_unit_id` -eq 1 ] && return 1
254+echo PASS
255+
256+start_test ch_peer_i_am_leader...
257+JUJU_REMOTE_UNIT="TEST/3"
258+JUJU_UNIT_NAME="TEST/2"
259+CH_MASTER=1
260+ch_peer_i_am_leader && return 1 || :
261+JUJU_UNIT_NAME="TEST/1"
262+ch_peer_i_am_leader || return 1 && :
263+echo PASS
264+
265+start_test "ch_peer_i_am_leader (unordered list 1)..."
266+JUJU_REMOTE_UNIT="TEST/3"
267+JUJU_UNIT_NAME="TEST/2"
268+CH_MASTER=3
269+ch_peer_i_am_leader && return 1 || :
270+echo PASS
271+
272+start_test "ch_peer_i_am_leader (unordered list 2)..."
273+JUJU_UNIT_NAME="TEST/1"
274+CH_MASTER=4
275+ch_peer_i_am_leader || return 1 && :
276+echo PASS
277+
278+start_test "ch_peer_i_am_leader (unordered list 3)..."
279+JUJU_UNIT_NAME="TEST/2"
280+CH_MASTER=3
281+ch_peer_i_am_leader && return 1 || :
282+echo PASS
283+
284+start_test "ch_peer_i_am_leader (unordered list 4)..."
285+JUJU_UNIT_NAME="TEST/3"
286+ch_peer_i_am_leader && return 1 && :
287+echo PASS
288+
289+start_test "ch_peer_i_am_leader (empty list)..."
290+JUJU_REMOTE_UNIT="TEST/3"
291+JUJU_UNIT_NAME="TEST/1"
292+CH_MASTER=-1
293+ch_peer_i_am_leader || return 1 && :
294+echo PASS
295+
296+start_test "ch_peer_i_am_leader (departed leader)..."
297+JUJU_REMOTE_UNIT="TEST/1"
298+JUJU_UNIT_NAME="TEST/4"
299+CH_MASTER=2
300+ch_peer_i_am_leader && return 1 || :
301+JUJU_UNIT_NAME="TEST/2"
302+ch_peer_i_am_leader || return 1 && :
303+echo PASS
304+
305+start_test ch_peer_leader...
306+JUJU_REMOTE_UNIT="TEST/3"
307+JUJU_UNIT_NAME="TEST/1"
308+CH_MASTER=1
309+[ "`ch_peer_leader`" = "TEST/1" ] || return 1
310+[ `ch_peer_leader --id` -eq 1 ] || return 1
311+JUJU_UNIT_NAME="TEST/2"
312+[ "`ch_peer_leader`" = "TEST/2" ] || return 1
313+[ `ch_peer_leader --id` -eq 2 ] || return 1
314+echo PASS
315+
316+start_test "ch_peer_scp -r..."
317+for i in 1 2 3
318+do
319+ #slave relation joined
320+ JUJU_UNIT_NAME="TEST/2"
321+ JUJU_REMOTE_UNIT="TEST/1"
322+ CH_MASTER=0
323+ if ch_peer_scp -r -p $CH_portnum -o "$CH_scpopt" "$CH_TEMPDIR/sourcedir/*" "$CH_TEMPDIR/destdir/" ; then break ; fi
324+ #master relation joined
325+ JUJU_UNIT_NAME="TEST/1"
326+ JUJU_REMOTE_UNIT="TEST/2"
327+ CH_MASTER=1
328+ if ch_peer_scp -r -p $CH_portnum -o "$CH_scpopt" "$CH_TEMPDIR/sourcedir/*" "$CH_TEMPDIR/destdir/" ; then break ; fi
329+done
330+[ ! -e $CH_TEMPDIR/destdir/ ] && output "dir not copied" && exit 1
331+[ ! -e $CH_TEMPDIR/destdir/testfile0 ] && output "file1 not copied" && exit 1
332+[ ! -e $CH_TEMPDIR/destdir/testfile1 ] && output "file2 not copied" && exit 1
333+CH_t1=`md5sum $CH_TEMPDIR/sourcedir/testfile0 | cut -d" " -f1`
334+CH_t2=`md5sum $CH_TEMPDIR/destdir/testfile0 | cut -d" " -f1`
335+[ ! "$CH_t1" = "$CH_t2" ] && output "md5sum differ" && exit 1
336+rm -rf $CH_TEMPDIR/destdir/*
337+echo PASS
338+
339+start_test "ch_peer_rsync..."
340+CH_scp_hostname=""
341+CH_scp_ssh_key_saved=""
342+CH_scp_ssh_key=""
343+CH_scp_copy_done=""
344+for i in 1 2 3
345+do
346+ #slave relation joined
347+ JUJU_UNIT_NAME="TEST/2"
348+ JUJU_REMOTE_UNIT="TEST/1"
349+ CH_MASTER=0
350+ if ch_peer_rsync -p $CH_portnum -o "-azq" "$CH_TEMPDIR/sourcedir/*" "$CH_TEMPDIR/destdir/" ; then break ; fi
351+ #master relation joined
352+ JUJU_UNIT_NAME="TEST/1"
353+ JUJU_REMOTE_UNIT="TEST/2"
354+ CH_MASTER=1
355+ if ch_peer_rsync -p $CH_portnum -o "-azq" "$CH_TEMPDIR/sourcedir/*" "$CH_TEMPDIR/destdir/" ; then break ; fi
356+done
357+[ ! -e $CH_TEMPDIR/destdir/ ] && output"dir not copied" && exit 1
358+[ ! -e $CH_TEMPDIR/destdir/testfile0 ] && output "file1 not copied" && exit 1
359+[ ! -e $CH_TEMPDIR/destdir/testfile1 ] && output "file2 not copied" && exit 1
360+CH_t1=`md5sum $CH_TEMPDIR/sourcedir/testfile0 | cut -d" " -f1`
361+CH_t2=`md5sum $CH_TEMPDIR/destdir/testfile0 | cut -d" " -f1`
362+[ ! "$CH_t1" = "$CH_t2" ] && output "md5sum differ" && exit 1
363+rm -rf $CH_TEMPDIR/destdir/*
364+echo PASS
365+
366+start_test "ch_peer_scp..."
367+CH_scp_hostname=""
368+CH_scp_ssh_key_saved=""
369+CH_scp_ssh_key=""
370+CH_scp_copy_done=""
371+for i in 1 2 3
372+do
373+ #slave relation joined
374+ JUJU_UNIT_NAME="TEST/2"
375+ JUJU_REMOTE_UNIT="TEST/1"
376+ CH_MASTER=0
377+ if ch_peer_scp -p $CH_portnum -o "-q" "$CH_TEMPDIR/sourcedir/testfile" "$CH_TEMPDIR/destdir/" "$CH_TEMPDIR/sourcedir/testfile1" "$CH_TEMPDIR/destdir/" ; then break ; fi
378+ #master relation joined
379+ JUJU_UNIT_NAME="TEST/1"
380+ JUJU_REMOTE_UNIT="TEST/2"
381+ CH_MASTER=1
382+ if ch_peer_scp -p $CH_portnum -o "-q" "$CH_TEMPDIR/sourcedir/testfile" "$CH_TEMPDIR/destdir/" "$CH_TEMPDIR/sourcedir/testfile1" "$CH_TEMPDIR/destdir/" ; then break ; fi
383+done
384+[ ! -e $CH_TEMPDIR/destdir/testfile ] && output "file1 not copied" && exit 1
385+[ ! -e $CH_TEMPDIR/destdir/testfile1 ] && output "file2 not copied" && exit 1
386+CH_t1=`md5sum $CH_TEMPDIR/sourcedir/testfile | cut -d" " -f1`
387+CH_t2=`md5sum $CH_TEMPDIR/destdir/testfile | cut -d" " -f1`
388+[ ! "$CH_t1" = "$CH_t2" ] && output "md5sum differ" && exit 1
389+rm -rf $CH_TEMPDIR/destdir/*
390+echo PASS
391+
392+start_test "ch_peer_copy_replay..."
393+CH_scp_hostname=""
394+CH_scp_ssh_key_saved=""
395+CH_scp_ssh_key=""
396+CH_scp_copy_done=""
397+#We are not in a relation, we are on master
398+JUJU_UNIT_NAME="TEST/1"
399+JUJU_REMOTE_UNIT=""
400+CH_MASTER=-1
401+if ! ch_peer_copy_replay ; then
402+ output "should not have returned not copied (1)"
403+ exit 1
404+fi
405+#We are not in a relation, we are on slave
406+JUJU_UNIT_NAME="TEST/2"
407+JUJU_REMOTE_UNIT=""
408+CH_MASTER=-1
409+if ch_peer_copy_replay ; then
410+ output "should not have returned copied (0)"
411+ exit 1
412+fi
413+[ ! -e $CH_TEMPDIR/destdir/testfile ] && output "file not copied" && exit 1
414+CH_t1=`md5sum $CH_TEMPDIR/sourcedir/testfile | cut -d" " -f1`
415+CH_t2=`md5sum $CH_TEMPDIR/destdir/testfile | cut -d" " -f1`
416+[ ! "$CH_t1" = "$CH_t2" ] && output "md5sum differ" && exit 1
417+[ ! -e $CH_TEMPDIR/destdir/ ] && output "dir not copied" && exit 1
418+[ ! -e $CH_TEMPDIR/destdir/testfile0 ] && output "file1 not copied" && exit 1
419+[ ! -e $CH_TEMPDIR/destdir/testfile1 ] && output "file2 not copied" && exit 1
420+CH_t1=`md5sum $CH_TEMPDIR/sourcedir/testfile0 | cut -d" " -f1`
421+CH_t2=`md5sum $CH_TEMPDIR/destdir/testfile0 | cut -d" " -f1`
422+[ ! "$CH_t1" = "$CH_t2" ] && output "md5sum differ" && exit 1
423+rm -rf $CH_TEMPDIR/destdir/*
424+echo PASS
425+
426+start_test "ch_peer_rsync (out of relation)..."
427+CH_scp_hostname=""
428+CH_scp_ssh_key_saved=""
429+CH_scp_ssh_key=""
430+CH_scp_copy_done=""
431+#We are not in a relation, we are on master
432+JUJU_UNIT_NAME="TEST/1"
433+JUJU_REMOTE_UNIT=""
434+CH_MASTER=-1
435+ch_peer_rsync -p $CH_portnum -o "-azq" "$CH_TEMPDIR/sourcedir/*" "$CH_TEMPDIR/destdir/" && chres=0 || chres=$?
436+if [ $chres -ne 101 ] ; then
437+ output "should not have returned not copied (received $chres, 101 expected)"
438+ exit 1
439+fi
440+#We are not in a relation, we are on slave
441+JUJU_UNIT_NAME="TEST/2"
442+JUJU_REMOTE_UNIT=""
443+CH_MASTER=-1
444+ch_peer_rsync -p $CH_portnum -o "-azq" "$CH_TEMPDIR/sourcedir/*" "$CH_TEMPDIR/destdir/" && chres=0 || chres=$?
445+if [ $chres -ne 100 ] ; then
446+ output "should not have returned copied (received $chres, 100 expected)"
447+ exit 1
448+fi
449+[ ! -e $CH_TEMPDIR/destdir/ ] && output "dir not copied" && exit 1
450+[ ! -e $CH_TEMPDIR/destdir/testfile0 ] && output "file1 not copied" && exit 1
451+[ ! -e $CH_TEMPDIR/destdir/testfile1 ] && output "file2 not copied" && exit 1
452+CH_t1=`md5sum $CH_TEMPDIR/sourcedir/testfile0 | cut -d" " -f1`
453+CH_t2=`md5sum $CH_TEMPDIR/destdir/testfile0 | cut -d" " -f1`
454+[ ! "$CH_t1" = "$CH_t2" ] && output "md5sum differ" && exit 1
455+rm -rf $CH_TEMPDIR/destdir/*
456+#restore authorized_keys & known_hosts
457+echo PASS
458+
459+start_test "ch_peer_copy_cleanup..."
460+# as a leader
461+JUJU_UNIT_NAME="TEST/1"
462+JUJU_REMOTE_UNIT="TEST/2"
463+CH_MASTER=-1
464+ch_peer_copy_cleanup "$JUJU_REMOTE_UNIT"
465+unitname=`echo $JUJU_UNIT_NAME | sed 's/\//-/g'`
466+[ `grep -F "$JUJU_REMOTE_UNIT" $HOME/ch_test/$unitname` ] && output "not cleaned up" && exit 1
467+# as a slave
468+JUJU_UNIT_NAME="TEST/2"
469+JUJU_REMOTE_UNIT="TEST/1"
470+CH_MASTER=-1
471+ch_peer_copy_cleanup "$JUJU_REMOTE_UNIT"
472+#nothing to check here other than if we did not choke on cleaning up something that does not exist
473+echo PASS
474+
475+trap - EXIT
476+cleanup_peer
477
478=== removed file 'tests/helpers/disabled_test_peer.sh'
479--- tests/helpers/disabled_test_peer.sh 2012-01-19 20:36:19 +0000
480+++ tests/helpers/disabled_test_peer.sh 1970-01-01 00:00:00 +0000
481@@ -1,472 +0,0 @@
482-#!/bin/sh
483-
484-# debug=1 full
485-# debug=2 client only
486-debug=0
487-
488-if [ -z "$test_home" ] ; then
489- test_home=`dirname $0`
490- test_home=`readlink -f $test_home`
491-fi
492-
493-[ "$LIB_SOURCED" = "1" ] || . $test_home/lib.sh
494-
495-set -ue
496-
497-JUJU_UNIT_NAME="EMPTY"
498-
499-#mock relation-list
500-alias relation-list=mock_relation_list
501-mock_relation_list()
502-{
503- [ -z $CH_MASTER ] && let CH_MASTER=1
504-
505- case $CH_MASTER in
506- 4)
507- echo "TEST/3
508-TEST/2
509-TEST/4"
510- ;;
511- 3)
512- echo "TEST/4
513-TEST/3
514-TEST/1"
515- ;;
516- 2)
517- echo "TEST/3
518-TEST/4"
519- ;;
520- 1)
521- echo "TEST/2
522-TEST/3
523-TEST/4"
524- ;;
525- 0)
526- echo "TEST/1
527-TEST/3
528-TEST/4"
529- ;;
530- -1)
531- echo ""
532- ;;
533- esac
534-
535-}
536-
537-#Save juju-log for debugging
538-CH_TEMPLOG="/tmp/$USER-tmp-juju-log"
539-echo "" > $CH_TEMPLOG
540-output "creating test-log in $CH_TEMPLOG"
541-alias juju-log=mock_juju_log
542-mock_juju_log()
543-{
544- echo "$*" >> $CH_TEMPLOG
545-}
546-
547-#mock unit-get
548-alias unit-get=mock_unit_get
549-mock_unit_get()
550-{
551- case $1 in
552- "private-address")
553- echo "localhost"
554- ;;
555- *)
556- echo "UNDEFINED"
557- ;;
558- esac
559-}
560-
561-#mock relation-set/get
562-alias relation-set=mock_relation_set
563-alias relation-get=mock_relation_get
564-CH_scp_hostname=""
565-CH_scp_ssh_key_saved=""
566-CH_scp_ssh_key=""
567-CH_scp_copy_done=""
568-mock_relation_set()
569-{
570- juju-log "mock_relation_set: $1"
571- CH_varname=`echo $1 | cut -d= -f1`
572- CH_value=`echo $1 | sed 's/^[^=]*=//'`
573- case $CH_varname in
574- "scp-hostname")
575- CH_scp_hostname=$CH_value
576- ;;
577- "scp-ssh-key-saved")
578- CH_scp_ssh_key_saved=$CH_value
579- ;;
580- "scp-ssh-key")
581- CH_scp_ssh_key="$CH_value"
582- ;;
583- "scp-copy-done")
584- CH_scp_copy_done=$CH_value
585- ;;
586- *)
587- juju-log "mock_relation_set: unknow var $CH_varname"
588- ;;
589- esac
590-}
591-mock_relation_get()
592-{
593- case $1 in
594- "scp-hostname")
595- echo $CH_scp_hostname
596- juju-log "mock_relation_get: $1 = $CH_scp_hostname"
597- ;;
598- "scp-ssh-key-saved")
599- echo $CH_scp_ssh_key_saved
600- juju-log "mock_relation_get: $1 = $CH_scp_ssh_key_saved"
601- ;;
602- "scp-ssh-key")
603- echo "$CH_scp_ssh_key"
604- juju-log "mock_relation_get: $1 = $CH_scp_ssh_key"
605- ;;
606- "scp-copy-done")
607- echo $CH_scp_copy_done
608- juju-log "mock_relation_get: $1 = $CH_scp_copy_done"
609- ;;
610- *)
611- juju-log "mock_relation_get: unknow var $1"
612- ;;
613- esac
614-}
615-
616-CH_TEMPDIR=""
617-
618-created_ssh_home=0
619-
620-cleanup_peer()
621-{
622- [ $debug = 1 ] && output "====== sshd server log ======" && cat /tmp/juju-sshd-log ; rm -f /tmp/juju-sshd-log
623- [ $debug -gt 1 ] && output "===== juju debug log ======" && cat $CH_TEMPLOG
624- output "Cleaning up..."
625- unalias juju-log
626- unalias relation-set
627- unalias relation-get
628- unalias unit-get
629- unalias relation-list
630- [ -n "$CH_TEMPDIR" ] || return 0
631- [ ! -f $CH_TEMPDIR/sshd.pid ] || kill -9 `cat $CH_TEMPDIR/sshd.pid`
632- rm -rf $CH_TEMPDIR
633- if [ $created_ssh_home = 1 ] ; then
634- backup_dir=`mktemp -d /tmp/backup-charm-helper.ssh.XXXXXXXX`
635- output "Backing up created $HOME/.ssh to $backup_dir/dot-ssh"
636- mv $HOME/.ssh $backup_dir/dot-ssh
637- fi
638- if [ -e $HOME/ch_test ] ; then
639- rm -rf $HOME/ch_test
640- fi
641-}
642-trap cleanup_peer EXIT
643-if [ $debug -gt 0 ] ; then echo "user: $USER, home: $HOME"; fi
644-if [ ! -d $HOME ] ; then
645- mkdir -p $HOME
646- chown $USER:$USER $HOME
647- chmod 700 $HOME
648-fi
649-if [ ! -d $HOME/.ssh ] ; then
650- mkdir -p $HOME/.ssh
651- chmod 700 $HOME/.ssh
652- created_ssh_home=1
653-else
654- output "ch_peer_scp can be destructive to \$HOME/.ssh, move it out of the way or"
655- output "run these tests in a clean chroot or with a test user. Skipping."
656- exit 0
657-fi
658-if [ x"$USER" = x"root" ] ; then
659- if ! touch /root/.ssh/known_hosts ; then
660- USER=`basename $HOME`
661- echo "forcing user to: $USER"
662- fi
663-fi
664-touch $HOME/.ssh/authorized_keys
665-touch $HOME/.ssh/known_hosts
666-chmod 600 $HOME/.ssh/authorized_keys
667-
668-# mock sshd server
669-CH_TEMPDIR=`mktemp -d "/tmp/juju-helpers-tmp.XXXXXXX"`
670-mkdir -p $CH_TEMPDIR/sourcedir/
671-mkdir -p $CH_TEMPDIR/destdir/
672-mkdir -p $CH_TEMPDIR/$HOME/
673-if ! [ -d /var/run/sshd ] ; then
674- if ! mkdir -p /var/run/sshd ; then
675- mkdir -p $HOME/var/run/sshd/
676- fi
677-fi
678-# Protect user's normal home dir
679-head -c 16384 /dev/urandom > $CH_TEMPDIR/sourcedir/testfile0
680-head -c 32385 /dev/urandom > $CH_TEMPDIR/sourcedir/testfile1
681-head -c 19998 /dev/urandom > $CH_TEMPDIR/sourcedir/testfile
682-CH_portnum=28822
683-# lucid's ssh-keygen does not accept -h, so we check for maverick or
684-# later to add -h
685-ssh_version=`dpkg -l 'openssh-client'|awk '/^ii/ { print $3 }'`
686-if dpkg --compare-versions $ssh_version lt 1:5.5p1-4ubuntu4 ; then
687- opts=""
688-else
689- opts="-h"
690-fi
691-ssh-keygen -t rsa -b 1024 -N "" $opts -f $CH_TEMPDIR/my_host_key > /dev/null 2>&1
692-if [ $debug = 1 ] ; then
693- /usr/sbin/sshd -e -o PidFile=$CH_TEMPDIR/sshd.pid -o UsePrivilegeSeparation=no -o StrictModes=no -d -h $CH_TEMPDIR/my_host_key -p $CH_portnum 2> /tmp/juju-sshd-log &
694- CH_scpopt="-v"
695- listening=1
696-else
697- /usr/sbin/sshd -e -o PidFile=$CH_TEMPDIR/sshd.pid -o UsePrivilegeSeparation=no -o StrictModes=no -h $CH_TEMPDIR/my_host_key -p $CH_portnum
698- # wait for server
699- output "waiting for sshd to be available"
700- listening=0
701- ch_tmp_result=`mktemp`
702- for i in 1 2 3 4 5 ; do
703- sleep 1
704-
705- ssh -o StrictHostKeyChecking=no -o PasswordAuthentication=no -p $CH_portnum bozo@localhost 2> $ch_tmp_result ||
706- if grep -q -F "Permission denied" $ch_tmp_result ; then
707- output Attempt $i succeeded.
708- listening=1
709- break
710- fi
711- output Attempt $i failed..
712- done
713- rm -f $ch_tmp_result
714- if [ $listening = 0 ] ; then
715- exit 1
716- fi
717- if [ $debug -gt 0 ]; then CH_scpopt="-v" ; else CH_scpopt="-q"; fi;
718-fi
719-
720-. $HELPERS_HOME/peer.sh
721-
722-start_test ch_unit_id...
723-JUJU_UNIT_NAME="TEST/1"
724-[ ! `ch_unit_id $JUJU_UNIT_NAME` -eq 1 ] && return 1
725-CH_bad="badarg"
726-ch_unit_id $CH_bad > /dev/null || return 1
727-echo PASS
728-
729-start_test ch_my_unit_id...
730-[ ! `ch_my_unit_id` -eq 1 ] && return 1
731-echo PASS
732-
733-start_test ch_peer_i_am_leader...
734-JUJU_REMOTE_UNIT="TEST/3"
735-JUJU_UNIT_NAME="TEST/2"
736-CH_MASTER=1
737-ch_peer_i_am_leader && return 1 || :
738-JUJU_UNIT_NAME="TEST/1"
739-ch_peer_i_am_leader || return 1 && :
740-echo PASS
741-
742-start_test "ch_peer_i_am_leader (unordered list 1)..."
743-JUJU_REMOTE_UNIT="TEST/3"
744-JUJU_UNIT_NAME="TEST/2"
745-CH_MASTER=3
746-ch_peer_i_am_leader && return 1 || :
747-echo PASS
748-
749-start_test "ch_peer_i_am_leader (unordered list 2)..."
750-JUJU_UNIT_NAME="TEST/1"
751-CH_MASTER=4
752-ch_peer_i_am_leader || return 1 && :
753-echo PASS
754-
755-start_test "ch_peer_i_am_leader (unordered list 3)..."
756-JUJU_UNIT_NAME="TEST/2"
757-CH_MASTER=3
758-ch_peer_i_am_leader && return 1 || :
759-echo PASS
760-
761-start_test "ch_peer_i_am_leader (unordered list 4)..."
762-JUJU_UNIT_NAME="TEST/3"
763-ch_peer_i_am_leader && return 1 && :
764-echo PASS
765-
766-start_test "ch_peer_i_am_leader (empty list)..."
767-JUJU_REMOTE_UNIT="TEST/3"
768-JUJU_UNIT_NAME="TEST/1"
769-CH_MASTER=-1
770-ch_peer_i_am_leader || return 1 && :
771-echo PASS
772-
773-start_test "ch_peer_i_am_leader (departed leader)..."
774-JUJU_REMOTE_UNIT="TEST/1"
775-JUJU_UNIT_NAME="TEST/4"
776-CH_MASTER=2
777-ch_peer_i_am_leader && return 1 || :
778-JUJU_UNIT_NAME="TEST/2"
779-ch_peer_i_am_leader || return 1 && :
780-echo PASS
781-
782-start_test ch_peer_leader...
783-JUJU_REMOTE_UNIT="TEST/3"
784-JUJU_UNIT_NAME="TEST/1"
785-CH_MASTER=1
786-[ "`ch_peer_leader`" = "TEST/1" ] || return 1
787-[ `ch_peer_leader --id` -eq 1 ] || return 1
788-JUJU_UNIT_NAME="TEST/2"
789-[ "`ch_peer_leader`" = "TEST/2" ] || return 1
790-[ `ch_peer_leader --id` -eq 2 ] || return 1
791-echo PASS
792-
793-start_test "ch_peer_scp -r..."
794-for i in 1 2 3
795-do
796- #slave relation joined
797- JUJU_UNIT_NAME="TEST/2"
798- JUJU_REMOTE_UNIT="TEST/1"
799- CH_MASTER=0
800- if ch_peer_scp -r -p $CH_portnum -o "$CH_scpopt" "$CH_TEMPDIR/sourcedir/*" "$CH_TEMPDIR/destdir/" ; then break ; fi
801- #master relation joined
802- JUJU_UNIT_NAME="TEST/1"
803- JUJU_REMOTE_UNIT="TEST/2"
804- CH_MASTER=1
805- if ch_peer_scp -r -p $CH_portnum -o "$CH_scpopt" "$CH_TEMPDIR/sourcedir/*" "$CH_TEMPDIR/destdir/" ; then break ; fi
806-done
807-[ ! -e $CH_TEMPDIR/destdir/ ] && output "dir not copied" && exit 1
808-[ ! -e $CH_TEMPDIR/destdir/testfile0 ] && output "file1 not copied" && exit 1
809-[ ! -e $CH_TEMPDIR/destdir/testfile1 ] && output "file2 not copied" && exit 1
810-CH_t1=`md5sum $CH_TEMPDIR/sourcedir/testfile0 | cut -d" " -f1`
811-CH_t2=`md5sum $CH_TEMPDIR/destdir/testfile0 | cut -d" " -f1`
812-[ ! "$CH_t1" = "$CH_t2" ] && output "md5sum differ" && exit 1
813-rm -rf $CH_TEMPDIR/destdir/*
814-echo PASS
815-
816-start_test "ch_peer_rsync..."
817-CH_scp_hostname=""
818-CH_scp_ssh_key_saved=""
819-CH_scp_ssh_key=""
820-CH_scp_copy_done=""
821-for i in 1 2 3
822-do
823- #slave relation joined
824- JUJU_UNIT_NAME="TEST/2"
825- JUJU_REMOTE_UNIT="TEST/1"
826- CH_MASTER=0
827- if ch_peer_rsync -p $CH_portnum -o "-azq" "$CH_TEMPDIR/sourcedir/*" "$CH_TEMPDIR/destdir/" ; then break ; fi
828- #master relation joined
829- JUJU_UNIT_NAME="TEST/1"
830- JUJU_REMOTE_UNIT="TEST/2"
831- CH_MASTER=1
832- if ch_peer_rsync -p $CH_portnum -o "-azq" "$CH_TEMPDIR/sourcedir/*" "$CH_TEMPDIR/destdir/" ; then break ; fi
833-done
834-[ ! -e $CH_TEMPDIR/destdir/ ] && output"dir not copied" && exit 1
835-[ ! -e $CH_TEMPDIR/destdir/testfile0 ] && output "file1 not copied" && exit 1
836-[ ! -e $CH_TEMPDIR/destdir/testfile1 ] && output "file2 not copied" && exit 1
837-CH_t1=`md5sum $CH_TEMPDIR/sourcedir/testfile0 | cut -d" " -f1`
838-CH_t2=`md5sum $CH_TEMPDIR/destdir/testfile0 | cut -d" " -f1`
839-[ ! "$CH_t1" = "$CH_t2" ] && output "md5sum differ" && exit 1
840-rm -rf $CH_TEMPDIR/destdir/*
841-echo PASS
842-
843-start_test "ch_peer_scp..."
844-CH_scp_hostname=""
845-CH_scp_ssh_key_saved=""
846-CH_scp_ssh_key=""
847-CH_scp_copy_done=""
848-for i in 1 2 3
849-do
850- #slave relation joined
851- JUJU_UNIT_NAME="TEST/2"
852- JUJU_REMOTE_UNIT="TEST/1"
853- CH_MASTER=0
854- if ch_peer_scp -p $CH_portnum -o "-q" "$CH_TEMPDIR/sourcedir/testfile" "$CH_TEMPDIR/destdir/" "$CH_TEMPDIR/sourcedir/testfile1" "$CH_TEMPDIR/destdir/" ; then break ; fi
855- #master relation joined
856- JUJU_UNIT_NAME="TEST/1"
857- JUJU_REMOTE_UNIT="TEST/2"
858- CH_MASTER=1
859- if ch_peer_scp -p $CH_portnum -o "-q" "$CH_TEMPDIR/sourcedir/testfile" "$CH_TEMPDIR/destdir/" "$CH_TEMPDIR/sourcedir/testfile1" "$CH_TEMPDIR/destdir/" ; then break ; fi
860-done
861-[ ! -e $CH_TEMPDIR/destdir/testfile ] && output "file1 not copied" && exit 1
862-[ ! -e $CH_TEMPDIR/destdir/testfile1 ] && output "file2 not copied" && exit 1
863-CH_t1=`md5sum $CH_TEMPDIR/sourcedir/testfile | cut -d" " -f1`
864-CH_t2=`md5sum $CH_TEMPDIR/destdir/testfile | cut -d" " -f1`
865-[ ! "$CH_t1" = "$CH_t2" ] && output "md5sum differ" && exit 1
866-rm -rf $CH_TEMPDIR/destdir/*
867-echo PASS
868-
869-start_test "ch_peer_copy_replay..."
870-CH_scp_hostname=""
871-CH_scp_ssh_key_saved=""
872-CH_scp_ssh_key=""
873-CH_scp_copy_done=""
874-#We are not in a relation, we are on master
875-JUJU_UNIT_NAME="TEST/1"
876-JUJU_REMOTE_UNIT=""
877-CH_MASTER=-1
878-if ! ch_peer_copy_replay ; then
879- output "should not have returned not copied (1)"
880- exit 1
881-fi
882-#We are not in a relation, we are on slave
883-JUJU_UNIT_NAME="TEST/2"
884-JUJU_REMOTE_UNIT=""
885-CH_MASTER=-1
886-if ch_peer_copy_replay ; then
887- output "should not have returned copied (0)"
888- exit 1
889-fi
890-[ ! -e $CH_TEMPDIR/destdir/testfile ] && output "file not copied" && exit 1
891-CH_t1=`md5sum $CH_TEMPDIR/sourcedir/testfile | cut -d" " -f1`
892-CH_t2=`md5sum $CH_TEMPDIR/destdir/testfile | cut -d" " -f1`
893-[ ! "$CH_t1" = "$CH_t2" ] && output "md5sum differ" && exit 1
894-[ ! -e $CH_TEMPDIR/destdir/ ] && output "dir not copied" && exit 1
895-[ ! -e $CH_TEMPDIR/destdir/testfile0 ] && output "file1 not copied" && exit 1
896-[ ! -e $CH_TEMPDIR/destdir/testfile1 ] && output "file2 not copied" && exit 1
897-CH_t1=`md5sum $CH_TEMPDIR/sourcedir/testfile0 | cut -d" " -f1`
898-CH_t2=`md5sum $CH_TEMPDIR/destdir/testfile0 | cut -d" " -f1`
899-[ ! "$CH_t1" = "$CH_t2" ] && output "md5sum differ" && exit 1
900-rm -rf $CH_TEMPDIR/destdir/*
901-echo PASS
902-
903-start_test "ch_peer_rsync (out of relation)..."
904-CH_scp_hostname=""
905-CH_scp_ssh_key_saved=""
906-CH_scp_ssh_key=""
907-CH_scp_copy_done=""
908-#We are not in a relation, we are on master
909-JUJU_UNIT_NAME="TEST/1"
910-JUJU_REMOTE_UNIT=""
911-CH_MASTER=-1
912-ch_peer_rsync -p $CH_portnum -o "-azq" "$CH_TEMPDIR/sourcedir/*" "$CH_TEMPDIR/destdir/" && chres=0 || chres=$?
913-if [ $chres -ne 101 ] ; then
914- output "should not have returned not copied (received $chres, 101 expected)"
915- exit 1
916-fi
917-#We are not in a relation, we are on slave
918-JUJU_UNIT_NAME="TEST/2"
919-JUJU_REMOTE_UNIT=""
920-CH_MASTER=-1
921-ch_peer_rsync -p $CH_portnum -o "-azq" "$CH_TEMPDIR/sourcedir/*" "$CH_TEMPDIR/destdir/" && chres=0 || chres=$?
922-if [ $chres -ne 100 ] ; then
923- output "should not have returned copied (received $chres, 100 expected)"
924- exit 1
925-fi
926-[ ! -e $CH_TEMPDIR/destdir/ ] && output "dir not copied" && exit 1
927-[ ! -e $CH_TEMPDIR/destdir/testfile0 ] && output "file1 not copied" && exit 1
928-[ ! -e $CH_TEMPDIR/destdir/testfile1 ] && output "file2 not copied" && exit 1
929-CH_t1=`md5sum $CH_TEMPDIR/sourcedir/testfile0 | cut -d" " -f1`
930-CH_t2=`md5sum $CH_TEMPDIR/destdir/testfile0 | cut -d" " -f1`
931-[ ! "$CH_t1" = "$CH_t2" ] && output "md5sum differ" && exit 1
932-rm -rf $CH_TEMPDIR/destdir/*
933-#restore authorized_keys & known_hosts
934-echo PASS
935-
936-start_test "ch_peer_copy_cleanup..."
937-# as a leader
938-JUJU_UNIT_NAME="TEST/1"
939-JUJU_REMOTE_UNIT="TEST/2"
940-CH_MASTER=-1
941-ch_peer_copy_cleanup "$JUJU_REMOTE_UNIT"
942-unitname=`echo $JUJU_UNIT_NAME | sed 's/\//-/g'`
943-[ `grep -F "$JUJU_REMOTE_UNIT" $HOME/ch_test/$unitname` ] && output "not cleaned up" && exit 1
944-# as a slave
945-JUJU_UNIT_NAME="TEST/2"
946-JUJU_REMOTE_UNIT="TEST/1"
947-CH_MASTER=-1
948-ch_peer_copy_cleanup "$JUJU_REMOTE_UNIT"
949-#nothing to check here other than if we did not choke on cleaning up something that does not exist
950-echo PASS
951-
952-trap - EXIT
953-cleanup_peer

Subscribers

People subscribed via source and target branches

to all changes: