added the smoketest script.
[joid.git] / ci / smoketest.sh
1 #!/bin/bash -ex
2
3 . ./cloud/admin-openrc
4
5 ##enable extra stuff only if testing manually
6
7 neutron security-group-rule-create --direction ingress --ethertype IPv4 --protocol icmp --remote-ip-prefix 0.0.0.0/0 default
8 neutron security-group-rule-create --direction ingress --ethertype IPv4 --protocol tcp --port-range-min 22 --port-range-max 22 --remote-ip-prefix 0.0.0.0/0 default
9
10 wget -P /tmp/images http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img
11 openstack image create --file /tmp/images/cirros-0.3.4-x86_64-disk.img --disk-format qcow2 --container-format bare "cirros-0.3.4-x86_64"
12 wget -P /tmp/images http://cloud-images.ubuntu.com/trusty/current/trusty-server-cloudimg-amd64-disk1.img
13 openstack image create --file /tmp/images/trusty-server-cloudimg-amd64-disk1.img --disk-format qcow2 --container-format bare "ubuntu-trusty-daily"
14 #wget -P /tmp/images http://cloud-images.ubuntu.com/trusty/current/xenial-server-cloudimg-amd64.tar.gz
15 #openstack image create --file /tmp/images/xenial-server-cloudimg-amd64.tar.gz --container-format bare --disk-format raw "xenial-server-cloudimg-amd64"
16
17 rm -rf /tmp/images
18
19 ## import key pair
20 openstack project create --description "Demo Tenant" demo
21 openstack user create --project demo --password demo --email demo@demo.demo demo
22
23 openstack keypair create --public-key ~/.ssh/id_rsa.pub ubuntu-keypair
24
25 ## create vm network
26 neutron net-create demo-net
27 neutron subnet-create demo-net 10.20.5.0/24 --name demo-subnet --gateway 10.20.5.1 --enable-dhcp --allocation-pool start=10.0.0.5,end=10.0.0.254 --dns-nameserver 8.8.8.8
28 neutron router-create demo-router
29 neutron router-gateway-set demo-router ext-net
30 neutron router-interface-add demo-router subnet=demo-subnet
31
32 # add a delay since the previous command takes the neutron-api offline for a while (?)
33 sleep 30
34
35 ## create pool of floating ips
36 i=0
37 while [ $i -ne 3 ]; do
38     flip=`neutron floatingip-create ext-net`
39     i=$((i + 1))
40 done
41
42 ##http://docs.openstack.org/juno/install-guide/install/apt/content/launch-instance-neutron.html
43  netid=`neutron net-show demo-net -c id -f value`
44  nova boot --flavor m1.small --image cirros-0.3.4-x86_64 --nic net-id=$netid --security-group default --key-name ubuntu-keypair demo-instance1
45  nova floating-ip-associate demo-instance1 $flip