source: ogServer-Git/tests/run-tests.py

Last change on this file was c2c6ce9, checked in by OpenGnSys Support Team <soporte-og@…>, 3 years ago

#915 Add large HTTP response test

This commit adds a test for HTTP responses that are too large to fit in
ogServer response buffer.

It also moves the basic sql data used for the other tests to its own
file, easing its reuse in several files.

  • Property mode set to 100755
File size: 2.5 KB
Line 
1#!/usr/bin/env python3
2
3import subprocess, glob, time, os
4
5sql_data = "INSERT INTO aulas (nombreaula, idcentro, urlfoto, grupoid, ubicacion, puestos, modomul, ipmul, pormul, velmul, router, netmask, ntp, dns, proxy, modp2p, timep2p) VALUES  ('Aula virtual', 1, 'aula.jpg', 0, 'Despliegue virtual con Vagrant.', 5, 2, '239.194.2.11', 9000, 70, '192.168.56.1', '255.255.255.0', '', '', '', 'peer', 30); INSERT INTO ordenadores (nombreordenador, ip, mac, idaula, idrepositorio, idperfilhard, idmenu, idproautoexec, grupoid, router, mascara, arranque, netiface, netdriver, fotoord) VALUES ('pc2', '192.168.2.1', '0800270E6501', 1, 1, 0, 0, 0, 0, '192.168.56.1', '255.255.255.0', '00unknown', 'eth0', 'generic', 'fotoordenador.gif'), ('pc2', '192.168.2.2', '0800270E6502', 1, 1, 0, 0, 0, 0, '192.168.56.1', '255.255.255.0', '00unknown', 'eth0', 'generic', 'fotoordenador.gif');"
6
7sql_create_user = "CREATE USER 'test-db'@'localhost'; GRANT ALL PRIVILEGES ON *.* To 'test-db'@'localhost' IDENTIFIED BY 'test-db';"
8
9sql_delete_user = "DROP USER 'test-db'@'localhost';"
10
11def start_mysql():
12
13    subprocess.run(['mysqladmin', 'drop', '-f', 'test-db'],
14            stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
15    subprocess.run(['mysqladmin', 'create', 'test-db'])
16    subprocess.run('mysql --default-character-set=utf8 test-db < ../cfg/ogAdmBD.sql', shell=True)
17    subprocess.run('mysql --default-character-set=utf8 test-db '
18                   '< config/basic_data.sql', shell=True)
19    subprocess.run(['mysql', '-D', 'test-db', '-e', sql_create_user])
20
21def stop_mysql():
22
23    subprocess.run(['mysql', '-D', 'test-db', '-e', sql_delete_user])
24    subprocess.run(['mysqladmin', 'drop', '-f', 'test-db'])
25
26if os.getuid() is not 0:
27    print('You need to be root to run these tests :-)')
28    exit()
29
30if os.path.isfile('../ogserver') is not True:
31    print('You need to build the ogserver binary to run these tests :-)')
32    exit()
33
34if os.path.isfile('/usr/bin/valgrind') is not True:
35    print('You need valgrind to run these tests :-)')
36    exit()
37
38print("Stopping ogServer service...")
39subprocess.run(['systemctl', 'stop', 'ogserver'])
40
41start_mysql();
42
43subprocess.Popen(['valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes --verbose --log-file=./valgrind-out.log ../ogserver -f config/ogserver.json'], shell=True)
44
45print("Waiting 5 seconds for daemon to be read...")
46time.sleep(5)
47
48subprocess.run('python3 -m unittest discover -s units -v', shell=True)
49
50stop_mysql();
51
52subprocess.run(['pkill', '-f', 'valgrind'])
Note: See TracBrowser for help on using the repository browser.