From fafd5a1c3764ba9561aa951fe843dd4bf68c88c8 Mon Sep 17 00:00:00 2001 From: Jerry Flood Date: Sat, 20 Apr 2019 07:14:30 -0400 Subject: Resolve failsafe plugin naming convention updated IT*.java naming to It*.java Issue-ID: OPTFRA-474 Change-Id: If96776af5b10fe712a5b72138af9d65b67bb271e Signed-off-by: Jerry Flood --- cmso-sonar/pom.xml | 12 +- .../onap/optf/cmso/it/ItFullIntegrationTest.java | 152 --------------------- cmso-sonar/src/it/resources/integration.properties | 7 - .../onap/optf/cmso/it/ItFullIntegrationTest.java | 152 +++++++++++++++++++++ .../src/test/resources/integration.properties | 7 + 5 files changed, 170 insertions(+), 160 deletions(-) delete mode 100644 cmso-sonar/src/it/java/org/onap/optf/cmso/it/ItFullIntegrationTest.java delete mode 100644 cmso-sonar/src/it/resources/integration.properties create mode 100644 cmso-sonar/src/test/java/org/onap/optf/cmso/it/ItFullIntegrationTest.java create mode 100644 cmso-sonar/src/test/resources/integration.properties (limited to 'cmso-sonar') diff --git a/cmso-sonar/pom.xml b/cmso-sonar/pom.xml index 3f0815f..b5d22d8 100644 --- a/cmso-sonar/pom.xml +++ b/cmso-sonar/pom.xml @@ -87,11 +87,21 @@ + + maven-surefire-plugin + + + **/It*.java + + + org.apache.maven.plugins maven-failsafe-plugin - ${project.basedir}/src/it/java + + **/It*.java + ${skipIntegrationTests} diff --git a/cmso-sonar/src/it/java/org/onap/optf/cmso/it/ItFullIntegrationTest.java b/cmso-sonar/src/it/java/org/onap/optf/cmso/it/ItFullIntegrationTest.java deleted file mode 100644 index d6eccb3..0000000 --- a/cmso-sonar/src/it/java/org/onap/optf/cmso/it/ItFullIntegrationTest.java +++ /dev/null @@ -1,152 +0,0 @@ -/* - * ============LICENSE_START============================================== Copyright (c) 2019 AT&T - * Intellectual Property. ======================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. ============LICENSE_END================================================= - */ - -package org.onap.optf.cmso.it; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.nio.file.StandardCopyOption; -import java.util.ArrayList; -import java.util.List; -import java.util.Properties; -import org.apache.commons.io.IOUtils; -import org.junit.Test; - -public class ItFullIntegrationTest { - - private Properties env = new Properties(); - - @Test - public void runTest() throws IOException { - InputStream is = new FileInputStream(new File("src/it/resources/integration.properties")); - env.load(is); - Process process = null; - try { - ProcessBuilder processBuilder = buildCommand(); - process = processBuilder.start(); - // debug.debug("engine command=" + commandString); - String stdout = IOUtils.toString(process.getInputStream(), "UTF-8"); - String stderr = IOUtils.toString(process.getErrorStream(), "UTF-8"); - System.out.println("stdout=" + stdout); - System.out.println("stderr=" + stderr); - copyJacocoFiles(); - copyClassFiles(); - copyForSonar(); - } catch (Exception e) { - e.printStackTrace(); - } finally { - if (process.isAlive()) { - process.destroyForcibly(); - } - } - } - - private void copyForSonar() throws IOException { - String[] jacocoFiles = env.getProperty("copy.jacoco.for.sonar").split(","); - for (String jacocoFile : jacocoFiles) { - String[] parts = jacocoFile.split("\\|"); - if (parts.length == 2) { - File source = new File(parts[0]); - File dest = new File(parts[1]); - if (source.exists() && source.isFile() && dest.getParentFile().isDirectory()) { - Path srcFile = Paths.get(source.getAbsolutePath()); - Path dstFile = Paths.get(dest.getAbsolutePath()); - Files.copy(srcFile, dstFile, StandardCopyOption.REPLACE_EXISTING); - } else { - System.out.println("Skipping " + jacocoFile); - } - } else { - System.out.println("Skipping " + jacocoFile); - } - - } - } - - private void copyClassFiles() throws IOException { - File dest = new File(env.getProperty("jacoco.exec.classes")); - dest.mkdirs(); - if (dest.isDirectory()) { - - String[] sourceFolders = env.getProperty("source.classes.folders").split(","); - for (String source : sourceFolders) { - String[] parts = source.split("\\|"); - if (parts.length == 2) { - Path destPath = Paths.get(dest.getAbsolutePath(), parts[0]); - destPath.toFile().mkdirs(); - File sourceFolder = new File(parts[1]); - if (sourceFolder.exists() && sourceFolder.isDirectory()) { - Path srcPath = Paths.get(sourceFolder.getAbsolutePath()); - copyFolder(srcPath, destPath); - } - } - } - } - } - - private void copyJacocoFiles() throws IOException { - File dest = new File(env.getProperty("jacoco.exec.dest")); - dest.mkdirs(); - if (dest.isDirectory()) { - - String[] sourceFiles = env.getProperty("jacoco.exec.source.files").split(","); - for (String source : sourceFiles) { - File sourceFile = new File(source); - if (sourceFile.exists()) { - Path destPath = Paths.get(dest.getAbsolutePath(), sourceFile.getName()); - Path srcPath = Paths.get(sourceFile.getAbsolutePath()); - Files.copy(srcPath, destPath, StandardCopyOption.REPLACE_EXISTING); - } - } - } - } - - private static void copyFolder(Path src, Path dest) { - try { - Files.walk(src).forEach(s -> { - try { - Path dpath = dest.resolve(src.relativize(s)); - if (Files.isDirectory(s)) { - if (!Files.exists(dpath)) { - Files.createDirectory(dpath); - } - return; - } - Files.copy(s, dpath); - } catch (Exception e) { - e.printStackTrace(); - } - }); - } catch (Exception ex) { - ex.printStackTrace(); - } - } - - private ProcessBuilder buildCommand() { - List command = new ArrayList<>(); - String basepath = env.getProperty("base.path", "./"); - command.add("/bin/bash"); - command.add("-x"); - command.add(basepath + "ete_test.sh"); - File workdir = new File(env.getProperty("workdir", "./docker/integration")); - ProcessBuilder processBuilder = new ProcessBuilder(); - processBuilder.directory(workdir); - processBuilder.command(command); - return processBuilder; - } -} diff --git a/cmso-sonar/src/it/resources/integration.properties b/cmso-sonar/src/it/resources/integration.properties deleted file mode 100644 index 48957a0..0000000 --- a/cmso-sonar/src/it/resources/integration.properties +++ /dev/null @@ -1,7 +0,0 @@ -base.path=./ -jacoco.exec.dest=target/code-coverage -jacoco.exec.classes=target/classes -source.classes.folders=service|../cmso-service/target/classes,optimizer|../cmso-optimizer/target/classes -jacoco.exec.source.files=docker/integration/cmso-service/logs/service.jacoco.exec,docker/integration/cmso-optimizer/logs/optimizer.jacoco.exec - -copy.jacoco.for.sonar=docker/integration/cmso-service/logs/service.jacoco.exec|../cmso-service/target/jacoco-it.exec,docker/integration/cmso-optimizer/logs/optimizer.jacoco.exec|../cmso-optimizer/target/jacoco-it.exec \ No newline at end of file diff --git a/cmso-sonar/src/test/java/org/onap/optf/cmso/it/ItFullIntegrationTest.java b/cmso-sonar/src/test/java/org/onap/optf/cmso/it/ItFullIntegrationTest.java new file mode 100644 index 0000000..aa3779a --- /dev/null +++ b/cmso-sonar/src/test/java/org/onap/optf/cmso/it/ItFullIntegrationTest.java @@ -0,0 +1,152 @@ +/* + * ============LICENSE_START============================================== Copyright (c) 2019 AT&T + * Intellectual Property. ======================================================================= + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. ============LICENSE_END================================================= + */ + +package org.onap.optf.cmso.it; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; +import java.util.ArrayList; +import java.util.List; +import java.util.Properties; +import org.apache.commons.io.IOUtils; +import org.junit.Test; + +public class ItFullIntegrationTest { + + private Properties env = new Properties(); + + @Test + public void runTest() throws IOException { + InputStream is = new FileInputStream(new File("src/test/resources/integration.properties")); + env.load(is); + Process process = null; + try { + ProcessBuilder processBuilder = buildCommand(); + process = processBuilder.start(); + // debug.debug("engine command=" + commandString); + String stdout = IOUtils.toString(process.getInputStream(), "UTF-8"); + String stderr = IOUtils.toString(process.getErrorStream(), "UTF-8"); + System.out.println("stdout=" + stdout); + System.out.println("stderr=" + stderr); + copyJacocoFiles(); + copyClassFiles(); + copyForSonar(); + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (process.isAlive()) { + process.destroyForcibly(); + } + } + } + + private void copyForSonar() throws IOException { + String[] jacocoFiles = env.getProperty("copy.jacoco.for.sonar").split(","); + for (String jacocoFile : jacocoFiles) { + String[] parts = jacocoFile.split("\\|"); + if (parts.length == 2) { + File source = new File(parts[0]); + File dest = new File(parts[1]); + if (source.exists() && source.isFile() && dest.getParentFile().isDirectory()) { + Path srcFile = Paths.get(source.getAbsolutePath()); + Path dstFile = Paths.get(dest.getAbsolutePath()); + Files.copy(srcFile, dstFile, StandardCopyOption.REPLACE_EXISTING); + } else { + System.out.println("Skipping " + jacocoFile); + } + } else { + System.out.println("Skipping " + jacocoFile); + } + + } + } + + private void copyClassFiles() throws IOException { + File dest = new File(env.getProperty("jacoco.exec.classes")); + dest.mkdirs(); + if (dest.isDirectory()) { + + String[] sourceFolders = env.getProperty("source.classes.folders").split(","); + for (String source : sourceFolders) { + String[] parts = source.split("\\|"); + if (parts.length == 2) { + Path destPath = Paths.get(dest.getAbsolutePath(), parts[0]); + destPath.toFile().mkdirs(); + File sourceFolder = new File(parts[1]); + if (sourceFolder.exists() && sourceFolder.isDirectory()) { + Path srcPath = Paths.get(sourceFolder.getAbsolutePath()); + copyFolder(srcPath, destPath); + } + } + } + } + } + + private void copyJacocoFiles() throws IOException { + File dest = new File(env.getProperty("jacoco.exec.dest")); + dest.mkdirs(); + if (dest.isDirectory()) { + + String[] sourceFiles = env.getProperty("jacoco.exec.source.files").split(","); + for (String source : sourceFiles) { + File sourceFile = new File(source); + if (sourceFile.exists()) { + Path destPath = Paths.get(dest.getAbsolutePath(), sourceFile.getName()); + Path srcPath = Paths.get(sourceFile.getAbsolutePath()); + Files.copy(srcPath, destPath, StandardCopyOption.REPLACE_EXISTING); + } + } + } + } + + private static void copyFolder(Path src, Path dest) { + try { + Files.walk(src).forEach(s -> { + try { + Path dpath = dest.resolve(src.relativize(s)); + if (Files.isDirectory(s)) { + if (!Files.exists(dpath)) { + Files.createDirectory(dpath); + } + return; + } + Files.copy(s, dpath); + } catch (Exception e) { + e.printStackTrace(); + } + }); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + + private ProcessBuilder buildCommand() { + List command = new ArrayList<>(); + String basepath = env.getProperty("base.path", "./"); + command.add("/bin/bash"); + command.add("-x"); + command.add(basepath + "ete_test.sh"); + File workdir = new File(env.getProperty("workdir", "./docker/integration")); + ProcessBuilder processBuilder = new ProcessBuilder(); + processBuilder.directory(workdir); + processBuilder.command(command); + return processBuilder; + } +} diff --git a/cmso-sonar/src/test/resources/integration.properties b/cmso-sonar/src/test/resources/integration.properties new file mode 100644 index 0000000..48957a0 --- /dev/null +++ b/cmso-sonar/src/test/resources/integration.properties @@ -0,0 +1,7 @@ +base.path=./ +jacoco.exec.dest=target/code-coverage +jacoco.exec.classes=target/classes +source.classes.folders=service|../cmso-service/target/classes,optimizer|../cmso-optimizer/target/classes +jacoco.exec.source.files=docker/integration/cmso-service/logs/service.jacoco.exec,docker/integration/cmso-optimizer/logs/optimizer.jacoco.exec + +copy.jacoco.for.sonar=docker/integration/cmso-service/logs/service.jacoco.exec|../cmso-service/target/jacoco-it.exec,docker/integration/cmso-optimizer/logs/optimizer.jacoco.exec|../cmso-optimizer/target/jacoco-it.exec \ No newline at end of file -- cgit 1.2.3-korg