Browse Source

Merge "Add Script for murano-dashboard jenkins"

Jenkins 2 years ago
parent
commit
1d1f4dd1fd
2 changed files with 154 additions and 0 deletions
  1. 91
    0
      utils/jenkins/murano_dashboard_tests.sh
  2. 63
    0
      utils/jenkins/parser.py

+ 91
- 0
utils/jenkins/murano_dashboard_tests.sh View File

@@ -0,0 +1,91 @@
1
+#!/bin/bash
2
+
3
+set -x
4
+
5
+# Virtual framebuffer settings
6
+#-----------------------------
7
+VFB_DISPLAY_SIZE='1280x1024'
8
+VFB_COLOR_DEPTH=16
9
+VFB_DISPLAY_NUM=22
10
+#-----------------------------
11
+
12
+export SSH_OPTS='-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no'
13
+export FUEL_PASSWD='r00tme'
14
+
15
+SNAPSHOT_NAME=$(dos.py snapshot-list "$ENV_NAME" | tail -1 | awk '{print $1}')
16
+
17
+dos.py revert-resume "$ENV_NAME" "$SNAPSHOT_NAME"
18
+
19
+
20
+ADMIN_NODE_IP=$(dos.py net-list $ENV_NAME | tail -1 | awk '{print $2}' | sed 's|/.*||g' | sed 's|.$|2|g')
21
+
22
+echo "LOG: fuel-master ip=$ADMIN_NODE_IP"
23
+
24
+sudo apt-get install --yes sshpass
25
+
26
+CONTROLLER_ID=`echo 'fuel node | \
27
+                     grep controller | \
28
+                     awk '\''{print $1}'\'' | \
29
+                     head -1' | \
30
+                     sshpass -p "$FUEL_PASSWD" \
31
+              ssh ${SSH_OPTS} -T root@"$ADMIN_NODE_IP"`
32
+
33
+echo "LOG: controller_id=$CONTROLLER_ID"
34
+
35
+##### Upload the murano-dashboard repo on controller node in home #####
36
+EXEC_CMD="echo 'apt-get install --yes git && git clone https://github.com/openstack/murano-dashboard.git' | ssh -T node-$CONTROLLER_ID"
37
+echo "$EXEC_CMD" | sshpass -p "$FUEL_PASSWD" ssh ${SSH_OPTS} -T root@"$ADMIN_NODE_IP"
38
+
39
+##### Installing Firefox version 46.0 #####
40
+FIREFOX_CMD="echo 'apt-get install --yes firefox && \
41
+             apt-get remove --yes firefox && \
42
+             wget https://ftp.mozilla.org/pub/firefox/releases/46.0/linux-x86_64/en-US/firefox-46.0.tar.bz2 && \
43
+             tar -xjf firefox-46.0.tar.bz2 && \
44
+             rm -rf /opt/firefox && \
45
+             mv firefox /opt/firefox46 && \
46
+             ln -s /opt/firefox46/firefox /usr/bin/firefox'"
47
+EXEC_CMD="$FIREFOX_CMD | ssh -T node-$CONTROLLER_ID"
48
+echo "$EXEC_CMD" | sshpass -p "$FUEL_PASSWD" ssh ${SSH_OPTS} -T root@"$ADMIN_NODE_IP"
49
+
50
+##### Installing Prerequisites on controller#####
51
+EXEC_CMD="echo 'apt-get install --yes python-pip xvfb xfonts-100dpi xfonts-75dpi xfonts-cyrillic xorg dbus-x11 && \
52
+          pip install --upgrade pip && \
53
+          pip install -U selenium nose' | ssh -T node-$CONTROLLER_ID"
54
+echo "$EXEC_CMD" | sshpass -p "$FUEL_PASSWD" ssh ${SSH_OPTS} -T root@"$ADMIN_NODE_IP"
55
+
56
+##### Copying script to master node, then to controller #####
57
+sshpass -p "$FUEL_PASSWD" scp ${SSH_OPTS} "$WORKSPACE/utils/jenkins/parser.py" "root@${ADMIN_NODE_IP}:/root/parser.py"
58
+echo "scp /root/parser.py/ node-${CONTROLLER_ID}:murano-dashboard/muranodashboard/tests/functional/config/" | sshpass -p "$FUEL_PASSWD" ssh ${SSH_OPTS} -T root@"$ADMIN_NODE_IP"
59
+
60
+##### Run python script for preparing config.conf for tests#####
61
+EXEC_CMD="echo '. /root/openrc && cd murano-dashboard/muranodashboard/tests/functional/config/ && chmod +x parser.py && ./parser.py -i /root/openrc' | ssh -T node-$CONTROLLER_ID"
62
+echo "$EXEC_CMD" | sshpass -p "$FUEL_PASSWD" ssh ${SSH_OPTS} -T root@"$ADMIN_NODE_IP"
63
+
64
+#####This variable should be set for pagination test running#####
65
+EXEC_CMD= "echo 'sed -i 's#MURANO_REPO_URL =.*#MURANO_REPO_URL = '\''http://localhost:8099'\''#g' murano-dashboard/muranodashboard/local/local_settings.d/_50_murano.py' | ssh -T node-$CONTROLLER_ID"
66
+echo "$EXEC_CMD" | sshpass -p "$FUEL_PASSWD" ssh ${SSH_OPTS} -T root@"$ADMIN_NODE_IP"
67
+
68
+fonts_path="/usr/share/fonts/X11/misc/"
69
+
70
+##### Running Xvfb #####
71
+XVFB_SESSION="echo 'Xvfb -fp \"${fonts_path}\" :${VFB_DISPLAY_NUM} -screen 0 \"${VFB_DISPLAY_SIZE}x${VFB_COLOR_DEPTH}\" &'"
72
+EXEC_CMD="$XVFB_SESSION | ssh -T node-$CONTROLLER_ID"
73
+echo "$EXEC_CMD" | sshpass -p "$FUEL_PASSWD" ssh ${SSH_OPTS} -T root@"$ADMIN_NODE_IP"
74
+
75
+##### Configuring VNC. Port forwarding example ssh -L 127.0.0.1:8000:controller_ip:5900  user@server #####
76
+EXEC_CMD="echo 'apt-get install --yes x11vnc && x11vnc -bg -forever -nopw -display :${VFB_DISPLAY_NUM} -ncache 10 && iptables -I INPUT 1 -p tcp --dport 5900 -j ACCEPT' | ssh -T node-$CONTROLLER_ID"
77
+echo "$EXEC_CMD" | sshpass -p "$FUEL_PASSWD" ssh ${SSH_OPTS} -T root@"$ADMIN_NODE_IP"
78
+
79
+##### Run tests #####
80
+RUN_TESTS="echo 'export DISPLAY=:${VFB_DISPLAY_NUM} && nosetests -sv murano-dashboard/muranodashboard/tests/functional/sanity_check.py --with-xunit --xunit-file /root/test_report.xml' | ssh -T node-$CONTROLLER_ID"
81
+echo "$RUN_TESTS" | sshpass -p "$FUEL_PASSWD" ssh ${SSH_OPTS} -T root@"$ADMIN_NODE_IP"
82
+
83
+##########################################################
84
+##### Copying results from controller to admin node: #####
85
+##### and then to host in workspace folder           #####
86
+##########################################################
87
+GET_REP_CMD="scp node-$CONTROLLER_ID:/root/test_report.xml /root/test_report.xml"
88
+echo "$GET_REP_CMD" |  sshpass -p "$FUEL_PASSWD" ssh ${SSH_OPTS} -T root@"$ADMIN_NODE_IP"
89
+sshpass -p "$FUEL_PASSWD" scp ${SSH_OPTS} root@"$ADMIN_NODE_IP":/root/test_report.xml "$WORKSPACE/logs/"
90
+
91
+exit 0

+ 63
- 0
utils/jenkins/parser.py View File

@@ -0,0 +1,63 @@
1
+#!/usr/bin/env python
2
+
3
+from __future__ import print_function
4
+
5
+import getopt
6
+import os.path
7
+import subprocess
8
+import sys
9
+
10
+# usage: parser.py -i <inputfile>
11
+
12
+
13
+def main(argv):
14
+    try:
15
+        opts, args = getopt.getopt(argv, "hi:", "ifile=")
16
+        if not opts:
17
+            print ('No options supplied. For help use -h')
18
+            sys.exit(2)
19
+    except getopt.GetoptError:
20
+        print ('parser.py -i <inputfile>')
21
+        sys.exit(2)
22
+    for opt, arg in opts:
23
+        if opt == '-h':
24
+            print ('parser.py -i <inputfile>')
25
+            sys.exit()
26
+        elif opt in ("-i", "--ifile"):
27
+            inputfile = arg
28
+            return inputfile
29
+
30
+
31
+def read_values(inputfile):
32
+    with open(inputfile, 'r') as inputfile:
33
+        dict = {k: v for line in inputfile if '=' in line for (k, v) in (
34
+            line.replace('\'', '').strip('export ').strip().split('=', 1),)}
35
+    return dict
36
+
37
+
38
+def create_config(dict):
39
+    cmd = subprocess.check_output(
40
+        'openstack endpoint list --long -c PublicURL -f \'value\'', shell=True)
41
+    keystone_url = None
42
+    for row in cmd.split('\n'):
43
+        if '5000' in row:
44
+                keystone_url = row.replace('v2.0', '')
45
+    uri = keystone_url.replace(':5000/', '')
46
+    with open('config.conf', 'w') as config_file:
47
+        seq = ['[murano]\n',
48
+               'horizon_url = ' + uri + '/horizon/\n',
49
+               'murano_url = ' + uri + ':8082\n',
50
+               'user = ' + dict['OS_USERNAME'] + '\n',
51
+               'password = ' + dict['OS_PASSWORD'] + '\n',
52
+               'tenant = ' + dict['OS_TENANT_NAME'] + '\n',
53
+               'keystone_url = ' + keystone_url + 'v3\n']
54
+        config_file.writelines(seq)
55
+
56
+if __name__ == "__main__":
57
+    inputfile = main(sys.argv[1:])
58
+    if not os.access(inputfile, os.R_OK):
59
+        print ("Cannot read the file: {0}. It may or not may exist".format(
60
+            inputfile))
61
+        sys.exit(2)
62
+    dict = read_values(inputfile)
63
+    create_config(dict)

Loading…
Cancel
Save