From cbe6c36d94f54875c097f28009a2a5a08e210d27 Mon Sep 17 00:00:00 2001 From: Chris Busch <62247804+cbuschfb@users.noreply.github.com> Date: Mon, 6 Jul 2020 10:43:03 -0400 Subject: [PATCH 1/5] Create LICENSE Add TIP standard license --- LICENSE | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..fdd69bac --- /dev/null +++ b/LICENSE @@ -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. From 4e39aa6060460c770755ec1b2d682caa05049550 Mon Sep 17 00:00:00 2001 From: Ben Greear Date: Fri, 14 Aug 2020 13:32:11 +0000 Subject: [PATCH 2/5] cicd/kpi: Fix pass/fail csv index. Ye olde off-by-one Signed-off-by: Ben Greear --- gui/kpi.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gui/kpi.java b/gui/kpi.java index 902537a2..790a7b69 100644 --- a/gui/kpi.java +++ b/gui/kpi.java @@ -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; From d09e2a7eefeb9d7f747d370447e5a80097518dc2 Mon Sep 17 00:00:00 2001 From: Ben Greear Date: Wed, 19 Aug 2020 06:17:47 -0700 Subject: [PATCH 3/5] cicd: Fix passing prompt into the openwrt_ctl script. So we can deal with DUT with prompts other than root@OpenWrt Signed-off-by: Ben Greear --- gui/basic_regression.bash | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gui/basic_regression.bash b/gui/basic_regression.bash index f8860ed2..935a40da 100755 --- a/gui/basic_regression.bash +++ b/gui/basic_regression.bash @@ -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? } From 22bb9fc0808c188cd75ca664d5a56dd7f7d3daec Mon Sep 17 00:00:00 2001 From: Ben Greear Date: Wed, 19 Aug 2020 07:07:59 -0700 Subject: [PATCH 4/5] kpi: Add initial attempt at integrating with slack. Code needs testing on real system and then needs the system call added to actually send info into slack. Signed-off-by: Ben Greear --- gui/kpi.java | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/gui/kpi.java b/gui/kpi.java index 790a7b69..53849fbc 100644 --- a/gui/kpi.java +++ b/gui/kpi.java @@ -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 @@ -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" + + " <" + 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_msg + " " + slack; + System.out.println(cmd); + // TODO: Call this as system call once we have it debugged + } + catch (Exception eeee) { + System.out.println("slack_msg: " + slack_msg + " slack_fname: " + slack_fname); + eeee.printStackTrace(); + } + } } runs_rows.append(row_text); From 99d5d77891f87b4891f1cb821bc05af42558f8fb Mon Sep 17 00:00:00 2001 From: Ben Greear Date: Wed, 19 Aug 2020 09:08:06 -0700 Subject: [PATCH 5/5] kpi: Fix slack integration. Seems to be working now. Signed-off-by: Ben Greear --- gui/kpi.java | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/gui/kpi.java b/gui/kpi.java index 53849fbc..ad2d38dd 100644 --- a/gui/kpi.java +++ b/gui/kpi.java @@ -161,16 +161,17 @@ public class kpi { DirectoryStream 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 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 stream3 = Files.newDirectoryStream(file2); @@ -629,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(); @@ -642,16 +643,27 @@ public class kpi { } if (!slack_fname.equals("")) { - String slack_msg = "'Content-type: application/json' --data '{\"text\":\"<" + results_url + "/|" + testbed_name + ">" - + " <" + results_url + "/" + run.getName() + "|" + run.getName() + ">" + 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_msg + " " + slack; + String cmd = "curl -X POST -H '" + slack_content_type + "' --data '" + slack_msg + "' " + slack; System.out.println(cmd); - // TODO: Call this as system call once we have it debugged + + 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);