02753ead3991dc00e8badba1b2cf0f4730dff1be
[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 [ -n "$SELF_HOST" ] && SELF_HOST="selftest.$(hostname)"
7 [ -n "$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 "selftest" >> $config
35
36 echo "e PLC_MAIL_ENABLED" >> $config
37 echo 0 >> $config
38
39 echo "e PLC_MAIL_SUPPORT_ADDRESS" >> $config
40 echo "mef@cs.princeton.edu" >> $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 "e PLC_NET_DNS1" >> $config
67 echo $SELF_IP >> $config
68
69 echo "e PLC_NET_DNS2" >> $config
70 echo $SELF_IP >> $config
71
72 echo "w" >> $config
73 echo "q" >> $config
74
75 plc-config-tty < $config
76
77 echo "$PW" > /etc/planetlab/pw
78 chmod 400 /etc/planetlab/pw
79
80 rm -f $config
81
82 #not yet
83 service plc start
84
85 ####################################################
86 # run api tests
87
88 ### TBD
89
90 # go no further than this for now
91 exit 0
92
93
94 ####################################################
95 # configure a node @ the local myplc
96
97 # xxx execute plcsh with the appropriate set of commands to
98 # - create a site
99 # - create a node
100 # - 
101
102
103 # grab a bootcd image with the configuration file built in
104 BOOTCDIMG=""
105
106 # setup qemu to run the node from the bootcd
107
108 yum -y install qemu
109 testdir=$(mktemp -d /var/tmp/selftest.XXXX)
110 cd $testdir
111 qemu-img create -f qcow disk.img 5GB
112
113 if [ -f "$BOOTCDIMG" ] ; then
114     # run qemu
115     # -x for serial line console
116     # -m 512 (512MB memory)
117     # -cdrom
118     qemu -x -m 512 -cdrom $BOOTCDIMG
119 fi
120
121
122 cd -
123
124 # run node tests
125
126 rm -rf $testdir
127 exit 0