use the DNS configuration of whatever the host/vserver was initialized with
[tests.git] / system / selftest
1 #!/bin/bash
2
3 SELF_HOST=$1
4 SELF_IP=$2
5 # all below addresses are those of the qemu host
6 [ -z "$SELF_HOST" ] && SELF_HOST="selftest.$(hostname)"
7 [ -z "$SELF_IP"   ] && SELF_IP="10.1.159.48"
8
9
10 ####################################################
11 # setup MyPLC
12
13 # install from repo
14 yum -y install myplc-native
15
16 # make sure its stopped
17 service plc stop
18
19 # turn off plc until its been configured
20 chkconfig plc off
21
22 ####################################################
23 # configure myplc for testing purposes
24 config=$(mktemp)
25 PW=$(od -N 16 -x /dev/urandom | head -1 | sed "s, ,,g")
26
27 echo "e PLC_ROOT_PASSWORD" >> $config
28 echo "$PW" >> $config
29
30 echo "e PLC_NAME" >> $config
31 echo "selftest" >> $config
32
33 echo "e PLC_ROOT_USER" >> $config
34 echo "root@localhost.localdomain" >> $config
35
36 echo "e PLC_MAIL_ENABLED" >> $config
37 echo 0 >> $config
38
39 echo "e PLC_MAIL_SUPPORT_ADDRESS" >> $config
40 echo "build@lists.planet-lab.org" >> $config
41
42 echo "e PLC_DB_HOST" >> $config
43 echo $SELF_HOST >> $config
44
45 echo "e PLC_API_HOST" >> $config
46 echo $SELF_HOST >> $config
47
48 echo "e PLC_WWW_HOST" >> $config
49 echo $SELF_HOST >> $config
50
51 echo "e PLC_BOOT_HOST" >> $config
52 echo $SELF_HOST >> $config
53
54 echo "e PLC_DB_IP" >> $config
55 echo $SELF_IP >> $config
56
57 echo "e PLC_API_IP" >> $config
58 echo $SELF_IP >> $config
59
60 echo "e PLC_WWW_IP" >> $config
61 echo $SELF_IP >> $config
62
63 echo "e PLC_BOOT_IP" >> $config
64 echo $SELF_IP >> $config
65
66 echo "w" >> $config
67 echo "q" >> $config
68
69 plc-config-tty < $config
70
71 echo "$PW" > /etc/planetlab/pw
72 chmod 400 /etc/planetlab/pw
73
74 rm -f $config
75
76 #not yet
77 service plc start
78
79 ####################################################
80 # run api tests
81
82 ### TBD
83
84 # go no further than this for now
85 exit 0
86
87
88 ####################################################
89 # configure a node @ the local myplc
90
91 # xxx execute plcsh with the appropriate set of commands to
92 # - create a site
93 # - create a node
94 # - 
95
96
97 # grab a bootcd image with the configuration file built in
98 BOOTCDIMG=""
99
100 # setup qemu to run the node from the bootcd
101
102 yum -y install qemu
103 testdir=$(mktemp -d /var/tmp/selftest.XXXX)
104 cd $testdir
105 qemu-img create -f qcow disk.img 5GB
106
107 if [ -f "$BOOTCDIMG" ] ; then
108     # run qemu
109     # -x for serial line console
110     # -m 512 (512MB memory)
111     # -cdrom
112     qemu -x -m 512 -cdrom $BOOTCDIMG
113 fi
114
115
116 cd -
117
118 # run node tests
119
120 rm -rf $testdir
121 exit 0