[general]
geo_lat=61.786838
geo_lng=34.353548
geo_alt=1
[tracks]
id=1,type=POLY,TF=0,VRT=(20:0:0)(21:0:30)(60)(40:0:0)(60)
[devices]
mac=CF0000000000,devtype=1,ip=127.0.1.1,cycle=30000,x=0.0,y=0.0,z=0
mac=C00000000001,devtype=2,ip=127.0.0.2,cycle=30000,x=5.0,y=0.0,z=0
mac=000000BAD001,devtype=4,cycle=2000,track=1
mac=000000BAD002,devtype=6,cycle=2000,track=1
#!/bin/bash set -e if [ "$#" -ne 2 ] then echo "Usage: ./${0} <base_config> <dev_num>" exit 1 fi INCPTESTER_CONF_PATH=./${1}.conf if [ ! -f ${INCPTESTER_CONF_PATH} ]; then cat ./incptester_geo-base.conf > ${INCPTESTER_CONF_PATH} fi alias get_next_mac='python -c "import sys; print '{:012x}'.format(int(sys.argv[1], 16)+int(sys.argv[2], 16)).upper()"' last_mac=$(tac ${INCPTESTER_CONF_PATH} | grep -m 1 . | grep -o -P "[A-z0-9]{12}") for count in $(seq ${2}); do next_mac=$(get_next_mac "0x${last_mac}" "0x1") echo "mac=${next_mac},devtype=6,cycle=2000,track=2" >> ${INCPTESTER_CONF_PATH} last_mac=${next_mac} done
@Load_stability_geo
Feature: Load_stability_geo
This test starts the large number of the devices and monitors the system resources
@Install
Scenario: Instalation of RealTrac system in geo mode
Given I delete the previous Realtrac-server from the both test-servers
And I prepare all deb configs
And I copy all configs and scripts to the test servers
And I install the main Realtrac-server on the test-server and incptester and stop service rtlserm for geo configuration
Then Run first part of the test with the inside load for 11520 steps
Given I install the app server
Then Run second part of the test with the inside load for 11520 steps
import rtls.test.utils.RTLSUtils; import cucumber.api.java.en.And; import cucumber.api.java.en.Then; import cucumber.api.java.en.When; public class LoadStabilityGeo { // some other methods @Then("^Run first part of the test with the inside load for (\\d+) steps") public void First_Monitoring(int count_time) throws ScriptFaildException, Exception { int times=0; double minutes; int check_time_min=10; //each 10 minutes the resources is verified monitoring_file=NameFileDataFormat("monitoring", "csv"); path_monitoring_file=" /home/"+user+"/TestResult/"; path_monitoring_file=path_monitoring_file+monitoring_file; minutes=0.5; while (times <= count_time) { run_ssh_cmd("resource_get.py "+path_monitoring_file+" rtls", "main_server"); If (((times%check_time_min)==0) && times!=0){ checkResource("rtls", rtlscp_port, rtlscpip, check_time_min); times=times+1; }else{ Sleep_time(minutes); times=times+1; } } System.out.println("The first part of the stress test in geo-mode is successfully finished"); } }
public class RTLSUtils { // some other methods public static void executeCommand(String command) throws ScriptFaildException { try { String line; System.out.println("Excecute " + command); String[] env = new String[]{"DEBIAN_FRONTEND=noninteractive"}; Process p = Runtime.getRuntime().exec(command, env); BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream())); BufferedReader error = new BufferedReader(new InputStreamReader(p.getErrorStream())); while ((line = input.readLine()) != null) { System.out.println(line); } input.close(); while ((line = error.readLine()) != null) { System.out.println(line); } error.close(); try { if (p.exitValue() != 0) { throw new ScriptFaildException(new Exception("error to execute command " + command)); } } catch (IllegalThreadStateException ex) { } } catch (IOException ex) { throw new ScriptFaildException(ex); } } }
#!/bin/bash set -e set -x # SCRIPT_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" # ( ) TEST_USER=user TEST_SERVER_IP=192.168.1.2 # # , if [ "${TEST_SERVER_IP}" == "127.0.0.1" ]; then COMMAND_PREFIX= else COMMAND_PREFIX="ssh ${TEST_USER}@${TEST_SERVER_IP}" fi APT_CONFIG_DIR="/home/${TEST_USER}/apt-get/" VERSION=$1 # deb if [ "${TEST_SERVER_IP}" == "127.0.0.1" ]; then if [ ! -d ${APT_CONFIG_DIR} ]; then mkdir ${APT_CONFIG_DIR} fi cp ${SCRIPT_PATH}/debconf.dat $APT_CONFIG_DIR else scp ${SCRIPT_PATH}/debconf.dat ${TEST_USER}@${TEST_SERVER_IP}:${APT_CONFIG_DIR} fi # ${COMMAND_PREFIX} sudo debconf-set-selections ${APT_CONFIG_DIR}debconf.dat ${COMMAND_PREFIX} sudo apt-get update && true ${COMMAND_PREFIX} sudo DEBIAN_FRONTEND=noninteractive apt-get install --force-yes -y some-package-${VERSION}
#!/usr/bin/python # -*- coding: utf-8 -*- # depends on; # sudo pip install psutil # Usage: python resources.py </path/to/file> <proc_name> import time import datetime import psutil import sys import csv def convert_bytes(bytes): ''' :param bytes: :return: ''' bytes = float(bytes) if bytes >= 1099511627776: terabytes = bytes / 1099511627776 size = '%.2fT' % terabytes elif bytes >= 1073741824: gigabytes = bytes / 1073741824 size = '%.2fG' % gigabytes elif bytes >= 1048576: megabytes = bytes / 1048576 size = '%.2fM' % megabytes elif bytes >= 1024: kilobytes = bytes / 1024 size = '%.2fK' % kilobytes else: size = '%.2fb' % bytes return size def get_string(proc, proc_name): ''' . :param proc: :param proc_name: :return: ''' data_time = datetime.datetime.fromtimestamp(time.time()).strftime("%Y-%m-%d %H:%M:%S") ram = convert_bytes(proc.memory_info().rss) ram_percent = round(proc.memory_percent(),2) cpu = proc.cpu_percent(interval=1) wrt_str = ("{0} {1} {2} {3} {4} {5}".format(data_time, proc_name, proc.pid, ram, ram_percent, cpu)) return wrt_str if __name__ == "__main__": if (len(sys.argv) == 3): pathresult_log = sys.argv[1] target_proc = sys.argv[2] # if (target_proc=="rtls"): res_log_rtls = open(pathresult_log, 'a') writer_rtls_log = csv.writer(res_log_rtls) elif (target_proc == "rtlsapp"): res_log_app = open(pathresult_log, 'a') writer_app_log = csv.writer(res_log_app) elif (target_proc == "all"): res_log_rtls = open(pathresult_log, 'a') res_log_app = open(pathresult_log, 'a') writer_rtls_log = csv.writer(res_log_rtls) writer_app_log = csv.writer(res_log_app) else: print ("Types of the test are not correct") sys.exit(1) proc_rtls = 0 proc_rtlsapp = 0 try: # procs = [p for p in psutil.process_iter()] for proc in procs: if (proc.name() == 'java' and proc.username() == 'rtlsadmin'): proc_rtls = proc elif (proc.name() == 'node' and proc.username() == 'rtlsapp'): proc_rtlsapp = proc except psutil.NoSuchProcess: pass else: # if (target_proc == "rtls" or target_proc == "all"): if (proc_rtls != 0): proc_name = "rtls-server" str_rtls = get_string(proc_rtls, proc_name) writer_rtls_log.writerow(str_rtls.split()) elif (target_proc == "rtlsapp" or target_proc == "all"): if (proc_rtlsapp != 0): proc_name = "rtls-app" str_rtlsapp = get_string(proc_rtlsapp, proc_name) writer_app_log.writerow(str_rtlsapp.split()) finally: # if (target_proc == "rtls" or target_proc == "all"): res_log_rtls.close() elif (target_proc == "rtlsapp" or target_proc == "all"): res_log_app.close() else: print("Input parameters are not correct") sys.exit(1)
Source: https://habr.com/ru/post/302138/
All Articles