From 6c2a63e8eebff37fbe919bbafe1b9ff174515a0d Mon Sep 17 00:00:00 2001 From: Anna Babu Palathingal <148897727+annaibm@users.noreply.github.com> Date: Thu, 20 Jun 2024 11:44:36 -0400 Subject: [PATCH] Parse data from TRSS url - TKG Parse data from TRSS url related:https://github.com/adoptium/TKG/issues/558 Signed-off-by: Anna Babu Palathingal --- src/org/testKitGen/TestDivider.java | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/org/testKitGen/TestDivider.java b/src/org/testKitGen/TestDivider.java index 8d503d7f..12cc7b0e 100644 --- a/src/org/testKitGen/TestDivider.java +++ b/src/org/testKitGen/TestDivider.java @@ -226,7 +226,15 @@ private Map getDataFromTRSS() { String level = getLevel(); Map map = new HashMap(); String URL = constructURL(impl, plat, group, level); - String command = "curl --silent --max-time 120 -L " + URL; + String osName = System.getProperty("os.name").toLowerCase(); + String command; + + if (osName.contains("win")) { + command = "cmd.exe /c curl --silent --max-time 120 -L -k \"" + URL + "\""; + } else { + command = "curl --silent --max-time 120 -L -k " + URL; + } + System.out.println("Attempting to get test duration data from TRSS."); System.out.println(command); Process process; @@ -238,7 +246,7 @@ private Map getDataFromTRSS() { } try (InputStream responseStream = process.getInputStream(); Reader responseReader = new BufferedReader(new InputStreamReader(responseStream))) { - parseDuration(responseReader, map); + parseDuration(responseReader, map); } catch (IOException | ParseException e) { System.out.println("Warning: cannot parse data from TRSS."); e.printStackTrace(); @@ -276,7 +284,15 @@ private Queue> createDurationQueue() { Map testsInvalid = new HashMap<>(); for (String test : allTests) { if (matchTRSS.contains(test) || matchCache.contains(test)) { - int duration = TRSSMap.containsKey(test) ? TRSSMap.get(test) : cacheMap.get(test); + int duration; + if (TRSSMap.containsKey(test)) { + duration = TRSSMap.get(test); + System.out.println("TRSSMap.get(" + test + "): " + duration); + } else { + duration = cacheMap.get(test); + System.out.println("cacheMap.get(" + test + "): " + duration); + } + // int duration = TRSSMap.containsKey(test) ? TRSSMap.get(test) : cacheMap.get(test); if (duration > 0) { durationQueue.offer(new AbstractMap.SimpleEntry<>(test, duration)); } else {