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

Last change on this file since ca633e6 was 4a06c7a, checked in by OpenGnSys Support Team <soporte-og@…>, 4 years ago

#915 Update run-tests.py to the latest changes

This handles changes in:

  • The host of the DB.
  • New json config file.
  • Property mode set to 100755
File size: 2.0 KB
RevLine 
[727a109]1#!/usr/bin/env python3
2
3import subprocess, glob, 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
[4a06c7a]7sql_create_user = "CREATE USER 'test-db'@'localhost'; GRANT ALL PRIVILEGES ON *.* To 'test-db'@'localhost' IDENTIFIED BY 'test-db';"
[727a109]8
[4a06c7a]9sql_delete_user = "DROP USER 'test-db'@'localhost';"
[727a109]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'])
[5b1efd0]16    subprocess.run('mysql --default-character-set=utf8 test-db < ../cfg/ogAdmBD.sql', shell=True)
[727a109]17    subprocess.run(['mysql', '-D', 'test-db', '-e', sql_data])
18    subprocess.run(['mysql', '-D', 'test-db', '-e', sql_create_user])
19
20def stop_mysql():
21
22    subprocess.run(['mysql', '-D', 'test-db', '-e', sql_delete_user])
23    subprocess.run(['mysqladmin', 'drop', '-f', 'test-db'])
24
25if os.getuid() is not 0:
26    print('You need to be root to run these tests :-)')
27    exit()
28
[333abbe]29if os.path.isfile('../ogserver') is not True:
30    print('You need to build the ogserver binary to run these tests :-)')
[882fec8]31    exit()
32
[727a109]33start_mysql();
34
[4a06c7a]35subprocess.Popen(['../ogserver -f config/ogserver.json'], shell=True)
[727a109]36
[880cc90]37subprocess.run('python3 -m unittest discover -s units -v', shell=True)
[727a109]38
39stop_mysql();
40
[333abbe]41subprocess.run(['pkill', 'ogserver'])
Note: See TracBrowser for help on using the repository browser.