Merge remote-tracking branch 'origin/master'

This commit is contained in:
Logan Lipke
2020-08-19 11:33:52 -07:00
3 changed files with 79 additions and 8 deletions

29
LICENSE Normal file
View File

@@ -0,0 +1,29 @@
BSD 3-Clause License
Copyright (c) 2020, Telecom Infra Project
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@@ -104,19 +104,19 @@ function pre_test {
then
# Kill any existing processes on this serial port
pkill -f ".*openwrt_ctl.*$LF_SERIAL.*"
../openwrt_ctl.py --action lurk --tty $LF_SERIAL --scheme serial --user root --passwd $LFPASSWD --prompt "\[root@" > $LF_SER_LOG 2>&1 &
../openwrt_ctl.py --action lurk $OWRTCTL_ARGS --tty $LF_SERIAL --scheme serial --user root --passwd $LFPASSWD --prompt "\[root@" > $LF_SER_LOG 2>&1 &
fi
if [ "_${AP_SERIAL}" != "_NONE" ]
then
# Kill any existing processes on this serial port
pkill -f ".*openwrt_ctl.*$AP_SERIAL.*"
../openwrt_ctl.py --action logread --tty $AP_SERIAL --scheme serial > $DUT_SER_LOG 2>&1 &
../openwrt_ctl.py --action logread $OWRTCTL_ARGS --tty $AP_SERIAL --scheme serial > $DUT_SER_LOG 2>&1 &
fi
}
function reboot_dut {
../openwrt_ctl.py --action reboot --tty $AP_SERIAL --scheme serial
../openwrt_ctl.py --action reboot $OWRTCTL_ARGS --tty $AP_SERIAL --scheme serial
# TODO: Support hard-power cycle with power-ctl switch as well?
}

View File

@@ -1,6 +1,6 @@
//
// LANforge-GUI Source Code
// Copyright (C) 1999-2018 Candela Technologies Inc
// Copyright (C) 1999-2020 Candela Technologies Inc
// http://www.candelatech.com
//
// This program is free software; you can redistribute it and/or
@@ -45,7 +45,7 @@ public class kpi {
public static int PRIORITY_IDX = 6;
public static int TEST_ID_IDX = 7;
public static int SHORT_DESC_IDX = 8;
public static int PASS_FAIL_IDX = 8;
public static int PASS_FAIL_IDX = 9;
public static int NUMERIC_SCORE_IDX = 10;
public static int NOTES_IDX = 11;
public static int UNITS_IDX = 12;
@@ -121,6 +121,8 @@ public class kpi {
String dir = null;
String results_url = "";
String caseid = "";
String slack_fname = "";
String testbed_name = "LANforge CICD";
for (int i = 0; i<args.length; i++) {
if (args[i].equals("--dir")) {
@@ -132,8 +134,18 @@ public class kpi {
else if (args[i].equals("--results_url")) {
results_url = args[i+1];
}
else if (args[i].equals("--slack_fname")) {
slack_fname = args[i+1];
}
else if (args[i].equals("--testbed_name")) {
testbed_name = args[i+1];
}
else if (args[i].equals("--help") || args[i].equals("-h") || args[i].equals("-?")) {
System.out.println("Usage: $0 --dir /path/to/test-collection");
System.out.println("Usage: $0 --dir /path/to/test-collection\n" +
"--caseid [case-id]\n" +
"--results_url [url]\n" +
"--slack_fname [slack url webhook file name]\n" +
"--testbed_name [My Testbed]");
System.exit(0);
}
}
@@ -149,16 +161,17 @@ public class kpi {
DirectoryStream<Path> stream = Files.newDirectoryStream(Paths.get(dir));
for (Path file: stream) {
File f = file.toFile(); // this is the test run dir
//System.out.println("Checking sub-directory/file (run): " + f.getAbsolutePath());
// Inside of it is individual tests.
if (!f.isDirectory()) {
continue;
}
//System.out.println("Checking sub-directory/file (run): " + f.getAbsolutePath());
DirectoryStream<Path> stream2 = Files.newDirectoryStream(file);
Run run = null;
for (Path file2: stream2) {
File f2 = file2.toFile(); // this is the test case dir in the test run
//System.out.println("Checking test-case directory/file: " + f2.getAbsolutePath());
// Directory full of test results?
if (f2.isDirectory()) {
DirectoryStream<Path> stream3 = Files.newDirectoryStream(file2);
@@ -617,7 +630,7 @@ public class kpi {
bw.write(System.lineSeparator());
bw.write(testrails_msg);
bw.write(System.lineSeparator());
bw.write("MSG URL: " + results_url);
bw.write("MSG URL: " + results_url + "/" + run.getName());
bw.write(System.lineSeparator());
bw.close();
@@ -628,6 +641,35 @@ public class kpi {
eee.printStackTrace();
}
}
if (!slack_fname.equals("")) {
String slack_content_type = "Content-type: application/json";
String slack_msg = "{\"text\":\"<" + results_url + "|" + testbed_name + ">"
+ " Results: <" + results_url + "/" + run.getName() + "|" + run.getName() + ">"
+ " Errors: " + (run.getLogCrashes() + run.getLogRestarting() + run.getLogBugs()) + " Warnings: " + run.getLogWarnings()
+ "\"}";
try {
BufferedReader br = new BufferedReader(new FileReader(slack_fname));
String slack = br.readLine();
String cmd = "curl -X POST -H '" + slack_content_type + "' --data '" + slack_msg + "' " + slack;
System.out.println(cmd);
ShellExec exec = new ShellExec(true, true);
int rv = exec.execute("curl", null, true,
"-X", "POST",
"-H", slack_content_type,
"--data", slack_msg, slack);
if (rv != 0) {
System.out.println("curl slack post of msg: " + slack_msg + " to: " + slack + " failed.\n");
System.out.println(exec.getOutput());
System.out.println(exec.getError());
}
}
catch (Exception eeee) {
System.out.println("slack_msg: " + slack_msg + " slack_fname: " + slack_fname);
eeee.printStackTrace();
}
}
}
runs_rows.append(row_text);