mirror of
https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
synced 2025-11-05 21:28:03 +00:00
scripts: Improve gui automation scripts.
This commit is contained in:
@@ -86,6 +86,8 @@ sub telnet {
|
|||||||
sub doCmd {
|
sub doCmd {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $cmd = shift;
|
my $cmd = shift;
|
||||||
|
my $nowait = shift;
|
||||||
|
|
||||||
#print "CMD[[$cmd]]\n";
|
#print "CMD[[$cmd]]\n";
|
||||||
my $t = ${$self->{telnet}};
|
my $t = ${$self->{telnet}};
|
||||||
if ( !$self->cli_send_silent() || (defined $ENV{'LOG_CLI'} && $ENV{'LOG_CLI'} ne "")) {
|
if ( !$self->cli_send_silent() || (defined $ENV{'LOG_CLI'} && $ENV{'LOG_CLI'} ne "")) {
|
||||||
@@ -93,6 +95,10 @@ sub doCmd {
|
|||||||
}
|
}
|
||||||
$t->print($cmd);
|
$t->print($cmd);
|
||||||
|
|
||||||
|
if (defined($nowait) && ($nowait == 1)) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
my @rslt = $t->waitfor('/ >>RSLT:(.*)/');
|
my @rslt = $t->waitfor('/ >>RSLT:(.*)/');
|
||||||
if ( !$self->cli_rcv_silent() ) {
|
if ( !$self->cli_rcv_silent() ) {
|
||||||
print "**************\n@rslt\n................\n\n";
|
print "**************\n@rslt\n................\n\n";
|
||||||
|
|||||||
48
gui/README.txt
Normal file
48
gui/README.txt
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
|
||||||
|
Notes on writing GUI automated tests (such as AP-Auto, TR-398, Dataplane, Capacity test, etc)
|
||||||
|
|
||||||
|
AP-Auto:
|
||||||
|
|
||||||
|
In the GUI, configure the AP-Auto test as wished, and save the test config on the
|
||||||
|
Advanced Configuration page. In this example, I use the name: ap-auto-32-64-dual
|
||||||
|
|
||||||
|
In LANforge CLI, you can dump the saved configuration:
|
||||||
|
|
||||||
|
default@btbits>> show_text_blob Plugin-Settings AP-Auto-ap-auto-32-64-dual
|
||||||
|
TEXT-BLOB:Plugin-Settings.AP-Auto-ap-auto-32-64-dual::[BLANK]
|
||||||
|
show_events: 1
|
||||||
|
show_log: 1
|
||||||
|
port_sorting: 0
|
||||||
|
notes0: Chamber to Chamber test.
|
||||||
|
bg: 0xE0ECF8
|
||||||
|
test_rig: TR-398 test bed
|
||||||
|
....
|
||||||
|
|
||||||
|
Save this text to a file for later use: AP-Auto-ap-auto-32-64-dual.txt
|
||||||
|
|
||||||
|
You can also use the ../lf_testmod.pl script to do this:
|
||||||
|
# The head and tail stuff trims leading and trailing lines, respectively.
|
||||||
|
../lf_testmod.pl --mgr 192.168.100.156 --action show --test_name AP-Auto-ap-auto-32-64-dual|tail -n +2 | head -n -2 > test_configs/mytest.txt
|
||||||
|
|
||||||
|
To load a test file:
|
||||||
|
|
||||||
|
lf_testmod.pl --mgr 192.168.100.156 --action set --test_name AP-Auto-ben --file test_configs/mytest.txt
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
###
|
||||||
|
Once test cases have been loaded, you can tell the GUI to run tests for you, potentially modifying the
|
||||||
|
test configuration through the GUI.
|
||||||
|
|
||||||
|
First, tell the GUI to read the latest test config from the server.
|
||||||
|
|
||||||
|
../lf_gui_cmd.pl --manager localhost --port 3990 --cmd "cli show_text_blob"
|
||||||
|
|
||||||
|
|
||||||
|
Now, tell the GUI to run a test with the new config.
|
||||||
|
# Note that the --tconfig option does not have the "AP-Auto-" prepended to it, that is automatically
|
||||||
|
# done by the GUI in order to make sure each test has its own namespace.
|
||||||
|
../lf_gui_cmd.pl --manager localhost --port 3990 --ttype "AP-Auto" --tname ap-auto-ben --tconfig ben --rpt_dest /tmp/lf_reports/
|
||||||
|
|
||||||
|
|
||||||
|
Check /tmp/lf_reports for the report files.
|
||||||
171
gui/test_configs/AP-Auto-ap-auto-32-64-dual.txt
Normal file
171
gui/test_configs/AP-Auto-ap-auto-32-64-dual.txt
Normal file
@@ -0,0 +1,171 @@
|
|||||||
|
show_events: 1
|
||||||
|
show_log: 1
|
||||||
|
port_sorting: 0
|
||||||
|
notes0: Chamber to Chamber test.
|
||||||
|
bg: 0xE0ECF8
|
||||||
|
test_rig: TR-398 test bed
|
||||||
|
show_scan: 1
|
||||||
|
auto_helper: 1
|
||||||
|
skip_2: 1
|
||||||
|
skip_5: 1
|
||||||
|
dut5-0: TR398-DUT NETGEAR68-5G
|
||||||
|
dut2-0: TR398-DUT NETGEAR68
|
||||||
|
dut5-1: NA
|
||||||
|
dut2-1: NA
|
||||||
|
dut5-2: NA
|
||||||
|
dut2-2: NA
|
||||||
|
spatial_streams: AUTO
|
||||||
|
bandw_options: AUTO
|
||||||
|
modes: Auto
|
||||||
|
upstream_port: 1.1.1 eth1
|
||||||
|
operator: Ben Greear @ Candela Technologies
|
||||||
|
mconn: 1
|
||||||
|
tos: 0
|
||||||
|
vid_buf: 500000
|
||||||
|
vid_speed: 700000
|
||||||
|
reset_stall_thresh_udp_dl: 100000
|
||||||
|
reset_stall_thresh_udp_ul: 100000
|
||||||
|
reset_stall_thresh_tcp_dl: 100000
|
||||||
|
reset_stall_thresh_tcp_ul: 100000
|
||||||
|
reset_stall_thresh_l4: 100000
|
||||||
|
reset_stall_thresh_voip: 0
|
||||||
|
stab_udp_dl_min: 500000
|
||||||
|
stab_udp_dl_max: 1544000
|
||||||
|
stab_udp_ul_min: 500000
|
||||||
|
stab_udp_ul_max: 1544000
|
||||||
|
stab_tcp_dl_min: 500000
|
||||||
|
stab_tcp_dl_max: 1544000
|
||||||
|
stab_tcp_ul_min: 500000
|
||||||
|
stab_tcp_ul_max: 1544000
|
||||||
|
dl_speed: 85%
|
||||||
|
ul_speed: 85%
|
||||||
|
max_stations_2: 32
|
||||||
|
max_stations_5: 64
|
||||||
|
max_stations_dual: 64
|
||||||
|
lt_sta: 2
|
||||||
|
voip_calls: 10
|
||||||
|
lt_dur: 120
|
||||||
|
reset_dur: 300
|
||||||
|
lt_gi: 30
|
||||||
|
dur20: 20
|
||||||
|
hunt_retries: 1
|
||||||
|
cap_dl: 1
|
||||||
|
cap_ul: 1
|
||||||
|
cap_use_pkt_sizes: 0
|
||||||
|
stability_reset_radios: 0
|
||||||
|
pkt_loss_thresh: 10000
|
||||||
|
frame_sizes: 200, 512, 1024, MTU
|
||||||
|
capacities: 1, 10, 32, 64, 128
|
||||||
|
pf_text0: # modes: /a, /an-20 4x4, /an-40 4x4, /b, /bg, /bgn-20, /anAC-20,40,80
|
||||||
|
pf_text1: # stations: 1, 10, 20, 50, ...
|
||||||
|
pf_text2: # Non-specified and fields set to "*" means match all.
|
||||||
|
pf_text3: # For a/b/g modes, Auto-BW == 20, Auto-NSS == 1
|
||||||
|
pf_text4: # For /n modes, Auto-BW == 40, Auto-NSS == 4
|
||||||
|
pf_text5: # For /ac and /ax modes, Auto-BW == 80, Auto-NSS == 4
|
||||||
|
pf_text6:
|
||||||
|
pf_text7: # /a mode
|
||||||
|
pf_text8: 5 * 64 2Mbps mode=802.11a sta=1
|
||||||
|
pf_text9: 5 * 1370 25Mbps mode=802.11a sta=1
|
||||||
|
pf_text10: 5 * MTU 26Mbps mode=802.11a sta=1
|
||||||
|
pf_text11:
|
||||||
|
pf_text12: 5 * 64 50Mbps mode=802.11an sta=1 bw=20 nss=4
|
||||||
|
pf_text13: 5 * 1370 245Mbps mode=802.11an sta=1 bw=20 nss=4
|
||||||
|
pf_text14: 5 * MTU 245Mbps mode=802.11an sta=1 bw=20 nss=4
|
||||||
|
pf_text15:
|
||||||
|
pf_text16: 5 * 64 50Mbps mode=802.11an sta=1 bw=40 nss=4
|
||||||
|
pf_text17: 5 * 1370 455Mbps mode=802.11an sta=1 bw=40 nss=4
|
||||||
|
pf_text18: 5 * MTU 456Mbps mode=802.11an sta=1 bw=40 nss=4
|
||||||
|
pf_text19:
|
||||||
|
pf_text20: # For any amount of /b stations
|
||||||
|
pf_text21: 2.4 * 64 1Mbps mode=802.11b sta=*
|
||||||
|
pf_text22: 2.4 * 1370 7Mbps mode=802.11b sta=*
|
||||||
|
pf_text23: 2.4 * MTU 7Mbps mode=802.11b sta=*
|
||||||
|
pf_text24:
|
||||||
|
pf_text25: # For any amount of /bg stations
|
||||||
|
pf_text26: 2.4 * 64 2Mbps mode=802.11bg sta=*
|
||||||
|
pf_text27: 2.4 * 1370 21Mbps mode=802.11bg sta=*
|
||||||
|
pf_text28: 2.4 * MTU 22Mbps mode=802.11bg sta=*
|
||||||
|
pf_text29:
|
||||||
|
pf_text30: # For /bgn 20Mhz stations.
|
||||||
|
pf_text31: 2.4 * 64 50Mbps mode=802.11bgn sta=1 bw=20 nss=4
|
||||||
|
pf_text32: 2.4 * 1370 240Mbps mode=802.11bgn sta=1 bw=20 nss=4
|
||||||
|
pf_text33: 2.4 * MTU 241Mbps mode=802.11bgn sta=1 bw=20 nss=4
|
||||||
|
pf_text34:
|
||||||
|
pf_text35: 2.4 * 64 50Mbps mode=802.11bgn sta=10 bw=20 nss=4
|
||||||
|
pf_text36: 2.4 * 1370 240Mbps mode=802.11bgn sta=10 bw=20 nss=4
|
||||||
|
pf_text37: 2.4 * MTU 241Mbps mode=802.11bgn sta=10 bw=20 nss=4
|
||||||
|
pf_text38:
|
||||||
|
pf_text39: 2.4 * 64 50Mbps mode=802.11bgn sta=50 bw=20 nss=4
|
||||||
|
pf_text40: 2.4 * 1370 240Mbps mode=802.11bgn sta=50 bw=20 nss=4
|
||||||
|
pf_text41: 2.4 * MTU 245Mbps mode=802.11bgn sta=50 bw=20 nss=4
|
||||||
|
pf_text42:
|
||||||
|
pf_text43: 2.4 * 64 50Mbps mode=802.11bgn sta=100 bw=20 nss=4
|
||||||
|
pf_text44: 2.4 * 1370 235Mbps mode=802.11bgn sta=100 bw=20 nss=4
|
||||||
|
pf_text45: 2.4 * MTU 245Mbps mode=802.11bgn sta=100 bw=20 nss=4
|
||||||
|
pf_text46:
|
||||||
|
pf_text47: 2.4 * 64 50Mbps mode=802.11bgn sta=200 bw=20 nss=4
|
||||||
|
pf_text48: 2.4 * 1370 230Mbps mode=802.11bgn sta=200 bw=20 nss=4
|
||||||
|
pf_text49: 2.4 * MTU 235Mbps mode=802.11bgn sta=200 bw=20 nss=4
|
||||||
|
pf_text50:
|
||||||
|
pf_text51: # 40Mhz /n on 2.4, same values for all number of stations currently.
|
||||||
|
pf_text52: 2.4 * 64 50Mbps mode=802.11bgn sta=* bw=40 nss=4
|
||||||
|
pf_text53: 2.4 * 1370 280Mbps mode=802.11bgn sta=* bw=40 nss=4
|
||||||
|
pf_text54: 2.4 * MTU 281Mbps mode=802.11bgn sta=* bw=40 nss=4
|
||||||
|
pf_text55:
|
||||||
|
pf_text56: # For /an-AC 20Mhz stations.
|
||||||
|
pf_text57: 5 * 64 50Mbps mode=802.11an-AC sta=1 bw=20 nss=4
|
||||||
|
pf_text58: 5 * 1370 300Mbps mode=802.11an-AC sta=1 bw=20 nss=4
|
||||||
|
pf_text59: 5 * MTU 305Mbps mode=802.11an-AC sta=1 bw=20 nss=4
|
||||||
|
pf_text60:
|
||||||
|
pf_text61: # For /an-AC 40Mhz stations
|
||||||
|
pf_text62: 5 * 64 50Mbps mode=802.11an-AC sta=1 bw=40 nss=4
|
||||||
|
pf_text63: 5 * 1370 615Mbps mode=802.11an-AC sta=1 bw=40 nss=4
|
||||||
|
pf_text64: 5 * MTU 630Mbps mode=802.11an-AC sta=1 bw=40 nss=4
|
||||||
|
pf_text65:
|
||||||
|
pf_text66: # For /an-AC 80Mhz stations.
|
||||||
|
pf_text67: 5 DL 64 50Mbps mode=802.11an-AC sta=1 bw=80 nss=4
|
||||||
|
pf_text68: 5 DL 1370 1300Mbps mode=802.11an-AC sta=1 bw=80 nss=4
|
||||||
|
pf_text69: 5 DL MTU 1300Mbps mode=802.11an-AC sta=1 bw=80 nss=4
|
||||||
|
pf_text70: 5 UL 64 50Mbps mode=802.11an-AC sta=1 bw=80 nss=4
|
||||||
|
pf_text71: 5 UL 1370 1100Mbps mode=802.11an-AC sta=1 bw=80 nss=4
|
||||||
|
pf_text72: 5 UL MTU 1100Mbps mode=802.11an-AC sta=1 bw=80 nss=4
|
||||||
|
pf_text73:
|
||||||
|
pf_text74: 5 DL 64 50Mbps mode=802.11an-AC sta=10 bw=80 nss=4
|
||||||
|
pf_text75: 5 DL 1370 1300Mbps mode=802.11an-AC sta=10 bw=80 nss=4
|
||||||
|
pf_text76: 5 DL MTU 1300Mbps mode=802.11an-AC sta=10 bw=80 nss=4
|
||||||
|
pf_text77: 5 UL 64 50Mbps mode=802.11an-AC sta=10 bw=80 nss=4
|
||||||
|
pf_text78: 5 UL 1370 1200Mbps mode=802.11an-AC sta=10 bw=80 nss=4
|
||||||
|
pf_text79: 5 UL MTU 1200Mbps mode=802.11an-AC sta=10 bw=80 nss=4
|
||||||
|
pf_text80:
|
||||||
|
pf_text81: 5 * 64 50Mbps mode=802.11an-AC sta=50 bw=80 nss=4
|
||||||
|
pf_text82: 5 * 1370 1200Mbps mode=802.11an-AC sta=50 bw=80 nss=4
|
||||||
|
pf_text83: 5 * MTU 1200Mbps mode=802.11an-AC sta=50 bw=80 nss=4
|
||||||
|
pf_text84:
|
||||||
|
pf_text85: 5 * 64 50Mbps mode=802.11an-AC sta=100 bw=80 nss=4
|
||||||
|
pf_text86: 5 * 1370 1100Mbps mode=802.11an-AC sta=100 bw=80 nss=4
|
||||||
|
pf_text87: 5 * MTU 1100Mbps mode=802.11an-AC sta=100 bw=80 nss=4
|
||||||
|
pf_text88:
|
||||||
|
pf_text89: # Auto (full capabilities) entries, for tput test, DUT is wave-1 3x3/2x2
|
||||||
|
pf_text90: 2.4 * 64 50Mbps mode=Auto sta=* bw=Auto nss=Auto
|
||||||
|
pf_text91: 2.4 * 1370 280Mbps mode=Auto sta=* bw=Auto nss=Auto
|
||||||
|
pf_text92: 2.4 * MTU 282Mbps mode=Auto sta=* bw=Auto nss=Auto
|
||||||
|
pf_text93:
|
||||||
|
pf_text94: 5 * 64 50Mbps mode=Auto sta=* bw=Auto nss=Auto
|
||||||
|
pf_text95: 5 * 1370 650Mbps mode=Auto sta=* bw=Auto nss=Auto
|
||||||
|
pf_text96: 5 * MTU 650Mbps mode=Auto sta=* bw=Auto nss=Auto
|
||||||
|
radio2-0: 1.1.8 wiphy1
|
||||||
|
radio2-1: 1.1.9 wiphy3
|
||||||
|
radio2-2: 1.1.10 wiphy5
|
||||||
|
radio5-0: 1.1.3 wiphy0
|
||||||
|
radio5-1: 1.1.5 wiphy2
|
||||||
|
radio5-2: 1.1.7 wiphy4
|
||||||
|
basic_cx: 1
|
||||||
|
tput: 0
|
||||||
|
dual_band_tput: 0
|
||||||
|
capacity: 0
|
||||||
|
longterm: 0
|
||||||
|
mix_stability: 0
|
||||||
|
loop_iter: 1
|
||||||
|
reset_batch_size: 1
|
||||||
|
reset_duration_min: 20000
|
||||||
|
reset_duration_max: 30000
|
||||||
@@ -31,6 +31,8 @@ my $tname = "lfgui-test";
|
|||||||
my $tconfig = ""; # test config
|
my $tconfig = ""; # test config
|
||||||
my $rpt_dest = "";
|
my $rpt_dest = "";
|
||||||
my $show_help = 0;
|
my $show_help = 0;
|
||||||
|
my @modifiers_key = ();
|
||||||
|
my @modifiers_val = ();
|
||||||
|
|
||||||
########################################################################
|
########################################################################
|
||||||
# Nothing to configure below here, most likely.
|
# Nothing to configure below here, most likely.
|
||||||
@@ -45,6 +47,7 @@ my $usage = qq($0 [--manager { hostname or address of LANforge GUI machine } ]
|
|||||||
[--tconfig {test configuration name, use defaults if not specified} ]
|
[--tconfig {test configuration name, use defaults if not specified} ]
|
||||||
[--rpt_dest {Copy report to destination once it is complete} ]
|
[--rpt_dest {Copy report to destination once it is complete} ]
|
||||||
[--cmd { command to send to the GUI } ]
|
[--cmd { command to send to the GUI } ]
|
||||||
|
[--modifier "
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
lf_gui_cmd.pl --manager localhost --port 3990 --ttype TR-398 --tname mytest --tconfig comxim --rpt_dest /var/www/html/lf_reports
|
lf_gui_cmd.pl --manager localhost --port 3990 --ttype TR-398 --tname mytest --tconfig comxim --rpt_dest /var/www/html/lf_reports
|
||||||
@@ -59,6 +62,8 @@ if (@ARGV < 2) {
|
|||||||
GetOptions (
|
GetOptions (
|
||||||
'help|h' => \$show_help,
|
'help|h' => \$show_help,
|
||||||
'manager|mgr|m=s' => \$lfmgr_host,
|
'manager|mgr|m=s' => \$lfmgr_host,
|
||||||
|
'modifier_key=s' => \@modifiers_key,
|
||||||
|
'modifier_val=s' => \@modifiers_val,
|
||||||
'ttype=s' => \$ttype,
|
'ttype=s' => \$ttype,
|
||||||
'tname=s' => \$tname,
|
'tname=s' => \$tname,
|
||||||
'tconfig=s' => \$tconfig,
|
'tconfig=s' => \$tconfig,
|
||||||
@@ -72,6 +77,13 @@ if ($show_help) {
|
|||||||
exit 0;
|
exit 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
my $lnk = @modifiers_key;
|
||||||
|
my $lnv = @modifiers_val;
|
||||||
|
if ($lnk != $lnv) {
|
||||||
|
print("ERROR: You must specify the same amount of modifers-key and modifiers-val entries.\n");
|
||||||
|
exit(3);
|
||||||
|
}
|
||||||
|
|
||||||
if ((defined $port) && ($port > 0)) {
|
if ((defined $port) && ($port > 0)) {
|
||||||
$lfmgr_port = $port;
|
$lfmgr_port = $port;
|
||||||
}
|
}
|
||||||
@@ -96,6 +108,14 @@ if ($ttype ne "") {
|
|||||||
print doCmd("cv load '$tname' '$tconfig'");
|
print doCmd("cv load '$tname' '$tconfig'");
|
||||||
}
|
}
|
||||||
print doCmd("cv click '$tname' 'Auto Save Report'");
|
print doCmd("cv click '$tname' 'Auto Save Report'");
|
||||||
|
|
||||||
|
my $i;
|
||||||
|
for ($i = 0; $i<@modifiers_key; $i++) {
|
||||||
|
my $k = $modifiers_key[$i];
|
||||||
|
my $v = $modifiers_val[$i];
|
||||||
|
print doCmd("cv set '$tname' '$k' '$v'");
|
||||||
|
}
|
||||||
|
|
||||||
print doCmd("cv click '$tname' 'Start'");
|
print doCmd("cv click '$tname' 'Start'");
|
||||||
while (1) {
|
while (1) {
|
||||||
my $rslt = doCmd("cv get '$tname' 'Report Location:'");
|
my $rslt = doCmd("cv get '$tname' 'Report Location:'");
|
||||||
@@ -120,6 +140,33 @@ if ($ttype ne "") {
|
|||||||
sleep(3);
|
sleep(3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Clean up our instance. This can take a while.
|
||||||
|
print doCmd("cv delete '$tname'");
|
||||||
|
while (1) {
|
||||||
|
my $rslt = doCmd("cv exists '$tname'");
|
||||||
|
print "Result-exists -:$rslt:-\n";
|
||||||
|
if ($rslt =~ /YES/) {
|
||||||
|
sleep(3);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
last;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Wait a bit more, CV will likey be rebuilt now.
|
||||||
|
sleep(5);
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
my $rslt = doCmd("cv is_built");
|
||||||
|
print "Result-built -:$rslt:-\n";
|
||||||
|
if ($rslt =~ /NO/) {
|
||||||
|
sleep(3);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
last;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
exit(0);
|
exit(0);
|
||||||
|
|||||||
178
lf_testmod.pl
Executable file
178
lf_testmod.pl
Executable file
@@ -0,0 +1,178 @@
|
|||||||
|
#!/usr/bin/perl -w
|
||||||
|
|
||||||
|
# This program is used to load GUI tests (TR-398, Capacity, etc) from a file
|
||||||
|
# and configure it in the LANforge server. See gui/README.txt
|
||||||
|
# (C) 2020 Candela Technologies Inc.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use diagnostics;
|
||||||
|
use Carp;
|
||||||
|
$SIG{ __DIE__ } = sub { Carp::confess( @_ ) };
|
||||||
|
$SIG{ __WARN__ } = sub { Carp::confess( @_ ) };
|
||||||
|
|
||||||
|
# Un-buffer output
|
||||||
|
$| = 1;
|
||||||
|
|
||||||
|
# use lib prepends to @INC, so put lower priority first
|
||||||
|
# This is before run-time, so cannot condition this with normal 'if' logic.
|
||||||
|
use lib '/home/lanforge/scripts';
|
||||||
|
use lib "../";
|
||||||
|
use lib "./";
|
||||||
|
|
||||||
|
use LANforge::Endpoint;
|
||||||
|
use LANforge::Port;
|
||||||
|
use LANforge::Utils;
|
||||||
|
use Net::Telnet ();
|
||||||
|
use Getopt::Long;
|
||||||
|
|
||||||
|
our $NA = 'NA';
|
||||||
|
our $NL = "\n";
|
||||||
|
|
||||||
|
# Default values for ye ole cmd-line args.
|
||||||
|
our $quiet = "yes";
|
||||||
|
our $test_type = "Plugin-Settings";
|
||||||
|
our $test_name = "";
|
||||||
|
our $file_name = "";
|
||||||
|
our $action = "show";
|
||||||
|
our $lfmgr_host = "localhost";
|
||||||
|
our $lfmgr_port = 4001;
|
||||||
|
|
||||||
|
########################################################################
|
||||||
|
# Nothing to configure below here, most likely.
|
||||||
|
########################################################################
|
||||||
|
|
||||||
|
our $usage = <<"__EndOfUsage__";
|
||||||
|
$0 [ --action {
|
||||||
|
show | set
|
||||||
|
} ]
|
||||||
|
[--file {data file name}]
|
||||||
|
[--test_name {test name or ALL}]
|
||||||
|
[--test_type {Plugin-Settings or other type or ALL}]
|
||||||
|
[--mgr {host-name | IP}]
|
||||||
|
[--mgr_port {ip port}]
|
||||||
|
[--quiet { yes | no }]
|
||||||
|
[--log_cli {1|filename}]
|
||||||
|
|
||||||
|
Example:
|
||||||
|
$0 --action set --test_name AP-Auto-ap-auto-32-64-dual --file test_configs/AP-Auto-ap-auto-32-64-dual.txt
|
||||||
|
__EndOfUsage__
|
||||||
|
|
||||||
|
my $i = 0;
|
||||||
|
my $cmd;
|
||||||
|
|
||||||
|
my $log_cli = "unset"; # use ENV{LOG_CLI} elsewhere
|
||||||
|
my $show_help = 0;
|
||||||
|
|
||||||
|
if (@ARGV < 2) {
|
||||||
|
print $usage;
|
||||||
|
exit 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
our $debug = 0;
|
||||||
|
|
||||||
|
GetOptions
|
||||||
|
(
|
||||||
|
'action|a=s' => \$::action,
|
||||||
|
'file=s' => \$::file_name,
|
||||||
|
'test_name=s' => \$::test_name,
|
||||||
|
'test_type=s' => \$::test_type,
|
||||||
|
'debug|d' => \$::debug,
|
||||||
|
'help|h' => \$show_help,
|
||||||
|
'log_cli=s{0,1}' => \$log_cli,
|
||||||
|
'manager|mgr|m=s' => \$::lfmgr_host,
|
||||||
|
'lfmgr_port|mgr_port|port|p=i' => \$::lfmgr_port,
|
||||||
|
'quiet|q=s' => \$::quiet,
|
||||||
|
|
||||||
|
) || die("$::usage");
|
||||||
|
|
||||||
|
if ($show_help) {
|
||||||
|
print $usage;
|
||||||
|
exit 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
use Data::Dumper;
|
||||||
|
|
||||||
|
if ($::debug) {
|
||||||
|
$ENV{DEBUG} = 1 if (!(defined $ENV{DEBUG}));
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($::quiet eq "0") {
|
||||||
|
$::quiet = "no";
|
||||||
|
}
|
||||||
|
elsif ($::quiet eq "1") {
|
||||||
|
$::quiet = "yes";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (defined $log_cli) {
|
||||||
|
if ($log_cli ne "unset") {
|
||||||
|
# here is how we reset the variable if it was used as a flag
|
||||||
|
if ($log_cli eq "") {
|
||||||
|
$ENV{'LOG_CLI'} = 1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$ENV{'LOG_CLI'} = $log_cli;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
our @valid_actions = qw(show set);
|
||||||
|
|
||||||
|
if (! (grep {$_ eq $::action} @::valid_actions )) {
|
||||||
|
die("Invalid action: $::action\n$::usage\n");
|
||||||
|
}
|
||||||
|
if ($::quiet eq "1" ) {
|
||||||
|
$::quiet = "yes";
|
||||||
|
}
|
||||||
|
|
||||||
|
# Open connection to the LANforge server.
|
||||||
|
our $utils = new LANforge::Utils();
|
||||||
|
$::utils->connect($lfmgr_host, $lfmgr_port);
|
||||||
|
|
||||||
|
|
||||||
|
if ($::action eq "show") {
|
||||||
|
$cmd = "show_text_blob $test_type $test_name";
|
||||||
|
my $r = $::utils->doCmd($cmd);
|
||||||
|
print $r;
|
||||||
|
print "\n\n";
|
||||||
|
}
|
||||||
|
elsif ($::action eq "set") {
|
||||||
|
if ($file_name eq "") {
|
||||||
|
print("ERROR: Must specify file name when doing the 'set' action\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
my @cmds = `cat $file_name`;
|
||||||
|
if (@cmds == 0) {
|
||||||
|
print("ERROR: Could not read any lines from the file: $file_name\n");
|
||||||
|
exit(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
# First clean out any old text blob.
|
||||||
|
$cmd = "rm_text_blob $test_type $test_name";
|
||||||
|
$::utils->doCmd($cmd);
|
||||||
|
|
||||||
|
# And add the new blob
|
||||||
|
for ($i = 0; $i<@cmds; $i++) {
|
||||||
|
my $ln = $cmds[$i];
|
||||||
|
chomp($ln);
|
||||||
|
|
||||||
|
# Skip blank lines
|
||||||
|
if ($ln eq "") {
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
|
||||||
|
$cmd = "add_text_blob '$test_type' '$test_name' $ln";
|
||||||
|
$::utils->doCmd($cmd, 1); # send and do not wait for result
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
die("Unknown action: $::action\n$::usage\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
exit(0);
|
||||||
|
|
||||||
|
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
|
||||||
|
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
|
||||||
Reference in New Issue
Block a user