From cc60dfa90ccdb0212452b8f0b8be6420e379fec7 Mon Sep 17 00:00:00 2001
From: Jack
Date: Wed, 4 Jan 2017 15:57:01 +0800
Subject: [PATCH 0001/2502] fixed JENKINS-39469, now "do not archive report"
works properly.
---
.../automation/tools/results/RunResultRecorder.java | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/src/main/java/com/hp/application/automation/tools/results/RunResultRecorder.java b/src/main/java/com/hp/application/automation/tools/results/RunResultRecorder.java
index e9670927e9..44527c5f14 100644
--- a/src/main/java/com/hp/application/automation/tools/results/RunResultRecorder.java
+++ b/src/main/java/com/hp/application/automation/tools/results/RunResultRecorder.java
@@ -87,6 +87,7 @@
import java.util.Map;
import java.util.TreeMap;
+import static com.hp.application.automation.tools.model.ResultsPublisherModel.dontArchiveResults;
import static com.hp.application.automation.tools.results.projectparser.performance.XmlParserUtil.getNode;
import static com.hp.application.automation.tools.results.projectparser.performance.XmlParserUtil.getNodeAttr;
@@ -286,6 +287,10 @@ private void archiveTestsReport(
"Report archiving mode is set to: "
+ _resultsPublisherModel.getArchiveTestResultsMode());
+ // if user specified not to archive report
+ if (_resultsPublisherModel.getArchiveTestResultsMode().equals(dontArchiveResults.getValue()))
+ return;
+
FilePath projectWS = runWorkspace;
// get the artifacts directory where we will upload the zipped report
From a5885ef218bf208f5f54ca69e89977a4a7d02409 Mon Sep 17 00:00:00 2001
From: YafimK
Date: Mon, 6 Mar 2017 18:22:53 +0200
Subject: [PATCH 0002/2502] Update temporary development version to
5.2-beta-snapshot
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index 7f70605330..991c927cf3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -8,7 +8,7 @@
hp-application-automation-tools-plugin
- 5.1
+ 5.2-beta-SNAPSHOThpiHP Application Automation ToolsThe plugin integrates Jenkins with the following HPE products - Service Virtualization, LoadRunner, Performance Center, Unified Functional Testing, QuickTest Professional, Service Test, Mobile Center, Application Lifecycle Management and Application Lifecycle Management Octane.
From f320257037d72233f0e2a6d1c5027d040f4dccc9 Mon Sep 17 00:00:00 2001
From: The Codacy Badger
Date: Sat, 18 Mar 2017 19:07:05 +0000
Subject: [PATCH 0003/2502] Add Codacy badge
---
readme.md | 3 +++
1 file changed, 3 insertions(+)
diff --git a/readme.md b/readme.md
index c2ff0335c8..9f0edd9f71 100644
--- a/readme.md
+++ b/readme.md
@@ -1,6 +1,9 @@

# HPE automation plugin for Jenkins CI
+
+[](https://www.codacy.com/app/HPEbot/hp-application-automation-tools-plugin?utm_source=github.com&utm_medium=referral&utm_content=hpsa/hp-application-automation-tools-plugin&utm_campaign=badger)
+
##### The plugin provides the ability to run HPE products with Jenkins during builds.
## Relevent links
From 9e88a993b845381208d269ff85606f7d2a68d6e2 Mon Sep 17 00:00:00 2001
From: Radislav Berkovich
Date: Thu, 2 Mar 2017 13:38:16 +0200
Subject: [PATCH 0004/2502] fix string related to help of ui location
---
.../OctaneServerSettingsBuilder/global.properties | 2 +-
.../OctaneServerSettingsBuilder/help-uiLocation.html | 12 +++++++++++-
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/src/main/resources/com/hp/application/automation/tools/settings/OctaneServerSettingsBuilder/global.properties b/src/main/resources/com/hp/application/automation/tools/settings/OctaneServerSettingsBuilder/global.properties
index db84c07ff0..7fb02ae20e 100644
--- a/src/main/resources/com/hp/application/automation/tools/settings/OctaneServerSettingsBuilder/global.properties
+++ b/src/main/resources/com/hp/application/automation/tools/settings/OctaneServerSettingsBuilder/global.properties
@@ -15,6 +15,6 @@ global.config.test.connection.progress=Connecting the ALM Octane server...
global.config.impersonatedUser.title=Jenkins user
global.config.impersonatedUser.description=The user to impersonate (Jobs will be executed on behalf of this user)
-global.config.dynamic.instanceId.title=Show plugin instance id
+global.config.dynamic.instanceId.title=Show plugin instance ID
global.config.instanceId.title=Instance id
global.config.instanceId.description=An ID to uniquely identify this instance of the plugin.
\ No newline at end of file
diff --git a/src/main/resources/com/hp/application/automation/tools/settings/OctaneServerSettingsBuilder/help-uiLocation.html b/src/main/resources/com/hp/application/automation/tools/settings/OctaneServerSettingsBuilder/help-uiLocation.html
index bbb0799742..00d18be14b 100644
--- a/src/main/resources/com/hp/application/automation/tools/settings/OctaneServerSettingsBuilder/help-uiLocation.html
+++ b/src/main/resources/com/hp/application/automation/tools/settings/OctaneServerSettingsBuilder/help-uiLocation.html
@@ -1,3 +1,13 @@
-Login into the ALM Octane application and copy & paste the location from your browser.
+
+ The URL of the ALM Octane server, using its fully qualified domain name (FQDN).
+
+ Use the following format (port number is optional): http://ALM_Octane_Host_Name / IP_address {:port number}/ui/?p=sharedSpaceID
+
+
+ Example: http://myServer.myCompany.com:8081/ui/?p=1002
+
+
+ Tip: You can copy the URL from the address bar of the browser in which you opened ALM Octane.
+
From b31de2930242c4a4ff2a1adce50a2f307cc5c2b6 Mon Sep 17 00:00:00 2001
From: leviy
Date: Thu, 2 Mar 2017 13:45:57 +0200
Subject: [PATCH 0005/2502] user story #218040: fix ignored tests
---
pom.xml | 16 +++++++---------
.../client/JenkinsMqmRestClientFactoryImpl.java | 2 +-
.../tools/octane/events/EventsService.java | 13 +------------
.../settings/OctaneServerSettingsBuilder.java | 3 ---
.../octane/configuration/ConfigApiTest.java | 16 ----------------
.../configuration/ConfigurationServiceTest.java | 5 +----
.../tools/octane/events/EventsTest.java | 5 +++--
.../tools/octane/tests/TestDispatcherTest.java | 3 +--
8 files changed, 14 insertions(+), 49 deletions(-)
diff --git a/pom.xml b/pom.xml
index 991c927cf3..f7610fb86c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -261,15 +261,7 @@
2.19.1
- **/ConfigApiTest.java
- **/ConfigurationServiceTest.java
- **/JUnitResultsTest.java
- **/TestApiTest.java
- **/TestDispatcherTest.java
- **/BuildActionsFreeStyleTest.java
- **/GherkinResultsTest.java
- **/TestNGExtensionTest.java
-
+ **/TestJenkinsDurationTest.java
@@ -435,6 +427,12 @@
true
+
+ org.jenkins-ci.plugins
+ git-client
+ 1.19.6
+
+
org.jenkins-ci.plugins.pipeline-stage-viewpipeline-rest-api
diff --git a/src/main/java/com/hp/application/automation/tools/octane/client/JenkinsMqmRestClientFactoryImpl.java b/src/main/java/com/hp/application/automation/tools/octane/client/JenkinsMqmRestClientFactoryImpl.java
index b65c2d6f18..084425ec6b 100644
--- a/src/main/java/com/hp/application/automation/tools/octane/client/JenkinsMqmRestClientFactoryImpl.java
+++ b/src/main/java/com/hp/application/automation/tools/octane/client/JenkinsMqmRestClientFactoryImpl.java
@@ -38,7 +38,7 @@
public class JenkinsMqmRestClientFactoryImpl implements JenkinsMqmRestClientFactory {
private static final Logger logger = LogManager.getLogger(JenkinsMqmRestClientFactoryImpl.class);
private static final String CLIENT_TYPE = "HPE_CI_CLIENT";
- private static MqmRestClient mqmRestClient;
+ private MqmRestClient mqmRestClient;
@Override
public synchronized MqmRestClient obtain(String location, String sharedSpace, String username, Secret password) {
diff --git a/src/main/java/com/hp/application/automation/tools/octane/events/EventsService.java b/src/main/java/com/hp/application/automation/tools/octane/events/EventsService.java
index 36bf0e8d67..633609418c 100644
--- a/src/main/java/com/hp/application/automation/tools/octane/events/EventsService.java
+++ b/src/main/java/com/hp/application/automation/tools/octane/events/EventsService.java
@@ -42,22 +42,11 @@
public final class EventsService implements ConfigurationListener {
private static final Logger logger = LogManager.getLogger(EventsService.class);
- private static EventsService extensionInstance;
private JenkinsMqmRestClientFactory clientFactory;
private EventsClient eventsClient;
public static EventsService getExtensionInstance() {
- if (extensionInstance == null) {
- List extensions = Jenkins.getInstance().getExtensionList(EventsService.class);
- if (extensions.isEmpty()) {
- throw new RuntimeException("events service was not initialized properly");
- } else if (extensions.size() > 1) {
- throw new RuntimeException("events service expected to be singleton, found " + extensions.size() + " instances");
- } else {
- extensionInstance = extensions.get(0);
- }
- }
- return extensionInstance;
+ return Jenkins.getInstance().getExtensionList(EventsService.class).get(0);
}
public void updateClient(ServerConfiguration conf) {
diff --git a/src/main/java/com/hp/application/automation/tools/settings/OctaneServerSettingsBuilder.java b/src/main/java/com/hp/application/automation/tools/settings/OctaneServerSettingsBuilder.java
index babfb32f22..c7efd23728 100644
--- a/src/main/java/com/hp/application/automation/tools/settings/OctaneServerSettingsBuilder.java
+++ b/src/main/java/com/hp/application/automation/tools/settings/OctaneServerSettingsBuilder.java
@@ -46,9 +46,6 @@ public class OctaneServerSettingsBuilder extends Builder {
private static final Logger logger = LogManager.getLogger(OctaneServerSettingsBuilder.class);
- @Inject
- private static BdiConfigurationFetcher bdiConfigurationFetcher;
-
@Override
public OctaneDescriptorImpl getDescriptor() {
return (OctaneDescriptorImpl) super.getDescriptor();
diff --git a/src/test/java/com/hp/application/automation/tools/octane/configuration/ConfigApiTest.java b/src/test/java/com/hp/application/automation/tools/octane/configuration/ConfigApiTest.java
index fe8a4dd4a4..6d90810f98 100644
--- a/src/test/java/com/hp/application/automation/tools/octane/configuration/ConfigApiTest.java
+++ b/src/test/java/com/hp/application/automation/tools/octane/configuration/ConfigApiTest.java
@@ -121,22 +121,6 @@ public void testSave() throws Exception {
}
}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
private void checkConfig(JSONObject config, String location, String sharedSpace, String username, Secret password) {
// check values returned
Assert.assertEquals(location, config.getString("location"));
diff --git a/src/test/java/com/hp/application/automation/tools/octane/configuration/ConfigurationServiceTest.java b/src/test/java/com/hp/application/automation/tools/octane/configuration/ConfigurationServiceTest.java
index 9bdc9e3586..e985b78d3e 100644
--- a/src/test/java/com/hp/application/automation/tools/octane/configuration/ConfigurationServiceTest.java
+++ b/src/test/java/com/hp/application/automation/tools/octane/configuration/ConfigurationServiceTest.java
@@ -26,10 +26,7 @@
import com.hp.application.automation.tools.octane.client.JenkinsMqmRestClientFactory;
import hudson.util.FormValidation;
import hudson.util.Secret;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.ClassRule;
-import org.junit.Test;
+import org.junit.*;
import org.jvnet.hudson.test.JenkinsRule;
import org.mockito.Mockito;
@SuppressWarnings({"squid:S2699","squid:S3658","squid:S2259","squid:S1872","squid:S2925","squid:S109","squid:S1607","squid:S2701","squid:S2698"})
diff --git a/src/test/java/com/hp/application/automation/tools/octane/events/EventsTest.java b/src/test/java/com/hp/application/automation/tools/octane/events/EventsTest.java
index ea43cac981..def8090d6d 100644
--- a/src/test/java/com/hp/application/automation/tools/octane/events/EventsTest.java
+++ b/src/test/java/com/hp/application/automation/tools/octane/events/EventsTest.java
@@ -72,7 +72,9 @@ public class EventsTest {
static public void beforeClass() throws Exception {
String p = System.getProperty("testingServerPort");
try {
- if (p != null) testingServerPort = Integer.parseInt(p);
+ if (p != null) {
+ testingServerPort = Integer.parseInt(p);
+ }
} catch (NumberFormatException nfe) {
logger.info("EVENTS TEST: bad port number format, default port will be used: " + testingServerPort);
}
@@ -93,7 +95,6 @@ static public void afterClass() throws Exception {
}
@Test
- @Ignore
public void testEventsA() throws Exception {
configurePlugin();
diff --git a/src/test/java/com/hp/application/automation/tools/octane/tests/TestDispatcherTest.java b/src/test/java/com/hp/application/automation/tools/octane/tests/TestDispatcherTest.java
index 1c9f33b960..d4c0d38071 100644
--- a/src/test/java/com/hp/application/automation/tools/octane/tests/TestDispatcherTest.java
+++ b/src/test/java/com/hp/application/automation/tools/octane/tests/TestDispatcherTest.java
@@ -223,11 +223,10 @@ public void testDispatcherSuspended() throws Exception {
Assert.assertEquals(1, queue.size());
}
- @Ignore
@Test
public void testDispatchMatrixBuild() throws Exception {
MatrixProject matrixProject = rule.createProject(MatrixProject.class, "TestDispatcherMatrix");
- matrixProject.setAxes(new AxisList(new Axis("OS", "Linux", "Windows")));
+ matrixProject.setAxes(new AxisList(new Axis("osType", "Linux", "Windows")));
Maven.MavenInstallation mavenInstallation = ToolInstallations.configureMaven3();
From e49826d55789635b45d7c345fc32ebc335aa34e6 Mon Sep 17 00:00:00 2001
From: lazara
Date: Sun, 5 Mar 2017 10:40:52 +0200
Subject: [PATCH 0006/2502] defect #249087: Mini Reg Day 12.53.20.90 Commits
and tests doesn't appear in Pipeline created from Pipeline under Folder and
always in status run
---
.../tools/octane/events/RunListenerImpl.java | 31 ++++++-------------
.../tools/octane/events/SCMListenerImpl.java | 16 ++--------
.../tools/octane/tests/TestDispatcher.java | 9 +++---
.../octane/tests/build/BuildHandlerUtils.java | 18 +++++++++--
4 files changed, 34 insertions(+), 40 deletions(-)
diff --git a/src/main/java/com/hp/application/automation/tools/octane/events/RunListenerImpl.java b/src/main/java/com/hp/application/automation/tools/octane/events/RunListenerImpl.java
index f9b64be5e9..e49f2fe5ae 100644
--- a/src/main/java/com/hp/application/automation/tools/octane/events/RunListenerImpl.java
+++ b/src/main/java/com/hp/application/automation/tools/octane/events/RunListenerImpl.java
@@ -17,6 +17,7 @@
package com.hp.application.automation.tools.octane.events;
import com.google.inject.Inject;
+import com.hp.application.automation.tools.octane.tests.build.BuildHandlerUtils;
import com.hp.octane.integrations.dto.DTOFactory;
import com.hp.octane.integrations.dto.events.CIEvent;
import com.hp.octane.integrations.dto.events.CIEventType;
@@ -35,8 +36,6 @@
import hudson.model.*;
import hudson.model.listeners.RunListener;
import jenkins.model.Jenkins;
-import org.jenkinsci.plugins.workflow.job.WorkflowJob;
-import org.jenkinsci.plugins.workflow.job.WorkflowRun;
import javax.annotation.Nonnull;
import java.util.Collection;
@@ -68,7 +67,7 @@ public void onStarted(final Run r, TaskListener listener) {
if (r.getClass().getName().equals("org.jenkinsci.plugins.workflow.job.WorkflowRun")) {
event = dtoFactory.newDTO(CIEvent.class)
.setEventType(CIEventType.STARTED)
- .setProject(JobProcessorFactory.getFlowProcessor(r.getParent()).getJobCiId())
+ .setProject(BuildHandlerUtils.getJobCiId(r))
.setBuildCiId(String.valueOf(r.getNumber()))
.setNumber(String.valueOf(r.getNumber()))
.setStartTime(r.getStartTimeInMillis())
@@ -83,8 +82,8 @@ public void onStarted(final Run r, TaskListener listener) {
AbstractBuild build = (AbstractBuild) r;
event = dtoFactory.newDTO(CIEvent.class)
.setEventType(CIEventType.STARTED)
- .setProject(getJobCiId(r))
- .setProjectDisplayName(getJobCiId(r))
+ .setProject(BuildHandlerUtils.getJobCiId(r))
+ .setProjectDisplayName(BuildHandlerUtils.getJobCiId(r))
.setBuildCiId(String.valueOf(build.getNumber()))
.setNumber(String.valueOf(build.getNumber()))
.setStartTime(build.getStartTimeInMillis())
@@ -101,8 +100,8 @@ public void onStarted(final Run r, TaskListener listener) {
AbstractBuild build = (AbstractBuild) r;
event = dtoFactory.newDTO(CIEvent.class)
.setEventType(CIEventType.STARTED)
- .setProject(getJobCiId(r))
- .setProjectDisplayName(getJobCiId(r))
+ .setProject(BuildHandlerUtils.getJobCiId(r))
+ .setProjectDisplayName(BuildHandlerUtils.getJobCiId(r))
.setBuildCiId(String.valueOf(build.getNumber()))
.setNumber(String.valueOf(build.getNumber()))
.setStartTime(build.getStartTimeInMillis())
@@ -135,18 +134,18 @@ public void onCompleted(Run r, @Nonnull TaskListener listener) {
}
CIEvent event = dtoFactory.newDTO(CIEvent.class)
.setEventType(CIEventType.FINISHED)
- .setProject(getJobCiId(r))
- .setProjectDisplayName(getJobCiId(r))
.setBuildCiId(String.valueOf(r.getNumber()))
.setNumber(String.valueOf(r.getNumber()))
+ .setProject(BuildHandlerUtils.getJobCiId(r))
.setStartTime(r.getStartTimeInMillis())
.setEstimatedDuration(r.getEstimatedDuration())
.setCauses(CIEventCausesFactory.processCauses(extractCauses(r)))
.setResult(result)
.setDuration(r.getDuration());
- if (r instanceof AbstractBuild) {
- event.setParameters(ParameterProcessors.getInstances(r));
+ if(r instanceof AbstractBuild){
+ event.setParameters(ParameterProcessors.getInstances(r))
+ .setProjectDisplayName(BuildHandlerUtils.getJobCiId(r));
}
if(event!=null){
EventsService.getExtensionInstance().dispatchEvent(event);
@@ -212,16 +211,6 @@ private static TopLevelItem getJobFromFolder(String causeJobName) {
return null;
}
- private static String getJobCiId(Run r) {
- if (r.getParent() instanceof MatrixConfiguration) {
- return JobProcessorFactory.getFlowProcessor(((MatrixRun) r).getParentBuild().getParent()).getJobCiId();
- }
- if (r.getParent().getClass().getName().equals("org.jenkinsci.plugins.workflow.job.WorkflowJob")) {
- return r.getParent().getName();
- }
- return JobProcessorFactory.getFlowProcessor(((AbstractBuild) r).getProject()).getJobCiId();
- }
-
private static List extractCauses(Run r) {
if (r.getParent() instanceof MatrixConfiguration) {
return ((MatrixRun) r).getParentBuild().getCauses();
diff --git a/src/main/java/com/hp/application/automation/tools/octane/events/SCMListenerImpl.java b/src/main/java/com/hp/application/automation/tools/octane/events/SCMListenerImpl.java
index c7015927b6..84d7e2dc2c 100644
--- a/src/main/java/com/hp/application/automation/tools/octane/events/SCMListenerImpl.java
+++ b/src/main/java/com/hp/application/automation/tools/octane/events/SCMListenerImpl.java
@@ -17,6 +17,7 @@
package com.hp.application.automation.tools.octane.events;
import com.hp.application.automation.tools.octane.model.processors.scm.SCMProcessor;
+import com.hp.application.automation.tools.octane.tests.build.BuildHandlerUtils;
import com.hp.octane.integrations.dto.DTOFactory;
import com.hp.octane.integrations.dto.events.CIEvent;
import com.hp.octane.integrations.dto.events.CIEventType;
@@ -84,7 +85,7 @@ else if (r.getParent() instanceof WorkflowJob) {
for (SCMData scmData : scmDataList) {
event = dtoFactory.newDTO(CIEvent.class)
.setEventType(CIEventType.SCM)
- .setProject(getProjectName(r))
+ .setProject(BuildHandlerUtils.getJobCiId(r))
.setBuildCiId(String.valueOf(r.getNumber()))
.setCauses(CIEventCausesFactory.processCauses(extractCauses(r)))
.setNumber(String.valueOf(r.getNumber()))
@@ -103,7 +104,7 @@ private void createSCMData(Run, ?> r, AbstractBuild build, SCMProcessor scmPro
SCMData scmData = scmProcessor.getSCMData(build);
event = dtoFactory.newDTO(CIEvent.class)
.setEventType(CIEventType.SCM)
- .setProject(getProjectName(r))
+ .setProject(BuildHandlerUtils.getJobCiId(r))
.setBuildCiId(String.valueOf(r.getNumber()))
.setCauses(CIEventCausesFactory.processCauses(extractCauses(r)))
.setNumber(String.valueOf(r.getNumber()))
@@ -111,17 +112,6 @@ private void createSCMData(Run, ?> r, AbstractBuild build, SCMProcessor scmPro
EventsService.getExtensionInstance().dispatchEvent(event);
}
- private String getProjectName(Run r) {
- if (r.getParent() instanceof MatrixConfiguration) {
- return ((MatrixRun) r).getParentBuild().getParent().getName();
- }
- if ("org.jenkinsci.plugins.workflow.job.WorkflowJob".equals(r.getParent().getClass().getName())) {
- return r.getParent().getName();
- }
- return ((AbstractBuild) r).getProject().getName();
- }
-
-
private List extractCauses(Run r) {
if (r.getParent() instanceof MatrixConfiguration) {
return ((MatrixRun) r).getParentBuild().getCauses();
diff --git a/src/main/java/com/hp/application/automation/tools/octane/tests/TestDispatcher.java b/src/main/java/com/hp/application/automation/tools/octane/tests/TestDispatcher.java
index e68146a141..7691c276ec 100644
--- a/src/main/java/com/hp/application/automation/tools/octane/tests/TestDispatcher.java
+++ b/src/main/java/com/hp/application/automation/tools/octane/tests/TestDispatcher.java
@@ -17,6 +17,7 @@
package com.hp.application.automation.tools.octane.tests;
import com.google.inject.Inject;
+import com.hp.application.automation.tools.octane.tests.build.BuildHandlerUtils;
import com.hp.mqm.client.MqmRestClient;
import com.hp.mqm.client.exception.SharedSpaceNotExistException;
import com.hp.mqm.client.exception.FileNotFoundException;
@@ -130,14 +131,14 @@ protected void doExecute(TaskListener listener) throws IOException, InterruptedE
continue;
}
- String jobName;
+ String jobCiId;
if (build instanceof MatrixRun) {
- jobName = ((MatrixRun) build).getProject().getParent().getName();
+ jobCiId = ((MatrixRun) build).getProject().getParent().getName();
} else {
- jobName = build.getParent().getName();
+ jobCiId = BuildHandlerUtils.getJobCiId(build);//build.getParent().getName();
}
- Boolean needTestResult = client.isTestResultRelevant(ConfigurationService.getModel().getIdentity(), jobName);
+ Boolean needTestResult = client.isTestResultRelevant(ConfigurationService.getModel().getIdentity(), jobCiId);
if (needTestResult) {
try {
diff --git a/src/main/java/com/hp/application/automation/tools/octane/tests/build/BuildHandlerUtils.java b/src/main/java/com/hp/application/automation/tools/octane/tests/build/BuildHandlerUtils.java
index a2a065058a..9c26b06588 100644
--- a/src/main/java/com/hp/application/automation/tools/octane/tests/build/BuildHandlerUtils.java
+++ b/src/main/java/com/hp/application/automation/tools/octane/tests/build/BuildHandlerUtils.java
@@ -2,9 +2,12 @@
package com.hp.application.automation.tools.octane.tests.build;
+import com.hp.application.automation.tools.octane.model.processors.projects.JobProcessorFactory;
import com.hp.application.automation.tools.octane.workflow.WorkflowBuildAdapter;
import com.hp.application.automation.tools.octane.workflow.WorkflowGraphListener;
import hudson.FilePath;
+import hudson.matrix.MatrixConfiguration;
+import hudson.matrix.MatrixRun;
import hudson.model.AbstractBuild;
import hudson.model.Run;
import org.jenkinsci.plugins.workflow.job.WorkflowRun;
@@ -21,7 +24,7 @@ public static BuildDescriptor getBuildType(Run, ?> build) {
}
}
return new BuildDescriptor(
- build.getParent().getName(),
+ BuildHandlerUtils.getJobCiId(build),
build.getParent().getName(),
String.valueOf(build.getNumber()),
String.valueOf(build.getNumber()),
@@ -34,7 +37,7 @@ public static String getProjectFullName(Run, ?> build) {
return ext.getProjectFullName(build);
}
}
- return build.getParent().getName();//builgetProject().getName();
+ return build.getParent().getFullName();
}
public static FilePath getWorkspace(Run,?> build){
@@ -75,4 +78,15 @@ public static List getBuildPerWorkspaces(Run build) {
return runsList;
}
}
+
+ public static String getJobCiId(Run r) {
+ if (r.getParent() instanceof MatrixConfiguration) {
+ return JobProcessorFactory.getFlowProcessor(((MatrixRun) r).getParentBuild().getParent()).getJobCiId();
+ }
+ if (r.getParent().getClass().getName().equals("org.jenkinsci.plugins.workflow.job.WorkflowJob")) {
+ return JobProcessorFactory.getFlowProcessor(r.getParent()).getJobCiId();
+ }
+ return JobProcessorFactory.getFlowProcessor(((AbstractBuild) r).getProject()).getJobCiId();
+ }
+
}
From f5a2c97064da39217eb3c4c1429bd7e7799f3896 Mon Sep 17 00:00:00 2001
From: lazara
Date: Sun, 5 Mar 2017 18:45:38 +0200
Subject: [PATCH 0007/2502] support matrix job inside folder, defect #249087:
Mini Reg Day 12.53.20.90 Commits and tests doesn't appear in Pipeline created
from Pipeline under Folder and always in status run
---
.../tools/octane/tests/TestDispatcher.java | 13 ++-----------
.../octane/tests/build/BuildHandlerExtension.java | 2 +-
.../octane/tests/build/MatrixBuildExtension.java | 6 +++---
3 files changed, 6 insertions(+), 15 deletions(-)
diff --git a/src/main/java/com/hp/application/automation/tools/octane/tests/TestDispatcher.java b/src/main/java/com/hp/application/automation/tools/octane/tests/TestDispatcher.java
index 7691c276ec..4bd32cf10b 100644
--- a/src/main/java/com/hp/application/automation/tools/octane/tests/TestDispatcher.java
+++ b/src/main/java/com/hp/application/automation/tools/octane/tests/TestDispatcher.java
@@ -34,7 +34,6 @@
import com.hp.application.automation.tools.octane.configuration.ServerConfiguration;
import hudson.Extension;
import hudson.FilePath;
-import hudson.matrix.MatrixRun;
import hudson.model.*;
import hudson.util.TimeUnit2;
import jenkins.YesNoMaybe;
@@ -117,28 +116,20 @@ protected void doExecute(TaskListener listener) throws IOException, InterruptedE
retryModel.success();
}
Job project = (Job) Jenkins.getInstance().getItemByFullName(item.getProjectName());
- // AbstractProject project1 = (AbstractProject) Jenkins.getInstance().getItemByFullName(item.getProjectName());
if (project == null) {
logger.warn("Project [" + item.getProjectName() + "] no longer exists, pending test results can't be submitted");
queue.remove();
continue;
}
Run build = project.getBuildByNumber(item.getBuildNumber());
- //AbstractBuild build = project.getBuildByNumber(item.getBuildNumber());
if (build == null) {
logger.warn("Build [" + item.getProjectName() + "#" + item.getBuildNumber() + "] no longer exists, pending test results can't be submitted");
queue.remove();
continue;
}
- String jobCiId;
- if (build instanceof MatrixRun) {
- jobCiId = ((MatrixRun) build).getProject().getParent().getName();
- } else {
- jobCiId = BuildHandlerUtils.getJobCiId(build);//build.getParent().getName();
- }
-
- Boolean needTestResult = client.isTestResultRelevant(ConfigurationService.getModel().getIdentity(), jobCiId);
+ Boolean needTestResult = client.isTestResultRelevant(
+ ConfigurationService.getModel().getIdentity(), BuildHandlerUtils.getJobCiId(build));
if (needTestResult) {
try {
diff --git a/src/main/java/com/hp/application/automation/tools/octane/tests/build/BuildHandlerExtension.java b/src/main/java/com/hp/application/automation/tools/octane/tests/build/BuildHandlerExtension.java
index 1bd60b2d41..69234a3488 100644
--- a/src/main/java/com/hp/application/automation/tools/octane/tests/build/BuildHandlerExtension.java
+++ b/src/main/java/com/hp/application/automation/tools/octane/tests/build/BuildHandlerExtension.java
@@ -7,7 +7,7 @@
import hudson.model.Hudson;
import hudson.model.Run;
-public abstract class BuildHandlerExtension implements ExtensionPoint {
+abstract class BuildHandlerExtension implements ExtensionPoint {
public abstract boolean supports(Run, ?> build);
diff --git a/src/main/java/com/hp/application/automation/tools/octane/tests/build/MatrixBuildExtension.java b/src/main/java/com/hp/application/automation/tools/octane/tests/build/MatrixBuildExtension.java
index 2b56568cd4..bb5d837bf3 100644
--- a/src/main/java/com/hp/application/automation/tools/octane/tests/build/MatrixBuildExtension.java
+++ b/src/main/java/com/hp/application/automation/tools/octane/tests/build/MatrixBuildExtension.java
@@ -20,6 +20,7 @@
import com.hp.application.automation.tools.octane.model.ModelFactory;
import com.hp.application.automation.tools.octane.model.processors.parameters.ParameterProcessors;
import hudson.Extension;
+import hudson.matrix.MatrixRun;
import hudson.model.AbstractBuild;
import hudson.model.Run;
@@ -39,7 +40,7 @@ public BuildDescriptor getBuildType(Run, ?> build) {
List parameters = ParameterProcessors.getInstances(build);
String subBuildName = ModelFactory.generateSubBuildName(parameters);
return new BuildDescriptor(
- matrixRun.getRootBuild().getProject().getName(),
+ BuildHandlerUtils.getJobCiId(build),
matrixRun.getRootBuild().getProject().getName(),
String.valueOf(build.getNumber()),
String.valueOf(build.getNumber()),
@@ -48,7 +49,6 @@ public BuildDescriptor getBuildType(Run, ?> build) {
@Override
public String getProjectFullName(Run, ?> build) {
- AbstractBuild matrixRun = (AbstractBuild) build;
- return matrixRun.getRootBuild().getProject().getName() + "/" + matrixRun.getProject().getName();
+ return ((MatrixRun)build).getProject().getFullName();
}
}
From 31111f17dd04484fb85b768d3d095a287ce3133d Mon Sep 17 00:00:00 2001
From: Michael Seldin
Date: Thu, 9 Mar 2017 14:21:17 +0200
Subject: [PATCH 0008/2502] added ${maven.exec.skip} to jekins-cli
exec
---
pom.xml | 1 +
1 file changed, 1 insertion(+)
diff --git a/pom.xml b/pom.xml
index f7610fb86c..e4b2a931ab 100644
--- a/pom.xml
+++ b/pom.xml
@@ -225,6 +225,7 @@
-restart--password-file ${id_rsa_file}
+ ${maven.exec.skip}
From 3ab19f072283c5d810f1d1afcd801abbf82568c8 Mon Sep 17 00:00:00 2001
From: radislavB
Date: Thu, 16 Mar 2017 15:02:14 +0200
Subject: [PATCH 0009/2502] fixing uft test detection (#18)
* fixing uft test detection
---
.../octane/actions/UFTParameterFactory.java | 152 ++++++--
.../actions/UFTTestDetectionBuildAction.java | 331 ++++++++++++++----
.../actions/UFTTestDetectionPublisher.java | 11 +-
.../octane/actions/dto/AutomatedTest.java | 28 +-
.../octane/actions/dto/AutomatedTests.java | 15 +-
.../octane/actions/dto/TestFramework.java | 42 +--
.../octane/actions/dto/TestingToolType.java | 37 +-
7 files changed, 454 insertions(+), 162 deletions(-)
diff --git a/src/main/java/com/hp/application/automation/tools/octane/actions/UFTParameterFactory.java b/src/main/java/com/hp/application/automation/tools/octane/actions/UFTParameterFactory.java
index 01273e7c69..598052923b 100644
--- a/src/main/java/com/hp/application/automation/tools/octane/actions/UFTParameterFactory.java
+++ b/src/main/java/com/hp/application/automation/tools/octane/actions/UFTParameterFactory.java
@@ -17,34 +17,36 @@
package com.hp.application.automation.tools.octane.actions;
import com.fasterxml.jackson.databind.ObjectMapper;
-
import org.apache.poi.poifs.filesystem.*;
import org.apache.poi.util.StringUtil;
import org.jdom2.Document;
import org.jdom2.Element;
-import org.jdom2.JDOMFactory;
import org.jdom2.input.SAXBuilder;
-import org.jdom2.input.sax.SAXHandlerFactory;
import org.jdom2.input.sax.XMLReaders;
-import java.io.*;
-import java.util.ArrayList;
-import java.util.List;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringReader;
+import java.util.*;
/**
* This class Converts UFT's Paramters info stored in Resource.mtr file into JSON string
*/
public class UFTParameterFactory {
- private static POIFSFileSystem poiFS;
- private static String xmlData = "";
+
+
private static final java.util.logging.Logger logger = java.util.logging.Logger.getLogger(UFTParameterFactory.class.getName());
- public static String convertResourceMtrAsJSON(InputStream resourceMtrInputStream) throws IOException {
+ public static String convertResourceMtrAsJSON(InputStream resourceMtrInputStream) throws IOException {
+
+ //String QTPFileParameterFileName = "resource.mtr";
+ //InputStream is = paths.get(0).getParent().child("Action0").child(QTPFileParameterFileName).read();
- //TODO: Check is exists
- poiFS = new POIFSFileSystem(resourceMtrInputStream);
+ POIFSFileSystem poiFS = new POIFSFileSystem(resourceMtrInputStream);
DirectoryNode root = poiFS.getRoot();
+ String xmlData = "";
for (Entry entry : root) {
String name = entry.getName();
@@ -56,24 +58,22 @@ public static String convertResourceMtrAsJSON(InputStream resourceMtrInputStrea
poiFS.createDocumentInputStream("ComponentInfo").read(content);
String fromUnicodeLE = StringUtil.getFromUnicodeLE(content);
xmlData = fromUnicodeLE.substring(fromUnicodeLE.indexOf('<')).replaceAll("\u0000", "");
-// System.out.println(xmlData);
}
}
}
+
try {
- SAXBuilder saxBuilder = new SAXBuilder(XMLReaders.NONVALIDATING, (SAXHandlerFactory) null, (JDOMFactory) null);
- Document document = null;
- document = saxBuilder.build(new StringReader(xmlData));
- Element classElement = document.getRootElement();
- List studentList = classElement.getChildren();
- ObjectMapper mapper = new ObjectMapper();
- ArrayList uftParameters = new ArrayList();
- UFTParameter uftParameter = new UFTParameter();
- for (int temp = 0; temp < studentList.size(); temp++) {
- Element tag = studentList.get(temp);
+ SAXBuilder saxBuilder = new SAXBuilder(XMLReaders.NONVALIDATING, null, null);
+ Document document = saxBuilder.build(new StringReader(xmlData));
+ Element rootElement = document.getRootElement();
+ List rootChildrenElements = rootElement.getChildren();
+ ArrayList uftParameters = new ArrayList<>();
+ for (int temp = 0; temp < rootChildrenElements.size(); temp++) {
+ Element tag = rootChildrenElements.get(temp);
if ("ArgumentsCollection".equalsIgnoreCase(tag.getName())) {
List children = tag.getChildren();
for (int i = 0; i < children.size(); i++) {
+ UFTParameter uftParameter = new UFTParameter();
Element element = children.get(i);
List elements = element.getChildren();
@@ -97,13 +97,15 @@ public static String convertResourceMtrAsJSON(InputStream resourceMtrInputStrea
uftParameter.setArgIsExternal(Integer.parseInt(element1.getValue()));
break;
default:
- logger.warning(String.format("Element name %s didn't match any case",element1.getName()));
+ logger.warning(String.format("Element name %s didn't match any case", element1.getName()));
break;
}
}
uftParameters.add(uftParameter);
}
- return mapper.writerWithDefaultPrettyPrinter().writeValueAsString(uftParameters);
+ ObjectMapper mapper = new ObjectMapper();
+ String result = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(uftParameters);
+ return result;
}
}
} catch (Exception e) {
@@ -112,7 +114,109 @@ public static String convertResourceMtrAsJSON(InputStream resourceMtrInputStrea
return null;
}
+ public static String convertApiTestXmlsAsJSON(File inputParameters, File outputParameters) throws IOException {
+ //String testInputParametersFileName = "TestInputParameters.xml";
+ //String testOutputParametersFileName = "TestOutputParameters.xml";
+ //URI inputParamsUri = paths.get(0).getParent().child(testInputParametersFileName).toURI();
+ //URI outputParamsUri = paths.get(0).getParent().child(testOutputParametersFileName).toURI();
+
+ //File inputParamsFile = new File(inputParamsUri);
+ //File outputParamsFile = new File(outputParamsUri);
+
+
+ List params = new ArrayList<>();
+ params.addAll(convertApiTestXmlToArguments(inputParameters, true));
+ params.addAll(convertApiTestXmlToArguments(outputParameters, false));
+ ObjectMapper mapper = new ObjectMapper();
+ String result = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(params);
+ return result;
+ }
+
+ public static Collection convertApiTestXmlToArguments(File parametersFile, boolean isInputParameters) throws IOException {
+
+ /*
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+ f
+
+
+ */
+
+ try {
+ SAXBuilder saxBuilder = new SAXBuilder(XMLReaders.NONVALIDATING, null, null);
+ Document document = saxBuilder.build(parametersFile);
+ Element rootElement = document.getRootElement();
+
+ Map uftParametersMap = new HashMap<>();
+ List argElements = getHierarchyChildElement(rootElement, "Schema", "schema", "element", "complexType", "sequence").getChildren();
+ for (Element argElement : argElements) {
+ String name = argElement.getAttributeValue("name");
+ String type = argElement.getAttributeValue("type").replace("xs:", "");
+ int direction = isInputParameters ? 0 : 1;
+
+ UFTParameter parameter = new UFTParameter();
+ parameter.setArgName(name);
+ parameter.setArgType(type);
+ parameter.setArgDirection(direction);
+ uftParametersMap.put(parameter.getArgName(), parameter);
+ }
+
+ //getArg default values
+ List argDefValuesElements = getHierarchyChildElement(rootElement, "Values", "Arguments").getChildren();
+ for (Element argElement : argDefValuesElements) {
+ UFTParameter parameter = uftParametersMap.get(argElement.getName());
+ if (parameter != null) {
+ parameter.setArgDefaultValue(argElement.getValue());
+ }
+ }
+
+ return uftParametersMap.values();
+ } catch (Exception e) {
+ logger.severe(e.getMessage());
+ }
+ return Collections.emptySet();
+ }
+
+ private static Element getHierarchyChildElement(Element root, String... childPath) {
+ Element parent;
+ Element found = root;
+ for (int i = 0; i < childPath.length; i++) {
+ parent = found;
+ found = null;
+ String elementName = childPath[i];
+
+ for (Element child : parent.getChildren()) {
+ if (child.getName().equals(elementName)) {
+ found = child;
+ break;
+ }
+ }
+ }
+ return found;
+ }
}
diff --git a/src/main/java/com/hp/application/automation/tools/octane/actions/UFTTestDetectionBuildAction.java b/src/main/java/com/hp/application/automation/tools/octane/actions/UFTTestDetectionBuildAction.java
index 6c7785de5a..9a577b70b4 100644
--- a/src/main/java/com/hp/application/automation/tools/octane/actions/UFTTestDetectionBuildAction.java
+++ b/src/main/java/com/hp/application/automation/tools/octane/actions/UFTTestDetectionBuildAction.java
@@ -16,78 +16,210 @@
package com.hp.application.automation.tools.octane.actions;
-import com.hp.application.automation.tools.octane.actions.dto.AutomatedTests;
-import com.hp.mqm.client.MqmRestClient;
import com.hp.application.automation.tools.octane.actions.dto.AutomatedTest;
+import com.hp.application.automation.tools.octane.actions.dto.AutomatedTests;
+import com.hp.application.automation.tools.octane.actions.dto.TestFramework;
+import com.hp.application.automation.tools.octane.actions.dto.TestingToolType;
import com.hp.application.automation.tools.octane.client.JenkinsMqmRestClientFactory;
import com.hp.application.automation.tools.octane.configuration.ConfigurationService;
import com.hp.application.automation.tools.octane.configuration.ServerConfiguration;
+import com.hp.mqm.client.MqmRestClient;
+import com.hp.mqm.client.exception.RequestErrorException;
+import com.hp.mqm.client.model.ListItem;
+import com.hp.mqm.client.model.PagedList;
+import com.hp.mqm.client.model.Test;
import hudson.ExtensionList;
import hudson.FilePath;
import hudson.model.AbstractBuild;
import hudson.model.Action;
+import hudson.model.BuildListener;
+import hudson.plugins.git.GitChangeSet;
+import hudson.scm.ChangeLogSet;
+import hudson.scm.EditType;
import jenkins.model.Jenkins;
import net.sf.json.JSONObject;
+import org.apache.commons.lang.StringUtils;
+import javax.ws.rs.core.Response;
+import java.io.File;
import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Set;
+import java.io.UnsupportedEncodingException;
+import java.util.*;
public class UFTTestDetectionBuildAction implements Action {
- private String message;
private AbstractBuild, ?> build;
+ private String workspaceId;
+ private BuildListener buildListener;
private static final java.util.logging.Logger logger = java.util.logging.Logger.getLogger(UFTTestDetectionBuildAction.class.getName());
+
+ private final String INITIAL_DETECTION_FILE = "INITIAL_DETECTION_FILE.txt";
+ private final String STFileExtention = ".st";//api test
+ private final String QTPFileExtention = ".tsp";//gui test
+
@Override
public String getIconFileName() {
- return "/plugin/testExample/img/build-goals.png";
+ return "notepad.png";
}
@Override
public String getDisplayName() {
- return "Test Example Build Page";
+ return "HP Octane UFT Tests Scanner Report";
}
@Override
public String getUrlName() {
- return "testExampleBA";
+ return "uft_report";
}
- public String getMessage() {
- return this.message;
+
+ public UFTTestDetectionBuildAction(final AbstractBuild, ?> build, String workspaceId, BuildListener buildListener) {
+ this.build = build;
+ this.workspaceId = workspaceId;
+ this.buildListener = buildListener;
}
- public int getBuildNumber() {
- return this.build.number;
+ public void startScanning() {
+ ServerConfiguration serverConfiguration = ConfigurationService.getServerConfiguration();
+ MqmRestClient client = createClient(serverConfiguration);
+ String serverURL = getServerURL(workspaceId, serverConfiguration.sharedSpace, serverConfiguration.location);
+
+ ChangeLogSet extends ChangeLogSet.Entry> changeSet = build.getChangeSet();
+ Object[] changeSetItems = changeSet.getItems();
+
+
+ try {
+ if (!isInitialDetectionDone()) {
+ printToConsole("Executing initial detection");
+ Collection foundTests = doInitialDetection(client, serverURL);
+ printToConsole(String.format("Found %s tests", foundTests.size()));
+ } else {
+ printToConsole("Executing ChangeSetDetection");
+ doChangeSetDetection(client, serverURL, changeSetItems);
+ }
+ } catch (InterruptedException | IOException e) {
+ e.printStackTrace();
+ }
}
- public AbstractBuild, ?> getBuild() {
- return build;
+ private void printToConsole(String msg) {
+ buildListener.getLogger().println("UFTTestDetectionBuildAction : " + msg);
+ logger.info(msg);
}
- private void findUFTTestsPath(List root, HashMap testData) throws IOException, InterruptedException {
- for (FilePath path : root) {
- if (path.isDirectory()) {
- findUFTTestsPath(path.list(), testData);
- } else {
- if (path.getName().contains(".tsp")) {
- String convertResourceMtrAsJSON = UFTParameterFactory.convertResourceMtrAsJSON(path.getParent().child("Action0").child("Resource.mtr").read());
- testData.put(path.getParent().getName(), convertResourceMtrAsJSON);
+ private void doChangeSetDetection(MqmRestClient client, String serverURL, Object[] changeSetItems) throws IOException, InterruptedException {
+ if (changeSetItems.length == 0) {
+ return;
+ }
+
+ boolean isGitChanges = changeSetItems[0] instanceof GitChangeSet;
+ if (!isGitChanges) {
+ printToConsole(String.format("Expected GitChangeSet but found %s, detection is canceled.", changeSetItems[0].getClass().getName()));
+ return;
+ }
+
+ List addedTests = new ArrayList<>();
+ List removedTests = new ArrayList<>();
+
+ for (int i = 0; i < changeSetItems.length; i++) {
+ GitChangeSet changeSet = (GitChangeSet) changeSetItems[i];
+ for (GitChangeSet.Path path : changeSet.getPaths()) {
+ if (EditType.ADD.equals(path.getEditType())) {
+ if (isTestMainFilePath(path.getPath())) {
+ String filePath = build.getWorkspace() + File.separator + path.getPath();
+ if (isFileExist(filePath)) {
+ FilePath testFolder = getTestFolderForTestMainFile(filePath);
+ scanFileSystemRecursively(build.getWorkspace(), testFolder, addedTests);
+ }
+
+ }
+ } else if (EditType.DELETE.equals(path.getEditType())) {
+ if (isTestMainFilePath(path.getPath())) {
+ String filePath = build.getWorkspace() + File.separator + path.getPath();
+ if (!isFileExist(filePath)) {
+ FilePath testFolder = getTestFolderForTestMainFile(filePath);
+ AutomatedTest test = createAutomatedTest(build.getWorkspace(), testFolder);
+ removedTests.add(test);
+ }
+ }
+
}
}
}
+
+ postTests(client, serverURL, addedTests);
+ deleteTests(client, removedTests);
+
}
- private static T getExtension(Class clazz) {
- ExtensionList items = Jenkins.getInstance().getExtensionList(clazz);
- return items.get(0);
+ private AutomatedTest createAutomatedTest(FilePath root, FilePath dirPath) throws IOException, InterruptedException {
+ AutomatedTest test = new AutomatedTest();
+ test.setName(dirPath.getName());
+
+ //set component - relative path from root
+ String testPath = dirPath.toURI().toString();
+ String rootPath = root.toURI().toString();
+ String path = testPath.replace(rootPath, "");
+ path = StringUtils.strip(path, "\\/");
+ String component = path.length() != dirPath.getName().length() ? path.substring(0, path.length() - dirPath.getName().length() - 1) : "";
+ test.setComponent(component);
+ return test;
+ }
+
+
+ private boolean isFileExist(String path) {
+ File file = new File(path);
+ return file.exists();
+ }
+
+ private boolean isInitialDetectionDone() {
+ try {
+ File rootFile = new File(build.getWorkspace().toURI());
+ File file = new File(rootFile, INITIAL_DETECTION_FILE);
+ return file.exists();
+
+ } catch (Exception e) {
+ return false;
+ }
+ }
+
+ private Collection doInitialDetection(MqmRestClient client, String serverURL) throws IOException, InterruptedException {
+ List tests = new ArrayList<>();
+
+ scanFileSystemRecursively(build.getWorkspace(), build.getWorkspace(), tests);
+
+ postTests(client, serverURL, tests);
+
+
+ File rootFile = new File(build.getWorkspace().toURI());
+ File file = new File(rootFile, INITIAL_DETECTION_FILE);
+ file.createNewFile();
+
+
+ return tests;
+ }
+
+ private void scanFileSystemRecursively(FilePath root, FilePath dirPath, List tests) throws IOException, InterruptedException {
+ List paths = dirPath.list();
+
+
+ //if it test folder - create new test, else drill down to subFolders
+ if (isUftTestFolder(paths)) {
+ AutomatedTest test = createAutomatedTest(root, dirPath);
+
+ tests.add(test);
+
+ } else {
+ for (FilePath path : paths) {
+ if (path.isDirectory()) {
+ scanFileSystemRecursively(root, path, tests);
+ }
+ }
+ }
}
- private MqmRestClient createClient() {
- ServerConfiguration configuration = ConfigurationService.getServerConfiguration();
+ private MqmRestClient createClient(ServerConfiguration configuration) {
JenkinsMqmRestClientFactory clientFactory = getExtension(JenkinsMqmRestClientFactory.class);
MqmRestClient client = clientFactory.obtain(
configuration.location,
@@ -97,53 +229,114 @@ private MqmRestClient createClient() {
return client;
}
- UFTTestDetectionBuildAction(final String message, final AbstractBuild, ?> build, String workspaceId) {
- this.message = message;
- this.build = build;
- MqmRestClient client = createClient();
- ServerConfiguration serverConfiguration = ConfigurationService.getServerConfiguration();
- try {
- HashMap uftTestData = new HashMap<>();
- findUFTTestsPath(build.getWorkspace().list(), uftTestData);
- ArrayList data = new ArrayList<>();
- AutomatedTests automatedTests = new AutomatedTests();
-
- logger.info(uftTestData.toString());
-
- Set keys = uftTestData.keySet();
- String[] uftTestNames = keys.toArray(new String[keys.size()]);
- for (int i = 0; i < uftTestNames.length; i++) {
- String uftTestName = uftTestNames[i];
- AutomatedTest automatedTest = new AutomatedTest();
- // todo: To enable once decided, need to get the ID dynamicly from server.
-// automatedTest.setFramework(new TestFramework());
-// automatedTest.setTesting_tool_type(new com.hp.application.automation.tools.jenkins.actions.dto.TestingToolType());
- automatedTest.setName(uftTestName);
- data.add(automatedTest);
- }
- automatedTests.setData(data);
- String uftTestJson = JSONObject.fromObject(automatedTests).toString();
- String serverURL = getServerURL(workspaceId, serverConfiguration.sharedSpace, serverConfiguration.location);
- JSONObject jsonObject = client.postTest(uftTestJson, uftTestData, serverURL);
- for (int i = 0; i < jsonObject.getInt("total_count"); i++) {
- String testID = ((JSONObject) jsonObject.getJSONArray("data").get(i)).getString("id");
- String testName = ((JSONObject) jsonObject.getJSONArray("data").get(i)).getString("name");
- try {
- String parametersJSON = uftTestData.get(testName);
- if (parametersJSON != null) {
- client.attachUFTParametersToTest(testID, parametersJSON, serverURL);
- }
+ private void postTests(MqmRestClient client, String serverURL, List tests) throws UnsupportedEncodingException {
+ if (tests.isEmpty()) {
+ return;
+ }
- } catch (IOException e) {
- logger.severe(e.getMessage());
+ completeUftProperties(client, Long.parseLong(workspaceId), tests);
+
+ int BULK_SIZE = 100;
+ for (int i = 0; i < tests.size(); i += BULK_SIZE)
+ try {
+ AutomatedTests data = AutomatedTests.createWithTests(tests.subList(i, Math.min(i + BULK_SIZE, tests.size())));
+ String uftTestJson = JSONObject.fromObject(data).toString();
+ client.postTest(uftTestJson, null, serverURL);
+ //JSONObject testObject = (JSONObject) jsonObject.getJSONArray("data").get(0);
+
+ } catch (RequestErrorException e) {
+ if (e.getStatusCode() != Response.Status.CONFLICT.getStatusCode()) {
+ throw e;
}
+ //else : the test with the same hash code , so do nothing
+ }
+ }
+
+ private void deleteTests(MqmRestClient client, List removedTests) throws UnsupportedEncodingException {
+ List idsToDelete = new ArrayList<>();
+ long workspaceIdAsLong = Long.parseLong(workspaceId);
+ for (AutomatedTest test : removedTests) {
+ Map queryFields = new HashMap<>();
+ queryFields.put("name", test.getName());
+ queryFields.put("component", test.getComponent());
+ PagedList foundTests = client.getTests(workspaceIdAsLong, queryFields, Arrays.asList("id"));
+ if (foundTests.getItems().size() == 1) {
+ idsToDelete.add(foundTests.getItems().get(0).getId());
}
- } catch (InterruptedException | IOException e) {
- logger.severe(e.getMessage());
+ }
+
+ int BULK_SIZE = 100;
+ for (int i = 0; i < idsToDelete.size(); i += BULK_SIZE) {
+ client.deleteTests(workspaceIdAsLong, idsToDelete.subList(i, Math.min(i + BULK_SIZE, idsToDelete.size())));
+ }
+ }
+
+
+ private void completeUftProperties(MqmRestClient client, long workspaceId, Collection tests) {
+ TestingToolType uftTestingTool = getUftTestingTool(client, workspaceId);
+ TestFramework uftFramework = getUftFramework(client, workspaceId);
+ for (AutomatedTest test : tests) {
+ test.setTesting_tool_type(uftTestingTool);
+ test.setFramework(uftFramework);
}
}
+ public boolean isUftTestFolder(List paths) {
+ for (FilePath path : paths) {
+ if (path.getName().endsWith(STFileExtention) || path.getName().endsWith(QTPFileExtention))
+ return true;
+ }
+
+ return false;
+ }
+
+ public boolean isTestMainFilePath(String path) {
+ String lowerPath = path.toLowerCase();
+ boolean isMainFile = lowerPath.endsWith(STFileExtention) || lowerPath.endsWith(QTPFileExtention);
+ return isMainFile;
+ }
+
+ public FilePath getTestFolderForTestMainFile(String path) {
+ if (isTestMainFilePath(path)) {
+ File file = new File(path);
+ File parent = file.getParentFile();
+ return new FilePath(parent);
+ }
+ return null;
+ }
+
+
+ private TestingToolType getUftTestingTool(MqmRestClient client, long workspaceId) {
+ PagedList testingTools = client.queryListItems("list_node.testing_tool_type", null, workspaceId, 0, 100);
+ String uftTestingToolLogicalName = "list_node.testing_tool_type.uft";
+
+ for (ListItem item : testingTools.getItems()) {
+ if (uftTestingToolLogicalName.equals(item.getLogicalName())) {
+ return TestingToolType.fromListItem(item);
+ }
+ }
+ return null;
+ }
+
+ private TestFramework getUftFramework(MqmRestClient client, long workspaceId) {
+ PagedList testingTools = client.queryListItems("list_node.je.framework", null, workspaceId, 0, 100);
+ String uftTestingToolLogicalName = "list_node.je.framework.uft";
+
+ for (ListItem item : testingTools.getItems()) {
+ if (uftTestingToolLogicalName.equals(item.getLogicalName())) {
+ return TestFramework.fromListItem(item);
+ }
+ }
+ return null;
+ }
+
private String getServerURL(String workspaceId, String sharedspaceId, String location) {
return location + "/api/shared_spaces/" + sharedspaceId + "/workspaces/" + workspaceId;
}
+
+ private static T getExtension(Class clazz) {
+ ExtensionList items = Jenkins.getInstance().getExtensionList(clazz);
+ return items.get(0);
+ }
+
}
\ No newline at end of file
diff --git a/src/main/java/com/hp/application/automation/tools/octane/actions/UFTTestDetectionPublisher.java b/src/main/java/com/hp/application/automation/tools/octane/actions/UFTTestDetectionPublisher.java
index 97d98579fa..3243f88f14 100644
--- a/src/main/java/com/hp/application/automation/tools/octane/actions/UFTTestDetectionPublisher.java
+++ b/src/main/java/com/hp/application/automation/tools/octane/actions/UFTTestDetectionPublisher.java
@@ -60,14 +60,9 @@ public UFTTestDetectionPublisher(String workspaceName) {
@Override
public boolean perform(AbstractBuild build, Launcher launcher, BuildListener listener) {
- // This is where you 'build' the project.
- // Since this is a dummy, we just say 'hello world' and call that a build.
-
- // This also shows how you can consult the global configuration of the builder
- String message = "";
-
- UFTTestDetectionBuildAction buildAction = new UFTTestDetectionBuildAction(message, build, getWorkspaceName());
- build.addAction(buildAction);
+ UFTTestDetectionBuildAction buildAction = new UFTTestDetectionBuildAction(build, getWorkspaceName(), listener);
+ buildAction.startScanning();
+ //build.addAction(buildAction);
return true;
}
diff --git a/src/main/java/com/hp/application/automation/tools/octane/actions/dto/AutomatedTest.java b/src/main/java/com/hp/application/automation/tools/octane/actions/dto/AutomatedTest.java
index d6e5985272..b0a329bb7a 100644
--- a/src/main/java/com/hp/application/automation/tools/octane/actions/dto/AutomatedTest.java
+++ b/src/main/java/com/hp/application/automation/tools/octane/actions/dto/AutomatedTest.java
@@ -22,11 +22,10 @@
public class AutomatedTest {
private String type = "test";
private String subtype = "test_automated";
- private com.hp.application.automation.tools.octane.actions.dto.TestingToolType testing_tool_type;
+ private TestingToolType testing_tool_type;
private TestFramework framework;
private String name;
-
- public AutomatedTest(){}
+ private String component;
public String getName() {
return name;
@@ -52,13 +51,6 @@ public void setSubtype(String subtype) {
this.subtype = subtype;
}
- public TestingToolType getTestingToolType() {
- return testing_tool_type;
- }
-
- public void setTesting_tool_type(TestingToolType testing_tool_type) {
- this.testing_tool_type = testing_tool_type;
- }
public TestFramework getFramework() {
return framework;
@@ -67,4 +59,20 @@ public TestFramework getFramework() {
public void setFramework(TestFramework framework) {
this.framework = framework;
}
+
+ public String getComponent() {
+ return component;
+ }
+
+ public void setComponent(String component) {
+ this.component = component;
+ }
+
+ public TestingToolType getTesting_tool_type() {
+ return testing_tool_type;
+ }
+
+ public void setTesting_tool_type(TestingToolType testing_tool_type) {
+ this.testing_tool_type = testing_tool_type;
+ }
}
diff --git a/src/main/java/com/hp/application/automation/tools/octane/actions/dto/AutomatedTests.java b/src/main/java/com/hp/application/automation/tools/octane/actions/dto/AutomatedTests.java
index 8a2b4c87df..75d00e560d 100644
--- a/src/main/java/com/hp/application/automation/tools/octane/actions/dto/AutomatedTests.java
+++ b/src/main/java/com/hp/application/automation/tools/octane/actions/dto/AutomatedTests.java
@@ -1,18 +1,27 @@
package com.hp.application.automation.tools.octane.actions.dto;
import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
/**
* Created by kashbi on 25/09/2016.
*/
public class AutomatedTests {
- private ArrayList data=new ArrayList<>();
- public ArrayList getData() {
+ private List data = new ArrayList<>();
+
+ public static AutomatedTests createWithTests(Collection tests) {
+ AutomatedTests result = new AutomatedTests();
+ result.setData(new ArrayList<>(tests));
+ return result;
+ }
+
+ public List getData() {
return data;
}
- public void setData(ArrayList data) {
+ public void setData(List data) {
this.data = data;
}
}
diff --git a/src/main/java/com/hp/application/automation/tools/octane/actions/dto/TestFramework.java b/src/main/java/com/hp/application/automation/tools/octane/actions/dto/TestFramework.java
index 1e6e70bc04..d76d6a6b34 100644
--- a/src/main/java/com/hp/application/automation/tools/octane/actions/dto/TestFramework.java
+++ b/src/main/java/com/hp/application/automation/tools/octane/actions/dto/TestFramework.java
@@ -17,17 +17,25 @@
package com.hp.application.automation.tools.octane.actions.dto;
+import com.hp.mqm.client.model.ListItem;
+
/**
* Created by kashbi on 25/09/2016.
*/
-@SuppressWarnings({"squid:S2699","squid:S3658","squid:S2259","squid:S1872","squid:S2925","squid:S109"})
+@SuppressWarnings({"squid:S2699", "squid:S3658", "squid:S2259", "squid:S1872", "squid:S2925", "squid:S109"})
public class TestFramework {
private String type = "list_node";
- private String logical_name = "list_node.testing_tool_type.uft";
- private String name = "UFT";
- private Integer index = 3;
- private Integer id = 1055;
-
+ private String logical_name;
+ private String name;
+ private Long id;
+
+ public static TestFramework fromListItem(ListItem item) {
+ TestFramework type = new TestFramework();
+ type.logical_name = item.getLogicalName();
+ type.id = item.getId();
+ type.name = item.getName();
+ return type;
+ }
public String getType() {
return type;
@@ -41,31 +49,11 @@ public String getLogical_name() {
return logical_name;
}
- public void setLogical_name(String logical_name) {
- this.logical_name = logical_name;
- }
-
public String getName() {
return name;
}
- public void setName(String name) {
- this.name = name;
- }
-
- public Integer getIndex() {
- return index;
- }
-
- public void setIndex(Integer index) {
- this.index = index;
- }
-
- public Integer getId() {
+ public Long getId() {
return id;
}
-
- public void setId(Integer id) {
- this.id = id;
- }
}
diff --git a/src/main/java/com/hp/application/automation/tools/octane/actions/dto/TestingToolType.java b/src/main/java/com/hp/application/automation/tools/octane/actions/dto/TestingToolType.java
index 33d3e862fa..315e01ff94 100644
--- a/src/main/java/com/hp/application/automation/tools/octane/actions/dto/TestingToolType.java
+++ b/src/main/java/com/hp/application/automation/tools/octane/actions/dto/TestingToolType.java
@@ -16,46 +16,41 @@
package com.hp.application.automation.tools.octane.actions.dto;
+import com.hp.mqm.client.model.ListItem;
+
/**
* Created by kashbi on 25/09/2016.
*/
@SuppressWarnings("squid:S109")
public class TestingToolType {
private String type = "list_node";
- private String logical_name = "list_node.testing_tool_type.uft";
- private String name = "UFT";
- private Integer index = 4;
- private Integer id = 1075;
+ private String logical_name;
+ private String name;
+ private Long id;
+
+ public static TestingToolType fromListItem(ListItem item) {
+ TestingToolType type = new TestingToolType();
+ type.logical_name = item.getLogicalName();
+ type.id = item.getId();
+ type.name = item.getName();
+ return type;
+ }
public String getType() {
return type;
}
- public void setType(String type) {
- this.type = type;
- }
public String getName() {
return name;
}
- public void setName(String name) {
- this.name = name;
- }
-
- public Integer getIndex() {
- return index;
- }
-
- public void setIndex(Integer index) {
- this.index = index;
- }
- public Integer getId() {
+ public Long getId() {
return id;
}
- public void setId(Integer id) {
- this.id = id;
+ public String getLogical_name() {
+ return logical_name;
}
}
From ba5a8fe137223d9289739bf3704632e2b8603423 Mon Sep 17 00:00:00 2001
From: Michael Seldin
Date: Mon, 20 Mar 2017 15:38:21 +0200
Subject: [PATCH 0010/2502] update versions of integrations-sdk and mqm-client
---
pom.xml | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/pom.xml b/pom.xml
index e4b2a931ab..41ca5dfe5a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -390,15 +390,15 @@
integrations-sdk
- com.hpe.alm.octane.plugins
- 1.0
+ com.hpe.adm.octane.ciplugins
+ 1.1mqm-rest-client
- com.hpe.alm.octane.plugins
- 1.0
+ com.hpe.adm.octane.ciplugins
+ 1.1
From d5d1aacc578909a420eb8b4fcc0faa72c0ed3bd4 Mon Sep 17 00:00:00 2001
From: franksha
Date: Wed, 22 Mar 2017 14:20:43 +0200
Subject: [PATCH 0011/2502] Add support for gherkin formatter version 12.53.22
(along with version 12.53.19) - change the default glob to
**/*OctaneGherkinResults.xml
---
.../tools/octane/actions/cucumber/CucumberResultsService.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/main/java/com/hp/application/automation/tools/octane/actions/cucumber/CucumberResultsService.java b/src/main/java/com/hp/application/automation/tools/octane/actions/cucumber/CucumberResultsService.java
index fedbc7113c..c10a98b6ca 100644
--- a/src/main/java/com/hp/application/automation/tools/octane/actions/cucumber/CucumberResultsService.java
+++ b/src/main/java/com/hp/application/automation/tools/octane/actions/cucumber/CucumberResultsService.java
@@ -35,7 +35,7 @@ public class CucumberResultsService {
public static final String GHERKIN_NGA_RESULTS_XML = "OctaneGherkinResults.xml";
public static final String GHERKIN_NGA_RESULTS = "OctaneGherkinResults";
- public static final String DEFAULT_GLOB = "**/" + GHERKIN_NGA_RESULTS_XML;
+ public static final String DEFAULT_GLOB = "**/*" + GHERKIN_NGA_RESULTS_XML;
private static BuildListener listener;
From d43f9f94c83f99ea2afebc73d5bdcb53e7b726ec Mon Sep 17 00:00:00 2001
From: Jackzenko
Date: Wed, 22 Mar 2017 21:35:09 +0530
Subject: [PATCH 0012/2502] =?UTF-8?q?fix=20for=20JENKINS-39441=EF=BC=9AHP?=
=?UTF-8?q?=20plugin=20doesnt=20fail=20pipeline=20stage=20in=20case=20if?=
=?UTF-8?q?=20ALM=20server=20was=20not=20configured=20(#148)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* fixed JENKINS-39441, HP plugin now sets build status to faliure before returning.
* Update RunFromAlmBuilder.java
---
.../application/automation/tools/run/RunFromAlmBuilder.java | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/main/java/com/hp/application/automation/tools/run/RunFromAlmBuilder.java b/src/main/java/com/hp/application/automation/tools/run/RunFromAlmBuilder.java
index 13eb0e1dca..35256822a6 100644
--- a/src/main/java/com/hp/application/automation/tools/run/RunFromAlmBuilder.java
+++ b/src/main/java/com/hp/application/automation/tools/run/RunFromAlmBuilder.java
@@ -136,6 +136,10 @@ public void perform(Run, ?> build, FilePath workspace, Launcher launcher,
if (almServerSettingsModel == null) {
listener.fatalError("An ALM server is not defined. Go to Manage Jenkins->Configure System and define your ALM server under Application Lifecycle Management");
+
+ // set pipeline stage as failure in case if ALM server was not configured
+ build.setResult(Result.FAILURE);
+
return;
}
From fb1dc42545633e4505479c4110acf219292666ee Mon Sep 17 00:00:00 2001
From: Yafim Kazak
Date: Wed, 22 Mar 2017 18:05:59 +0200
Subject: [PATCH 0013/2502] Fix for an issue with using LoadRuner with
underscore in the name (#156)
* Fix to issue with error watching performance reports in Jenkins in case you use scenario with underscore in the name.
* code conventions fixes
* code conventions fixes
* code conventions fixes
---
.../results/PerformanceJobReportAction.java | 2 +-
.../tools/results/RunResultRecorder.java | 135 ++++++++++--------
2 files changed, 77 insertions(+), 60 deletions(-)
diff --git a/src/main/java/com/hp/application/automation/tools/results/PerformanceJobReportAction.java b/src/main/java/com/hp/application/automation/tools/results/PerformanceJobReportAction.java
index d396c67dd6..a7ec91d4b3 100644
--- a/src/main/java/com/hp/application/automation/tools/results/PerformanceJobReportAction.java
+++ b/src/main/java/com/hp/application/automation/tools/results/PerformanceJobReportAction.java
@@ -59,7 +59,7 @@ public PerformanceJobReportAction(Run, ?> build, LrJobResults resultFiles) {
}
/**
- * Merge results of several runs - espcially useful in pipeline jobs with multiple LR steps
+ * Merge results of several runs - especially useful in pipeline jobs with multiple LR steps
*
* @param resultFiles the result files
*/
diff --git a/src/main/java/com/hp/application/automation/tools/results/RunResultRecorder.java b/src/main/java/com/hp/application/automation/tools/results/RunResultRecorder.java
index e9670927e9..de58f73d4e 100644
--- a/src/main/java/com/hp/application/automation/tools/results/RunResultRecorder.java
+++ b/src/main/java/com/hp/application/automation/tools/results/RunResultRecorder.java
@@ -110,8 +110,8 @@ public class RunResultRecorder extends Recorder implements Serializable, MatrixA
private static final String REPORTMETADATE_XML = "report_metadata.xml";
private static final String TRANSACTION_SUMMARY_FOLDER = "TransactionSummary";
private static final String TRANSACTION_REPORT_NAME = "Report3";
- public static final String SLA_ACTUAL_VALUE_LABEL = "ActualValue";
- public static final String SLA_GOAL_VALUE_LABEL = "GoalValue";
+ private static final String SLA_ACTUAL_VALUE_LABEL = "ActualValue";
+ private static final String SLA_GOAL_VALUE_LABEL = "GoalValue";
public static final String SLA_ULL_NAME = "FullName";
public static final String ARCHIVING_TEST_REPORTS_FAILED_DUE_TO_XML_PARSING_ERROR =
"Archiving test reports failed due to xml parsing error: ";
@@ -304,9 +304,9 @@ private void archiveTestsReport(
*/
// add previous report names for aggregation when using pipelines.
- for (SuiteResult suiteResult : testResult.getSuites()) {
- String[] temp = suiteResult.getName().split("_");
- reportNames.add(temp[temp.length - 1]);
+ PerformanceJobReportAction performanceJobReportAction = build.getAction(PerformanceJobReportAction.class);
+ if (performanceJobReportAction != null){
+ reportNames.addAll(performanceJobReportAction.getLrResultBuildDataset().getLrScenarioResults().keySet());
}
for (String resultsFilePath : resultFiles) {
@@ -332,6 +332,9 @@ private void archiveTestsReport(
continue;
}
String testFolderPath = testSuiteElement.getAttribute("name");
+ int testPathArr = testFolderPath.lastIndexOf('\\');
+ String testName = testFolderPath.substring(testPathArr + 1);
+ reportNames.add(testName);
String testStatus = ("0".equals(testSuiteElement.getAttribute("failures"))) ? "pass" : "fail";
Node testCaseNode = testSuiteElement.getElementsByTagName("testcase").item(0);
@@ -364,9 +367,13 @@ private void archiveTestsReport(
try {
FilePath testSla = copyRunReport(reportFolder, build.getRootDir(),
testFolder.getName());
- runReportList.add(testSla);
+ if(testSla == null){
+ listener.getLogger().println("no RunReport.xml file was created");
+ } else {
+ runReportList.add(testSla);
+ }
} catch (IOException | InterruptedException e) {
- listener.getLogger().println(e.getMessage());
+ listener.getLogger().println(e);
}
}
}
@@ -648,8 +655,17 @@ private Boolean collectAndPrepareHtmlReports(Run build, TaskListener listener, L
return true;
}
+ /**
+ * Copies the run report from the executing node to the Jenkins master for processing.
+ * @param reportFolder
+ * @param buildDir
+ * @param scenarioName
+ * @return
+ * @throws IOException
+ * @throws InterruptedException
+ */
private FilePath copyRunReport(FilePath reportFolder, File buildDir, String
- scenerioName)
+ scenarioName)
throws IOException, InterruptedException {
FilePath slaReportFilePath = new FilePath(reportFolder, "RunReport.xml");
if (slaReportFilePath.exists()) {
@@ -668,13 +684,13 @@ private FilePath copyRunReport(FilePath reportFolder, File buildDir, String
tmpZipFile.unzip(slaDirectoryFilePath);
FilePath slaFile = new FilePath(slaDirectoryFilePath, "RunReport.xml");
slaFile.getBaseName();
- slaFile.renameTo(new FilePath(slaDirectoryFilePath, scenerioName + ".xml"));
+ slaFile.renameTo(new FilePath(slaDirectoryFilePath, scenarioName + ".xml"));
- slaFile = new FilePath(slaDirectoryFilePath, scenerioName + ".xml");
+ slaFile = new FilePath(slaDirectoryFilePath, scenarioName + ".xml");
return slaFile;
}
- throw (new IOException("no RunReport.xml file was created"));
+ return null;
}
private boolean archiveFolder(FilePath reportFolder,
@@ -841,58 +857,60 @@ private void outputReportFiles(List reportNames, File reportDirectory, T
writer.close();
File indexFile = new File(reportDirectory, REPORT_INDEX_NAME);
- writer = new BufferedWriter(new FileWriter(indexFile));
-
- Iterator resultIterator = null;
- if ((testResult != null) && (!testResult.getSuites().isEmpty())) {
- resultIterator = testResult.getSuites().iterator();//get the first
- }
- for (String report : reportNames) {
- SuiteResult suitResult = null;
- if ((resultIterator != null) && resultIterator.hasNext()) {
- suitResult = resultIterator.next();
+ try {
+ writer = new BufferedWriter(new FileWriter(indexFile));
+ Iterator resultIterator = null;
+ if ((testResult != null) && (!testResult.getSuites().isEmpty())) {
+ resultIterator = testResult.getSuites().iterator();//get the first
}
- if (suitResult == null) {
- writer.write(report + "\t##\t##\t##%n");
- } else {
- int iDuration = (int) suitResult.getDuration();
- StringBuilder bld = new StringBuilder();
- String duration = "";
- if ((iDuration / SECS_IN_DAY) > 0) {
- bld.append(String.format("%dday ", iDuration / SECS_IN_DAY));
- iDuration = iDuration % SECS_IN_DAY;
- }
- if ((iDuration / SECS_IN_HOUR) > 0) {
- bld.append(String.format("%02dhr ", iDuration / SECS_IN_HOUR));
- iDuration = iDuration % SECS_IN_HOUR;
- } else if (!duration.isEmpty()) {
- bld.append("00hr ");
- }
- if ((iDuration / SECS_IN_MINUTE) > 0) {
- bld.append(String.format("%02dmin ", iDuration / SECS_IN_MINUTE));
- iDuration = iDuration % SECS_IN_MINUTE;
- } else if (!duration.isEmpty()) {
- bld.append("00min ");
+ for (String report : reportNames) {
+ SuiteResult suitResult = null;
+ if ((resultIterator != null) && resultIterator.hasNext()) {
+ suitResult = resultIterator.next();
}
- bld.append(String.format("%02dsec", iDuration));
- duration = bld.toString();
- int iPassCount = 0;
- int iFailCount = 0;
- for (Iterator i = suitResult.getCases().iterator(); i.hasNext(); ) {
- CaseResult caseResult = (CaseResult) i.next();
- iPassCount += caseResult.getPassCount();
- iFailCount += caseResult.getFailCount();
+ if (suitResult == null) {
+ writer.write(report + "\t##\t##\t##%n");
+ } else {
+ int iDuration = (int) suitResult.getDuration();
+ StringBuilder bld = new StringBuilder();
+ String duration = "";
+ if ((iDuration / SECS_IN_DAY) > 0) {
+ bld.append(String.format("%dday ", iDuration / SECS_IN_DAY));
+ iDuration = iDuration % SECS_IN_DAY;
+ }
+ if ((iDuration / SECS_IN_HOUR) > 0) {
+ bld.append(String.format("%02dhr ", iDuration / SECS_IN_HOUR));
+ iDuration = iDuration % SECS_IN_HOUR;
+ } else if (!duration.isEmpty()) {
+ bld.append("00hr ");
+ }
+ if ((iDuration / SECS_IN_MINUTE) > 0) {
+ bld.append(String.format("%02dmin ", iDuration / SECS_IN_MINUTE));
+ iDuration = iDuration % SECS_IN_MINUTE;
+ } else if (!duration.isEmpty()) {
+ bld.append("00min ");
+ }
+ bld.append(String.format("%02dsec", iDuration));
+ duration = bld.toString();
+ int iPassCount = 0;
+ int iFailCount = 0;
+ for (Iterator i = suitResult.getCases().iterator(); i.hasNext(); ) {
+ CaseResult caseResult = (CaseResult) i.next();
+ iPassCount += caseResult.getPassCount();
+ iFailCount += caseResult.getFailCount();
+ }
+ writer.write(
+ String.format("%s\t%s\t%d\t%d%n",
+ report,
+ duration,
+ iPassCount,
+ iFailCount));
}
- writer.write(
- String.format("%s\t%s\t%d\t%d%n",
- report,
- duration,
- iPassCount,
- iFailCount));
}
+ } finally {
+ writer.flush();
+ writer.close();
}
- writer.flush();
- writer.close();
}
/**
@@ -992,7 +1010,6 @@ private JobLrScenarioResult parseScenarioResults(FilePath slaFilePath)
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
Document doc = dBuilder.parse(slaFilePath.read());
-// doc.getDocumentElement().normalize();
processSLA(jobLrScenarioResult, doc);
processLrScenarioStats(jobLrScenarioResult, doc);
From 5c3e59f5e09f163ac87a1772cd0c22dc0beeb5f1 Mon Sep 17 00:00:00 2001
From: Jackzenko
Date: Wed, 22 Mar 2017 21:36:24 +0530
Subject: [PATCH 0014/2502] UFT ALM MC Jenkins should use same fields names
(#153)
---
HpToolsLauncher/TestRunners/GuiTestRunner.cs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/HpToolsLauncher/TestRunners/GuiTestRunner.cs b/HpToolsLauncher/TestRunners/GuiTestRunner.cs
index e8560581fc..06f1621102 100644
--- a/HpToolsLauncher/TestRunners/GuiTestRunner.cs
+++ b/HpToolsLauncher/TestRunners/GuiTestRunner.cs
@@ -20,10 +20,10 @@ public class GuiTestRunner : IFileSysTestRunner
{
// Setting keys for mobile
private const string MOBILE_HOST_ADDRESS = "ALM_MobileHostAddress";
- private const string MOBILE_HOST_PORT = "MobileHostPort";
+ private const string MOBILE_HOST_PORT = "ALM_MobileHostPort";
private const string MOBILE_USER = "ALM_MobileUserName";
private const string MOBILE_PASSWORD = "ALM_MobilePassword";
- private const string MOBILE_USE_SSL = "MobileUseSSL";
+ private const string MOBILE_USE_SSL = "ALM_MobileUseSSL";
private const string MOBILE_USE_PROXY= "MobileProxySetting_UseProxy";
private const string MOBILE_PROXY_SETTING_ADDRESS = "MobileProxySetting_Address";
private const string MOBILE_PROXY_SETTING_PORT = "MobileProxySetting_Port";
From 1339c9cc701571990b34f44298a156ac2783d5f6 Mon Sep 17 00:00:00 2001
From: bamh
Date: Wed, 22 Mar 2017 18:07:15 +0200
Subject: [PATCH 0015/2502] Support HTTPS protocol for PCS (#155)
* index on master: ab83a3d Merge remote-tracking branch 'remotes/origin/5.0.1-beta-SNAPSHOT'
* Revert pom changes
* Merge branch '5.0.1-beta-SNAPSHOT' of https://github.com/hpsa/hp-application-automation-tools-plugin into development
# Conflicts:
# .github/PULL_REQUEST_TEMPLATE.md
* Added some comments
* changes according to sonarlint
* changes for sonarlint
* Remove some comments
* Comments
* * Fix for supporting SECURITY-170 changes
* https://jenkins.io/blog/2016/05/11/security-update/
* https://issues.jenkins-ci.org/browse/JENKINS-39654
* code changes for sonarlint
---
.../automation/tools/model/PcModel.java | 18 +++++-
.../automation/tools/pc/PcClient.java | 20 ++++++-
.../automation/tools/pc/PcRestProxy.java | 53 +++++++++++-----
.../tools/run/AdditionalParametersAction.java | 60 +++++++++++++++++++
.../automation/tools/run/PcBuilder.java | 35 +++++++----
.../tools/run/PcBuilder/config.jelly | 9 ++-
.../automation/tools/pc/MockPcModel.java | 5 +-
.../automation/tools/pc/MockPcRestProxy.java | 9 +--
.../tools/pc/MockPcRestProxyBadResponses.java | 7 ++-
.../automation/tools/pc/PcTestBase.java | 7 ++-
.../automation/tools/pc/TestPcClient.java | 4 +-
.../pc/TestPcClientNegativeScenrios.java | 9 ++-
12 files changed, 186 insertions(+), 50 deletions(-)
create mode 100644 src/main/java/com/hp/application/automation/tools/run/AdditionalParametersAction.java
diff --git a/src/main/java/com/hp/application/automation/tools/model/PcModel.java b/src/main/java/com/hp/application/automation/tools/model/PcModel.java
index aca6d8cdb4..620cad6626 100644
--- a/src/main/java/com/hp/application/automation/tools/model/PcModel.java
+++ b/src/main/java/com/hp/application/automation/tools/model/PcModel.java
@@ -1,3 +1,6 @@
+/*
+* Takes all the parameter from the job in order to create a loadtest object
+* */
package com.hp.application.automation.tools.model;
import java.util.Arrays;
@@ -24,11 +27,12 @@ public class PcModel {
private final String description;
private final boolean addRunToTrendReport;
private final String trendReportId;
+ private final boolean HTTPSProtocol;
@DataBoundConstructor
public PcModel(String pcServerName, String almUserName, String almPassword, String almDomain, String almProject,
String testId, String testInstanceId, String timeslotDurationHours, String timeslotDurationMinutes,
- PostRunAction postRunAction, boolean vudsMode, String description, boolean addRunToTrendReport, String trendReportId) {
+ PostRunAction postRunAction, boolean vudsMode, String description, boolean addRunToTrendReport, String trendReportId, boolean HTTPSProtocol) {
this.pcServerName = pcServerName;
this.almUserName = almUserName;
@@ -42,6 +46,7 @@ public PcModel(String pcServerName, String almUserName, String almPassword, Stri
this.vudsMode = vudsMode;
this.description = description;
this.addRunToTrendReport = addRunToTrendReport;
+ this.HTTPSProtocol = HTTPSProtocol;
this.trendReportId = trendReportId;
}
@@ -107,6 +112,9 @@ public String getDescription() {
return this.description;
}
+ public boolean httpsProtocol(){
+ return this.HTTPSProtocol;
+ }
public static List getPostRunActions() {
@@ -128,7 +136,7 @@ public String runParamsToString() {
"TestInstanceID='%s', TimeslotDuration='%s', PostRunAction='%s'%s%s]",
almDomain, almProject, testId, testInstanceId,
- timeslotDuration, postRunAction.getValue(), vudsModeString, trendString);
+ timeslotDuration, postRunAction.getValue(), vudsModeString, trendString,HTTPSProtocol);
}
@@ -139,4 +147,10 @@ public String getTrendReportId() {
public boolean isAddRunToTrendReport() {
return addRunToTrendReport;
}
+
+ public String isHTTPSProtocol(){
+ if (!HTTPSProtocol)
+ return "http";
+ return "https";
+ }
}
diff --git a/src/main/java/com/hp/application/automation/tools/pc/PcClient.java b/src/main/java/com/hp/application/automation/tools/pc/PcClient.java
index f9f3139204..e3bdb42fcd 100644
--- a/src/main/java/com/hp/application/automation/tools/pc/PcClient.java
+++ b/src/main/java/com/hp/application/automation/tools/pc/PcClient.java
@@ -20,6 +20,12 @@
* THE SOFTWARE.
*/
+
+/*
+* Implements the main method of loadtest
+*
+* */
+
package com.hp.application.automation.tools.pc;
import hudson.FilePath;
@@ -49,7 +55,7 @@ public class PcClient {
public PcClient(PcModel pcModel, PrintStream logger) {
model = pcModel;
- restProxy = new PcRestProxy(model.getPcServerName(), model.getAlmDomain(), model.getAlmProject());
+ restProxy = new PcRestProxy(model.isHTTPSProtocol(),model.getPcServerName(), model.getAlmDomain(), model.getAlmProject(),logger);
this.logger = logger;
}
@@ -66,13 +72,24 @@ public boolean login() {
loggedIn = restProxy.authenticate(user, model.getAlmPassword().toString());
} catch (PcException e) {
logger.println(e.getMessage());
+ // stackTraceToString(e);
} catch (Exception e) {
logger.println(e);
+ // stackTraceToString(e);
}
logger.println(String.format("Login %s", loggedIn ? "succeeded" : "failed"));
return loggedIn;
}
+// public void stackTraceToString(Throwable e) {
+// StringBuilder sb = new StringBuilder();
+// logger.println("DEBUGMSG - STACKTRACE");
+// for (StackTraceElement element : e.getStackTrace()) {
+// logger.println("DEBUGMSG - " + element.toString());
+// }
+// }
+
+
public boolean isLoggedIn() {
return loggedIn;
@@ -247,7 +264,6 @@ public void waitForRunToPublishOnTrendReport(int runId, String trendReportId) th
break;
}else{
Thread.sleep(5000);
- logger.println("Publishing...");
counter++;
if(counter >= 120){
logger.println("Error: Publishing didn't ended after 10 minutes, aborting...");
diff --git a/src/main/java/com/hp/application/automation/tools/pc/PcRestProxy.java b/src/main/java/com/hp/application/automation/tools/pc/PcRestProxy.java
index 8bfe0cfabc..a6d1a63aa1 100644
--- a/src/main/java/com/hp/application/automation/tools/pc/PcRestProxy.java
+++ b/src/main/java/com/hp/application/automation/tools/pc/PcRestProxy.java
@@ -20,6 +20,9 @@
* THE SOFTWARE.
*/
+/*
+* Implements the REST API methods for executing the loadtest
+* */
package com.hp.application.automation.tools.pc;
import com.hp.application.automation.tools.common.PcException;
@@ -27,6 +30,7 @@
import com.hp.application.automation.tools.rest.RESTConstants;
import com.hp.application.automation.tools.sse.sdk.Base64Encoder;
import org.apache.commons.io.IOUtils;
+import org.apache.http.Header;
import org.apache.http.HttpHeaders;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
@@ -45,19 +49,22 @@
import org.apache.http.protocol.BasicHttpContext;
import org.apache.http.protocol.HttpContext;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
import java.io.OutputStream;
+import java.io.InputStream;
+import java.io.IOException;
+import java.io.FileOutputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import java.io.PrintStream;
+
+
import static org.apache.commons.httpclient.HttpStatus.*;
public class PcRestProxy {
-
- protected static final String BASE_PC_API_URL = "http://%s/LoadTest/rest";
+
+ protected static final String BASE_PC_API_URL = "%s://%s/LoadTest/rest";
protected static final String BASE_PC_API_AUTHENTICATION_URL = BASE_PC_API_URL + "/authentication-point";
protected static final String AUTHENTICATION_LOGIN_URL = BASE_PC_API_AUTHENTICATION_URL + "/authenticate";
protected static final String AUTHENTICATION_LOGOUT_URL = BASE_PC_API_AUTHENTICATION_URL + "/logout";
@@ -76,21 +83,26 @@ public class PcRestProxy {
private String pcServer;
private String domain;
private String project;
+ private String webProtocol;
private HttpClient client;
private HttpContext context;
private CookieStore cookieStore;
-
- public PcRestProxy(String pcServerName, String almDomain, String almProject) {
-
+ // private PrintStream logger;
+
+ public PcRestProxy(String webProtocolName, String pcServerName, String almDomain, String almProject,PrintStream mainLogger) {
+
+// logger = mainLogger;
pcServer = pcServerName;
domain = almDomain;
project = almProject;
- baseURL = String.format(PC_API_RESOURCES_TEMPLATE, pcServer, domain, project);
+ webProtocol = webProtocolName;
+ baseURL = String.format(PC_API_RESOURCES_TEMPLATE, webProtocol,pcServer, domain, project);
PoolingClientConnectionManager cxMgr = new PoolingClientConnectionManager(SchemeRegistryFactory.createDefault());
cxMgr.setMaxTotal(100);
cxMgr.setDefaultMaxPerRoute(20);
+
client = new DefaultHttpClient(cxMgr);
context = new BasicHttpContext();
@@ -100,10 +112,9 @@ public PcRestProxy(String pcServerName, String almDomain, String almProject) {
public boolean authenticate(String userName, String password) throws PcException, ClientProtocolException, IOException {
-
String userNameAndPassword = userName + ":" + password;
String encodedCredentials = Base64Encoder.encode(userNameAndPassword.getBytes());
- HttpGet authRequest = new HttpGet(String.format(AUTHENTICATION_LOGIN_URL, pcServer));
+ HttpGet authRequest = new HttpGet(String.format(AUTHENTICATION_LOGIN_URL,webProtocol, pcServer));
authRequest.addHeader("Authorization", String.format("Basic %s", encodedCredentials));
executeRequest(authRequest);
return true;
@@ -111,6 +122,7 @@ public boolean authenticate(String userName, String password) throws PcException
public PcRunResponse startRun(int testId, int testInstaceId, TimeslotDuration timeslotDuration,
String postRunAction, boolean vudsMode) throws PcException, ClientProtocolException, IOException {
+ // logger.println("Starting run");
HttpPost startRunRequest = new HttpPost(String.format(baseURL + "/%s", RUNS_RESOURCE_NAME));
startRunRequest.addHeader(RESTConstants.CONTENT_TYPE, CONTENT_TYPE_XML);
PcRunRequest runRequestData = new PcRunRequest(testId, testInstaceId, 0, timeslotDuration, postRunAction, vudsMode);
@@ -204,23 +216,32 @@ public PcRunEventLog getRunEventLog(int runId) throws PcException, ClientProtoco
}
public boolean logout() throws PcException, ClientProtocolException, IOException {
- HttpGet logoutRequest = new HttpGet(String.format(AUTHENTICATION_LOGOUT_URL, pcServer));
+ HttpGet logoutRequest = new HttpGet(String.format(AUTHENTICATION_LOGOUT_URL, webProtocol,pcServer));
executeRequest(logoutRequest);
return true;
}
protected HttpResponse executeRequest(HttpRequestBase request) throws PcException, IOException {
- HttpResponse response = client.execute(request,context);
+// logger.println(String.format("DEBUGMSG - Request uri %s",request.getURI().toString()));
+// logger.println(String.format("DEBUGMSG - Request Method %s",request.getMethod().toString()));
+// // Print all headers
+// logger.println("DEBUGMSG - Headers");
+// List httpHeaders = Arrays.asList(request.getAllHeaders());
+// for (Header header : httpHeaders) {
+// logger.println("DEBUGMSG - " + header.getName() + " : " + header.getValue());
+// }
+ HttpResponse response = client.execute(request,context);
if (!isOk(response)){
String message;
try {
String content = IOUtils.toString(response.getEntity().getContent());
+// logger.println("DEBUGMSG - response content: " + content);
PcErrorResponse exception = PcErrorResponse.xmlToObject(content);
- message = String.format("%s Error code: %s", exception.ExceptionMessage, exception.ErrorCode);
- } catch (Exception ex) {
+ message = String.format("%s Error code: %s", exception.ExceptionMessage, exception.ErrorCode);
+ } catch (Exception ex) {
message = response.getStatusLine().toString();
}
- throw new PcException(message);
+ throw new PcException("executeRequest exception: " + message);
}
return response;
}
diff --git a/src/main/java/com/hp/application/automation/tools/run/AdditionalParametersAction.java b/src/main/java/com/hp/application/automation/tools/run/AdditionalParametersAction.java
new file mode 100644
index 0000000000..b9b104f9d7
--- /dev/null
+++ b/src/main/java/com/hp/application/automation/tools/run/AdditionalParametersAction.java
@@ -0,0 +1,60 @@
+package com.hp.application.automation.tools.run;
+
+import hudson.EnvVars;
+import hudson.Extension;
+import hudson.model.EnvironmentContributor;
+import hudson.model.ParameterValue;
+import hudson.model.Run;
+import hudson.model.TaskListener;
+import hudson.model.ParametersAction;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * Fix for supporting SECURITY-170 changes
+ * https://jenkins.io/blog/2016/05/11/security-update/
+ * https://issues.jenkins-ci.org/browse/JENKINS-39654
+ *
+ */
+public class AdditionalParametersAction extends ParametersAction{
+
+ private List parameters;
+
+ public AdditionalParametersAction(List cparameters){
+ this.parameters = Collections.unmodifiableList(cparameters);
+ }
+
+
+
+ @Override
+ public List getParameters() {
+ return Collections.unmodifiableList(parameters);
+ }
+
+ @Override
+ public ParameterValue getParameter(String name){
+ for (ParameterValue p : parameters) {
+ if (p == null)
+ continue;
+ if (p.getName().equals(name))
+ return p;
+ }
+ return null;
+ }
+
+ @Extension
+ public static final class AdditionalParametersActionEnvironmentContributor extends EnvironmentContributor {
+ @Override
+ public void buildEnvironmentFor(Run r, EnvVars envs, TaskListener listener)
+ throws IOException, InterruptedException {
+ AdditionalParametersAction action = r.getAction(AdditionalParametersAction.class);
+ if (action != null) {
+ for (ParameterValue p : action.getParameters()) {
+ envs.putIfNotNull(p.getName(), String.valueOf(p.getValue()));
+ }
+ }
+ }
+ }
+}
diff --git a/src/main/java/com/hp/application/automation/tools/run/PcBuilder.java b/src/main/java/com/hp/application/automation/tools/run/PcBuilder.java
index 21f2c37899..0fcd40f6ce 100644
--- a/src/main/java/com/hp/application/automation/tools/run/PcBuilder.java
+++ b/src/main/java/com/hp/application/automation/tools/run/PcBuilder.java
@@ -20,12 +20,15 @@
* THE SOFTWARE.
*/
+
+/*
+* Create the PCModel and the PCClient and allows the connection between the job and PC
+* */
package com.hp.application.automation.tools.run;
import com.hp.application.automation.tools.common.PcException;
import com.hp.application.automation.tools.model.PcModel;
import com.hp.application.automation.tools.model.PostRunAction;
-import com.hp.application.automation.tools.model.SecretContainer;
import com.hp.application.automation.tools.model.TimeslotDuration;
import com.hp.application.automation.tools.pc.*;
import com.hp.application.automation.tools.sse.result.model.junit.Error;
@@ -56,6 +59,7 @@
import java.lang.reflect.Method;
import java.text.Format;
import java.text.SimpleDateFormat;
+import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@@ -88,7 +92,6 @@ public class PcBuilder extends Builder implements SimpleBuildStep{
private FilePath pcReportFile;
private String junitResultsFileName;
private PrintStream logger;
- // private boolean trendReportReady;
@DataBoundConstructor
public PcBuilder(
@@ -106,13 +109,14 @@ public PcBuilder(
boolean statusBySLA,
String description,
boolean addRunToTrendReport,
- String trendReportId) {
+ String trendReportId,
+ boolean HTTPSProtocol) {
this.almUserName = almUserName;
this.almPassword = almPassword;
this.timeslotDurationHours = timeslotDurationHours;
this.timeslotDurationMinutes = timeslotDurationMinutes;
this.statusBySLA = statusBySLA;
-
+
pcModel =
new PcModel(
pcServerName.trim(),
@@ -128,7 +132,8 @@ public PcBuilder(
vudsMode,
description,
addRunToTrendReport,
- trendReportId);
+ trendReportId,
+ HTTPSProtocol);
}
@Override
@@ -215,11 +220,13 @@ private Testsuites run(PcClient pcClient, Run, ?> build)
boolean trendReportReady = false;
try {
runId = pcClient.startRun();
-
+ List parameters = new ArrayList<>();
+ parameters.add(new StringParameterValue(RUNID_BUILD_VARIABLE, "" + runId));
// This allows a user to access the runId from within Jenkins using a build variable.
- build.addAction(new ParametersAction(new StringParameterValue(RUNID_BUILD_VARIABLE, "" + runId)));
+ build.addAction(new AdditionalParametersAction(parameters));
logger.print("Set " + RUNID_BUILD_VARIABLE + " Env Variable to " + runId + "\n");
-
+
+
response = pcClient.waitForRunCompletion(runId);
@@ -340,7 +347,7 @@ private boolean validateTrendReportIdIsNumeric(String trendReportId, boolean add
}
catch(NumberFormatException e) {
- res = FormValidation.error("Illegal Parameter: trend report ID is is not a number");
+ res = FormValidation.error("Illegal Parameter: trend report ID is not a number");
}
}
@@ -589,6 +596,7 @@ public boolean isAddRunToTrendReport()
return getPcModel().isAddRunToTrendReport();
}
+
public boolean isVudsMode()
{
return getPcModel().isVudsMode();
@@ -608,6 +616,11 @@ public String getAlmPassword() {
return almPassword;
}
+ public boolean isHTTPSProtocol()
+ {
+ return getPcModel().httpsProtocol();
+ }
+
public boolean isStatusBySLA() {
return statusBySLA;
}
@@ -617,9 +630,9 @@ public boolean isStatusBySLA() {
@Extension
@Symbol("pcBuild")
public static final class DescriptorImpl extends BuildStepDescriptor {
-
+
public DescriptorImpl() {
-
+
load();
}
diff --git a/src/main/resources/com/hp/application/automation/tools/run/PcBuilder/config.jelly b/src/main/resources/com/hp/application/automation/tools/run/PcBuilder/config.jelly
index e9211d4684..2d834aabdf 100644
--- a/src/main/resources/com/hp/application/automation/tools/run/PcBuilder/config.jelly
+++ b/src/main/resources/com/hp/application/automation/tools/run/PcBuilder/config.jelly
@@ -117,6 +117,8 @@
+
+
@@ -203,8 +205,11 @@
-
+
+
+
+
+
diff --git a/src/test/java/com/hp/application/automation/tools/pc/MockPcModel.java b/src/test/java/com/hp/application/automation/tools/pc/MockPcModel.java
index 850b0f4621..35970925b8 100644
--- a/src/test/java/com/hp/application/automation/tools/pc/MockPcModel.java
+++ b/src/test/java/com/hp/application/automation/tools/pc/MockPcModel.java
@@ -26,9 +26,10 @@ public class MockPcModel extends PcModel {
public MockPcModel(String pcServerName, String almUserName, String almPassword, String almDomain,
String almProject, String testId, String testInstanceId, String timeslotDurationHours,
- String timeslotDurationMinutes, PostRunAction postRunAction, boolean vudsMode, String description) {
+ String timeslotDurationMinutes, PostRunAction postRunAction, boolean vudsMode, String description,boolean webProtocol) {
super(pcServerName, almUserName, almPassword, almDomain, almProject, testId, testInstanceId, timeslotDurationHours,
- timeslotDurationMinutes, postRunAction, vudsMode, description, false, null);
+ timeslotDurationMinutes, postRunAction, vudsMode, description, false, null,false
+ );
}
@Override
diff --git a/src/test/java/com/hp/application/automation/tools/pc/MockPcRestProxy.java b/src/test/java/com/hp/application/automation/tools/pc/MockPcRestProxy.java
index 8583dcee85..9a514b4efe 100644
--- a/src/test/java/com/hp/application/automation/tools/pc/MockPcRestProxy.java
+++ b/src/test/java/com/hp/application/automation/tools/pc/MockPcRestProxy.java
@@ -18,6 +18,7 @@
import java.io.File;
import java.io.IOException;
+import java.io.PrintStream;
import java.util.Arrays;
import java.util.Iterator;
@@ -41,8 +42,8 @@ public class MockPcRestProxy extends PcRestProxy {
private static Iterator runState = initializeRunStateIterator();
- public MockPcRestProxy(String pcServerName, String almDomain, String almProject) {
- super(pcServerName, almDomain, almProject);
+ public MockPcRestProxy(String webProtocol, String pcServerName, String almDomain, String almProject,PrintStream logger) {
+ super(webProtocol, pcServerName, almDomain, almProject,logger);
}
@Override
@@ -50,8 +51,8 @@ protected HttpResponse executeRequest(HttpRequestBase request) throws PcExceptio
IOException {
HttpResponse response = null;
String requestUrl = request.getURI().toString();
- if (requestUrl.equals(String.format(AUTHENTICATION_LOGIN_URL, PC_SERVER_NAME))
- || requestUrl.equals(String.format(AUTHENTICATION_LOGOUT_URL, PC_SERVER_NAME))
+ if (requestUrl.equals(String.format(AUTHENTICATION_LOGIN_URL,WEB_PROTOCOL, PC_SERVER_NAME))
+ || requestUrl.equals(String.format(AUTHENTICATION_LOGOUT_URL,WEB_PROTOCOL, PC_SERVER_NAME))
|| requestUrl.equals(String.format(getBaseURL() + "/%s/%s/%s", RUNS_RESOURCE_NAME, RUN_ID, STOP_MODE))) {
response = getOkResponse();
} else if (requestUrl.equals(String.format(getBaseURL() + "/%s", RUNS_RESOURCE_NAME))
diff --git a/src/test/java/com/hp/application/automation/tools/pc/MockPcRestProxyBadResponses.java b/src/test/java/com/hp/application/automation/tools/pc/MockPcRestProxyBadResponses.java
index dc7d7dd948..3fd1fa3b56 100644
--- a/src/test/java/com/hp/application/automation/tools/pc/MockPcRestProxyBadResponses.java
+++ b/src/test/java/com/hp/application/automation/tools/pc/MockPcRestProxyBadResponses.java
@@ -17,6 +17,7 @@
package com.hp.application.automation.tools.pc;
import java.io.IOException;
+import java.io.PrintStream;
import java.util.Arrays;
import java.util.Iterator;
@@ -36,8 +37,8 @@ public class MockPcRestProxyBadResponses extends PcRestProxy {
private static Iterator runState = initializeRunStateIterator();
- public MockPcRestProxyBadResponses(String pcServerName, String almDomain, String almProject) {
- super(pcServerName, almDomain, almProject);
+ public MockPcRestProxyBadResponses(String webProtocol, String pcServerName, String almDomain, String almProject,PrintStream logger) {
+ super(webProtocol, pcServerName, almDomain, almProject,logger);
}
@Override
@@ -45,7 +46,7 @@ protected HttpResponse executeRequest(HttpRequestBase request) throws PcExceptio
IOException {
HttpResponse response = null;
String requestUrl = request.getURI().toString();
- if (requestUrl.equals(String.format(AUTHENTICATION_LOGIN_URL, PC_SERVER_NAME))) {
+ if (requestUrl.equals(String.format(AUTHENTICATION_LOGIN_URL,WEB_PROTOCOL, PC_SERVER_NAME))) {
throw new PcException(pcAuthenticationFailureMessage);
} else if (requestUrl.equals(String.format(getBaseURL() + "/%s", RUNS_RESOURCE_NAME))){
throw new PcException(pcNoTimeslotExceptionMessage);
diff --git a/src/test/java/com/hp/application/automation/tools/pc/PcTestBase.java b/src/test/java/com/hp/application/automation/tools/pc/PcTestBase.java
index 945382c47a..849e50e3bd 100644
--- a/src/test/java/com/hp/application/automation/tools/pc/PcTestBase.java
+++ b/src/test/java/com/hp/application/automation/tools/pc/PcTestBase.java
@@ -18,6 +18,8 @@
import com.hp.application.automation.tools.model.PostRunAction;
+import java.io.PrintStream;
+
public interface PcTestBase {
public static final String PC_SERVER_NAME = "pcServer.hp.com";
@@ -37,13 +39,16 @@ public interface PcTestBase {
public static final String RUN_ID_WAIT = "8";
public static final String REPORT_ID = "9";
public static final String STOP_MODE = "stop";
+ public static final String WEB_PROTOCOL = "http";
+ public static final Boolean IS_HTTPS = false;
+ public static final PrintStream LOGGER = null;
public static final MockPcModel pcModel = new MockPcModel(PC_SERVER_NAME, ALM_USER_NAME,
ALM_PASSWORD, ALM_DOMAIN, ALM_PROJECT,
TEST_ID, TEST_INSTANCE_ID,
TIMESLOT_DURATION_HOURS,
TIMESLOT_DURATION_MINUTES, POST_RUN_ACTION,
- VUDS_MODE, DESCRIPTION);
+ VUDS_MODE, DESCRIPTION,IS_HTTPS);
public static final String runResponseEntity = "" +
"" + TEST_ID + "" +
diff --git a/src/test/java/com/hp/application/automation/tools/pc/TestPcClient.java b/src/test/java/com/hp/application/automation/tools/pc/TestPcClient.java
index 852e28e20f..f2a103ef2e 100644
--- a/src/test/java/com/hp/application/automation/tools/pc/TestPcClient.java
+++ b/src/test/java/com/hp/application/automation/tools/pc/TestPcClient.java
@@ -33,8 +33,8 @@ public class TestPcClient {
@BeforeClass
public static void setUp() {
try {
- PcRestProxy resetProxy = new MockPcRestProxy(PcTestBase.PC_SERVER_NAME, PcTestBase.ALM_DOMAIN,
- PcTestBase.ALM_PROJECT);
+ PcRestProxy resetProxy = new MockPcRestProxy(PcTestBase.WEB_PROTOCOL, PcTestBase.PC_SERVER_NAME, PcTestBase.ALM_DOMAIN,
+ PcTestBase.ALM_PROJECT,PcTestBase.LOGGER);
pcClient = new PcClient(PcTestBase.pcModel, System.out, resetProxy);
} catch (Exception e) {
e.printStackTrace(System.out);
diff --git a/src/test/java/com/hp/application/automation/tools/pc/TestPcClientNegativeScenrios.java b/src/test/java/com/hp/application/automation/tools/pc/TestPcClientNegativeScenrios.java
index 6530b9bee7..c37c8337e6 100644
--- a/src/test/java/com/hp/application/automation/tools/pc/TestPcClientNegativeScenrios.java
+++ b/src/test/java/com/hp/application/automation/tools/pc/TestPcClientNegativeScenrios.java
@@ -44,8 +44,8 @@ public class TestPcClientNegativeScenrios {
public static void setUp() {
System.out.println("Starting HP Performance Center client negative testing scenarios:");
try {
- PcRestProxy resetProxy = new MockPcRestProxyBadResponses(PcTestBase.PC_SERVER_NAME, PcTestBase.ALM_DOMAIN,
- PcTestBase.ALM_PROJECT);
+ PcRestProxy resetProxy = new MockPcRestProxyBadResponses(PcTestBase.WEB_PROTOCOL,PcTestBase.PC_SERVER_NAME, PcTestBase.ALM_DOMAIN,
+ PcTestBase.ALM_PROJECT,PcTestBase.LOGGER);
pcClient = new PcClient(PcTestBase.pcModel, new PrintStream(new OutputStream() {
@Override
@@ -89,9 +89,8 @@ public void testPublishRunReportWithEmptyResults() {
System.out.println("Testing Publish PC Run Report to while run results are empty");
try {
- FilePath reportHtml = pcClient.publishRunReport(Integer.parseInt(PcTestBase.RUN_ID), String.format(
- PcBuilder.getRunReportStructure(), RESOURCES_DIR, PcBuilder.getArtifactsDirectoryName(),
- PcTestBase.RUN_ID));
+ FilePath reportHtml = pcClient.publishRunReport(Integer.parseInt(PcTestBase.RUN_ID),
+ String.format(PcBuilder.getRunReportStructure(), RESOURCES_DIR, PcBuilder.getArtifactsDirectoryName(),PcTestBase.RUN_ID));
Assert.assertNull("pcClient.publishRunReport should have returned null due to empty run results",
reportHtml);
} catch (Exception e) {
From 6118063b94d7e318a7bb0471c5e78a5084ec29ae Mon Sep 17 00:00:00 2001
From: Yafim Kazak
Date: Wed, 22 Mar 2017 18:07:31 +0200
Subject: [PATCH 0016/2502] Added support for LoadRunner RunReport.xml parsing
in non-english locale enviroments (#163)
* Diffrent language locale support fix
* Fix for supporting diffrent locale
---
.gitignore | 1 -
LRAnalysisLauncher/Program.cs | 68 ++++++++++++++++++-----------------
2 files changed, 35 insertions(+), 34 deletions(-)
diff --git a/.gitignore b/.gitignore
index b277c21ced..572f977ddd 100644
--- a/.gitignore
+++ b/.gitignore
@@ -38,7 +38,6 @@ Ankh.NoLoad
#Tooling
_ReSharper*/
*.resharper
-[Tt]est[Rr]esult*
*.sass-cache
#Project files
diff --git a/LRAnalysisLauncher/Program.cs b/LRAnalysisLauncher/Program.cs
index 547e40b3d3..29cae940be 100644
--- a/LRAnalysisLauncher/Program.cs
+++ b/LRAnalysisLauncher/Program.cs
@@ -26,6 +26,7 @@
using Analysis.ApiSL;
using Analysis.Api.Dictionaries;
using System.Diagnostics;
+using System.Globalization;
using System.Linq;
namespace LRAnalysisLauncher
@@ -45,9 +46,9 @@ static void log()
static void log(string msg)
{
Console.WriteLine(msg);
- // writer.WriteLine(msg);
+ // writer.WriteLine(msg);
}
-// static StreamWriter writer = new StreamWriter(new FileStream("c:\\AnalysisLauncherOutput.txt", FileMode.OpenOrCreate, FileAccess.Write));
+ // static StreamWriter writer = new StreamWriter(new FileStream("c:\\AnalysisLauncherOutput.txt", FileMode.OpenOrCreate, FileAccess.Write));
//args: lrr location, lra location, html report location
[STAThread]
static int Main(string[] args)
@@ -61,7 +62,7 @@ static int Main(string[] args)
if (args.Length != 3)
{
ShowHelp();
- return (int) Launcher.ExitCodeEnum.Aborted;
+ return (int)Launcher.ExitCodeEnum.Aborted;
}
string lrrlocation = args[0];
@@ -70,7 +71,7 @@ static int Main(string[] args)
log("creating analysis COM object");
LrAnalysis analysis = new LrAnalysis();
-
+
Session session = analysis.Session;
log("creating analysis session");
if (session.Create(lralocation, lrrlocation))
@@ -139,11 +140,11 @@ static int Main(string[] args)
// stopper.Start();
// log("Gathering Duration statistics");
// stopper.Start();
- //DateTime startTime = Helper.FromUnixTime(currentRun.StartTime);
- //DateTime endTime = Helper.FromUnixTime(currentRun.EndTime);
- //durationElement.SetAttribute("End", endTime.ToString());
- //durationElement.SetAttribute("Start", startTime.ToString());
- //durationElement.SetAttribute("Duration", Helper.GetScenarioDuration(currentRun));
+ //DateTime startTime = Helper.FromUnixTime(currentRun.StartTime);
+ //DateTime endTime = Helper.FromUnixTime(currentRun.EndTime);
+ //durationElement.SetAttribute("End", endTime.ToString());
+ //durationElement.SetAttribute("Start", startTime.ToString());
+ //durationElement.SetAttribute("Duration", Helper.GetScenarioDuration(currentRun));
//}
general.AppendChild(durationElement);
@@ -213,6 +214,7 @@ static int Main(string[] args)
int iCounter = 0; // set counter
log("WholeRunRules : " + slaResult.WholeRunRules.Count);
+ CultureInfo formatProvider = new CultureInfo("en-US");
foreach (SlaWholeRunRuleResult a in slaResult.WholeRunRules)
{
log(Resources.DoubleLineSeperator);
@@ -224,21 +226,21 @@ static int Main(string[] args)
log("Transaction Name : " + b.TransactionName);
elem.SetAttribute("TransactionName", b.TransactionName.ToString());
log("Percentile : " + b.Percentage);
- elem.SetAttribute("Percentile", b.Percentage.ToString());
+ elem.SetAttribute("Percentile", b.Percentage.ToString(formatProvider));
elem.SetAttribute("FullName", b.RuleUiName);
log("Full Name : " + b.RuleUiName);
log("Measurement : " + b.Measurement);
elem.SetAttribute("Measurement", b.Measurement.ToString());
log("Goal Value : " + b.GoalValue);
- elem.SetAttribute("GoalValue", b.GoalValue.ToString());
+ elem.SetAttribute("GoalValue", b.GoalValue.ToString(formatProvider));
log("Actual value : " + b.ActualValue);
- elem.SetAttribute("ActualValue", b.ActualValue.ToString());
+ elem.SetAttribute("ActualValue", b.ActualValue.ToString(formatProvider));
log("status : " + b.Status);
elem.AppendChild(xmlDoc.CreateTextNode(b.Status.ToString()));
if (b.Status.Equals(SlaRuleStatus.Failed)) // 0 = failed
{
- iPassed = (int) Launcher.ExitCodeEnum.Failed;
+ iPassed = (int)Launcher.ExitCodeEnum.Failed;
}
iCounter++;
}
@@ -250,15 +252,15 @@ static int Main(string[] args)
log("Measurement : " + a.Measurement);
elem.SetAttribute("Measurement", a.Measurement.ToString());
log("Goal Value : " + a.GoalValue);
- elem.SetAttribute("GoalValue", a.GoalValue.ToString());
+ elem.SetAttribute("GoalValue", a.GoalValue.ToString(formatProvider));
log("Actual value : " + a.ActualValue);
- elem.SetAttribute("ActualValue", a.ActualValue.ToString());
+ elem.SetAttribute("ActualValue", a.ActualValue.ToString(formatProvider));
log("status : " + a.Status);
elem.AppendChild(xmlDoc.CreateTextNode(a.Status.ToString()));
if (a.Status.Equals(SlaRuleStatus.Failed)) // 0 = failed
{
- iPassed = (int) Launcher.ExitCodeEnum.Failed;
+ iPassed = (int)Launcher.ExitCodeEnum.Failed;
}
}
root.AppendChild(elem);
@@ -288,9 +290,9 @@ static int Main(string[] args)
foreach (SlaLoadThreshold slat in b.LoadThresholds)
{
XmlElement loadThr = xmlDoc.CreateElement("SlaLoadThreshold");
- loadThr.SetAttribute("StartLoadValue", slat.StartLoadValue.ToString());
- loadThr.SetAttribute("EndLoadValue", slat.EndLoadValue.ToString());
- loadThr.SetAttribute("ThresholdValue", slat.ThresholdValue.ToString());
+ loadThr.SetAttribute("StartLoadValue", slat.StartLoadValue.ToString(formatProvider));
+ loadThr.SetAttribute("EndLoadValue", slat.EndLoadValue.ToString(formatProvider));
+ loadThr.SetAttribute("ThresholdValue", slat.ThresholdValue.ToString(formatProvider));
rule.AppendChild(loadThr);
}
@@ -301,9 +303,9 @@ static int Main(string[] args)
XmlElement subsubelem = xmlDoc.CreateElement("TimeRangeInfo");
subsubelem.SetAttribute("StartTime", slatri.StartTime.ToString());
subsubelem.SetAttribute("EndTime", slatri.EndTime.ToString());
- subsubelem.SetAttribute("GoalValue", slatri.GoalValue.ToString());
- subsubelem.SetAttribute("ActualValue", slatri.ActualValue.ToString());
- subsubelem.SetAttribute("LoadValue", slatri.LoadValue.ToString());
+ subsubelem.SetAttribute("GoalValue", slatri.GoalValue.ToString(formatProvider));
+ subsubelem.SetAttribute("ActualValue", slatri.ActualValue.ToString(formatProvider));
+ subsubelem.SetAttribute("LoadValue", slatri.LoadValue.ToString(formatProvider));
subsubelem.InnerText = slatri.Status.ToString();
timeRanges.AppendChild(subsubelem);
}
@@ -312,7 +314,7 @@ static int Main(string[] args)
rule.AppendChild(xmlDoc.CreateTextNode(b.Status.ToString()));
if (b.Status.Equals(SlaRuleStatus.Failed)) // 0 = failed
{
- iPassed = (int) Launcher.ExitCodeEnum.Failed;
+ iPassed = (int)Launcher.ExitCodeEnum.Failed;
}
iCounter++;
}
@@ -329,9 +331,9 @@ static int Main(string[] args)
foreach (SlaLoadThreshold slat in a.LoadThresholds)
{
XmlElement loadThr = xmlDoc.CreateElement("SlaLoadThreshold");
- loadThr.SetAttribute("StartLoadValue", slat.StartLoadValue.ToString());
- loadThr.SetAttribute("EndLoadValue", slat.EndLoadValue.ToString());
- loadThr.SetAttribute("ThresholdValue", slat.ThresholdValue.ToString());
+ loadThr.SetAttribute("StartLoadValue", slat.StartLoadValue.ToString(formatProvider));
+ loadThr.SetAttribute("EndLoadValue", slat.EndLoadValue.ToString(formatProvider));
+ loadThr.SetAttribute("ThresholdValue", slat.ThresholdValue.ToString(formatProvider));
rule.AppendChild(loadThr);
}
@@ -342,9 +344,9 @@ static int Main(string[] args)
XmlElement subsubelem = xmlDoc.CreateElement("TimeRangeInfo");
subsubelem.SetAttribute("StartTime", slatri.StartTime.ToString());
subsubelem.SetAttribute("EndTime", slatri.EndTime.ToString());
- subsubelem.SetAttribute("GoalValue", slatri.GoalValue.ToString());
- subsubelem.SetAttribute("ActualValue", slatri.ActualValue.ToString());
- subsubelem.SetAttribute("LoadValue", slatri.LoadValue.ToString());
+ subsubelem.SetAttribute("GoalValue", slatri.GoalValue.ToString(formatProvider));
+ subsubelem.SetAttribute("ActualValue", slatri.ActualValue.ToString(formatProvider));
+ subsubelem.SetAttribute("LoadValue", slatri.LoadValue.ToString(formatProvider));
subsubelem.InnerText = slatri.Status.ToString();
timeRanges.AppendChild(subsubelem);
}
@@ -353,7 +355,7 @@ static int Main(string[] args)
rule.AppendChild(xmlDoc.CreateTextNode(a.Status.ToString()));
if (a.Status.Equals(SlaRuleStatus.Failed))
{
- iPassed = (int) Launcher.ExitCodeEnum.Failed;
+ iPassed = (int)Launcher.ExitCodeEnum.Failed;
}
}
@@ -380,7 +382,7 @@ static int Main(string[] args)
{
log(Resources.CannotCreateSession);
- return (int) Launcher.ExitCodeEnum.Aborted;
+ return (int)Launcher.ExitCodeEnum.Aborted;
}
log("closing analysis session");
session.Close();
@@ -395,13 +397,13 @@ static int Main(string[] args)
log(ex.Message);
log(ex.StackTrace);
}
- return (int) Launcher.ExitCodeEnum.Aborted;
+ return (int)Launcher.ExitCodeEnum.Aborted;
}
catch (Exception e)
{
log(e.Message);
log(e.StackTrace);
- return (int) Launcher.ExitCodeEnum.Aborted;
+ return (int)Launcher.ExitCodeEnum.Aborted;
}
From 3dbc7de62c2f66fa0cd719b3f5fe9e70008ffbdf Mon Sep 17 00:00:00 2001
From: Jane
Date: Thu, 23 Mar 2017 00:16:31 +0800
Subject: [PATCH 0017/2502] [MC Jenkins Plugin] Using MC Wizard tool required
from user double aunthentication (due to cross domain connection) and
selected device/app/metrics options not saved (#151)
* Defect#5550: open job wizard without login again and keep the job info
* Defect#5550: revert the version number to 5.1-SNAPSHOT
* Defect#5550: add java doc for method modify
---
.../automation/tools/run/RunFromFileBuilder.java | 8 +++++++-
.../automation/tools/run/RunFromFileBuilder/config.jelly | 2 +-
src/main/webapp/configure.js | 3 ++-
3 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/src/main/java/com/hp/application/automation/tools/run/RunFromFileBuilder.java b/src/main/java/com/hp/application/automation/tools/run/RunFromFileBuilder.java
index 1564ea7109..c50b2084fd 100644
--- a/src/main/java/com/hp/application/automation/tools/run/RunFromFileBuilder.java
+++ b/src/main/java/com/hp/application/automation/tools/run/RunFromFileBuilder.java
@@ -532,6 +532,8 @@ public boolean isApplicable(
/**
* Gets job id.
+ * If there is already a job created by jenkins plugin, then return this job id,
+ * otherwise, create a new temp job and return the new job id.
*
* @param mcUrl the mc url
* @param mcUserName the mc user name
@@ -539,10 +541,14 @@ public boolean isApplicable(
* @param proxyAddress the proxy address
* @param proxyUserName the proxy user name
* @param proxyPassword the proxy password
+ * @param previousJobId the previous job id
* @return the job id
*/
@JavaScriptMethod
- public String getJobId(String mcUrl, String mcUserName, String mcPassword, String proxyAddress, String proxyUserName, String proxyPassword) {
+ public String getJobId(String mcUrl, String mcUserName, String mcPassword, String proxyAddress, String proxyUserName, String proxyPassword, String previousJobId) {
+ if(null != previousJobId && !previousJobId.isEmpty()){
+ return previousJobId;
+ }
return instance.createTempJob(mcUrl, mcUserName, mcPassword, proxyAddress, proxyUserName, proxyPassword);
}
diff --git a/src/main/resources/com/hp/application/automation/tools/run/RunFromFileBuilder/config.jelly b/src/main/resources/com/hp/application/automation/tools/run/RunFromFileBuilder/config.jelly
index 9e217d3f42..5aa83a390d 100644
--- a/src/main/resources/com/hp/application/automation/tools/run/RunFromFileBuilder/config.jelly
+++ b/src/main/resources/com/hp/application/automation/tools/run/RunFromFileBuilder/config.jelly
@@ -122,7 +122,7 @@
-
+
+* @version 1.0
+*/
+public class LrScriptResultsParserTest {
+
+@Before
+public void before() throws Exception {
+}
+
+@After
+public void after() throws Exception {
+}
+
+/**
+*
+* Method: parse(String scriptName)
+*
+*/
+@Test
+public void testParse() throws Exception {
+ final String pathname = "C:\\Jenkins\\jobs\\TestRunLRScriptReg\\builds\\13\\WebHttpHtml1\\Results.xml";
+ final String junitOutput = "C:\\Jenkins\\jobs\\TestRunLRScriptReg\\builds\\31\\WebHttpHtml1\\JunitResult.xml";
+
+ FilePath resultFile = new FilePath(new File(pathname));
+ FilePath junitFile = new FilePath(new File(junitOutput));
+
+// LrScriptResultsParser lrscriptresultparser = new LrScriptResultsParser();
+// lrscriptresultparser.parse(resultFile, junitFile);
+
+ TestResult testResult = new TestResult();
+ testResult.parse(new File(junitOutput));
+ testResult.tally();
+
+
+}
+
+
+}
From e0a036eb51a63fa12861e8b36895c7d7dfd3b9d5 Mon Sep 17 00:00:00 2001
From: Yafim Kazak
Date: Sun, 2 Apr 2017 09:40:11 +0300
Subject: [PATCH 0038/2502] Update pom.xml
Update version for release
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index c8cb80b7b0..97eb36acd5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -8,7 +8,7 @@
hp-application-automation-tools-plugin
- 5.2-beta-SNAPSHOT
+ 5.101-beta-SNAPSHOThpiHP Application Automation ToolsThe plugin integrates Jenkins with the following HPE products - Service Virtualization, LoadRunner, Performance Center, Unified Functional Testing, QuickTest Professional, Service Test, Mobile Center, Application Lifecycle Management and Application Lifecycle Management Octane.
From cbc0c0ecedd1120a0e377d88ddb3db1377a64c6d Mon Sep 17 00:00:00 2001
From: Yafim Kazak
Date: Sun, 2 Apr 2017 09:49:55 +0300
Subject: [PATCH 0039/2502] Update readme.md
---
readme.md | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/readme.md b/readme.md
index 9f0edd9f71..d26915ad5f 100644
--- a/readme.md
+++ b/readme.md
@@ -4,6 +4,13 @@
[](https://www.codacy.com/app/HPEbot/hp-application-automation-tools-plugin?utm_source=github.com&utm_medium=referral&utm_content=hpsa/hp-application-automation-tools-plugin&utm_campaign=badger)
+Project status:
+[](https://ci.appveyor.com/project/HPEbot/hp-application-automation-tools-plugin)
+
+Latest release branch status:
+[](https://ci.appveyor.com/project/HPEbot/hp-application-automation-tools-plugin/branch/latest)
+
+
##### The plugin provides the ability to run HPE products with Jenkins during builds.
## Relevent links
From f0116799fb224e448ec62823eda5cc0409295308 Mon Sep 17 00:00:00 2001
From: Yafim Kazak
Date: Mon, 3 Apr 2017 12:06:41 +0300
Subject: [PATCH 0040/2502] Update pom.xml
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index 97eb36acd5..6fd8a8d3df 100644
--- a/pom.xml
+++ b/pom.xml
@@ -8,7 +8,7 @@
hp-application-automation-tools-plugin
- 5.101-beta-SNAPSHOT
+ 5.1.0.1-beta-SNAPSHOThpiHP Application Automation ToolsThe plugin integrates Jenkins with the following HPE products - Service Virtualization, LoadRunner, Performance Center, Unified Functional Testing, QuickTest Professional, Service Test, Mobile Center, Application Lifecycle Management and Application Lifecycle Management Octane.
From d72efb6ed6f6540a1a21f71ffaca90bf239c65c6 Mon Sep 17 00:00:00 2001
From: Yafim Kazak
Date: Tue, 4 Apr 2017 09:07:35 +0300
Subject: [PATCH 0041/2502] moved style files to main resources (#179)
fixed LRScript to support jenkins enviroment variabals
---
.../automation/tools/run/RunLRScript.java | 12 +++++++-----
src/main/resources/{lib/LR => }/LR_SCRIPT_REPORT.css | 0
src/main/resources/{lib/LR => }/PDetails.xsl | 4 ++--
3 files changed, 9 insertions(+), 7 deletions(-)
rename src/main/resources/{lib/LR => }/LR_SCRIPT_REPORT.css (100%)
rename src/main/resources/{lib/LR => }/PDetails.xsl (99%)
diff --git a/src/main/java/com/hp/application/automation/tools/run/RunLRScript.java b/src/main/java/com/hp/application/automation/tools/run/RunLRScript.java
index 74a2cb0b9f..8891000afa 100644
--- a/src/main/java/com/hp/application/automation/tools/run/RunLRScript.java
+++ b/src/main/java/com/hp/application/automation/tools/run/RunLRScript.java
@@ -53,8 +53,8 @@ public class RunLRScript extends Builder implements SimpleBuildStep {
public static final String LR_SCRIPT_HTML_REPORT_CSS = "PResults.css";
private static final String LINUX_MDRV_PATH = "/bin/mdrv";
private static final String WIN_MDRV_PATH = "\\bin\\mmdrv.exe";
- private static final String LR_SCRIPT_HTML_XSLT = "\\lib\\LR\\PDetails.xsl";
- private static final String LR_SCRIPT_HTML_CSS = "\\lib\\LR\\LR_SCRIPT_REPORT.css";
+ private static final String LR_SCRIPT_HTML_XSLT = "PDetails.xsl";
+ private static final String LR_SCRIPT_HTML_CSS = "LR_SCRIPT_REPORT.css";
private final String lrScriptPath;
private Jenkins jenkinsInstance;
private PrintStream logger;
@@ -77,12 +77,13 @@ public void perform(@Nonnull Run, ?> build, @Nonnull FilePath workspace, @Nonn
FilePath buildWorkDir = workspace.child(build.getId());
buildWorkDir.mkdirs();
buildWorkDir = buildWorkDir.absolutize();
- FilePath scriptPath = workspace.child(this.lrScriptPath);
-
+ env = build.getEnvironment(listener);
+ FilePath scriptPath = workspace.child(env.expand(this.lrScriptPath));
FilePath scriptWorkDir = buildWorkDir.child(scriptName);
scriptWorkDir.mkdirs();
scriptWorkDir = scriptWorkDir.absolutize();
- env = build.getEnvironment(listener);
+
+
if (runScriptMdrv(launcher, args, env, scriptPath, scriptWorkDir)) {
build.setResult(Result.FAILURE);
return;
@@ -125,6 +126,7 @@ public void perform(@Nonnull Run, ?> build, @Nonnull FilePath workspace, @Nonn
private FilePath copyXsltToNode(@Nonnull FilePath workspace) throws IOException, InterruptedException {
final URL xsltPath = jenkinsInstance.pluginManager.uberClassLoader.getResource(LR_SCRIPT_HTML_XSLT);
+ logger.println("loading XSLT from " + xsltPath.getFile());
FilePath xsltOnNode = workspace.child("resultsHtml.xslt");
if (!xsltOnNode.exists()) {
xsltOnNode.copyFrom(xsltPath);
diff --git a/src/main/resources/lib/LR/LR_SCRIPT_REPORT.css b/src/main/resources/LR_SCRIPT_REPORT.css
similarity index 100%
rename from src/main/resources/lib/LR/LR_SCRIPT_REPORT.css
rename to src/main/resources/LR_SCRIPT_REPORT.css
diff --git a/src/main/resources/lib/LR/PDetails.xsl b/src/main/resources/PDetails.xsl
similarity index 99%
rename from src/main/resources/lib/LR/PDetails.xsl
rename to src/main/resources/PDetails.xsl
index 879efb2a12..3f1377f183 100644
--- a/src/main/resources/lib/LR/PDetails.xsl
+++ b/src/main/resources/PDetails.xsl
@@ -1,5 +1,5 @@
-
+
From 5a753b070e65ad67d105e323ae944081c5dfc6d3 Mon Sep 17 00:00:00 2001
From: YafimK
Date: Tue, 4 Apr 2017 23:36:16 +0300
Subject: [PATCH 0042/2502] [maven-release-plugin] prepare release
hp-application-automation-tools-plugin-5.1.0.1-beta
---
pom.xml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/pom.xml b/pom.xml
index 6fd8a8d3df..c2449efcec 100644
--- a/pom.xml
+++ b/pom.xml
@@ -8,7 +8,7 @@
hp-application-automation-tools-plugin
- 5.1.0.1-beta-SNAPSHOT
+ 5.1.0.1-betahpiHP Application Automation ToolsThe plugin integrates Jenkins with the following HPE products - Service Virtualization, LoadRunner, Performance Center, Unified Functional Testing, QuickTest Professional, Service Test, Mobile Center, Application Lifecycle Management and Application Lifecycle Management Octane.
@@ -47,7 +47,7 @@
scm:git:ssh://git@github.com/hpsa/hp-application-automation-tools-plugin.git
https://github.com/hpsa/hp-application-automation-tools-plugin
- HEAD
+ hp-application-automation-tools-plugin-5.1.0.1-betaJIRA
From ab5b1dd1595d937e3fec4a8eeef07797a2f74dc1 Mon Sep 17 00:00:00 2001
From: YafimK
Date: Tue, 4 Apr 2017 23:36:28 +0300
Subject: [PATCH 0043/2502] [maven-release-plugin] prepare for next development
iteration
---
pom.xml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/pom.xml b/pom.xml
index c2449efcec..27802338cc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -8,7 +8,7 @@
hp-application-automation-tools-plugin
- 5.1.0.1-beta
+ 5.1.0.2-beta-SNAPSHOThpiHP Application Automation ToolsThe plugin integrates Jenkins with the following HPE products - Service Virtualization, LoadRunner, Performance Center, Unified Functional Testing, QuickTest Professional, Service Test, Mobile Center, Application Lifecycle Management and Application Lifecycle Management Octane.
@@ -47,7 +47,7 @@
scm:git:ssh://git@github.com/hpsa/hp-application-automation-tools-plugin.git
https://github.com/hpsa/hp-application-automation-tools-plugin
- hp-application-automation-tools-plugin-5.1.0.1-beta
+ HEADJIRA
From ca90fd9009f307eaed8233eadd1bf964d71c3846 Mon Sep 17 00:00:00 2001
From: radislavB
Date: Thu, 6 Apr 2017 14:55:21 +0300
Subject: [PATCH 0044/2502] fix discovery recursive job calling (#178)
* discovery recursive job calling
don't throw exception if fail to discover one of the jobs
* don't throw exception if fail to discover one of the jobs - fix defect
* add javaDoc
---
.../tools/octane/CIJenkinsServicesImpl.java | 58 +++--
.../builders/AbstractBuilderProcessor.java | 20 +-
.../builders/BuildTriggerProcessor.java | 13 +-
.../builders/MultiJobBuilderProcessor.java | 19 +-
.../ParameterizedTriggerProcessor.java | 16 +-
.../projects/AbstractProjectProcessor.java | 230 +++++++++++-------
.../projects/FreeStyleProjectProcessor.java | 14 +-
.../projects/JobProcessorFactory.java | 19 +-
.../projects/MatrixProjectProcessor.java | 14 +-
.../projects/MavenProjectProcessor.java | 16 +-
.../projects/MultiJobProjectProcessor.java | 14 +-
11 files changed, 239 insertions(+), 194 deletions(-)
diff --git a/src/main/java/com/hp/application/automation/tools/octane/CIJenkinsServicesImpl.java b/src/main/java/com/hp/application/automation/tools/octane/CIJenkinsServicesImpl.java
index 75cf55d563..c0ae883ab3 100644
--- a/src/main/java/com/hp/application/automation/tools/octane/CIJenkinsServicesImpl.java
+++ b/src/main/java/com/hp/application/automation/tools/octane/CIJenkinsServicesImpl.java
@@ -66,6 +66,9 @@
import java.util.Set;
import java.util.regex.Pattern;
+/**
+ * Base implementation of SPI(service provider interface) of Octane CI SDK for Jenkins
+ */
public class CIJenkinsServicesImpl implements CIPluginServices {
private static final Logger logger = LogManager.getLogger(CIJenkinsServicesImpl.class);
private static final DTOFactory dtoFactory = DTOFactory.getInstance();
@@ -158,36 +161,45 @@ public CIJobsList getJobsList(boolean includeParameters) {
List itemNames = (List) Jenkins.getInstance().getTopLevelItemNames();
for (String name : itemNames) {
tmpItem = Jenkins.getInstance().getItem(name);
- if (tmpItem instanceof AbstractProject) {
- AbstractProject abstractProject = (AbstractProject) tmpItem;
- tmpConfig = dtoFactory.newDTO(PipelineNode.class)
- .setJobCiId(JobProcessorFactory.getFlowProcessor(abstractProject).getJobCiId())
- .setName(name);
- if (includeParameters) {
- tmpConfig.setParameters(ParameterProcessors.getConfigs(abstractProject));
- }
- list.add(tmpConfig);
- } else if (tmpItem.getClass().getName().equals("org.jenkinsci.plugins.workflow.job.WorkflowJob")) {
- Job tmpJob = (Job) tmpItem;
- tmpConfig = dtoFactory.newDTO(PipelineNode.class)
- .setJobCiId(JobProcessorFactory.getFlowProcessor(tmpJob).getJobCiId())
- .setName(name);
- if (includeParameters) {
- tmpConfig.setParameters(ParameterProcessors.getConfigs(tmpJob));
- }
- list.add(tmpConfig);
- } else if (tmpItem.getClass().getName().equals("com.cloudbees.hudson.plugins.folder.Folder")) {
- for (Job tmpJob : tmpItem.getAllJobs()) {
+
+ try {
+ if (tmpItem instanceof AbstractProject) {
+ AbstractProject abstractProject = (AbstractProject) tmpItem;
+ if (abstractProject.isDisabled()) {
+ continue;
+ }
+ tmpConfig = dtoFactory.newDTO(PipelineNode.class)
+ .setJobCiId(JobProcessorFactory.getFlowProcessor(abstractProject).getJobCiId())
+ .setName(name);
+ if (includeParameters) {
+ tmpConfig.setParameters(ParameterProcessors.getConfigs(abstractProject));
+ }
+ list.add(tmpConfig);
+ } else if (tmpItem.getClass().getName().equals("org.jenkinsci.plugins.workflow.job.WorkflowJob")) {
+ Job tmpJob = (Job) tmpItem;
tmpConfig = dtoFactory.newDTO(PipelineNode.class)
.setJobCiId(JobProcessorFactory.getFlowProcessor(tmpJob).getJobCiId())
- .setName(tmpJob.getName());
+ .setName(name);
if (includeParameters) {
tmpConfig.setParameters(ParameterProcessors.getConfigs(tmpJob));
}
list.add(tmpConfig);
+ } else if (tmpItem.getClass().getName().equals("com.cloudbees.hudson.plugins.folder.Folder")) {
+ for (Job tmpJob : tmpItem.getAllJobs()) {
+ tmpConfig = dtoFactory.newDTO(PipelineNode.class)
+ .setJobCiId(JobProcessorFactory.getFlowProcessor(tmpJob).getJobCiId())
+ .setName(tmpJob.getName());
+ if (includeParameters) {
+ tmpConfig.setParameters(ParameterProcessors.getConfigs(tmpJob));
+ }
+ list.add(tmpConfig);
+ }
+ } else {
+ logger.info("item '" + name + "' is not of supported type");
}
- } else {
- logger.info("item '" + name + "' is not of supported type");
+ } catch (Throwable e) {
+ logger.error("Failed to add job '" + name + "' to JobList : " + e.getClass().getCanonicalName() + " - " + e.getMessage(), e);
+ //throw e;
}
}
diff --git a/src/main/java/com/hp/application/automation/tools/octane/model/processors/builders/AbstractBuilderProcessor.java b/src/main/java/com/hp/application/automation/tools/octane/model/processors/builders/AbstractBuilderProcessor.java
index 5e43314224..55ff10157a 100644
--- a/src/main/java/com/hp/application/automation/tools/octane/model/processors/builders/AbstractBuilderProcessor.java
+++ b/src/main/java/com/hp/application/automation/tools/octane/model/processors/builders/AbstractBuilderProcessor.java
@@ -23,17 +23,17 @@
import java.util.List;
/**
- * Created with IntelliJ IDEA.
- * User: gullery
- * Date: 09/01/15
- * Time: 00:59
- * To change this template use File | Settings | File Templates.
+ * Base class for discovery/provisioning of an internal phases/steps of the specific Job
*/
-
public abstract class AbstractBuilderProcessor {
- protected ArrayList phases = new ArrayList();
+ protected ArrayList phases = new ArrayList<>();
- public List getPhases() {
- return phases;
- }
+ /**
+ * Retrieves previously processed and prepared phases of the specific Builder (Jenkins' internal Job invoker)
+ *
+ * @return list of phases
+ */
+ public List getPhases() {
+ return phases;
+ }
}
diff --git a/src/main/java/com/hp/application/automation/tools/octane/model/processors/builders/BuildTriggerProcessor.java b/src/main/java/com/hp/application/automation/tools/octane/model/processors/builders/BuildTriggerProcessor.java
index a9c2c4ba4b..6eaac3388b 100644
--- a/src/main/java/com/hp/application/automation/tools/octane/model/processors/builders/BuildTriggerProcessor.java
+++ b/src/main/java/com/hp/application/automation/tools/octane/model/processors/builders/BuildTriggerProcessor.java
@@ -18,6 +18,7 @@
import com.hp.application.automation.tools.octane.model.ModelFactory;
import hudson.model.AbstractProject;
+import hudson.model.Job;
import hudson.tasks.BuildTrigger;
import hudson.tasks.Publisher;
import org.apache.logging.log4j.LogManager;
@@ -26,25 +27,21 @@
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+import java.util.Set;
/**
- * Created with IntelliJ IDEA.
- * User: gullery
- * Date: 08/01/15
- * Time: 23:01
- * To change this template use File | Settings | File Templates.
+ * Implementation for discovery/provisioning of an internal phases/steps of the specific Job in context of BuildTrigger
*/
-
public class BuildTriggerProcessor extends AbstractBuilderProcessor {
private static final Logger logger = LogManager.getLogger(BuildTriggerProcessor.class);
- public BuildTriggerProcessor(Publisher publisher, AbstractProject project) {
+ public BuildTriggerProcessor(Publisher publisher, AbstractProject project, Set processedJobs) {
BuildTrigger t = (BuildTrigger) publisher;
super.phases = new ArrayList<>();
List items = t.getChildProjects(project.getParent());
for (Iterator iterator = items.iterator(); iterator.hasNext(); ) {
AbstractProject next = iterator.next();
- if (next == null) {
+ if (next == null || processedJobs.contains(next)) {
iterator.remove();
logger.warn("encountered null project reference; considering it as corrupted configuration and skipping");
}
diff --git a/src/main/java/com/hp/application/automation/tools/octane/model/processors/builders/MultiJobBuilderProcessor.java b/src/main/java/com/hp/application/automation/tools/octane/model/processors/builders/MultiJobBuilderProcessor.java
index 08769dcda2..17d8eb1806 100644
--- a/src/main/java/com/hp/application/automation/tools/octane/model/processors/builders/MultiJobBuilderProcessor.java
+++ b/src/main/java/com/hp/application/automation/tools/octane/model/processors/builders/MultiJobBuilderProcessor.java
@@ -20,6 +20,7 @@
import com.tikal.jenkins.plugins.multijob.MultiJobBuilder;
import com.tikal.jenkins.plugins.multijob.PhaseJobsConfig;
import hudson.model.AbstractProject;
+import hudson.model.Job;
import hudson.tasks.Builder;
import jenkins.model.Jenkins;
import org.apache.logging.log4j.LogManager;
@@ -27,29 +28,27 @@
import java.util.ArrayList;
import java.util.List;
+import java.util.Set;
/**
- * Created with IntelliJ IDEA.
- * User: gullery
- * Date: 08/01/15
- * Time: 23:02
- * To change this template use File | Settings | File Templates.
+ * Implementation for discovery/provisioning of an internal phases/steps of the specific Job in context of MultiJob Plugin
*/
-
public class MultiJobBuilderProcessor extends AbstractBuilderProcessor {
private static final Logger logger = LogManager.getLogger(MultiJobBuilderProcessor.class);
- public MultiJobBuilderProcessor(Builder builder) {
+ public MultiJobBuilderProcessor(Builder builder, Set processedJobs) {
MultiJobBuilder b = (MultiJobBuilder) builder;
super.phases = new ArrayList<>();
List items = new ArrayList<>();
AbstractProject tmpProject;
for (PhaseJobsConfig config : b.getPhaseJobs()) {
tmpProject = (AbstractProject) Jenkins.getInstance().getItem(config.getJobName());
- if (tmpProject != null) {
- items.add(tmpProject);
- } else {
+ if (tmpProject == null) {
logger.warn("project named '" + config.getJobName() + "' not found; considering this as corrupted configuration and skipping the project");
+ } else if (processedJobs.contains(tmpProject)) {
+ logger.warn("project named '" + config.getJobName() + "' is duplicated");
+ } else {
+ items.add(tmpProject);
}
}
super.phases.add(ModelFactory.createStructurePhase(b.getPhaseName(), true, items));
diff --git a/src/main/java/com/hp/application/automation/tools/octane/model/processors/builders/ParameterizedTriggerProcessor.java b/src/main/java/com/hp/application/automation/tools/octane/model/processors/builders/ParameterizedTriggerProcessor.java
index 7ef4f743d4..789f14a03d 100644
--- a/src/main/java/com/hp/application/automation/tools/octane/model/processors/builders/ParameterizedTriggerProcessor.java
+++ b/src/main/java/com/hp/application/automation/tools/octane/model/processors/builders/ParameterizedTriggerProcessor.java
@@ -31,19 +31,15 @@
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+import java.util.Set;
/**
- * Created with IntelliJ IDEA.
- * User: gullery
- * Date: 08/01/15
- * Time: 23:01
- * To change this template use File | Settings | File Templates.
+ * Implementation for discovery/provisioning of an internal phases/steps of the specific Job in context of ParameterizedTrigger Plugin
*/
-
public class ParameterizedTriggerProcessor extends AbstractBuilderProcessor {
private static final Logger logger = LogManager.getLogger(ParameterizedTriggerProcessor.class);
- public ParameterizedTriggerProcessor(Builder builder, Job job, String phasesName) {
+ public ParameterizedTriggerProcessor(Builder builder, Job job, String phasesName, Set processedJobs) {
TriggerBuilder b = (TriggerBuilder) builder;
super.phases = new ArrayList<>();
List items;
@@ -51,7 +47,7 @@ public ParameterizedTriggerProcessor(Builder builder, Job job, String phasesName
items = config.getProjectList(job.getParent(), null);
for (Iterator iterator = items.iterator(); iterator.hasNext(); ) {
AbstractProject next = iterator.next();
- if (next == null) {
+ if (next == null || processedJobs.contains(next)) {
iterator.remove();
logger.warn("encountered null project reference; considering it as corrupted configuration and skipping");
}
@@ -60,7 +56,7 @@ public ParameterizedTriggerProcessor(Builder builder, Job job, String phasesName
}
}
- public ParameterizedTriggerProcessor(Publisher publisher, AbstractProject project, String phasesName) {
+ public ParameterizedTriggerProcessor(Publisher publisher, AbstractProject project, String phasesName, Set processedJobs) {
BuildTrigger t = (BuildTrigger) publisher;
super.phases = new ArrayList<>();
List items;
@@ -68,7 +64,7 @@ public ParameterizedTriggerProcessor(Publisher publisher, AbstractProject projec
items = config.getProjectList(project.getParent(), null);
for (Iterator iterator = items.iterator(); iterator.hasNext(); ) {
AbstractProject next = iterator.next();
- if (next == null) {
+ if (next == null || processedJobs.contains(next)) {
iterator.remove();
logger.warn("encountered null project reference; considering it as corrupted configuration and skipping");
}
diff --git a/src/main/java/com/hp/application/automation/tools/octane/model/processors/projects/AbstractProjectProcessor.java b/src/main/java/com/hp/application/automation/tools/octane/model/processors/projects/AbstractProjectProcessor.java
index 243735759f..5407359b78 100644
--- a/src/main/java/com/hp/application/automation/tools/octane/model/processors/projects/AbstractProjectProcessor.java
+++ b/src/main/java/com/hp/application/automation/tools/octane/model/processors/projects/AbstractProjectProcessor.java
@@ -16,11 +16,11 @@
package com.hp.application.automation.tools.octane.model.processors.projects;
-import com.hp.octane.integrations.dto.pipelines.PipelinePhase;
import com.hp.application.automation.tools.octane.model.processors.builders.AbstractBuilderProcessor;
import com.hp.application.automation.tools.octane.model.processors.builders.BuildTriggerProcessor;
import com.hp.application.automation.tools.octane.model.processors.builders.MultiJobBuilderProcessor;
import com.hp.application.automation.tools.octane.model.processors.builders.ParameterizedTriggerProcessor;
+import com.hp.octane.integrations.dto.pipelines.PipelinePhase;
import hudson.model.AbstractProject;
import hudson.model.Job;
import hudson.tasks.BuildStep;
@@ -33,6 +33,7 @@
import java.util.ArrayList;
import java.util.List;
+import java.util.Set;
/**
* Created with IntelliJ IDEA.
@@ -42,95 +43,142 @@
* To change this template use File | Settings | File Templates.
*/
-@SuppressWarnings({"squid:S1132","squid:S1872"})
+@SuppressWarnings({"squid:S1132", "squid:S1872"})
public abstract class AbstractProjectProcessor {
- private static final Logger logger = LogManager.getLogger(AbstractProjectProcessor.class);
- private final List internals = new ArrayList<>();
- private final List postBuilds = new ArrayList<>();
-
- T job;
-
- AbstractProjectProcessor(T job) {
- this.job = job;
- }
-
- // PUBLIC APIs
- //
- public abstract List tryGetBuilders();
-
- public abstract void scheduleBuild(String parametersBody);
-
- public String getJobCiId() {
- if (job.getParent().getClass().getName().equals("com.cloudbees.hudson.plugins.folder.Folder")) {
- String jobPlainName = job.getFullName(); // e.g: myFolder/myJob
- return jobPlainName.replaceAll("/", "/job/");
- } else {
- return job.getName();
- }
- }
-
- public List getInternals() {
- return internals;
- }
-
- public List getPostBuilds() {
- return postBuilds;
- }
-
- // INTERNALS
- //
- void processBuilders(List builders, Job job) {
- this.processBuilders(builders, job, "");
- }
-
- void processBuilders(List builders, Job job, String phasesName) {
- for (Builder builder : builders) {
- builderClassValidator(builder, job, phasesName);
- }
- }
-
- @SuppressWarnings("unchecked")
- void processPublishers(Job job) {
- if (job instanceof AbstractProject) {
- AbstractProject project = (AbstractProject) job;
- AbstractBuilderProcessor builderProcessor;
- List publishers = project.getPublishersList();
- for (Publisher publisher : publishers) {
- builderProcessor = null;
- if (publisher.getClass().getName().equals("hudson.tasks.BuildTrigger")) {
- builderProcessor = new BuildTriggerProcessor(publisher, project);
- } else if (publisher.getClass().getName().equals("hudson.plugins.parameterizedtrigger.BuildTrigger")) {
- builderProcessor = new ParameterizedTriggerProcessor(publisher, project, "");
- }
- if (builderProcessor != null) {
- postBuilds.addAll(builderProcessor.getPhases());
- } else {
- logger.debug("not yet supported publisher (post build) action: " + publisher.getClass().getName());
- }
- }
- }
- }
-
- private void builderClassValidator(Builder builder, Job job, String phasesName) {
- AbstractBuilderProcessor builderProcessor = null;
- if (builder.getClass().getName().equals("org.jenkinsci.plugins.conditionalbuildstep.ConditionalBuilder")) {
- ConditionalBuilder conditionalBuilder = (ConditionalBuilder) builder;
- for (BuildStep currentBuildStep : conditionalBuilder.getConditionalbuilders()) {
- builderClassValidator((Builder) currentBuildStep, job, phasesName);
- }
- } else if (builder.getClass().getName().equals("org.jenkinsci.plugins.conditionalbuildstep.singlestep.SingleConditionalBuilder")) {
- SingleConditionalBuilder singleConditionalBuilder = (SingleConditionalBuilder) builder;
- builderClassValidator((Builder) singleConditionalBuilder.getBuildStep(), job, phasesName);
- } else if (builder.getClass().getName().equals("hudson.plugins.parameterizedtrigger.TriggerBuilder")) {
- builderProcessor = new ParameterizedTriggerProcessor(builder, job, phasesName);
- } else if (builder.getClass().getName().equals("com.tikal.jenkins.plugins.multijob.MultiJobBuilder")) {
- builderProcessor = new MultiJobBuilderProcessor(builder);
- }
-
- if (builderProcessor != null) {
- internals.addAll(builderProcessor.getPhases());
- } else {
- logger.debug("not yet supported build (internal) action: " + builder.getClass().getName());
- }
- }
+ private static final Logger logger = LogManager.getLogger(AbstractProjectProcessor.class);
+ private final List internals = new ArrayList<>();
+ private final List postBuilds = new ArrayList<>();
+
+ T job;
+
+ AbstractProjectProcessor(T job) {
+ this.job = job;
+ }
+
+ /**
+ * Attempt to retrieve an [internal] build phases of the Job
+ *
+ * @return
+ */
+ public abstract List tryGetBuilders();
+
+ /**
+ * Enqueue Job's run with the specified parameters
+ *
+ * @param parametersBody parameters for the Job execution in a RAW JSON format
+ */
+ public abstract void scheduleBuild(String parametersBody);
+
+ /**
+ * Retrieve Job's CI ID
+ *
+ * @return Job's CI ID
+ */
+ public String getJobCiId() {
+ if (job.getParent().getClass().getName().equals("com.cloudbees.hudson.plugins.folder.Folder")) {
+ String jobPlainName = job.getFullName(); // e.g: myFolder/myJob
+ return jobPlainName.replaceAll("/", "/job/");
+ } else {
+ return job.getName();
+ }
+ }
+
+ /**
+ * Discover an internal phases of the Job
+ *
+ * @return list of phases
+ */
+ public List getInternals() {
+ return internals;
+ }
+
+ /**
+ * Discover a post build phases of the Job
+ *
+ * @return list of phases
+ */
+ public List getPostBuilds() {
+ return postBuilds;
+ }
+
+ /**
+ * Internal API
+ * Processes and prepares Job's children for future use - internal flow
+ *
+ * @param builders Job's builders
+ * @param job Job to process
+ * @param processedJobs previously processed Jobs in this Job's hierarchical chain in order to break the recursive flows
+ */
+ void processBuilders(List builders, Job job, Set processedJobs) {
+ this.processBuilders(builders, job, "", processedJobs);
+ }
+
+ /**
+ * Internal API
+ * Processes and prepares Job's children for future use - internal flow
+ *
+ * @param builders Job's builders
+ * @param job Job to process
+ * @param phasesName Targeted phase name in case of available one
+ * @param processedJobs previously processed Jobs in this Job's hierarchical chain in order to break the recursive flows
+ */
+ void processBuilders(List builders, Job job, String phasesName, Set processedJobs) {
+ for (Builder builder : builders) {
+ builderClassValidator(builder, job, phasesName, processedJobs);
+ }
+ }
+
+ /**
+ * Internal API
+ * Processes and prepares Job's children for future use - post build flow
+ *
+ * @param job Job to process
+ * @param processedJobs previously processed Jobs in this Job's hierarchical chain in order to break the recursive flows
+ */
+ @SuppressWarnings("unchecked")
+ void processPublishers(Job job, Set processedJobs) {
+ if (job instanceof AbstractProject) {
+ AbstractProject project = (AbstractProject) job;
+ processedJobs.add(job);
+ AbstractBuilderProcessor builderProcessor;
+ List publishers = project.getPublishersList();
+ for (Publisher publisher : publishers) {
+ builderProcessor = null;
+ if (publisher.getClass().getName().equals("hudson.tasks.BuildTrigger")) {
+ builderProcessor = new BuildTriggerProcessor(publisher, project, processedJobs);
+ } else if (publisher.getClass().getName().equals("hudson.plugins.parameterizedtrigger.BuildTrigger")) {
+ builderProcessor = new ParameterizedTriggerProcessor(publisher, project, "", processedJobs);
+ }
+ if (builderProcessor != null) {
+ postBuilds.addAll(builderProcessor.getPhases());
+ } else {
+ logger.debug("not yet supported publisher (post build) action: " + publisher.getClass().getName());
+ }
+ }
+ }
+ }
+
+ private void builderClassValidator(Builder builder, Job job, String phasesName, Set processedJobs) {
+ processedJobs.add(job);
+ AbstractBuilderProcessor builderProcessor = null;
+ if (builder.getClass().getName().equals("org.jenkinsci.plugins.conditionalbuildstep.ConditionalBuilder")) {
+ ConditionalBuilder conditionalBuilder = (ConditionalBuilder) builder;
+ for (BuildStep currentBuildStep : conditionalBuilder.getConditionalbuilders()) {
+ builderClassValidator((Builder) currentBuildStep, job, phasesName, processedJobs);
+ }
+ } else if (builder.getClass().getName().equals("org.jenkinsci.plugins.conditionalbuildstep.singlestep.SingleConditionalBuilder")) {
+ SingleConditionalBuilder singleConditionalBuilder = (SingleConditionalBuilder) builder;
+ builderClassValidator((Builder) singleConditionalBuilder.getBuildStep(), job, phasesName, processedJobs);
+ } else if (builder.getClass().getName().equals("hudson.plugins.parameterizedtrigger.TriggerBuilder")) {
+ builderProcessor = new ParameterizedTriggerProcessor(builder, job, phasesName, processedJobs);
+ } else if (builder.getClass().getName().equals("com.tikal.jenkins.plugins.multijob.MultiJobBuilder")) {
+ builderProcessor = new MultiJobBuilderProcessor(builder, processedJobs);
+ }
+
+ if (builderProcessor != null) {
+ internals.addAll(builderProcessor.getPhases());
+ } else {
+ logger.debug("not yet supported build (internal) action: " + builder.getClass().getName());
+ }
+ }
}
diff --git a/src/main/java/com/hp/application/automation/tools/octane/model/processors/projects/FreeStyleProjectProcessor.java b/src/main/java/com/hp/application/automation/tools/octane/model/processors/projects/FreeStyleProjectProcessor.java
index d1b572ac83..382a29e817 100644
--- a/src/main/java/com/hp/application/automation/tools/octane/model/processors/projects/FreeStyleProjectProcessor.java
+++ b/src/main/java/com/hp/application/automation/tools/octane/model/processors/projects/FreeStyleProjectProcessor.java
@@ -21,27 +21,23 @@
import hudson.tasks.Builder;
import java.util.List;
+import java.util.Set;
/**
- * Created with IntelliJ IDEA.
- * User: gullery
- * Date: 24/12/14
- * Time: 13:47
- * To change this template use File | Settings | File Templates.
+ * Implementation for discovery/provisioning of an internal phases/steps of the specific FreeStyleProject
*/
-
class FreeStyleProjectProcessor extends AbstractProjectProcessor {
- FreeStyleProjectProcessor(Job job) {
+ FreeStyleProjectProcessor(Job job, Set processedJobs) {
super((FreeStyleProject) job);
// Internal phases
//
- super.processBuilders(this.job.getBuilders(), this.job);
+ super.processBuilders(this.job.getBuilders(), this.job, processedJobs);
// Post build phases
//
- super.processPublishers(this.job);
+ super.processPublishers(this.job, processedJobs);
}
@Override
diff --git a/src/main/java/com/hp/application/automation/tools/octane/model/processors/projects/JobProcessorFactory.java b/src/main/java/com/hp/application/automation/tools/octane/model/processors/projects/JobProcessorFactory.java
index ce4329f400..e4dbd66d01 100644
--- a/src/main/java/com/hp/application/automation/tools/octane/model/processors/projects/JobProcessorFactory.java
+++ b/src/main/java/com/hp/application/automation/tools/octane/model/processors/projects/JobProcessorFactory.java
@@ -18,6 +18,9 @@
import hudson.model.Job;
+import java.util.HashSet;
+import java.util.Set;
+
/**
* Created by gadiel on 30/11/2016.
*
@@ -29,17 +32,23 @@ public class JobProcessorFactory {
private JobProcessorFactory() {
}
- public static AbstractProjectProcessor getFlowProcessor(T job) {
+ public static AbstractProjectProcessor getFlowProcessor(T job){
+ Set processedJobs = new HashSet<>();
+ return getFlowProcessor(job, processedJobs);
+ }
+
+ private static AbstractProjectProcessor getFlowProcessor(T job, Set processedJobs) {
AbstractProjectProcessor flowProcessor;
+ processedJobs.add(job);
if (job.getClass().getName().equals("hudson.model.FreeStyleProject")) {
- flowProcessor = new FreeStyleProjectProcessor(job);
+ flowProcessor = new FreeStyleProjectProcessor(job, processedJobs);
} else if (job.getClass().getName().equals("hudson.matrix.MatrixProject")) {
- flowProcessor = new MatrixProjectProcessor(job);
+ flowProcessor = new MatrixProjectProcessor(job, processedJobs);
} else if (job.getClass().getName().equals("hudson.maven.MavenModuleSet")) {
- flowProcessor = new MavenProjectProcessor(job);
+ flowProcessor = new MavenProjectProcessor(job, processedJobs);
} else if (job.getClass().getName().equals("com.tikal.jenkins.plugins.multijob.MultiJobProject")) {
- flowProcessor = new MultiJobProjectProcessor(job);
+ flowProcessor = new MultiJobProjectProcessor(job, processedJobs);
} else if (job.getClass().getName().equals("org.jenkinsci.plugins.workflow.job.WorkflowJob")) {
flowProcessor = new WorkFlowJobProcessor(job);
} else {
diff --git a/src/main/java/com/hp/application/automation/tools/octane/model/processors/projects/MatrixProjectProcessor.java b/src/main/java/com/hp/application/automation/tools/octane/model/processors/projects/MatrixProjectProcessor.java
index 30c8241190..c3bed2ba14 100644
--- a/src/main/java/com/hp/application/automation/tools/octane/model/processors/projects/MatrixProjectProcessor.java
+++ b/src/main/java/com/hp/application/automation/tools/octane/model/processors/projects/MatrixProjectProcessor.java
@@ -21,27 +21,23 @@
import hudson.tasks.Builder;
import java.util.List;
+import java.util.Set;
/**
- * Created with IntelliJ IDEA.
- * User: gullery
- * Date: 24/12/14
- * Time: 13:30
- * To change this template use File | Settings | File Templates.
+ * Implementation for discovery/provisioning of an internal phases/steps of the specific Job in context of MatrixProject Plugin
*/
-
class MatrixProjectProcessor extends AbstractProjectProcessor {
- MatrixProjectProcessor(Job project) {
+ MatrixProjectProcessor(Job project, Set processedJobs) {
super((MatrixProject) project);
// Internal phases
//
- super.processBuilders(this.job.getBuilders(), this.job);
+ super.processBuilders(this.job.getBuilders(), this.job, processedJobs);
// Post build phases
//
- super.processPublishers(this.job);
+ super.processPublishers(this.job, processedJobs);
}
@Override
diff --git a/src/main/java/com/hp/application/automation/tools/octane/model/processors/projects/MavenProjectProcessor.java b/src/main/java/com/hp/application/automation/tools/octane/model/processors/projects/MavenProjectProcessor.java
index 2fd11bea78..8e70f44f07 100644
--- a/src/main/java/com/hp/application/automation/tools/octane/model/processors/projects/MavenProjectProcessor.java
+++ b/src/main/java/com/hp/application/automation/tools/octane/model/processors/projects/MavenProjectProcessor.java
@@ -22,30 +22,26 @@
import java.util.ArrayList;
import java.util.List;
+import java.util.Set;
/**
- * Created with IntelliJ IDEA.
- * User: gullery
- * Date: 24/12/14
- * Time: 13:35
- * To change this template use File | Settings | File Templates.
+ * Implementation for discovery/provisioning of an internal phases/steps of the specific Job in context of Maven Plugin
*/
-
class MavenProjectProcessor extends AbstractProjectProcessor {
- MavenProjectProcessor(Job mavenJob) {
+ MavenProjectProcessor(Job mavenJob, Set processedJobs) {
super((MavenModuleSet) mavenJob);
// Internal phases - pre maven phases
//
- super.processBuilders(this.job.getPrebuilders(), this.job, "pre-maven");
+ super.processBuilders(this.job.getPrebuilders(), this.job, "pre-maven", processedJobs);
// Internal phases - post maven phases
//
- super.processBuilders(this.job.getPostbuilders(), this.job, "post-maven");
+ super.processBuilders(this.job.getPostbuilders(), this.job, "post-maven", processedJobs);
// Post build phases
//
- super.processPublishers(this.job);
+ super.processPublishers(this.job, processedJobs);
}
@Override
diff --git a/src/main/java/com/hp/application/automation/tools/octane/model/processors/projects/MultiJobProjectProcessor.java b/src/main/java/com/hp/application/automation/tools/octane/model/processors/projects/MultiJobProjectProcessor.java
index dac4959b62..488ec29970 100644
--- a/src/main/java/com/hp/application/automation/tools/octane/model/processors/projects/MultiJobProjectProcessor.java
+++ b/src/main/java/com/hp/application/automation/tools/octane/model/processors/projects/MultiJobProjectProcessor.java
@@ -21,26 +21,22 @@
import hudson.tasks.Builder;
import java.util.List;
+import java.util.Set;
/**
- * Created with IntelliJ IDEA.
- * User: gullery
- * Date: 24/12/14
- * Time: 13:40
- * To change this template use File | Settings | File Templates.
+ * Implementation for discovery/provisioning of an internal phases/steps of the specific Job in context of MultiJob Plugin
*/
-
class MultiJobProjectProcessor extends AbstractProjectProcessor {
- MultiJobProjectProcessor(Job job) {
+ MultiJobProjectProcessor(Job job, Set processedJobs) {
super((MultiJobProject) job);
// Internal phases
//
- super.processBuilders(this.job.getBuilders(), this.job);
+ super.processBuilders(this.job.getBuilders(), this.job, processedJobs);
// Post build phases
//
- super.processPublishers(this.job);
+ super.processPublishers(this.job, processedJobs);
}
@Override
From d56cf95d53422a40006e46fb7f401484ba95bb7f Mon Sep 17 00:00:00 2001
From: Jackzenko
Date: Fri, 7 Apr 2017 17:35:16 +0800
Subject: [PATCH 0045/2502] fixed Jenkins 20323 unable to run functional tests
from file system in normal mode (#154)
* added RunMode support in Launcher.exe
* added support for running UFT test on "Normal" mode to Jenkins
* fixed proper variable names to make more sense, changed text box to drop down list.
* variable name fix to avoid anbigous with almRunMode
* wrapped uft option in "UFT specific settings"
* created overloaded constructor for general constructor FileSystemTestsRunner()
* use overloaded FileSystemTestsRunner() constructor only if props file contains uftRunMode parameter
* sonar fix
---
HpToolsLauncher/Launcher.cs | 11 ++++-
.../Runners/FileSystemTestsRunner.cs | 46 +++++++++++++------
HpToolsLauncher/TestRunners/GuiTestRunner.cs | 6 ++-
.../tools/model/RunFromFileSystemModel.java | 45 +++++++++++++++++-
.../pipelineSteps/UftScenarioLoadStep.java | 36 +++++++++++++++
.../tools/run/RunFromFileBuilder.java | 14 +++++-
.../UftScenarioLoadStep/config.jelly | 13 +++++-
.../tools/run/RunFromFileBuilder/config.jelly | 15 ++++++
8 files changed, 164 insertions(+), 22 deletions(-)
diff --git a/HpToolsLauncher/Launcher.cs b/HpToolsLauncher/Launcher.cs
index 9670b05594..7b6d961c1d 100644
--- a/HpToolsLauncher/Launcher.cs
+++ b/HpToolsLauncher/Launcher.cs
@@ -507,7 +507,16 @@ IAssetRunner CreateRunner(TestStorageType runType, JavaProperties ciParams)
mobileinfo = _ciParams["mobileinfo"];
}
- runner = new FileSystemTestsRunner(validTests, timeout, pollingInterval, perScenarioTimeOutMinutes, ignoreErrorStrings, jenkinsEnvVariables, mcConnectionInfo, mobileinfo);
+ if (_ciParams.ContainsKey("fsUftRunMode"))
+ {
+ string uftRunMode = "Fast";
+ uftRunMode = _ciParams["fsUftRunMode"];
+ runner = new FileSystemTestsRunner(validTests, timeout, uftRunMode, pollingInterval, perScenarioTimeOutMinutes, ignoreErrorStrings, jenkinsEnvVariables, mcConnectionInfo, mobileinfo);
+ }
+ else
+ {
+ runner = new FileSystemTestsRunner(validTests, timeout, pollingInterval, perScenarioTimeOutMinutes, ignoreErrorStrings, jenkinsEnvVariables, mcConnectionInfo, mobileinfo);
+ }
break;
diff --git a/HpToolsLauncher/Runners/FileSystemTestsRunner.cs b/HpToolsLauncher/Runners/FileSystemTestsRunner.cs
index 337ab9f193..96485dba5b 100644
--- a/HpToolsLauncher/Runners/FileSystemTestsRunner.cs
+++ b/HpToolsLauncher/Runners/FileSystemTestsRunner.cs
@@ -23,6 +23,7 @@ public class FileSystemTestsRunner : RunnerBase, IDisposable
private int _errors, _fail;
private bool _useUFTLicense;
private TimeSpan _timeout = TimeSpan.MaxValue;
+ private readonly string _uftRunMode;
private Stopwatch _stopwatch = null;
private string _abortFilename = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\stop" + Launcher.UniqueTimeStamp + ".txt";
@@ -43,6 +44,29 @@ public class FileSystemTestsRunner : RunnerBase, IDisposable
#endregion
+ ///
+ /// overloaded constructor for adding support for run mode selection
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public FileSystemTestsRunner(List sources,
+ TimeSpan timeout,
+ string uftRunMode,
+ int ControllerPollingInterval,
+ TimeSpan perScenarioTimeOutMinutes,
+ List ignoreErrorStrings,
+ Dictionary jenkinsEnvVariables,
+ McConnectionInfo mcConnection,
+ string mobileInfo,
+ bool useUFTLicense = false)
+ :this(sources, timeout, ControllerPollingInterval, perScenarioTimeOutMinutes, ignoreErrorStrings, jenkinsEnvVariables, mcConnection, mobileInfo, useUFTLicense)
+ {
+ _uftRunMode = uftRunMode;
+ }
+
///
/// creates instance of the runner given a source.
///
@@ -51,15 +75,14 @@ public class FileSystemTestsRunner : RunnerBase, IDisposable
///
///
public FileSystemTestsRunner(List sources,
- TimeSpan timeout,
- int ControllerPollingInterval,
- TimeSpan perScenarioTimeOutMinutes,
- List ignoreErrorStrings,
- Dictionary jenkinsEnvVariables,
- McConnectionInfo mcConnection,
- string mobileInfo,
- bool useUFTLicense = false
- )
+ TimeSpan timeout,
+ int ControllerPollingInterval,
+ TimeSpan perScenarioTimeOutMinutes,
+ List ignoreErrorStrings,
+ Dictionary jenkinsEnvVariables,
+ McConnectionInfo mcConnection,
+ string mobileInfo,
+ bool useUFTLicense = false)
{
_jenkinsEnvVariables = jenkinsEnvVariables;
//search if we have any testing tools installed
@@ -155,9 +178,6 @@ public FileSystemTestsRunner(List sources,
ConsoleWriter.WriteLine(Resources.GeneralDoubleSeperator);
}
-
-
-
///
/// runs all tests given to this runner and returns a suite of run resutls
///
@@ -282,7 +302,7 @@ private TestRunResults RunHPToolsTest(TestInfo testinf, ref string errorReason)
runner = new ApiTestRunner(this, _timeout - _stopwatch.Elapsed);
break;
case TestType.QTP:
- runner = new GuiTestRunner(this, _useUFTLicense, _timeout - _stopwatch.Elapsed, _mcConnection, _mobileInfoForAllGuiTests);
+ runner = new GuiTestRunner(this, _useUFTLicense, _timeout - _stopwatch.Elapsed, _uftRunMode, _mcConnection, _mobileInfoForAllGuiTests);
break;
case TestType.LoadRunner:
AppDomain.CurrentDomain.AssemblyResolve += Helper.HPToolsAssemblyResolver;
diff --git a/HpToolsLauncher/TestRunners/GuiTestRunner.cs b/HpToolsLauncher/TestRunners/GuiTestRunner.cs
index 06f1621102..2266e25287 100644
--- a/HpToolsLauncher/TestRunners/GuiTestRunner.cs
+++ b/HpToolsLauncher/TestRunners/GuiTestRunner.cs
@@ -35,6 +35,7 @@ public class GuiTestRunner : IFileSysTestRunner
private readonly IAssetRunner _runNotifier;
private readonly object _lockObject = new object();
private TimeSpan _timeLeftUntilTimeout = TimeSpan.MaxValue;
+ private readonly string _uftRunMode;
private Stopwatch _stopwatch = null;
private Application _qtpApplication;
private ParameterDefinitions _qtpParamDefs;
@@ -49,9 +50,10 @@ public class GuiTestRunner : IFileSysTestRunner
///
///
///
- public GuiTestRunner(IAssetRunner runNotifier, bool useUftLicense, TimeSpan timeLeftUntilTimeout, McConnectionInfo mcConnectionInfo, string mobileInfo)
+ public GuiTestRunner(IAssetRunner runNotifier, bool useUftLicense, TimeSpan timeLeftUntilTimeout, string uftRunMode, McConnectionInfo mcConnectionInfo, string mobileInfo)
{
_timeLeftUntilTimeout = timeLeftUntilTimeout;
+ _uftRunMode = uftRunMode;
_stopwatch = Stopwatch.StartNew();
_runNotifier = runNotifier;
_useUFTLicense = useUftLicense;
@@ -386,7 +388,7 @@ private GuiTestRunResult ExecuteQTPRun(TestRunResults testResults)
Type runResultsOptionstype = Type.GetTypeFromProgID("QuickTest.RunResultsOptions");
var options = (RunResultsOptions)Activator.CreateInstance(runResultsOptionstype);
options.ResultsLocation = testResults.ReportLocation;
- _qtpApplication.Options.Run.RunMode = "Fast";
+ _qtpApplication.Options.Run.RunMode = _uftRunMode;
//Check for cancel before executing
if (_runCancelled())
diff --git a/src/main/java/com/hp/application/automation/tools/model/RunFromFileSystemModel.java b/src/main/java/com/hp/application/automation/tools/model/RunFromFileSystemModel.java
index 1c6bbf76fd..d0388c1092 100644
--- a/src/main/java/com/hp/application/automation/tools/model/RunFromFileSystemModel.java
+++ b/src/main/java/com/hp/application/automation/tools/model/RunFromFileSystemModel.java
@@ -14,6 +14,8 @@
import org.kohsuke.stapler.DataBoundConstructor;
import javax.annotation.Nullable;
+import java.util.Arrays;
+import java.util.List;
import java.util.Properties;
/**
@@ -25,8 +27,14 @@ public class RunFromFileSystemModel {
public static final String MOBILE_PROXY_SETTING_USER_NAME = "MobileProxySetting_UserName";
public static final String MOBILE_PROXY_SETTING_AUTHENTICATION = "MobileProxySetting_Authentication";
public static final String MOBILE_USE_SSL = "MobileUseSSL";
+
+ public final static EnumDescription FAST_RUN_MODE = new EnumDescription("Fast", "Fast");
+ public final static EnumDescription NORMAL_RUN_MODE = new EnumDescription("Normal", "Normal");
+ public final static List fsUftRunModes = Arrays.asList(FAST_RUN_MODE, NORMAL_RUN_MODE);
+
private String fsTests;
private String fsTimeout;
+ private String fsUftRunMode;
private String controllerPollingInterval;
private String perScenarioTimeOut;
private String ignoreErrorStrings;
@@ -72,7 +80,7 @@ public class RunFromFileSystemModel {
* @param useSSL the use ssl
*/
@SuppressWarnings("squid:S00107")
- public RunFromFileSystemModel(String fsTests, String fsTimeout, String controllerPollingInterval,String perScenarioTimeOut,
+ public RunFromFileSystemModel(String fsTests, String fsTimeout, String fsUftRunMode, String controllerPollingInterval,String perScenarioTimeOut,
String ignoreErrorStrings, String mcServerName, String fsUserName, String fsPassword,
String fsDeviceId, String fsTargetLab, String fsManufacturerAndModel, String fsOs,
String fsAutActions, String fsLaunchAppName, String fsDevicesMetrics, String fsInstrumented,
@@ -81,7 +89,7 @@ public RunFromFileSystemModel(String fsTests, String fsTimeout, String controlle
this.setFsTests(fsTests);
this.fsTimeout = fsTimeout;
-
+ this.fsUftRunMode = fsUftRunMode;
this.perScenarioTimeOut = perScenarioTimeOut;
this.controllerPollingInterval = controllerPollingInterval;
@@ -120,6 +128,7 @@ public RunFromFileSystemModel(String fsTests) {
//Init default vals
this.fsTimeout = "";
+ this.fsUftRunMode = "Fast";
this.controllerPollingInterval = "30";
this.perScenarioTimeOut = "10";
this.ignoreErrorStrings = "";
@@ -148,6 +157,15 @@ public void setFsTimeout(String fsTimeout) {
this.fsTimeout = fsTimeout;
}
+ /**
+ * Sets fs runMode.
+ *
+ * @param fsUftRunMode the fs runMode
+ */
+ public void setFsUftRunMode(String fsUftRunMode) {
+ this.fsUftRunMode = fsUftRunMode;
+ }
+
/**
* Sets mc server name.
*
@@ -301,6 +319,22 @@ public String getFsTimeout() {
return fsTimeout;
}
+ /**
+ * Gets fs runMode.
+ *
+ * @return the fs runMode
+ */
+ public String getFsUftRunMode() {
+ return fsUftRunMode;
+ }
+
+ /**
+ * Gets fs runModes
+ *
+ * @return the fs runModes
+ */
+ public List getFsUftRunModes() { return fsUftRunModes; }
+
/**
* Gets mc server name.
*
@@ -580,6 +614,13 @@ private Properties createProperties(EnvVars envVars) {
props.put("fsTimeout", "" + fsTimeout);
}
+ if (StringUtils.isEmpty(fsUftRunMode)){
+ props.put("fsUftRunMode", "Fast");
+ }
+ else{
+ props.put("fsUftRunMode", "" + fsUftRunMode);
+ }
+
if (StringUtils.isEmpty(controllerPollingInterval)){
props.put("controllerPollingInterval", "30");
diff --git a/src/main/java/com/hp/application/automation/tools/pipelineSteps/UftScenarioLoadStep.java b/src/main/java/com/hp/application/automation/tools/pipelineSteps/UftScenarioLoadStep.java
index d0f5a2f476..96068cf598 100644
--- a/src/main/java/com/hp/application/automation/tools/pipelineSteps/UftScenarioLoadStep.java
+++ b/src/main/java/com/hp/application/automation/tools/pipelineSteps/UftScenarioLoadStep.java
@@ -25,6 +25,7 @@
import com.hp.application.automation.tools.model.EnumDescription;
import com.hp.application.automation.tools.model.ResultsPublisherModel;
+import com.hp.application.automation.tools.model.RunFromFileSystemModel;
import com.hp.application.automation.tools.results.RunResultRecorder;
import com.hp.application.automation.tools.run.RunFromFileBuilder;
import hudson.Extension;
@@ -89,6 +90,34 @@ public void setFsTimeout(String fsTimeout) {
runFromFileBuilder.setFsTimeout(fsTimeout);
}
+ /**
+ * Gets fsUftRunMode
+ *
+ * @return fsUftRunMode value
+ */
+ public String getFsUftRunMode() {
+ return runFromFileBuilder.getRunFromFileModel().getFsUftRunMode();
+ }
+
+ /**
+ * Sets fsUftRunMode value
+ *
+ * @param fsUftRunMode the fsUftRunMode value
+ */
+ @DataBoundSetter
+ public void setFsUftRunMode(String fsUftRunMode) {
+ runFromFileBuilder.setFsUftRunMode(fsUftRunMode);
+ }
+
+ /**
+ * Gets fsUftRunModes
+ *
+ * @return fsUftRunModes value
+ */
+ public List getFsUftRunModes() {
+ return RunFromFileSystemModel.fsUftRunModes;
+ }
+
/**
* Gets test paths.
*
@@ -141,6 +170,13 @@ public String getDisplayName() {
return "Run UFT scenario";
}
+ /**
+ * Gets fs runModes
+ *
+ * @return the fs runModes
+ */
+ public List getFsUftRunModes() { return RunFromFileSystemModel.fsUftRunModes; }
+
/**
* Gets report archive modes.
*
diff --git a/src/main/java/com/hp/application/automation/tools/run/RunFromFileBuilder.java b/src/main/java/com/hp/application/automation/tools/run/RunFromFileBuilder.java
index c50b2084fd..a05155d0fb 100644
--- a/src/main/java/com/hp/application/automation/tools/run/RunFromFileBuilder.java
+++ b/src/main/java/com/hp/application/automation/tools/run/RunFromFileBuilder.java
@@ -111,12 +111,12 @@ public RunFromFileBuilder(RunFromFileSystemModel runFromFileModel) {
*/
@SuppressWarnings("squid:S00107")
@Deprecated
- public RunFromFileBuilder(String fsTests, String fsTimeout, String controllerPollingInterval,
+ public RunFromFileBuilder(String fsTests, String fsTimeout, String fsUftRunMode, String controllerPollingInterval,
String perScenarioTimeOut, String ignoreErrorStrings, String mcServerName, String fsUserName, String fsPassword, String fsDeviceId, String fsTargetLab,
String fsManufacturerAndModel, String fsOs, String fsAutActions, String fsLaunchAppName, String fsDevicesMetrics, String fsInstrumented, String fsExtraApps, String fsJobId,
ProxySettings proxySettings, boolean useSSL) {
- runFromFileModel = new RunFromFileSystemModel(fsTests, fsTimeout, controllerPollingInterval,
+ runFromFileModel = new RunFromFileSystemModel(fsTests, fsTimeout, fsUftRunMode, controllerPollingInterval,
perScenarioTimeOut, ignoreErrorStrings, mcServerName, fsUserName, fsPassword, fsDeviceId, fsTargetLab, fsManufacturerAndModel, fsOs, fsAutActions, fsLaunchAppName,
fsDevicesMetrics, fsInstrumented, fsExtraApps, fsJobId, proxySettings, useSSL);
}
@@ -170,6 +170,16 @@ public void setFsTimeout(String fsTimeout) {
runFromFileModel.setFsTimeout(fsTimeout);
}
+ /**
+ * Sets fs runMode.
+ *
+ * @param fsUftRunMode the fs runMode
+ */
+ @DataBoundSetter
+ public void setFsUftRunMode(String fsUftRunMode) {
+ runFromFileModel.setFsUftRunMode(fsUftRunMode);
+ }
+
/**
* Sets mc server name.
*
diff --git a/src/main/resources/com/hp/application/automation/tools/pipelineSteps/UftScenarioLoadStep/config.jelly b/src/main/resources/com/hp/application/automation/tools/pipelineSteps/UftScenarioLoadStep/config.jelly
index c1c1648d2f..e7708f14f5 100644
--- a/src/main/resources/com/hp/application/automation/tools/pipelineSteps/UftScenarioLoadStep/config.jelly
+++ b/src/main/resources/com/hp/application/automation/tools/pipelineSteps/UftScenarioLoadStep/config.jelly
@@ -31,11 +31,20 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/resources/com/hp/application/automation/tools/octane/actions/UFTTestDetectionPublisher/config.jelly b/src/main/resources/com/hp/application/automation/tools/octane/actions/UFTTestDetectionPublisher/config.jelly
index 9544040c52..062bff98ec 100644
--- a/src/main/resources/com/hp/application/automation/tools/octane/actions/UFTTestDetectionPublisher/config.jelly
+++ b/src/main/resources/com/hp/application/automation/tools/octane/actions/UFTTestDetectionPublisher/config.jelly
@@ -12,8 +12,12 @@
-->
-
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/resources/com/hp/application/automation/tools/octane/actions/UFTTestDetectionPublisher/help-workspaceName.html b/src/main/resources/com/hp/application/automation/tools/octane/actions/UFTTestDetectionPublisher/help-workspaceName.html
deleted file mode 100644
index bd659d82bf..0000000000
--- a/src/main/resources/com/hp/application/automation/tools/octane/actions/UFTTestDetectionPublisher/help-workspaceName.html
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
- Select Workspace name to assign the detected UFT tests to.
-
From 6a908c416da87dfb3a92bad23d65022c2fa3903f Mon Sep 17 00:00:00 2001
From: radislavB
Date: Thu, 11 May 2017 13:31:46 +0300
Subject: [PATCH 0056/2502] Improvements in ExecutorConnectivityService (#189)
* create credentials + code review with radi fixes + add http statuses enum class
* before deleteExecutor print to log that job is going to be deleted
* adding comments and license details
* add possibility to change getOutdateThreshold by SystemProperty
---
pom.xml | 2 +-
.../automation/tools/common/HttpStatus.java | 76 +++++++++
.../tools/octane/CIJenkinsServicesImpl.java | 11 +-
.../executor/ExecutorConnTestService.java | 118 --------------
.../executor/ExecutorConnectivityService.java | 153 ++++++++++++++++++
.../TestExecutionJobCreatorService.java | 1 +
.../tools/octane/executor/UftJobCleaner.java | 15 +-
7 files changed, 250 insertions(+), 126 deletions(-)
create mode 100644 src/main/java/com/hp/application/automation/tools/common/HttpStatus.java
delete mode 100644 src/main/java/com/hp/application/automation/tools/octane/executor/ExecutorConnTestService.java
create mode 100644 src/main/java/com/hp/application/automation/tools/octane/executor/ExecutorConnectivityService.java
diff --git a/pom.xml b/pom.xml
index e9217c06bf..239a0a1048 100644
--- a/pom.xml
+++ b/pom.xml
@@ -388,7 +388,7 @@
integrations-sdkcom.hpe.adm.octane.ciplugins
- 1.3
+ 1.4
diff --git a/src/main/java/com/hp/application/automation/tools/common/HttpStatus.java b/src/main/java/com/hp/application/automation/tools/common/HttpStatus.java
new file mode 100644
index 0000000000..55321e0bc0
--- /dev/null
+++ b/src/main/java/com/hp/application/automation/tools/common/HttpStatus.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2017 Hewlett-Packard Development Company, L.P.
+ * 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.
+ *
+ */
+
+package com.hp.application.automation.tools.common;
+
+/**
+ * Created by shitritn on 10/05/2017.
+ * enum class that define all http protocol statuses with thire cuase for intenral use in plugin
+ */
+public enum HttpStatus {
+ OK(200, "OK"),
+ CREATED(201, "Created"),
+ ACCEPTED(202, "Accepted"),
+ NO_CONTENT(204, "No Content"),
+ RESET_CONTENT(205, "Reset Content"),
+ PARTIAL_CONTENT(206, "Partial Content"),
+ MOVED_PERMANENTLY(301, "Moved Permanently"),
+ FOUND(302, "Found"),
+ SEE_OTHER(303, "See Other"),
+ NOT_MODIFIED(304, "Not Modified"),
+ USE_PROXY(305, "Use Proxy"),
+ TEMPORARY_REDIRECT(307, "Temporary Redirect"),
+ BAD_REQUEST(400, "Bad Request"),
+ UNAUTHORIZED(401, "Unauthorized"),
+ PAYMENT_REQUIRED(402, "Payment Required"),
+ FORBIDDEN(403, "Forbidden"),
+ NOT_FOUND(404, "Not Found"),
+ METHOD_NOT_ALLOWED(405, "Method Not Allowed"),
+ NOT_ACCEPTABLE(406, "Not Acceptable"),
+ PROXY_AUTHENTICATION_REQUIRED(407, "Proxy Authentication Required"),
+ REQUEST_TIMEOUT(408, "Request Timeout"),
+ CONFLICT(409, "Conflict"),
+ GONE(410, "Gone"),
+ LENGTH_REQUIRED(411, "Length Required"),
+ PRECONDITION_FAILED(412, "Precondition Failed"),
+ REQUEST_ENTITY_TOO_LARGE(413, "Request Entity Too Large"),
+ REQUEST_URI_TOO_LONG(414, "Request-URI Too Long"),
+ UNSUPPORTED_MEDIA_TYPE(415, "Unsupported Media Type"),
+ REQUESTED_RANGE_NOT_SATISFIABLE(416, "Requested Range Not Satisfiable"),
+ EXPECTATION_FAILED(417, "Expectation Failed"),
+ INTERNAL_SERVER_ERROR(500, "Internal Server Error"),
+ NOT_IMPLEMENTED(501, "Not Implemented"),
+ BAD_GATEWAY(502, "Bad Gateway"),
+ SERVICE_UNAVAILABLE(503, "Service Unavailable"),
+ GATEWAY_TIMEOUT(504, "Gateway Timeout"),
+ HTTP_VERSION_NOT_SUPPORTED(505, "HTTP Version Not Supported");
+
+ private final int code;
+ private final String reason;
+
+ private HttpStatus(int statusCode, String reason) {
+ this.code = statusCode;
+ this.reason = reason;
+ }
+
+ public int getCode() {
+ return code;
+ }
+
+ public String getReason() {
+ return reason;
+ }
+}
diff --git a/src/main/java/com/hp/application/automation/tools/octane/CIJenkinsServicesImpl.java b/src/main/java/com/hp/application/automation/tools/octane/CIJenkinsServicesImpl.java
index 976704f2e7..9c5a2a935e 100644
--- a/src/main/java/com/hp/application/automation/tools/octane/CIJenkinsServicesImpl.java
+++ b/src/main/java/com/hp/application/automation/tools/octane/CIJenkinsServicesImpl.java
@@ -19,7 +19,7 @@
import com.hp.application.automation.tools.model.OctaneServerSettingsModel;
import com.hp.application.automation.tools.octane.configuration.ConfigurationService;
import com.hp.application.automation.tools.octane.configuration.ServerConfiguration;
-import com.hp.application.automation.tools.octane.executor.ExecutorConnTestService;
+import com.hp.application.automation.tools.octane.executor.ExecutorConnectivityService;
import com.hp.application.automation.tools.octane.executor.TestExecutionJobCreatorService;
import com.hp.application.automation.tools.octane.model.ModelFactory;
import com.hp.application.automation.tools.octane.model.processors.parameters.ParameterProcessors;
@@ -30,6 +30,7 @@
import com.hp.octane.integrations.dto.DTOFactory;
import com.hp.octane.integrations.dto.configuration.CIProxyConfiguration;
import com.hp.octane.integrations.dto.configuration.OctaneConfiguration;
+import com.hp.octane.integrations.dto.connectivity.OctaneResponse;
import com.hp.octane.integrations.dto.executor.CredentialsInfo;
import com.hp.octane.integrations.dto.executor.DiscoveryInfo;
import com.hp.octane.integrations.dto.executor.TestConnectivityInfo;
@@ -548,8 +549,8 @@ public void runTestSuiteExecution(TestSuiteExecutionInfo suiteExecutionInfo) {
}
@Override
- public boolean checkRepositoryConnectivity(TestConnectivityInfo testConnectivityInfo) {
- return ExecutorConnTestService.checkRepositoryConnectivity(testConnectivityInfo);
+ public OctaneResponse checkRepositoryConnectivity(TestConnectivityInfo testConnectivityInfo) {
+ return ExecutorConnectivityService.checkRepositoryConnectivity(testConnectivityInfo);
}
@Override
@@ -558,8 +559,8 @@ public void deleteExecutor(String id) {
}
@Override
- public CredentialsInfo upsertCredentials(CredentialsInfo credentialsInfo) {
- return ExecutorConnTestService.upsertRepositoryCredentials(credentialsInfo);
+ public OctaneResponse upsertCredentials(CredentialsInfo credentialsInfo) {
+ return ExecutorConnectivityService.upsertRepositoryCredentials(credentialsInfo);
}
}
diff --git a/src/main/java/com/hp/application/automation/tools/octane/executor/ExecutorConnTestService.java b/src/main/java/com/hp/application/automation/tools/octane/executor/ExecutorConnTestService.java
deleted file mode 100644
index e200e2944d..0000000000
--- a/src/main/java/com/hp/application/automation/tools/octane/executor/ExecutorConnTestService.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Copyright 2017 Hewlett-Packard Development Company, L.P.
- * 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.
- *
- */
-
-package com.hp.application.automation.tools.octane.executor;
-
-import com.cloudbees.plugins.credentials.CredentialsProvider;
-import com.cloudbees.plugins.credentials.CredentialsScope;
-import com.cloudbees.plugins.credentials.CredentialsStore;
-import com.cloudbees.plugins.credentials.SystemCredentialsProvider;
-import com.cloudbees.plugins.credentials.domains.Domain;
-import com.cloudbees.plugins.credentials.impl.BaseStandardCredentials;
-import com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl;
-import com.hp.octane.integrations.dto.executor.CredentialsInfo;
-import com.hp.octane.integrations.dto.executor.TestConnectivityInfo;
-import com.hp.octane.integrations.dto.scm.SCMType;
-import hudson.EnvVars;
-import hudson.model.Item;
-import hudson.model.TaskListener;
-import hudson.plugins.git.GitException;
-import hudson.plugins.git.GitTool;
-import org.apache.commons.lang.StringUtils;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import org.jenkinsci.plugins.gitclient.Git;
-import org.jenkinsci.plugins.gitclient.GitClient;
-
-import java.io.IOException;
-import java.util.List;
-
-/**
- * Utility for handling of scm repositories
- */
-public class ExecutorConnTestService {
-
- private static final Logger logger = LogManager.getLogger(ExecutorConnTestService.class);
-
- /**
- * Validate that scm repository is valid
- * @param testConnectivityInfo
- * @return
- */
- public static boolean checkRepositoryConnectivity(TestConnectivityInfo testConnectivityInfo) {
- if (testConnectivityInfo.getScmRepository() != null &&
- StringUtils.isNotEmpty(testConnectivityInfo.getScmRepository().getUrl()) &&
- SCMType.GIT.equals(testConnectivityInfo.getScmRepository().getType())) {
-
- BaseStandardCredentials c = null;
- if (StringUtils.isNotEmpty(testConnectivityInfo.getUsername()) && testConnectivityInfo.getPassword() != null) {
- c = new UsernamePasswordCredentialsImpl(CredentialsScope.GLOBAL, null, null, testConnectivityInfo.getUsername(), testConnectivityInfo.getPassword());
- }
-
- try {
- EnvVars environment = new EnvVars(System.getenv());
- GitClient git = Git.with(TaskListener.NULL, environment).using(GitTool.getDefaultInstallation().getGitExe()).getClient();
- git.addDefaultCredentials(c);
- git.getHeadRev(testConnectivityInfo.getScmRepository().getUrl(), "HEAD");
-
- return true;
- } catch (IOException | InterruptedException e) {
- logger.error("Failed to connect to git : " + e.getMessage());
- } catch (GitException e) {
- logger.error("Failed to execute getHeadRev : " + e.getMessage());
- }
- }
- return false;
- }
-
- /**
- * Insert of update(if already exist) of credentials in Jenkins.
- * If credentialsInfo containscredentialsId - we update existing credentials with new user/password, otherwise - create new credentials
- * @param credentialsInfo
- * @return created/updated credentials with filled credentials id
- */
- public static CredentialsInfo upsertRepositoryCredentials(final CredentialsInfo credentialsInfo) {
-
- if (StringUtils.isEmpty(credentialsInfo.getCredentialId())) {
- if (StringUtils.isNotEmpty(credentialsInfo.getUsername()) && credentialsInfo.getPassword() != null) {
- BaseStandardCredentials c = new UsernamePasswordCredentialsImpl(CredentialsScope.GLOBAL, null, null, credentialsInfo.getUsername(), credentialsInfo.getPassword());
- CredentialsStore store = new SystemCredentialsProvider.StoreImpl();
- try {
- store.addCredentials(Domain.global(), c);
- credentialsInfo.setCredentialId(c.getId());
- } catch (IOException e) {
- logger.error("Failed to add credentials " + e.getMessage());
- }
- }
- } else {
- List list = CredentialsProvider.lookupCredentials(BaseStandardCredentials.class, (Item) null, null);
- for (BaseStandardCredentials cred : list) {
- if (cred.getId().equals(credentialsInfo.getCredentialId())) {
- BaseStandardCredentials newCred = new UsernamePasswordCredentialsImpl(CredentialsScope.GLOBAL, credentialsInfo.getCredentialId(),
- null, credentialsInfo.getUsername(), credentialsInfo.getPassword());
- CredentialsStore store = new SystemCredentialsProvider.StoreImpl();
- try {
- store.updateCredentials(Domain.global(), cred, newCred);
- } catch (IOException e) {
- logger.error("Failed to add credentials " + e.getMessage());
- }
- }
- }
- }
-
- return credentialsInfo;
- }
-}
diff --git a/src/main/java/com/hp/application/automation/tools/octane/executor/ExecutorConnectivityService.java b/src/main/java/com/hp/application/automation/tools/octane/executor/ExecutorConnectivityService.java
new file mode 100644
index 0000000000..8e1163fd5e
--- /dev/null
+++ b/src/main/java/com/hp/application/automation/tools/octane/executor/ExecutorConnectivityService.java
@@ -0,0 +1,153 @@
+/*
+ * Copyright 2017 Hewlett-Packard Development Company, L.P.
+ * 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.
+ *
+ */
+
+package com.hp.application.automation.tools.octane.executor;
+
+import com.cloudbees.plugins.credentials.CredentialsProvider;
+import com.cloudbees.plugins.credentials.CredentialsScope;
+import com.cloudbees.plugins.credentials.CredentialsStore;
+import com.cloudbees.plugins.credentials.SystemCredentialsProvider;
+import com.cloudbees.plugins.credentials.domains.Domain;
+import com.cloudbees.plugins.credentials.domains.DomainRequirement;
+import com.cloudbees.plugins.credentials.impl.BaseStandardCredentials;
+import com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl;
+import com.hp.application.automation.tools.common.HttpStatus;
+import com.hp.octane.integrations.dto.DTOFactory;
+import com.hp.octane.integrations.dto.connectivity.OctaneResponse;
+import com.hp.octane.integrations.dto.executor.CredentialsInfo;
+import com.hp.octane.integrations.dto.executor.TestConnectivityInfo;
+import com.hp.octane.integrations.dto.scm.SCMType;
+import hudson.EnvVars;
+import hudson.model.Item;
+import hudson.model.TaskListener;
+import hudson.plugins.git.GitException;
+import hudson.plugins.git.GitTool;
+import org.apache.commons.lang.StringUtils;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.jenkinsci.plugins.gitclient.Git;
+import org.jenkinsci.plugins.gitclient.GitClient;
+
+import java.io.IOException;
+import java.util.List;
+
+/**
+ * Utility for handling connectivity with scm repositories
+ */
+public class ExecutorConnectivityService {
+
+ private static final Logger logger = LogManager.getLogger(ExecutorConnectivityService.class);
+
+ /**
+ * Validate that scm repository is valid
+ *
+ * @param testConnectivityInfo contains values to check
+ * @return OctaneResponse return status code and error to show for client
+ */
+ public static OctaneResponse checkRepositoryConnectivity(TestConnectivityInfo testConnectivityInfo) {
+ OctaneResponse result = DTOFactory.getInstance().newDTO(OctaneResponse.class);
+ if (testConnectivityInfo.getScmRepository() != null &&
+ StringUtils.isNotEmpty(testConnectivityInfo.getScmRepository().getUrl()) &&
+ SCMType.GIT.equals(testConnectivityInfo.getScmRepository().getType())) {
+
+ BaseStandardCredentials c = null;
+ if (StringUtils.isNotEmpty(testConnectivityInfo.getUsername()) && testConnectivityInfo.getPassword() != null) {
+ c = new UsernamePasswordCredentialsImpl(CredentialsScope.GLOBAL, null, null, testConnectivityInfo.getUsername(), testConnectivityInfo.getPassword());
+ } else if (StringUtils.isEmpty(testConnectivityInfo.getCredentialsId())) {
+ c = getCredentialsById(testConnectivityInfo.getCredentialsId());
+ }
+
+ try {
+ EnvVars environment = new EnvVars(System.getenv());
+ GitClient git = Git.with(TaskListener.NULL, environment).using(GitTool.getDefaultInstallation().getGitExe()).getClient();
+ git.addDefaultCredentials(c);
+ git.getHeadRev(testConnectivityInfo.getScmRepository().getUrl(), "HEAD");
+
+ result = result.setStatus(HttpStatus.OK.getCode());
+
+ } catch (IOException | InterruptedException e) {
+ logger.error("Failed to connect to git : " + e.getMessage());
+ result.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.getCode());
+ result.setBody(e.getMessage());
+ } catch (GitException e) {
+ logger.error("Failed to execute getHeadRev : " + e.getMessage());
+ result.setStatus(HttpStatus.NOT_FOUND.getCode());
+ result.setBody(e.getMessage());
+ }
+ } else {
+ result.setStatus(HttpStatus.BAD_REQUEST.getCode());
+ result.setBody("Missing input for testing");
+ }
+ return result;
+ }
+
+ /**
+ * Insert of update(if already exist) of credentials in Jenkins.
+ * If credentialsInfo contains credentialsId - we update existing credentials with new user/password, otherwise - create new credentials
+ *
+ * @param credentialsInfo contains values to insert / update - exist credentials will be updated or recreate if deleted in jenkins
+ * @return OctaneResponse created/updated credentials with filled credentials id as body
+ */
+ public static OctaneResponse upsertRepositoryCredentials(final CredentialsInfo credentialsInfo) {
+
+ OctaneResponse result = DTOFactory.getInstance().newDTO(OctaneResponse.class);
+ result.setStatus(HttpStatus.CREATED.getCode());
+
+ if (StringUtils.isNotEmpty(credentialsInfo.getCredentialsId())) {
+ BaseStandardCredentials cred = getCredentialsById(credentialsInfo.getCredentialsId());
+ if (cred != null) {
+ BaseStandardCredentials newCred = new UsernamePasswordCredentialsImpl(CredentialsScope.GLOBAL, credentialsInfo.getCredentialsId(),
+ null, credentialsInfo.getUsername(), credentialsInfo.getPassword());
+ CredentialsStore store = new SystemCredentialsProvider.StoreImpl();
+ try {
+ store.updateCredentials(Domain.global(), cred, newCred);
+ result.setStatus(HttpStatus.CREATED.getCode());
+ result.setBody(newCred.getId());
+ } catch (IOException e) {
+ logger.error("Failed to update credentials " + e.getMessage());
+ result.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.getCode());
+ result.setBody("Failed to update credentials " + e.getMessage());
+ }
+ return result;
+ }
+ }
+ if (StringUtils.isNotEmpty(credentialsInfo.getUsername()) && credentialsInfo.getPassword() != null) {
+ BaseStandardCredentials c = new UsernamePasswordCredentialsImpl(CredentialsScope.GLOBAL, credentialsInfo.getCredentialsId(), null, credentialsInfo.getUsername(), credentialsInfo.getPassword());
+ CredentialsStore store = new SystemCredentialsProvider.StoreImpl();
+ try {
+ store.addCredentials(Domain.global(), c);
+ result.setStatus(HttpStatus.CREATED.getCode());
+ result.setBody(c.getId());
+ } catch (IOException e) {
+ logger.error("Failed to add credentials " + e.getMessage());
+ result.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.getCode());
+ result.setBody("Failed to add credentials " + e.getMessage());
+ }
+ }
+
+ return result;
+ }
+
+ private static BaseStandardCredentials getCredentialsById(String credentialsId) {
+ List list = CredentialsProvider.lookupCredentials(BaseStandardCredentials.class, (Item) null, null, (DomainRequirement) null);
+ for (BaseStandardCredentials cred : list) {
+ if (cred.getId().equals(credentialsId))
+ return cred;
+ }
+ return null;
+ }
+}
diff --git a/src/main/java/com/hp/application/automation/tools/octane/executor/TestExecutionJobCreatorService.java b/src/main/java/com/hp/application/automation/tools/octane/executor/TestExecutionJobCreatorService.java
index f069244893..6debb4c166 100644
--- a/src/main/java/com/hp/application/automation/tools/octane/executor/TestExecutionJobCreatorService.java
+++ b/src/main/java/com/hp/application/automation/tools/octane/executor/TestExecutionJobCreatorService.java
@@ -373,6 +373,7 @@ public static void deleteExecutor(String id) {
}
try {
+ logger.warn(String.format("Job %s is going to be deleted since matching executor in Octane was deleted", proj.getName()));
proj.delete();
} catch (IOException | InterruptedException e) {
logger.error("Failed to delete job " + proj.getName() + " : " + e.getMessage());
diff --git a/src/main/java/com/hp/application/automation/tools/octane/executor/UftJobCleaner.java b/src/main/java/com/hp/application/automation/tools/octane/executor/UftJobCleaner.java
index b2cc834e58..bc3cf56248 100644
--- a/src/main/java/com/hp/application/automation/tools/octane/executor/UftJobCleaner.java
+++ b/src/main/java/com/hp/application/automation/tools/octane/executor/UftJobCleaner.java
@@ -23,6 +23,7 @@
import hudson.model.PeriodicWork;
import hudson.model.TaskListener;
import jenkins.model.Jenkins;
+import org.apache.commons.lang.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -48,7 +49,7 @@ public UftJobCleaner() {
@Override
public long getRecurrencePeriod() {
- return DAY;
+ return HOUR;
}
@Override
@@ -57,7 +58,17 @@ public long getInitialDelay() {
}
private long getOutdateThreshold() {
- return 7;
+ int DEFAULT_OUTDATE_THRESHOLD = 7;
+ int threshold = DEFAULT_OUTDATE_THRESHOLD;
+ String paramValue = System.getProperty("octane.plugin.UftJobCleaner.outdateThreshold");
+ if (StringUtils.isNotEmpty(paramValue)) {
+ try {
+ threshold = Integer.parseInt(paramValue);
+ } catch (NumberFormatException e) {
+ threshold = DEFAULT_OUTDATE_THRESHOLD;
+ }
+ }
+ return threshold;
}
@Override
From 835020160983daa4757ee29ae9fb1c6bff7c9703 Mon Sep 17 00:00:00 2001
From: radislavB
Date: Thu, 11 May 2017 13:32:02 +0300
Subject: [PATCH 0057/2502] Fix createMtbxFileInWs to handle saving mtbx file
on slave machine workspace (#190)
---
.../tools/model/RunFromFileSystemModel.java | 29 ++++++++++++-------
1 file changed, 19 insertions(+), 10 deletions(-)
diff --git a/src/main/java/com/hp/application/automation/tools/model/RunFromFileSystemModel.java b/src/main/java/com/hp/application/automation/tools/model/RunFromFileSystemModel.java
index 55da31fe57..6fa60b7886 100644
--- a/src/main/java/com/hp/application/automation/tools/model/RunFromFileSystemModel.java
+++ b/src/main/java/com/hp/application/automation/tools/model/RunFromFileSystemModel.java
@@ -5,21 +5,23 @@
package com.hp.application.automation.tools.model;
-import com.hp.application.automation.tools.common.RuntimeIOException;
import com.hp.application.automation.tools.mc.JobConfigurationProxy;
import hudson.EnvVars;
import hudson.FilePath;
import hudson.util.Secret;
import hudson.util.VariableResolver;
import net.minidev.json.JSONObject;
-import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.StringUtils;
import org.kohsuke.stapler.DataBoundConstructor;
import javax.annotation.Nullable;
-import java.io.File;
import java.io.IOException;
+import java.io.InputStream;
+import java.text.Format;
+import java.text.SimpleDateFormat;
import java.util.Arrays;
+import java.util.Date;
import java.util.List;
import java.util.Properties;
@@ -690,16 +692,23 @@ private Properties createProperties(EnvVars envVars) {
private String createMtbxFileInWs(String mtbxContent) {
try {
+ Date now = new Date();
+ Format formatter = new SimpleDateFormat("ddMMyyyyHHmmssSSS");
+ String time = formatter.format(now);
- String filePath = File.separator + "test_suite.mtbx";
- String fullPath = workspace.getRemote() + filePath;
+ String fileName = "test_suite_" + time + ".mtbx";
- String content = mtbxContent.replace("${WORKSPACE}", workspace.getRemote());
- FileUtils.writeStringToFile(new File(fullPath), content);
+ FilePath remoteFile = workspace.child(fileName);
- return "${WORKSPACE}" + filePath;
- } catch (IOException e) {
- throw new RuntimeIOException("Failed to save MTBX file : " + e.getMessage());
+ String mtbxContentUpdated = mtbxContent.replace("${WORKSPACE}", workspace.getRemote());
+ InputStream in = IOUtils.toInputStream(mtbxContentUpdated, "UTF-8");
+ remoteFile.copyFrom(in);
+
+ String filePath = remoteFile.getRemote();
+ return filePath;
+
+ } catch (IOException | InterruptedException e) {
+ throw new RuntimeException("Failed to save MTBX file : " + e.getMessage());
}
}
From e1c13c637aad686cefa68af48fe6c25d3d1a98ec Mon Sep 17 00:00:00 2001
From: Jackzenko
Date: Sun, 21 May 2017 12:20:17 +0800
Subject: [PATCH 0058/2502] fixed report path issue for TFS plugin (#192)
CPE QCIM1J93134 How to configure Microsoft TFS 'Copy Publish Artifact' task, for API Testing results
JIRA ticket: JENKINS-44364
https://issues.jenkins-ci.org/projects/JENKINS/issues/JENKINS-44364
AGM defect number: 35681
---
HpToolsLauncher/TestRunners/ApiTestRunner.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/HpToolsLauncher/TestRunners/ApiTestRunner.cs b/HpToolsLauncher/TestRunners/ApiTestRunner.cs
index 86e84b52fc..5a73fe0460 100644
--- a/HpToolsLauncher/TestRunners/ApiTestRunner.cs
+++ b/HpToolsLauncher/TestRunners/ApiTestRunner.cs
@@ -72,7 +72,7 @@ public TestRunResults RunTest(TestInfo testinf, ref string errorReason, RunCance
ConsoleWriter.ActiveTestRun = runDesc;
ConsoleWriter.WriteLine(DateTime.Now.ToString(Launcher.DateFormat) + " Running: " + testinf.TestPath);
- runDesc.ReportLocation = Helper.CreateTempDir();
+ runDesc.ReportLocation = testinf.TestPath;
runDesc.ErrorDesc = errorReason;
runDesc.TestPath = testinf.TestPath;
runDesc.TestState = TestState.Unknown;
From e86d97dc31020dee7356d07606ecf2ceb4bcb7a4 Mon Sep 17 00:00:00 2001
From: bamh
Date: Sun, 21 May 2017 11:25:04 +0300
Subject: [PATCH 0059/2502] PC Adding features (#194)
* index on master: ab83a3d Merge remote-tracking branch 'remotes/origin/5.0.1-beta-SNAPSHOT'
* Revert pom changes
* Merge branch '5.0.1-beta-SNAPSHOT' of https://github.com/hpsa/hp-application-automation-tools-plugin into development
# Conflicts:
# .github/PULL_REQUEST_TEMPLATE.md
* Added some comments
* changes according to sonarlint
* changes for sonarlint
* Remove some comments
* Comments
* * Fix for supporting SECURITY-170 changes
* https://jenkins.io/blog/2016/05/11/security-update/
* https://issues.jenkins-ci.org/browse/JENKINS-39654
* code changes for sonarlint
* Changes in PC configuration section header
* Adding support for Jenkins using proxy: https://issues.jenkins-ci.org/browse/JENKINS-44314
Changing the HTTPS checkbox position
* Adding link under Test ID text box for browsing to the PC Server
---
.../automation/tools/model/PcModel.java | 8 ++-
.../automation/tools/pc/PcClient.java | 11 ++--
.../automation/tools/pc/PcRestProxy.java | 53 ++++++++++++++-----
.../automation/tools/run/PcBuilder.java | 10 ++--
.../tools/run/PcBuilder/config.jelly | 27 +++++++++-
.../tools/run/PcBuilder/help-proxyOutURL.html | 5 ++
.../automation/tools/pc/MockPcModel.java | 18 +------
.../automation/tools/pc/MockPcRestProxy.java | 20 +------
.../tools/pc/MockPcRestProxyBadResponses.java | 20 +------
9 files changed, 96 insertions(+), 76 deletions(-)
create mode 100644 src/main/resources/com/hp/application/automation/tools/run/PcBuilder/help-proxyOutURL.html
diff --git a/src/main/java/com/hp/application/automation/tools/model/PcModel.java b/src/main/java/com/hp/application/automation/tools/model/PcModel.java
index 620cad6626..d5d8b2031b 100644
--- a/src/main/java/com/hp/application/automation/tools/model/PcModel.java
+++ b/src/main/java/com/hp/application/automation/tools/model/PcModel.java
@@ -28,11 +28,12 @@ public class PcModel {
private final boolean addRunToTrendReport;
private final String trendReportId;
private final boolean HTTPSProtocol;
+ private final String proxyOutURL;
@DataBoundConstructor
public PcModel(String pcServerName, String almUserName, String almPassword, String almDomain, String almProject,
String testId, String testInstanceId, String timeslotDurationHours, String timeslotDurationMinutes,
- PostRunAction postRunAction, boolean vudsMode, String description, boolean addRunToTrendReport, String trendReportId, boolean HTTPSProtocol) {
+ PostRunAction postRunAction, boolean vudsMode, String description, boolean addRunToTrendReport, String trendReportId, boolean HTTPSProtocol, String proxyOutURL) {
this.pcServerName = pcServerName;
this.almUserName = almUserName;
@@ -48,6 +49,7 @@ public PcModel(String pcServerName, String almUserName, String almPassword, Stri
this.addRunToTrendReport = addRunToTrendReport;
this.HTTPSProtocol = HTTPSProtocol;
this.trendReportId = trendReportId;
+ this.proxyOutURL = proxyOutURL;
}
protected SecretContainer setPassword(String almPassword) {
@@ -116,6 +118,10 @@ public boolean httpsProtocol(){
return this.HTTPSProtocol;
}
+ public String getProxyOutURL(){
+ return this.proxyOutURL;
+ }
+
public static List getPostRunActions() {
return Arrays.asList(PostRunAction.values());
diff --git a/src/main/java/com/hp/application/automation/tools/pc/PcClient.java b/src/main/java/com/hp/application/automation/tools/pc/PcClient.java
index e3bdb42fcd..115f239f01 100644
--- a/src/main/java/com/hp/application/automation/tools/pc/PcClient.java
+++ b/src/main/java/com/hp/application/automation/tools/pc/PcClient.java
@@ -54,9 +54,14 @@ public class PcClient {
private PrintStream logger;
public PcClient(PcModel pcModel, PrintStream logger) {
- model = pcModel;
- restProxy = new PcRestProxy(model.isHTTPSProtocol(),model.getPcServerName(), model.getAlmDomain(), model.getAlmProject(),logger);
- this.logger = logger;
+ try {
+ model = pcModel;
+ restProxy = new PcRestProxy(model.isHTTPSProtocol(),model.getPcServerName(), model.getAlmDomain(), model.getAlmProject(),logger, model.getProxyOutURL());
+ this.logger = logger;
+ }catch (PcException e){
+ logger.println(e.getMessage());
+ }
+
}
public PcClient(PcModel pcModel, PrintStream logger, T proxy) {
diff --git a/src/main/java/com/hp/application/automation/tools/pc/PcRestProxy.java b/src/main/java/com/hp/application/automation/tools/pc/PcRestProxy.java
index a6d1a63aa1..fd10aa7fa7 100644
--- a/src/main/java/com/hp/application/automation/tools/pc/PcRestProxy.java
+++ b/src/main/java/com/hp/application/automation/tools/pc/PcRestProxy.java
@@ -30,8 +30,8 @@
import com.hp.application.automation.tools.rest.RESTConstants;
import com.hp.application.automation.tools.sse.sdk.Base64Encoder;
import org.apache.commons.io.IOUtils;
-import org.apache.http.Header;
import org.apache.http.HttpHeaders;
+import org.apache.http.HttpHost;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.CookieStore;
@@ -40,6 +40,7 @@
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpRequestBase;
import org.apache.http.client.protocol.ClientContext;
+import org.apache.http.conn.params.ConnRoutePNames;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.BasicCookieStore;
@@ -53,9 +54,7 @@
import java.io.InputStream;
import java.io.IOException;
import java.io.FileOutputStream;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
+import java.util.*;
import java.io.PrintStream;
@@ -84,13 +83,16 @@ public class PcRestProxy {
private String domain;
private String project;
private String webProtocol;
+ private String proxyScheme;
+ private String proxyHostName;
+ private int proxyPort;
private HttpClient client;
private HttpContext context;
private CookieStore cookieStore;
// private PrintStream logger;
- public PcRestProxy(String webProtocolName, String pcServerName, String almDomain, String almProject,PrintStream mainLogger) {
+ public PcRestProxy(String webProtocolName, String pcServerName, String almDomain, String almProject,PrintStream mainLogger, String proxyOutURL) throws PcException {
// logger = mainLogger;
pcServer = pcServerName;
@@ -104,12 +106,42 @@ public PcRestProxy(String webProtocolName, String pcServerName, String almDomain
cxMgr.setDefaultMaxPerRoute(20);
- client = new DefaultHttpClient(cxMgr);
+ client = new DefaultHttpClient(cxMgr);
+ if (proxyOutURL != null && !proxyOutURL.isEmpty()) {
+ // Setting proxy
+ // we should get the full proxy URL from the user: http(s)://:
+ // PAC (proxy auto-config) or Automatic configuration script is not supported (for example our proxy: http://autocache.hpecorp.net/)
+ getProxyDataFromURL(proxyOutURL);
+ HttpHost proxy = new HttpHost(proxyHostName, proxyPort, proxyScheme);
+ client.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
+ }
context = new BasicHttpContext();
cookieStore = new BasicCookieStore();
context.setAttribute(ClientContext.COOKIE_STORE, cookieStore);
}
+ private void getProxyDataFromURL(String proxyURL) throws PcException{
+
+ try {
+ if (proxyURL != null && !proxyURL.isEmpty()){
+ proxyScheme = proxyURL.split("://")[0];
+ proxyHostName = proxyURL.split("://")[1].split(":")[0];
+ if (proxyURL.split("://")[1].contains(":")){
+ proxyPort = Integer.parseInt(proxyURL.split("://")[1].split(":")[1]);
+ }else{
+ proxyPort = 80;
+ }
+
+ }
+ } catch (Exception ex) {
+ throw new PcException("Error: Validating Proxy URL: " + ex + " Please add a proxy URL in this pattern: http(s)://: or leave blank");
+ }
+
+
+
+
+ }
+
public boolean authenticate(String userName, String password) throws PcException, ClientProtocolException, IOException {
String userNameAndPassword = userName + ":" + password;
@@ -222,14 +254,7 @@ public boolean logout() throws PcException, ClientProtocolException, IOException
}
protected HttpResponse executeRequest(HttpRequestBase request) throws PcException, IOException {
-// logger.println(String.format("DEBUGMSG - Request uri %s",request.getURI().toString()));
-// logger.println(String.format("DEBUGMSG - Request Method %s",request.getMethod().toString()));
-// // Print all headers
-// logger.println("DEBUGMSG - Headers");
-// List httpHeaders = Arrays.asList(request.getAllHeaders());
-// for (Header header : httpHeaders) {
-// logger.println("DEBUGMSG - " + header.getName() + " : " + header.getValue());
-// }
+
HttpResponse response = client.execute(request,context);
if (!isOk(response)){
String message;
diff --git a/src/main/java/com/hp/application/automation/tools/run/PcBuilder.java b/src/main/java/com/hp/application/automation/tools/run/PcBuilder.java
index 0fcd40f6ce..812ca2a5b0 100644
--- a/src/main/java/com/hp/application/automation/tools/run/PcBuilder.java
+++ b/src/main/java/com/hp/application/automation/tools/run/PcBuilder.java
@@ -110,7 +110,8 @@ public PcBuilder(
String description,
boolean addRunToTrendReport,
String trendReportId,
- boolean HTTPSProtocol) {
+ boolean HTTPSProtocol,
+ String proxyOutURL) {
this.almUserName = almUserName;
this.almPassword = almPassword;
this.timeslotDurationHours = timeslotDurationHours;
@@ -133,7 +134,8 @@ public PcBuilder(
description,
addRunToTrendReport,
trendReportId,
- HTTPSProtocol);
+ HTTPSProtocol,
+ proxyOutURL);
}
@Override
@@ -625,6 +627,8 @@ public boolean isStatusBySLA() {
return statusBySLA;
}
+ public String getProxyOutURL(){ return getPcModel().getProxyOutURL();}
+
// This indicates to Jenkins that this is an implementation of an extension
// point
@Extension
@@ -646,7 +650,7 @@ public boolean isApplicable(
@Override
public String getDisplayName() {
- return "Execute HP tests using HP Performance Center";
+ return "Execute performance test using Performance Center";
}
public FormValidation doCheckPcServerName(@QueryParameter String value) {
diff --git a/src/main/resources/com/hp/application/automation/tools/run/PcBuilder/config.jelly b/src/main/resources/com/hp/application/automation/tools/run/PcBuilder/config.jelly
index 2d834aabdf..15bf085df5 100644
--- a/src/main/resources/com/hp/application/automation/tools/run/PcBuilder/config.jelly
+++ b/src/main/resources/com/hp/application/automation/tools/run/PcBuilder/config.jelly
@@ -59,6 +59,22 @@
}
+ function verifyURLAvailable(){
+
+ var pcServer = document.getElementsByName("pc.pcServerName")[0].value;
+ var scheme = "http";
+ if(document.getElementsByName("pc.HTTPSProtocol")[0].checked){
+ scheme = "https"
+ }
+ if(pcServer){
+ var popup = window.open(scheme + "://" + pcServer + "/loadtest/");
+ popup.opener = null;
+ }else{
+ alert("Performance Center Server name is missing.");
+ }
+ return false;
+ }
+
@@ -75,8 +91,9 @@
-
+
+
@@ -92,9 +109,15 @@
+
+ Browse to find the Test ID
+
+
+
+
@@ -205,7 +228,7 @@
-
+
diff --git a/src/main/resources/com/hp/application/automation/tools/run/PcBuilder/help-proxyOutURL.html b/src/main/resources/com/hp/application/automation/tools/run/PcBuilder/help-proxyOutURL.html
new file mode 100644
index 0000000000..34149e688b
--- /dev/null
+++ b/src/main/resources/com/hp/application/automation/tools/run/PcBuilder/help-proxyOutURL.html
@@ -0,0 +1,5 @@
+
+ Add your local proxy as following: http(s)://<host>:<port>
+ Leave empty if not using a local proxy.
+ PAC (proxy auto-config) or Automatic configuration script are not supported.
+
\ No newline at end of file
diff --git a/src/test/java/com/hp/application/automation/tools/pc/MockPcModel.java b/src/test/java/com/hp/application/automation/tools/pc/MockPcModel.java
index 35970925b8..d8f8baf43c 100644
--- a/src/test/java/com/hp/application/automation/tools/pc/MockPcModel.java
+++ b/src/test/java/com/hp/application/automation/tools/pc/MockPcModel.java
@@ -1,19 +1,3 @@
-/*
- * Copyright 2017 Hewlett-Packard Development Company, L.P.
- * 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.
- *
- */
-
package com.hp.application.automation.tools.pc;
import com.hp.application.automation.tools.model.PcModel;
@@ -28,7 +12,7 @@ public MockPcModel(String pcServerName, String almUserName, String almPassword,
String almProject, String testId, String testInstanceId, String timeslotDurationHours,
String timeslotDurationMinutes, PostRunAction postRunAction, boolean vudsMode, String description,boolean webProtocol) {
super(pcServerName, almUserName, almPassword, almDomain, almProject, testId, testInstanceId, timeslotDurationHours,
- timeslotDurationMinutes, postRunAction, vudsMode, description, false, null,false
+ timeslotDurationMinutes, postRunAction, vudsMode, description, false, null,false,null
);
}
diff --git a/src/test/java/com/hp/application/automation/tools/pc/MockPcRestProxy.java b/src/test/java/com/hp/application/automation/tools/pc/MockPcRestProxy.java
index 9a514b4efe..000920b412 100644
--- a/src/test/java/com/hp/application/automation/tools/pc/MockPcRestProxy.java
+++ b/src/test/java/com/hp/application/automation/tools/pc/MockPcRestProxy.java
@@ -1,19 +1,3 @@
-/*
- * Copyright 2017 Hewlett-Packard Development Company, L.P.
- * 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.
- *
- */
-
package com.hp.application.automation.tools.pc;
import java.io.File;
@@ -42,8 +26,8 @@ public class MockPcRestProxy extends PcRestProxy {
private static Iterator runState = initializeRunStateIterator();
- public MockPcRestProxy(String webProtocol, String pcServerName, String almDomain, String almProject,PrintStream logger) {
- super(webProtocol, pcServerName, almDomain, almProject,logger);
+ public MockPcRestProxy(String webProtocol, String pcServerName, String almDomain, String almProject,PrintStream logger) throws PcException {
+ super(webProtocol, pcServerName, almDomain, almProject,logger,null);
}
@Override
diff --git a/src/test/java/com/hp/application/automation/tools/pc/MockPcRestProxyBadResponses.java b/src/test/java/com/hp/application/automation/tools/pc/MockPcRestProxyBadResponses.java
index 3fd1fa3b56..91acdc5854 100644
--- a/src/test/java/com/hp/application/automation/tools/pc/MockPcRestProxyBadResponses.java
+++ b/src/test/java/com/hp/application/automation/tools/pc/MockPcRestProxyBadResponses.java
@@ -1,19 +1,3 @@
-/*
- * Copyright 2017 Hewlett-Packard Development Company, L.P.
- * 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.
- *
- */
-
package com.hp.application.automation.tools.pc;
import java.io.IOException;
@@ -37,8 +21,8 @@ public class MockPcRestProxyBadResponses extends PcRestProxy {
private static Iterator runState = initializeRunStateIterator();
- public MockPcRestProxyBadResponses(String webProtocol, String pcServerName, String almDomain, String almProject,PrintStream logger) {
- super(webProtocol, pcServerName, almDomain, almProject,logger);
+ public MockPcRestProxyBadResponses(String webProtocol, String pcServerName, String almDomain, String almProject,PrintStream logger) throws PcException {
+ super(webProtocol, pcServerName, almDomain, almProject,logger,null);
}
@Override
From d6195f036372562012c8aa91de2123a227917562 Mon Sep 17 00:00:00 2001
From: radislavB
Date: Sun, 28 May 2017 08:51:10 +0300
Subject: [PATCH 0060/2502] Improving uft test discovery and execution (#195)
* support discovery of data tables
* increment version of mqm-rest-client
* revert - last change
* small fixes
* fix running test from file system in mtbx file , while tests executed on slave
* small fixes
* support discovery of data tables
* support discovery of data tables
* tech: add license header
* Defect #317023: [ Jenkins plugin] Tests doesn't appear in Pipeline created from Maven project under Folder and always in status run
* improving JobCleaner to remove orphan discovery jobs
* adding fullScan parameter for discovery job
* 1.set deleted tests to be not executable
2.fix detection of deleted data tables
3.fix detection of test on linux (failed to replaceAll / by \\)
* add some java docs
* add some java docs
* codacy fixes
* tech : When deleting test from octane there is no option to updated it from UFT repository (the test doesn't exists)
* fix sonarLint issues
* refactor error handling of createMtbxFileInWs
---
pom.xml | 2 +-
.../tools/model/RunFromFileSystemModel.java | 50 +--
.../actions/UFTTestDetectionBuildAction.java | 18 ++
.../actions/UFTTestDetectionPublisher.java | 15 +-
.../tools/octane/actions/UFTTestUtil.java | 7 +-
.../octane/actions/dto/AutomatedTest.java | 26 +-
.../octane/actions/dto/ScmResourceFile.java | 88 ++++++
.../octane/actions/dto/ScmResources.java | 43 +++
.../configuration/ConfigurationService.java | 114 ++++++-
.../tools/octane/events/TestListenerImpl.java | 21 +-
.../TestExecutionJobCreatorService.java | 57 ++--
.../executor/UFTTestDetectionResult.java | 66 +++-
.../executor/UFTTestDetectionService.java | 183 ++++++++---
.../tools/octane/executor/UftJobCleaner.java | 137 +++++++-
.../executor/UftTestDiscoveryDispatcher.java | 294 ++++++++++++------
.../tests/build/MavenBuildExtension.java | 4 +-
.../tools/run/RunFromFileBuilder.java | 36 ++-
.../UFTTestDetectionBuildAction/index.jelly | 46 +++
.../UFTTestDetectionPublisher/config.jelly | 2 +-
19 files changed, 933 insertions(+), 276 deletions(-)
create mode 100644 src/main/java/com/hp/application/automation/tools/octane/actions/dto/ScmResourceFile.java
create mode 100644 src/main/java/com/hp/application/automation/tools/octane/actions/dto/ScmResources.java
diff --git a/pom.xml b/pom.xml
index 239a0a1048..abad3cbbeb 100644
--- a/pom.xml
+++ b/pom.xml
@@ -395,7 +395,7 @@
mqm-rest-clientcom.hpe.adm.octane.ciplugins
- 1.3
+ 1.4.1
diff --git a/src/main/java/com/hp/application/automation/tools/model/RunFromFileSystemModel.java b/src/main/java/com/hp/application/automation/tools/model/RunFromFileSystemModel.java
index 6fa60b7886..77e4f82e6f 100644
--- a/src/main/java/com/hp/application/automation/tools/model/RunFromFileSystemModel.java
+++ b/src/main/java/com/hp/application/automation/tools/model/RunFromFileSystemModel.java
@@ -7,21 +7,14 @@
import com.hp.application.automation.tools.mc.JobConfigurationProxy;
import hudson.EnvVars;
-import hudson.FilePath;
import hudson.util.Secret;
import hudson.util.VariableResolver;
import net.minidev.json.JSONObject;
-import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.StringUtils;
import org.kohsuke.stapler.DataBoundConstructor;
import javax.annotation.Nullable;
-import java.io.IOException;
-import java.io.InputStream;
-import java.text.Format;
-import java.text.SimpleDateFormat;
import java.util.Arrays;
-import java.util.Date;
import java.util.List;
import java.util.Properties;
@@ -61,7 +54,6 @@ public class RunFromFileSystemModel {
private String fsJobId;
private ProxySettings proxySettings;
private boolean useSSL;
- private FilePath workspace;
/**
* Instantiates a new Run from file system model.
@@ -600,16 +592,14 @@ private Properties createProperties(EnvVars envVars) {
Properties props = new Properties();
if (!StringUtils.isEmpty(this.fsTests)) {
- String expandedFsTests;
- if (isMtbxContent(fsTests)) {
- String path = createMtbxFileInWs(fsTests);
- expandedFsTests = envVars.expand(path);
+ String expandedFsTests = envVars.expand(fsTests);
+ String[] testsArr;
+ if (isMtbxContent(expandedFsTests)) {
+ testsArr = new String[]{expandedFsTests};
} else {
- expandedFsTests = envVars.expand(fsTests);
+ testsArr = expandedFsTests.replaceAll("\r", "").split("\n");
}
- String[] testsArr = expandedFsTests.replaceAll("\r", "").split("\n");
-
int i = 1;
for (String test : testsArr) {
@@ -690,30 +680,8 @@ private Properties createProperties(EnvVars envVars) {
return props;
}
- private String createMtbxFileInWs(String mtbxContent) {
- try {
- Date now = new Date();
- Format formatter = new SimpleDateFormat("ddMMyyyyHHmmssSSS");
- String time = formatter.format(now);
-
- String fileName = "test_suite_" + time + ".mtbx";
-
- FilePath remoteFile = workspace.child(fileName);
-
- String mtbxContentUpdated = mtbxContent.replace("${WORKSPACE}", workspace.getRemote());
- InputStream in = IOUtils.toInputStream(mtbxContentUpdated, "UTF-8");
- remoteFile.copyFrom(in);
-
- String filePath = remoteFile.getRemote();
- return filePath;
-
- } catch (IOException | InterruptedException e) {
- throw new RuntimeException("Failed to save MTBX file : " + e.getMessage());
- }
- }
-
- private static boolean isMtbxContent(String fsTests) {
- return fsTests.toLowerCase().contains("");
+ public static boolean isMtbxContent(String testContent) {
+ return testContent.toLowerCase().contains("");
}
/**
@@ -731,8 +699,4 @@ public JSONObject getJobDetails(String mcUrl, String proxyAddress, String proxyU
}
return JobConfigurationProxy.getInstance().getJobById(mcUrl, fsUserName, fsPassword.getPlainText(), proxyAddress, proxyUserName, proxyPassword, fsJobId);
}
-
- public void setWorkspace(FilePath workspace) {
- this.workspace = workspace;
- }
}
diff --git a/src/main/java/com/hp/application/automation/tools/octane/actions/UFTTestDetectionBuildAction.java b/src/main/java/com/hp/application/automation/tools/octane/actions/UFTTestDetectionBuildAction.java
index d1774ad697..fd21068c18 100644
--- a/src/main/java/com/hp/application/automation/tools/octane/actions/UFTTestDetectionBuildAction.java
+++ b/src/main/java/com/hp/application/automation/tools/octane/actions/UFTTestDetectionBuildAction.java
@@ -87,6 +87,24 @@ public boolean getHasUpdatedTests() {
return results.getUpdatedTests().size() > 0;
}
+ /**
+ * used by ~\src\main\resources\com\hp\application\automation\tools\octane\actions\UFTTestDetectionBuildAction\index.jelly
+ *
+ * @return
+ */
+ public boolean getHasNewScmResources() {
+ return results.getNewScmResourceFiles().size() > 0;
+ }
+
+ /**
+ * used by ~\src\main\resources\com\hp\application\automation\tools\octane\actions\UFTTestDetectionBuildAction\index.jelly
+ *
+ * @return
+ */
+ public boolean getHasDeletedScmResources() {
+ return results.getDeletedScmResourceFiles().size() > 0;
+ }
+
public void setResults(UFTTestDetectionResult results) {
this.results = results;
}
diff --git a/src/main/java/com/hp/application/automation/tools/octane/actions/UFTTestDetectionPublisher.java b/src/main/java/com/hp/application/automation/tools/octane/actions/UFTTestDetectionPublisher.java
index 9f56676508..b7a5418481 100644
--- a/src/main/java/com/hp/application/automation/tools/octane/actions/UFTTestDetectionPublisher.java
+++ b/src/main/java/com/hp/application/automation/tools/octane/actions/UFTTestDetectionPublisher.java
@@ -47,30 +47,33 @@
import java.io.IOException;
import java.util.List;
+/**
+ * Post-build action of Uft test detection
+ */
public class UFTTestDetectionPublisher extends Recorder {
private final String workspaceName;
- private final String scmResourceId;
+ private final String scmRepositoryId;
public String getWorkspaceName() {
return workspaceName;
}
- public String getScmResourceId() {
- return scmResourceId;
+ public String getScmRepositoryId() {
+ return scmRepositoryId;
}
// Fields in config.jelly must match the parameter names in the "DataBoundConstructor"
@DataBoundConstructor
- public UFTTestDetectionPublisher(String workspaceName, String scmResourceId) {
+ public UFTTestDetectionPublisher(String workspaceName, String scmRepositoryId) {
this.workspaceName = workspaceName;
- this.scmResourceId = scmResourceId;
+ this.scmRepositoryId = scmRepositoryId;
}
@Override
public boolean perform(AbstractBuild build, Launcher launcher, BuildListener listener) {
- UFTTestDetectionResult results = UFTTestDetectionService.startScanning(build, getWorkspaceName(), getScmResourceId(), listener);
+ UFTTestDetectionResult results = UFTTestDetectionService.startScanning(build, getWorkspaceName(), getScmRepositoryId(), listener);
UFTTestDetectionBuildAction buildAction = new UFTTestDetectionBuildAction(build, results);
build.addAction(buildAction);
diff --git a/src/main/java/com/hp/application/automation/tools/octane/actions/UFTTestUtil.java b/src/main/java/com/hp/application/automation/tools/octane/actions/UFTTestUtil.java
index dc5f585c61..3b364eca3f 100644
--- a/src/main/java/com/hp/application/automation/tools/octane/actions/UFTTestUtil.java
+++ b/src/main/java/com/hp/application/automation/tools/octane/actions/UFTTestUtil.java
@@ -41,8 +41,13 @@ public class UFTTestUtil {
* @return test description
*/
public static String getTestDescription(FilePath dirPath) {
- String desc = null;
+ String desc;
+
try {
+ if(!dirPath.exists()){
+ return null;
+ }
+
FilePath tspTestFile = new FilePath(dirPath, "Test.tsp");
InputStream is = new FileInputStream(tspTestFile.getRemote());
String xmlContent = decodeXmlContent(is);
diff --git a/src/main/java/com/hp/application/automation/tools/octane/actions/dto/AutomatedTest.java b/src/main/java/com/hp/application/automation/tools/octane/actions/dto/AutomatedTest.java
index d8f9250ab8..5c4028c970 100644
--- a/src/main/java/com/hp/application/automation/tools/octane/actions/dto/AutomatedTest.java
+++ b/src/main/java/com/hp/application/automation/tools/octane/actions/dto/AutomatedTest.java
@@ -21,18 +21,16 @@
import javax.xml.bind.annotation.*;
/**
- * Created by kashbi on 25/09/2016.
+ * This file represents automated test for sending to Octane
*/
-@XmlRootElement(name="test")
+@XmlRootElement(name = "test")
@XmlAccessorType(XmlAccessType.FIELD)
public class AutomatedTest {
@XmlTransient
private Long id;
@XmlTransient
- private String type = "test";
- @XmlTransient
- private String subtype = "test_automated";
+ private String type = "test_automated";
@XmlTransient
private ListNodeEntity testingToolType;
@XmlTransient
@@ -48,6 +46,8 @@ public class AutomatedTest {
private String name;
@XmlAttribute
private String packageName;
+ @XmlAttribute
+ private Boolean executable;
private String description;
@@ -70,14 +70,6 @@ public void setType(String type) {
this.type = type;
}
- public String getSubtype() {
- return subtype;
- }
-
- public void setSubtype(String subtype) {
- this.subtype = subtype;
- }
-
public ListNodeEntity getFramework() {
return framework;
}
@@ -141,4 +133,12 @@ public Long getId() {
public void setId(Long id) {
this.id = id;
}
+
+ public Boolean getExecutable() {
+ return executable;
+ }
+
+ public void setExecutable(Boolean executable) {
+ this.executable = executable;
+ }
}
diff --git a/src/main/java/com/hp/application/automation/tools/octane/actions/dto/ScmResourceFile.java b/src/main/java/com/hp/application/automation/tools/octane/actions/dto/ScmResourceFile.java
new file mode 100644
index 0000000000..271977585d
--- /dev/null
+++ b/src/main/java/com/hp/application/automation/tools/octane/actions/dto/ScmResourceFile.java
@@ -0,0 +1,88 @@
+/*
+ * Copyright 2017 Hewlett-Packard Development Company, L.P.
+ * 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.
+ *
+ */
+
+package com.hp.application.automation.tools.octane.actions.dto;
+
+import javax.xml.bind.annotation.*;
+
+/**
+ * This file represents scm resource for sending to Octane
+ */
+@XmlRootElement(name="dataTable")
+@XmlAccessorType(XmlAccessType.FIELD)
+public class ScmResourceFile {
+
+ @XmlTransient
+ private Long id;
+ @XmlTransient
+ private String type = "scm_resource_file";
+ @XmlTransient
+ private BaseRefEntity scmRepository;
+
+ private String name;
+
+ private String relativePath;
+
+ private String relativePathPrevious;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getRelativePath() {
+ return relativePath;
+ }
+
+ public void setRelativePath(String relativePath) {
+ this.relativePath = relativePath;
+ }
+
+ public String getRelativePathPrevious() {
+ return relativePathPrevious;
+ }
+
+ public void setRelativePathPrevious(String relativePathPrevious) {
+ this.relativePathPrevious = relativePathPrevious;
+ }
+
+ public BaseRefEntity getScmRepository() {
+ return scmRepository;
+ }
+
+ public void setScmRepository(BaseRefEntity scmRepository) {
+ this.scmRepository = scmRepository;
+ }
+}
diff --git a/src/main/java/com/hp/application/automation/tools/octane/actions/dto/ScmResources.java b/src/main/java/com/hp/application/automation/tools/octane/actions/dto/ScmResources.java
new file mode 100644
index 0000000000..0810fb5173
--- /dev/null
+++ b/src/main/java/com/hp/application/automation/tools/octane/actions/dto/ScmResources.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2017 Hewlett-Packard Development Company, L.P.
+ * 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.
+ *
+ */
+
+package com.hp.application.automation.tools.octane.actions.dto;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * This file represents collection of scm resources for sending to Octane
+ */
+public class ScmResources {
+
+ private List data = new ArrayList<>();
+
+ public static ScmResources createWithItems(Collection resources) {
+ ScmResources result = new ScmResources();
+ result.setData(new ArrayList<>(resources));
+ return result;
+ }
+
+ public List getData() {
+ return data;
+ }
+
+ public void setData(List data) {
+ this.data = data;
+ }
+}
diff --git a/src/main/java/com/hp/application/automation/tools/octane/configuration/ConfigurationService.java b/src/main/java/com/hp/application/automation/tools/octane/configuration/ConfigurationService.java
index 7172a6b3ea..5111cc5f90 100644
--- a/src/main/java/com/hp/application/automation/tools/octane/configuration/ConfigurationService.java
+++ b/src/main/java/com/hp/application/automation/tools/octane/configuration/ConfigurationService.java
@@ -16,35 +16,115 @@
package com.hp.application.automation.tools.octane.configuration;
+import com.google.inject.Inject;
import com.hp.application.automation.tools.model.OctaneServerSettingsModel;
+import com.hp.application.automation.tools.octane.client.JenkinsMqmRestClientFactoryImpl;
import com.hp.application.automation.tools.settings.OctaneServerSettingsBuilder;
+import com.hp.mqm.client.MqmRestClient;
+import com.hp.mqm.client.exception.LoginException;
+import com.hp.mqm.client.exception.RequestException;
+import com.hp.mqm.client.exception.SharedSpaceNotExistException;
import hudson.Extension;
import hudson.Plugin;
-import hudson.model.Hudson;
import jenkins.model.Jenkins;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+/***
+ * Octane plugin configuration service -
+ * 1. helps to change Octane configuration
+ * 2. helps to get Octane configuration and model
+ * 3. helps to get RestClient based on some configuration
+ */
@Extension
public class ConfigurationService {
- public static OctaneServerSettingsModel getModel() {
- return getOctaneDescriptor().getModel();
- }
+ private JenkinsMqmRestClientFactoryImpl clientFactory;
+
+ private static Logger logger = LogManager.getLogger(ConfigurationService.class);
+
+ /**
+ * Get current {@see OctaneServerSettingsModel} model
+ *
+ * @return
+ */
+ public static OctaneServerSettingsModel getModel() {
+ return getOctaneDescriptor().getModel();
+ }
+
+ /**
+ * Get current Octane server configuration (that is based on model)
+ *
+ * @return
+ */
+ public static ServerConfiguration getServerConfiguration() {
+ return getOctaneDescriptor().getServerConfiguration();
+ }
+
+ /**
+ * Change model (used by tests)
+ *
+ * @param newModel
+ */
+ public static void configurePlugin(OctaneServerSettingsModel newModel) {
+ getOctaneDescriptor().setModel(newModel);
+ }
+
+ private static OctaneServerSettingsBuilder.OctaneDescriptorImpl getOctaneDescriptor() {
+ return Jenkins.getInstance().getDescriptorByType(OctaneServerSettingsBuilder.OctaneDescriptorImpl.class);
+ }
+
+ /**
+ * Get plugin version
+ *
+ * @return
+ */
+ public static String getPluginVersion() {
+ Plugin plugin = Jenkins.getInstance().getPlugin("hp-application-automation-tools-plugin");
+ return plugin.getWrapper().getVersion();
+ }
+
+ /**
+ * Create restClient based on some server configuration
+ *
+ * @param serverConfiguration
+ * @return
+ */
+ public MqmRestClient createClient(ServerConfiguration serverConfiguration) {
+
+ if (!serverConfiguration.isValid()) {
+ logger.warn("MQM server configuration is not valid");
+ return null;
+ }
- public static ServerConfiguration getServerConfiguration() {
- return getOctaneDescriptor().getServerConfiguration();
- }
+ MqmRestClient client = clientFactory.obtain(
+ serverConfiguration.location,
+ serverConfiguration.sharedSpace,
+ serverConfiguration.username,
+ serverConfiguration.password);
- public static void configurePlugin(OctaneServerSettingsModel newModel){
- getOctaneDescriptor().setModel(newModel);
- }
+ try {
+ client.validateConfigurationWithoutLogin();
+ return client;
+ } catch (SharedSpaceNotExistException e) {
+ logger.warn("Invalid shared space");
+ } catch (LoginException e) {
+ logger.warn("Login failed : " + e.getMessage());
+ } catch (RequestException e) {
+ logger.warn("Problem with communication with MQM server : " + e.getMessage());
+ }
- private static OctaneServerSettingsBuilder.OctaneDescriptorImpl getOctaneDescriptor(){
- return Hudson.getInstance().getDescriptorByType(OctaneServerSettingsBuilder.OctaneDescriptorImpl.class);
- }
+ return null;
+ }
- public static String getPluginVersion(){
- Plugin plugin = Jenkins.getInstance().getPlugin("hp-application-automation-tools-plugin");
- return plugin.getWrapper().getVersion();
- }
+ /**
+ * Inject client factory
+ *
+ * @param clientFactory
+ */
+ @Inject
+ public void setMqmRestClientFactory(JenkinsMqmRestClientFactoryImpl clientFactory) {
+ this.clientFactory = clientFactory;
+ }
}
diff --git a/src/main/java/com/hp/application/automation/tools/octane/events/TestListenerImpl.java b/src/main/java/com/hp/application/automation/tools/octane/events/TestListenerImpl.java
index 0c56a6ba62..5c0e68f30d 100644
--- a/src/main/java/com/hp/application/automation/tools/octane/events/TestListenerImpl.java
+++ b/src/main/java/com/hp/application/automation/tools/octane/events/TestListenerImpl.java
@@ -1,16 +1,31 @@
+/*
+ * Copyright 2017 Hewlett-Packard Development Company, L.P.
+ * 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.
+ *
+ */
+
package com.hp.application.automation.tools.octane.events;
import com.google.inject.Inject;
import com.hp.application.automation.tools.octane.tests.TestListener;
import hudson.Extension;
-import hudson.model.Run;
-import hudson.model.TaskListener;
+import hudson.model.*;
import hudson.model.listeners.RunListener;
import javax.annotation.Nonnull;
/**
- * Created by leviy on 27/03/2017.
+ * Listener on job complete event
*/
@Extension
public class TestListenerImpl extends RunListener {
diff --git a/src/main/java/com/hp/application/automation/tools/octane/executor/TestExecutionJobCreatorService.java b/src/main/java/com/hp/application/automation/tools/octane/executor/TestExecutionJobCreatorService.java
index 6debb4c166..354d343ca2 100644
--- a/src/main/java/com/hp/application/automation/tools/octane/executor/TestExecutionJobCreatorService.java
+++ b/src/main/java/com/hp/application/automation/tools/octane/executor/TestExecutionJobCreatorService.java
@@ -64,6 +64,7 @@ public class TestExecutionJobCreatorService {
public static final String EXECUTOR_ID_PARAMETER_NAME = "executorId";
public static final String SUITE_ID_PARAMETER_NAME = "suiteId";
public static final String SUITE_RUN_ID_PARAMETER_NAME = "suiteRunId";
+ public static final String FULL_SCAN_PARAMETER_NAME = "Full Scan";
/**
* Create (if needed) and run test execution
@@ -123,8 +124,8 @@ private static FreeStyleProject getExecutionJob(TestSuiteExecutionInfo suiteExec
setScmRepository(suiteExecutionInfo.getScmRepository(), suiteExecutionInfo.getScmRepositoryCredentialsId(), proj);
setBuildDiscarder(proj, 20);
- addParameter(proj, SUITE_ID_PARAMETER_NAME, suiteExecutionInfo.getSuiteId(), true, "Octane suite id");
- addParameter(proj, SUITE_RUN_ID_PARAMETER_NAME, null, false, "This parameter is relevant only if the suite is run from Octane and allows to publish tests to the existing Octane suite run");
+ addConstantParameter(proj, SUITE_ID_PARAMETER_NAME, suiteExecutionInfo.getSuiteId(), "Octane suite id");
+ addStringParameter(proj, SUITE_RUN_ID_PARAMETER_NAME, null, "This parameter is relevant only if the suite is run from Octane and allows to publish tests to the existing Octane suite run");
addAssignedNode(proj);
//add build action
@@ -239,12 +240,15 @@ public static void runTestDiscovery(DiscoveryInfo discoveryInfo) {
*/
FreeStyleProject proj = getDiscoveryJob(discoveryInfo);
+ //start job
if (proj != null) {
- if (discoveryInfo.isForceFullDiscovery() && proj.getWorkspace() != null) {
- UFTTestDetectionService.removeInitialDetectionFlag(proj.getWorkspace());
- }
+ ParameterValue executorIdParam = new StringParameterValue(EXECUTOR_ID_PARAMETER_NAME, discoveryInfo.getExecutorId());
+ ParameterValue fullScanParam = new BooleanParameterValue(FULL_SCAN_PARAMETER_NAME, discoveryInfo.isForceFullDiscovery());
+ ParametersAction parameters = new ParametersAction(executorIdParam, fullScanParam);
- proj.scheduleBuild2(0);
+ Cause cause = new Cause.UserIdCause();
+ CauseAction causeAction = new CauseAction(cause);
+ proj.scheduleBuild2(0, parameters, causeAction);
}
}
@@ -263,7 +267,8 @@ private static FreeStyleProject getDiscoveryJob(DiscoveryInfo discoveryInfo) {
setScmRepository(discoveryInfo.getScmRepository(), discoveryInfo.getScmRepositoryCredentialsId(), proj);
setBuildDiscarder(proj, 20);
- addParameter(proj, EXECUTOR_ID_PARAMETER_NAME, discoveryInfo.getExecutorId(), true, "Octane executor id");
+ addConstantParameter(proj, EXECUTOR_ID_PARAMETER_NAME, discoveryInfo.getExecutorId(), "Octane executor id");
+ addBooleanParameter(proj, FULL_SCAN_PARAMETER_NAME, false, "Indicate whether to scan full scm repository to discover all tests or to use changes (Change Sets) to update already existing tests");
//set polling once in two minutes
SCMTrigger scmTrigger = new SCMTrigger("H/2 * * * *");//H/2 * * * * : once in two minutes
@@ -321,27 +326,37 @@ public void run() {
}, delayStartPolling);
}
- private static void addParameter(FreeStyleProject proj, String parameterName, String parameterValue, boolean constantValue, String desc) throws IOException {
+ private static ParametersDefinitionProperty getParametersDefinitions(FreeStyleProject proj) throws IOException {
ParametersDefinitionProperty parameters = proj.getProperty(ParametersDefinitionProperty.class);
if (parameters == null) {
parameters = new ParametersDefinitionProperty(new ArrayList());
proj.addProperty(parameters);
}
+ return parameters;
+ }
- if (constantValue) {
- if (parameters.getParameterDefinition(parameterName) == null) {
- //String name, List choices, String defaultValue, String description
- ParameterDefinition param = new ChoiceParameterDefinition(parameterName, new String[]{parameterValue}, desc);
- parameters.getParameterDefinitions().add(param);
- }
- } else {
- if (parameters.getParameterDefinition(parameterName) == null) {
- //String name, List choices, String defaultValue, String description
- ParameterDefinition param = new StringParameterDefinition(parameterName, null, desc);
- parameters.getParameterDefinitions().add(param);
- }
+ private static void addConstantParameter(FreeStyleProject proj, String parameterName, String parameterValue, String desc) throws IOException {
+ ParametersDefinitionProperty parameters = getParametersDefinitions(proj);
+ if (parameters.getParameterDefinition(parameterName) == null) {
+ ParameterDefinition param = new ChoiceParameterDefinition(parameterName, new String[]{parameterValue}, desc);
+ parameters.getParameterDefinitions().add(param);
+ }
+ }
+
+ private static void addStringParameter(FreeStyleProject proj, String parameterName, String defaultValue, String desc) throws IOException {
+ ParametersDefinitionProperty parameters = getParametersDefinitions(proj);
+ if (parameters.getParameterDefinition(parameterName) == null) {
+ ParameterDefinition param = new StringParameterDefinition(parameterName, defaultValue, desc);
+ parameters.getParameterDefinitions().add(param);
}
+ }
+ private static void addBooleanParameter(FreeStyleProject proj, String parameterName, Boolean defaultValue, String desc) throws IOException {
+ ParametersDefinitionProperty parameters = getParametersDefinitions(proj);
+ if (parameters.getParameterDefinition(parameterName) == null) {
+ ParameterDefinition param = new BooleanParameterDefinition(parameterName, defaultValue, desc);
+ parameters.getParameterDefinitions().add(param);
+ }
}
/**
@@ -373,7 +388,7 @@ public static void deleteExecutor(String id) {
}
try {
- logger.warn(String.format("Job %s is going to be deleted since matching executor in Octane was deleted", proj.getName()));
+ logger.warn(String.format("Job '%s' is going to be deleted since matching executor in Octane was deleted", proj.getName()));
proj.delete();
} catch (IOException | InterruptedException e) {
logger.error("Failed to delete job " + proj.getName() + " : " + e.getMessage());
diff --git a/src/main/java/com/hp/application/automation/tools/octane/executor/UFTTestDetectionResult.java b/src/main/java/com/hp/application/automation/tools/octane/executor/UFTTestDetectionResult.java
index ffcff781f4..7525fa663a 100644
--- a/src/main/java/com/hp/application/automation/tools/octane/executor/UFTTestDetectionResult.java
+++ b/src/main/java/com/hp/application/automation/tools/octane/executor/UFTTestDetectionResult.java
@@ -17,33 +17,53 @@
package com.hp.application.automation.tools.octane.executor;
import com.hp.application.automation.tools.octane.actions.dto.AutomatedTest;
+import com.hp.application.automation.tools.octane.actions.dto.ScmResourceFile;
import javax.xml.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
-
-@XmlRootElement(name="detectionResult")
+/**
+ * This file represents result of UFT detection files (tests and data tables)
+ */
+@XmlRootElement(name = "detectionResult")
@XmlAccessorType(XmlAccessType.FIELD)
public class UFTTestDetectionResult {
- @XmlElementWrapper(name="newTests")
- @XmlElement(name="test")
+ @XmlElementWrapper(name = "newTests")
+ @XmlElement(name = "test")
private List newTests = new ArrayList<>();
+ @XmlElementWrapper(name = "deletedTests")
+ @XmlElement(name = "test")
private List deletedTests = new ArrayList<>();
+ @XmlElementWrapper(name = "updatedTests")
+ @XmlElement(name = "test")
private List updatedTests = new ArrayList<>();
+ @XmlElementWrapper(name = "newDataTables")
+ @XmlElement(name = "dataTable")
+ private List newScmResourceFiles = new ArrayList<>();
+
+ @XmlElementWrapper(name = "deletedDataTables")
+ @XmlElement(name = "dataTable")
+ private List deletedScmResourceFiles = new ArrayList<>();
+
+ @XmlElementWrapper(name = "updatedDataTables")
+ @XmlElement(name = "dataTable")
+ private List updatedScmResourceFiles = new ArrayList<>();
+
+
@XmlAttribute
- private String scmResourceId;
+ private String scmRepositoryId;
@XmlAttribute
private String workspaceId;
@XmlAttribute
- private boolean initialDetection;
+ private boolean fullScan;
public List getNewTests() {
return newTests;
@@ -57,12 +77,12 @@ public List getUpdatedTests() {
return updatedTests;
}
- public String getScmResourceId() {
- return scmResourceId;
+ public String getScmRepositoryId() {
+ return scmRepositoryId;
}
- public void setScmResourceId(String scmResourceId) {
- this.scmResourceId = scmResourceId;
+ public void setScmRepositoryId(String scmRepositoryId) {
+ this.scmRepositoryId = scmRepositoryId;
}
public String getWorkspaceId() {
@@ -73,15 +93,29 @@ public void setWorkspaceId(String workspaceId) {
this.workspaceId = workspaceId;
}
- public boolean isInitialDetection() {
- return initialDetection;
+ public boolean isFullScan() {
+ return fullScan;
}
- public void setInitialDetection(boolean initialDetection) {
- this.initialDetection = initialDetection;
+ public void setFullScan(boolean fullScan) {
+ this.fullScan = fullScan;
}
- public boolean hasChanges(){
- return !getNewTests().isEmpty() || !getUpdatedTests().isEmpty();
+ public boolean hasChanges() {
+ return !getNewTests().isEmpty() || !getUpdatedTests().isEmpty() || !getDeletedTests().isEmpty()
+ || !getNewScmResourceFiles().isEmpty() || !getDeletedScmResourceFiles().isEmpty() || !getUpdatedScmResourceFiles().isEmpty();
}
+
+ public List getNewScmResourceFiles() {
+ return newScmResourceFiles;
+ }
+
+ public List getDeletedScmResourceFiles() {
+ return deletedScmResourceFiles;
+ }
+
+ public List getUpdatedScmResourceFiles() {
+ return updatedScmResourceFiles;
+ }
+
}
\ No newline at end of file
diff --git a/src/main/java/com/hp/application/automation/tools/octane/executor/UFTTestDetectionService.java b/src/main/java/com/hp/application/automation/tools/octane/executor/UFTTestDetectionService.java
index f36bc23d30..28b16ef2db 100644
--- a/src/main/java/com/hp/application/automation/tools/octane/executor/UFTTestDetectionService.java
+++ b/src/main/java/com/hp/application/automation/tools/octane/executor/UFTTestDetectionService.java
@@ -19,12 +19,10 @@
import com.hp.application.automation.tools.octane.actions.UFTTestUtil;
import com.hp.application.automation.tools.octane.actions.UftTestType;
import com.hp.application.automation.tools.octane.actions.dto.AutomatedTest;
+import com.hp.application.automation.tools.octane.actions.dto.ScmResourceFile;
import hudson.ExtensionList;
import hudson.FilePath;
-import hudson.model.AbstractBuild;
-import hudson.model.BuildListener;
-import hudson.model.Run;
-import hudson.model.TaskListener;
+import hudson.model.*;
import hudson.plugins.git.GitChangeSet;
import hudson.scm.ChangeLogSet;
import hudson.scm.EditType;
@@ -49,31 +47,49 @@ public class UFTTestDetectionService {
private static final String DETECTION_RESULT_FILE = "detection_result.xml";
private static final String STFileExtention = ".st";//api test
private static final String QTPFileExtention = ".tsp";//gui test
+ private static final String XLSXExtention = ".xlsx";//excel file
+ private static final String XLSExtention = ".xls";//excel file
+ private static final String windowsPathSplitter = "\\";
+ private static final String linuxPathSplitter = "/";
- public static UFTTestDetectionResult startScanning(AbstractBuild, ?> build, String workspaceId, String scmResourceId, BuildListener buildListener) {
+
+ public static UFTTestDetectionResult startScanning(AbstractBuild, ?> build, String workspaceId, String scmRepositoryId, BuildListener buildListener) {
ChangeLogSet extends ChangeLogSet.Entry> changeSet = build.getChangeSet();
Object[] changeSetItems = changeSet.getItems();
UFTTestDetectionResult result = null;
try {
- boolean initialDetection = !initialDetectionFileExist(build.getWorkspace());
- if (initialDetection) {
+ boolean fullScan = build.getId().equals("1") || !initialDetectionFileExist(build.getWorkspace()) || isFullScan((build));
+ if (fullScan) {
printToConsole(buildListener, "Executing initial detection");
result = doInitialDetection(build.getWorkspace());
} else {
printToConsole(buildListener, "Executing changeSet detection");
result = doChangeSetDetection(changeSetItems, build.getWorkspace());
removeTestDuplicated(result.getUpdatedTests());
+ removeFalsePositiveDeletedDataTables(result.getDeletedTests(), result.getDeletedScmResourceFiles());
}
- printToConsole(buildListener, String.format("Found %s new tests", result.getNewTests().size()));
- printToConsole(buildListener, String.format("Found %s updated tests", result.getUpdatedTests().size()));
-
+ if (!result.getNewTests().isEmpty()) {
+ printToConsole(buildListener, String.format("Found %s new tests", result.getNewTests().size()));
+ }
+ if (!result.getUpdatedTests().isEmpty()) {
+ printToConsole(buildListener, String.format("Found %s updated tests", result.getUpdatedTests().size()));
+ }
+ if (!result.getDeletedTests().isEmpty()) {
+ printToConsole(buildListener, String.format("Found %s deleted tests", result.getDeletedTests().size()));
+ }
+ if (!result.getNewScmResourceFiles().isEmpty()) {
+ printToConsole(buildListener, String.format("Found %s new data tables", result.getNewScmResourceFiles().size()));
+ }
+ if (!result.getDeletedScmResourceFiles().isEmpty()) {
+ printToConsole(buildListener, String.format("Found %s deleted data tables", result.getDeletedScmResourceFiles().size()));
+ }
- result.setScmResourceId(scmResourceId);
+ result.setScmRepositoryId(scmRepositoryId);
result.setWorkspaceId(workspaceId);
- result.setInitialDetection(initialDetection);
+ result.setFullScan(fullScan);
sortTests(result.getNewTests());
sortTests(result.getUpdatedTests());
publishDetectionResults(build, buildListener, result);
@@ -82,6 +98,7 @@ public static UFTTestDetectionResult startScanning(AbstractBuild, ?> build, St
UftTestDiscoveryDispatcher dispatcher = getExtension(UftTestDiscoveryDispatcher.class);
dispatcher.enqueueResult(build.getProject().getName(), build.getNumber());
}
+ createInitialDetectionFile(build.getWorkspace());
} catch (InterruptedException | IOException e) {
e.printStackTrace();
@@ -90,6 +107,45 @@ public static UFTTestDetectionResult startScanning(AbstractBuild, ?> build, St
return result;
}
+ /**
+ * Deleted data table might be part of deleted test. During discovery its very hard to know.
+ * Here we pass through all deleted data tables, if we found table parent is test package - we know that the delete was part of test delete
+ *
+ * @param deletedTests
+ * @param deletedScmResourceFiles
+ */
+ private static void removeFalsePositiveDeletedDataTables(List deletedTests, List deletedScmResourceFiles) {
+ if (!deletedScmResourceFiles.isEmpty() && !deletedTests.isEmpty()) {
+
+ List falsePositive = new ArrayList<>();
+ for (ScmResourceFile item : deletedScmResourceFiles) {
+ int parentSplitterIndex = item.getRelativePath().lastIndexOf(windowsPathSplitter);
+ if (parentSplitterIndex != -1) {
+ String parentName = item.getRelativePath().substring(0, parentSplitterIndex);
+ for (AutomatedTest test : deletedTests) {
+ String testPath = test.getPackage() + windowsPathSplitter + test.getName();
+ if (testPath.equals(parentName)) {
+ falsePositive.add(item);
+ break;
+ }
+ }
+ }
+ }
+ deletedScmResourceFiles.removeAll(falsePositive);
+ }
+ }
+
+ private static boolean isFullScan(AbstractBuild, ?> build) {
+ ParametersAction parameters = build.getAction(ParametersAction.class);
+ if (parameters != null) {
+ ParameterValue parameterValue = parameters.getParameter(TestExecutionJobCreatorService.FULL_SCAN_PARAMETER_NAME);
+ if (parameterValue != null) {
+ return (Boolean) parameterValue.getValue();
+ }
+ }
+ return false;
+ }
+
private static void sortTests(List newTests) {
Collections.sort(newTests, new Comparator() {
@Override
@@ -143,24 +199,40 @@ private static UFTTestDetectionResult doChangeSetDetection(Object[] changeSetIte
for (int i = 0; i < changeSetItems.length; i++) {
GitChangeSet changeSet = (GitChangeSet) changeSetItems[i];
for (GitChangeSet.Path path : changeSet.getPaths()) {
+ String fileFullPath = workspace + File.separator + path.getPath();
if (isTestMainFilePath(path.getPath())) {
- String filePath = workspace + File.separator + path.getPath();
if (EditType.ADD.equals(path.getEditType())) {
- if (isFileExist(filePath)) {
- FilePath testFolder = getTestFolderForTestMainFile(filePath);
- scanFileSystemRecursively(workspace, testFolder, result.getNewTests());
+ if (isFileExist(fileFullPath)) {
+ FilePath testFolder = getTestFolderForTestMainFile(fileFullPath);
+ scanFileSystemRecursively(workspace, testFolder, result.getNewTests(), result.getNewScmResourceFiles());
}
} else if (EditType.DELETE.equals(path.getEditType())) {
- if (!isFileExist(filePath)) {
- FilePath testFolder = getTestFolderForTestMainFile(filePath);
- AutomatedTest test = createAutomatedTest(workspace, testFolder);
+ if (!isFileExist(fileFullPath)) {
+ FilePath testFolder = getTestFolderForTestMainFile(fileFullPath);
+ AutomatedTest test = createAutomatedTest(workspace, testFolder, null, false);
result.getDeletedTests().add(test);
}
} else if (EditType.EDIT.equals(path.getEditType())) {
- if (isFileExist(filePath)) {
- FilePath testFolder = getTestFolderForTestMainFile(filePath);
- scanFileSystemRecursively(workspace, testFolder, result.getUpdatedTests());
+ if (isFileExist(fileFullPath)) {
+ FilePath testFolder = getTestFolderForTestMainFile(fileFullPath);
+ scanFileSystemRecursively(workspace, testFolder, result.getUpdatedTests(), result.getUpdatedScmResourceFiles());
+ }
+ }
+ } else if (isUftDataTableFile(path.getPath())) {
+ FilePath filePath = new FilePath(new File(fileFullPath));
+ if (EditType.ADD.equals(path.getEditType())) {
+ UftTestType testType = isUftTestFolder(filePath.getParent().list());
+ if (testType.isNone()) {
+ if (filePath.exists()) {
+ ScmResourceFile resourceFile = createDataTable(workspace, filePath);
+ result.getNewScmResourceFiles().add(resourceFile);
+ }
+ }
+ } else if (EditType.DELETE.equals(path.getEditType())) {
+ if (!filePath.exists()) {
+ ScmResourceFile resourceFile = createDataTable(workspace, filePath);
+ result.getDeletedScmResourceFiles().add(resourceFile);
}
}
}
@@ -170,20 +242,37 @@ private static UFTTestDetectionResult doChangeSetDetection(Object[] changeSetIte
return result;
}
- private static AutomatedTest createAutomatedTest(FilePath root, FilePath dirPath) throws IOException, InterruptedException {
+ private static AutomatedTest createAutomatedTest(FilePath root, FilePath dirPath, UftTestType testType, boolean executable) throws IOException, InterruptedException {
AutomatedTest test = new AutomatedTest();
test.setName(dirPath.getName());
- //set component - relative path from root
- String testPath = dirPath.toURI().toString();
- String rootPath = root.toURI().toString();
- String path = testPath.replace(rootPath, "");
- path = StringUtils.strip(path, "\\/");
- String _package = path.length() != dirPath.getName().length() ? path.substring(0, path.length() - dirPath.getName().length() - 1) : "";
- test.setPackage(_package);
+
+ String relativePath = getRelativePath(root, dirPath);
+ String packageName = relativePath.length() != dirPath.getName().length() ? relativePath.substring(0, relativePath.length() - dirPath.getName().length() - 1) : "";
+ test.setPackage(packageName);
+ test.setExecutable(executable);
+
+ if (testType != null && !testType.isNone()) {
+ test.setUftTestType(testType);
+ }
+
+ String description = UFTTestUtil.getTestDescription(dirPath);
+ test.setDescription(description);
+
return test;
}
+ private static String getRelativePath(FilePath root, FilePath path) throws IOException, InterruptedException {
+ String testPath = path.getRemote();
+ String rootPath = root.getRemote();
+ String relativePath = testPath.replace(rootPath, "");
+ relativePath = StringUtils.strip(relativePath, windowsPathSplitter + linuxPathSplitter);
+ //we want all paths will be in sindows style, because tests are run in windows, therefore we replace all linux splitters (/) by windows one (\)
+ //http://stackoverflow.com/questions/23869613/how-to-replace-one-or-more-in-string-with-just
+ relativePath = relativePath.replaceAll(linuxPathSplitter, windowsPathSplitter + windowsPathSplitter);//str.replaceAll("/", "\\\\");
+ return relativePath;
+ }
+
private static boolean isFileExist(String path) {
File file = new File(path);
return file.exists();
@@ -200,7 +289,7 @@ private static boolean initialDetectionFileExist(FilePath workspace) {
}
}
- public static void createInitialDetectionFile(FilePath workspace) {
+ private static void createInitialDetectionFile(FilePath workspace) {
try {
File rootFile = new File(workspace.toURI());
File file = new File(rootFile, INITIAL_DETECTION_FILE);
@@ -210,7 +299,7 @@ public static void createInitialDetectionFile(FilePath workspace) {
}
}
- public static void removeInitialDetectionFlag(FilePath workspace) {
+ /*private static void removeInitialDetectionFlag(FilePath workspace) {
try {
File rootFile = new File(workspace.toURI());
File file = new File(rootFile, INITIAL_DETECTION_FILE);
@@ -218,35 +307,47 @@ public static void removeInitialDetectionFlag(FilePath workspace) {
} catch (IOException | InterruptedException e) {
logger.error("Failed to removeInitialDetectionFlag");
}
- }
+ }*/
private static UFTTestDetectionResult doInitialDetection(FilePath workspace) throws IOException, InterruptedException {
UFTTestDetectionResult result = new UFTTestDetectionResult();
- scanFileSystemRecursively(workspace, workspace, result.getNewTests());
+ scanFileSystemRecursively(workspace, workspace, result.getNewTests(), result.getNewScmResourceFiles());
return result;
}
- private static void scanFileSystemRecursively(FilePath root, FilePath dirPath, List foundTests) throws IOException, InterruptedException {
- List paths = dirPath.list();
+ private static void scanFileSystemRecursively(FilePath root, FilePath dirPath, List foundTests, List foundResources) throws IOException, InterruptedException {
+ List paths = dirPath.isDirectory() ? dirPath.list() : Arrays.asList(dirPath);
//if it test folder - create new test, else drill down to subFolders
UftTestType testType = isUftTestFolder(paths);
if (!testType.isNone()) {
- AutomatedTest test = createAutomatedTest(root, dirPath);
- test.setUftTestType(testType);
- String description = UFTTestUtil.getTestDescription(dirPath);
- test.setDescription(description);
+ AutomatedTest test = createAutomatedTest(root, dirPath, testType, true);
foundTests.add(test);
} else {
for (FilePath path : paths) {
if (path.isDirectory()) {
- scanFileSystemRecursively(root, path, foundTests);
+ scanFileSystemRecursively(root, path, foundTests, foundResources);
+ } else if (isUftDataTableFile(path.getName())) {
+ ScmResourceFile dataTable = createDataTable(root, path);
+ foundResources.add(dataTable);
}
}
}
}
+ private static ScmResourceFile createDataTable(FilePath root, FilePath path) throws IOException, InterruptedException {
+ ScmResourceFile resourceFile = new ScmResourceFile();
+ resourceFile.setName(path.getName());
+ resourceFile.setRelativePath(getRelativePath(root, path));
+ return resourceFile;
+
+ }
+
+ private static boolean isUftDataTableFile(String path) {
+ return path.endsWith(XLSXExtention) || path.endsWith(XLSExtention);
+ }
+
private static UftTestType isUftTestFolder(List paths) {
for (FilePath path : paths) {
if (path.getName().endsWith(STFileExtention)) {
diff --git a/src/main/java/com/hp/application/automation/tools/octane/executor/UftJobCleaner.java b/src/main/java/com/hp/application/automation/tools/octane/executor/UftJobCleaner.java
index bc3cf56248..858e4dabaf 100644
--- a/src/main/java/com/hp/application/automation/tools/octane/executor/UftJobCleaner.java
+++ b/src/main/java/com/hp/application/automation/tools/octane/executor/UftJobCleaner.java
@@ -16,20 +16,25 @@
package com.hp.application.automation.tools.octane.executor;
+import com.google.inject.Inject;
+import com.hp.application.automation.tools.octane.actions.UFTTestDetectionPublisher;
+import com.hp.application.automation.tools.octane.configuration.ConfigurationService;
+import com.hp.application.automation.tools.octane.configuration.ServerConfiguration;
import com.hp.application.automation.tools.octane.tests.AbstractSafeLoggingAsyncPeriodWork;
+import com.hp.mqm.client.MqmRestClient;
+import com.hp.mqm.client.QueryHelper;
+import com.hp.mqm.client.model.Entity;
+import com.hp.mqm.client.model.PagedList;
import hudson.Extension;
-import hudson.model.FreeStyleProject;
-import hudson.model.ParametersDefinitionProperty;
-import hudson.model.PeriodicWork;
-import hudson.model.TaskListener;
+import hudson.model.*;
import jenkins.model.Jenkins;
+import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.io.IOException;
-import java.util.Date;
-import java.util.List;
+import java.util.*;
/**
@@ -40,7 +45,8 @@
public class UftJobCleaner extends AbstractSafeLoggingAsyncPeriodWork {
private static Logger logger = LogManager.getLogger(UftJobCleaner.class);
-
+ private ConfigurationService configurationService;
+ private static String EXECUTORS_COLLECTION_NAME = "executors";
public UftJobCleaner() {
super("Uft Job Cleaner");
@@ -74,8 +80,13 @@ private long getOutdateThreshold() {
@Override
protected void doExecute(TaskListener listener) throws IOException, InterruptedException {
List jobs = Jenkins.getInstance().getAllItems(FreeStyleProject.class);
- long thresholdTimeInMillis = new Date().getTime() - PeriodicWork.DAY * getOutdateThreshold();
+ clearExecutionJobs(jobs);
+ clearDiscoveryJobs(jobs);
+ }
+
+ private void clearExecutionJobs(List jobs) {
+ long thresholdTimeInMillis = new Date().getTime() - PeriodicWork.DAY * getOutdateThreshold();
int clearCounter = 0;
for (FreeStyleProject job : jobs) {
if (isExecutorJob(job) && job.getLastBuild() != null && !job.isBuilding()) {
@@ -92,18 +103,118 @@ protected void doExecute(TaskListener listener) throws IOException, InterruptedE
}
}
- logger.warn(String.format("Cleaner found %s outdated job", clearCounter));
+ logger.warn(String.format("Cleaner found %s outdated execution job", clearCounter));
}
private boolean isExecutorJob(FreeStyleProject job) {
ParametersDefinitionProperty parameters = job.getProperty(ParametersDefinitionProperty.class);
- if (parameters != null &&
+ boolean isExecutorJob = job.getName().contains("execution job") &&
+ parameters != null &&
parameters.getParameterDefinition(TestExecutionJobCreatorService.SUITE_ID_PARAMETER_NAME) != null &&
- parameters.getParameterDefinition(TestExecutionJobCreatorService.SUITE_RUN_ID_PARAMETER_NAME) != null) {
- return true;
+ parameters.getParameterDefinition(TestExecutionJobCreatorService.SUITE_RUN_ID_PARAMETER_NAME) != null;
+
+ return isExecutorJob;
+ }
+
+
+ private boolean isDiscoveryJobJob(FreeStyleProject job) {
+ ParametersDefinitionProperty parameters = job.getProperty(ParametersDefinitionProperty.class);
+ boolean isDiscoveryJob = job.getName().contains("discovery job") &&
+ parameters != null &&
+ parameters.getParameterDefinition(TestExecutionJobCreatorService.EXECUTOR_ID_PARAMETER_NAME) != null;
+ return isDiscoveryJob;
+ }
+
+ private void clearDiscoveryJobs(List jobs) {
+
+ //Generally, after deleting executor in Octane, relevant job in Jenkins is also deleted. But if jenkins was down during delete of executor, job remains
+ //This method handle orphan job that doesn't hava mathing executors in Octane
+ //1. build map of discovery jobs per workspace
+ //2. Loop by workspace
+ //2.1 Get from octane executors in workspace
+ //2.2 If some discovery job exist that doesn't have matching executor - remove it from Jenkins
+
+ Map> workspace2executorId2DiscoveryJobMap = new HashMap<>();
+ for (FreeStyleProject job : jobs) {
+ if (isDiscoveryJobJob(job)) {
+ Long executorId = getExecutorId(job);
+ Long workspaceId = getOctaneWorkspaceId(job);
+ if (executorId != null && workspaceId != null) {
+ if (!workspace2executorId2DiscoveryJobMap.containsKey(workspaceId)) {
+ workspace2executorId2DiscoveryJobMap.put(workspaceId, new HashedMap());
+ }
+ workspace2executorId2DiscoveryJobMap.get(workspaceId).put(executorId, job);
+ }
+ }
}
- return false;
+
+ if (!workspace2executorId2DiscoveryJobMap.isEmpty()) {
+ ServerConfiguration serverConfiguration = ConfigurationService.getServerConfiguration();
+ MqmRestClient client = configurationService.createClient(serverConfiguration);
+ if (client != null) {
+ int deleteCounter = 0;
+ for (Long workspaceId : workspace2executorId2DiscoveryJobMap.keySet()) {
+ Map discoveryJobs = workspace2executorId2DiscoveryJobMap.get(workspaceId);
+ List conditions = new ArrayList<>();
+ conditions.add(QueryHelper.conditionIn("id", discoveryJobs.keySet(), true));
+ try {
+ PagedList entities = client.getEntities(workspaceId, EXECUTORS_COLLECTION_NAME, conditions, Arrays.asList("id"));
+ Set octaneExecutorIds = new HashSet<>();
+ for (Entity executor : entities.getItems()) {
+ octaneExecutorIds.add(executor.getId());
+ }
+ for (Long jobExecutorId : discoveryJobs.keySet()) {
+ if (!octaneExecutorIds.contains(jobExecutorId)) {
+ //found discovery job that is not related to any executor in Octane
+ FreeStyleProject job = discoveryJobs.get(jobExecutorId);
+ try {
+ logger.warn(String.format("Job %s is going to be deleted as is doesn't have matching executor in Octane in workspace %s", job.getName(), workspaceId));
+ deleteCounter++;
+ job.delete();
+
+ } catch (Exception e) {
+ logger.warn(String.format("Failed to delete job %s : %s", job.getName(), e.getMessage()));
+ }
+
+ }
+ }
+ } catch (Exception e) {
+ //on exception - do nothing and skip to next workspace
+ logger.warn(String.format("Failed to get executors from workspace %s : %s", workspaceId, e.getMessage()));
+ continue;
+ }
+ }
+ logger.warn(String.format("Cleaner found %s not-related discovery job", deleteCounter));
+ }
+ }
+ }
+
+
+ private Long getExecutorId(FreeStyleProject job) {
+ ParametersDefinitionProperty parameters = job.getProperty(ParametersDefinitionProperty.class);
+ ParameterDefinition pd = parameters.getParameterDefinition(TestExecutionJobCreatorService.EXECUTOR_ID_PARAMETER_NAME);
+ String value = (String) pd.getDefaultParameterValue().getValue();
+ return Long.valueOf(value);
}
+ private Long getOctaneWorkspaceId(FreeStyleProject job) {
+
+ UFTTestDetectionPublisher uftTestDetectionPublisher = null;
+ List publishers = job.getPublishersList();
+ for (Object publisher : publishers) {
+ if (publisher instanceof UFTTestDetectionPublisher) {
+ uftTestDetectionPublisher = (UFTTestDetectionPublisher) publisher;
+ String workspaceId = uftTestDetectionPublisher.getWorkspaceName();
+ return Long.valueOf(workspaceId);
+ }
+ }
+
+ return null;
+ }
+
+ @Inject
+ public void setConfigurationService(ConfigurationService configurationService) {
+ this.configurationService = configurationService;
+ }
}
diff --git a/src/main/java/com/hp/application/automation/tools/octane/executor/UftTestDiscoveryDispatcher.java b/src/main/java/com/hp/application/automation/tools/octane/executor/UftTestDiscoveryDispatcher.java
index ec5645e2e4..1b6f20066a 100644
--- a/src/main/java/com/hp/application/automation/tools/octane/executor/UftTestDiscoveryDispatcher.java
+++ b/src/main/java/com/hp/application/automation/tools/octane/executor/UftTestDiscoveryDispatcher.java
@@ -17,24 +17,20 @@
package com.hp.application.automation.tools.octane.executor;
import com.google.inject.Inject;
+import com.hp.application.automation.tools.common.HttpStatus;
import com.hp.application.automation.tools.octane.ResultQueue;
import com.hp.application.automation.tools.octane.actions.UftTestType;
import com.hp.application.automation.tools.octane.actions.dto.*;
-import com.hp.application.automation.tools.octane.client.JenkinsMqmRestClientFactory;
-import com.hp.application.automation.tools.octane.client.JenkinsMqmRestClientFactoryImpl;
import com.hp.application.automation.tools.octane.configuration.ConfigurationService;
import com.hp.application.automation.tools.octane.configuration.ServerConfiguration;
import com.hp.application.automation.tools.octane.tests.AbstractSafeLoggingAsyncPeriodWork;
import com.hp.mqm.client.MqmRestClient;
-import com.hp.mqm.client.exception.LoginException;
+import com.hp.mqm.client.QueryHelper;
import com.hp.mqm.client.exception.RequestErrorException;
-import com.hp.mqm.client.exception.RequestException;
-import com.hp.mqm.client.exception.SharedSpaceNotExistException;
+import com.hp.mqm.client.model.Entity;
import com.hp.mqm.client.model.ListItem;
import com.hp.mqm.client.model.PagedList;
-import com.hp.mqm.client.model.Test;
import hudson.Extension;
-import hudson.model.AbstractBuild;
import hudson.model.Job;
import hudson.model.Run;
import hudson.model.TaskListener;
@@ -64,10 +60,13 @@
public class UftTestDiscoveryDispatcher extends AbstractSafeLoggingAsyncPeriodWork {
private static Logger logger = LogManager.getLogger(UftTestDiscoveryDispatcher.class);
- private final static int RESPONSE_STATUS_CONFLICT = 409;
+ private final static String TESTS_COLLECTION_NAME = "automated_tests";
+ private final static String SCM_RESOURCE_FILES_COLLECTION_NAME = "scm_resource_files";
+
+ private final static int BULK_SIZE = 100;
private UftTestDiscoveryQueue queue;
- private JenkinsMqmRestClientFactory clientFactory;
+ private ConfigurationService configurationService;
public UftTestDiscoveryDispatcher() {
super("Uft Test Discovery Dispatcher");
@@ -81,82 +80,107 @@ protected void doExecute(TaskListener listener) throws IOException, InterruptedE
}
logger.warn("Queue size " + queue.size());
- //logger.info("... done, left to send " + events.size() + " events");
ServerConfiguration serverConfiguration = ConfigurationService.getServerConfiguration();
- MqmRestClient client = createClient(serverConfiguration);
+ MqmRestClient client = configurationService.createClient(serverConfiguration);
+
if (client == null) {
+ logger.warn("There are pending discovered UFT tests, but MQM server configuration is not valid, results can't be submitted");
return;
}
- ResultQueue.QueueItem item;
- while ((item = queue.peekFirst()) != null) {
+ ResultQueue.QueueItem item = null;
+ try {
+ while ((item = queue.peekFirst()) != null) {
- Job project = (Job) Jenkins.getInstance().getItemByFullName(item.getProjectName());
- if (project == null) {
- logger.warn("Project [" + item.getProjectName() + "] no longer exists, pending discovered tests can't be submitted");
- queue.remove();
- continue;
- }
+ Job project = (Job) Jenkins.getInstance().getItemByFullName(item.getProjectName());
+ if (project == null) {
+ logger.warn("Project [" + item.getProjectName() + "] no longer exists, pending discovered tests can't be submitted");
+ queue.remove();
+ continue;
+ }
- Run build = project.getBuildByNumber(item.getBuildNumber());
- if (build == null) {
- logger.warn("Build [" + item.getProjectName() + "#" + item.getBuildNumber() + "] no longer exists, pending discovered tests can't be submitted");
- queue.remove();
- continue;
- }
+ Run build = project.getBuildByNumber(item.getBuildNumber());
+ if (build == null) {
+ logger.warn("Build [" + item.getProjectName() + "#" + item.getBuildNumber() + "] no longer exists, pending discovered tests can't be submitted");
+ queue.remove();
+ continue;
+ }
+
+ UFTTestDetectionResult result = UFTTestDetectionService.readDetectionResults(build);
+ if (result == null) {
+ logger.warn("Build [" + item.getProjectName() + "#" + item.getBuildNumber() + "] no longer contains valid detection result file");
+ queue.remove();
+ continue;
+ }
- UFTTestDetectionResult result = UFTTestDetectionService.readDetectionResults(build);
- if (result == null) {
- logger.warn("Build [" + item.getProjectName() + "#" + item.getBuildNumber() + "] no longer contains valid detection result file");
+ logger.warn("Persistence [" + item.getProjectName() + "#" + item.getBuildNumber() + "]");
+ dispatchDetectionResults(item, client, result);
queue.remove();
- continue;
}
-
- logger.warn("Persistence [" + item.getProjectName() + "#" + item.getBuildNumber() + "]");
- dispatchDetectionResults(item, client, serverConfiguration, result);
- if (result.isInitialDetection()) {
- UFTTestDetectionService.createInitialDetectionFile(((AbstractBuild) build).getWorkspace());
+ } catch (Exception e) {
+ if (item != null) {
+ item.incrementFailCount();
+ int maxTrial = 5;
+ if (item.incrementFailCount() > maxTrial) {
+ queue.remove();
+ logger.warn("Failed to persist discovery of [" + item.getProjectName() + "#" + item.getBuildNumber() + "] after " + maxTrial + " trials");
+ }
}
- queue.remove();
}
}
- private void dispatchDetectionResults(ResultQueue.QueueItem item, MqmRestClient client, ServerConfiguration serverConfiguration, UFTTestDetectionResult result) throws UnsupportedEncodingException {
- String serverURL = getServerURL(result.getWorkspaceId(), serverConfiguration.sharedSpace, serverConfiguration.location);
+ private void dispatchDetectionResults(ResultQueue.QueueItem item, MqmRestClient client, UFTTestDetectionResult result) throws UnsupportedEncodingException {
//post new tests
if (!result.getNewTests().isEmpty()) {
- boolean posted = postTests(client, serverURL, result.getNewTests(), result.getWorkspaceId(), result.getScmResourceId());
+ boolean posted = postTests(client, result.getNewTests(), result.getWorkspaceId(), result.getScmRepositoryId());
logger.warn("Persistence [" + item.getProjectName() + "#" + item.getBuildNumber() + "] : " + result.getNewTests().size() + " new tests posted successfully = " + posted);
}
- //post updated
+ //post test updated
if (!result.getUpdatedTests().isEmpty()) {
- boolean updated = updateTests(client, result.getUpdatedTests(), result.getWorkspaceId());
+ boolean updated = updateTests(client, result.getUpdatedTests(), result.getWorkspaceId(), result.getScmRepositoryId());
logger.warn("Persistence [" + item.getProjectName() + "#" + item.getBuildNumber() + "] : " + result.getUpdatedTests().size() + " updated tests posted successfully = " + updated);
}
+
+ //post test deleted
+ if (!result.getDeletedTests().isEmpty()) {
+ boolean updated = setTestsNotExecutable(client, result.getDeletedTests(), result.getWorkspaceId());
+ logger.warn("Persistence [" + item.getProjectName() + "#" + item.getBuildNumber() + "] : " + result.getDeletedTests().size() + " deleted tests set as not executable successfully = " + updated);
+ }
+
+ //post scm resources
+ if (!result.getNewScmResourceFiles().isEmpty()) {
+ boolean posted = postScmResources(client, result.getNewScmResourceFiles(), result.getWorkspaceId(), result.getScmRepositoryId());
+ logger.warn("Persistence [" + item.getProjectName() + "#" + item.getBuildNumber() + "] : " + result.getNewScmResourceFiles().size() + " new scmResources posted successfully = " + posted);
+ }
+
+ //delete scm resources
+ if (!result.getDeletedScmResourceFiles().isEmpty()) {
+ boolean posted = deleteScmResources(client, result.getDeletedScmResourceFiles(), result.getWorkspaceId(), result.getScmRepositoryId());
+ logger.warn("Persistence [" + item.getProjectName() + "#" + item.getBuildNumber() + "] : " + result.getDeletedScmResourceFiles().size() + " scmResources deleted successfully = " + posted);
+ }
+
}
- private static boolean postTests(MqmRestClient client, String serverURL, List tests, String workspaceId, String scmResourceId) throws UnsupportedEncodingException {
+ private static boolean postTests(MqmRestClient client, List tests, String workspaceId, String scmRepositoryId) throws UnsupportedEncodingException {
if (!tests.isEmpty()) {
try {
- completeTestProperties(client, Long.parseLong(workspaceId), tests, scmResourceId);
+ completeTestProperties(client, Long.parseLong(workspaceId), tests, scmRepositoryId);
} catch (RequestErrorException e) {
logger.error("Failed to completeTestProperties : " + e.getMessage());
return false;
}
- int BULK_SIZE = 100;
for (int i = 0; i < tests.size(); i += BULK_SIZE)
try {
AutomatedTests data = AutomatedTests.createWithTests(tests.subList(i, Math.min(i + BULK_SIZE, tests.size())));
String uftTestJson = convertToJsonString(data);
- client.postTest(uftTestJson, null, serverURL);
- //JSONObject testObject = (JSONObject) jsonObject.getJSONArray("data").get(0);
+ client.postEntities(Long.parseLong(workspaceId), TESTS_COLLECTION_NAME, uftTestJson);
} catch (RequestErrorException e) {
- if (e.getStatusCode() != RESPONSE_STATUS_CONFLICT) {
+ if (e.getStatusCode() != HttpStatus.CONFLICT.getCode()) {
logger.error("Failed to postTests to Octane : " + e.getMessage());
return false;
}
@@ -167,14 +191,38 @@ private static boolean postTests(MqmRestClient client, String serverURL, List resources, String workspaceId, String scmResourceId) throws UnsupportedEncodingException {
+
+ if (!resources.isEmpty()) {
+ try {
+ completeScmResourceProperties(resources, scmResourceId);
+ } catch (RequestErrorException e) {
+ logger.error("Failed to completeTestProperties : " + e.getMessage());
+ return false;
+ }
+
+ for (int i = 0; i < resources.size(); i += BULK_SIZE)
+ try {
+ ScmResources data = ScmResources.createWithItems(resources.subList(i, Math.min(i + BULK_SIZE, resources.size())));
+ String uftTestJson = convertToJsonString(data);
+
+ client.postEntities(Long.parseLong(workspaceId), SCM_RESOURCE_FILES_COLLECTION_NAME, uftTestJson);
+
+ } catch (RequestErrorException e) {
+ if (e.getStatusCode() != HttpStatus.CONFLICT.getCode()) {
+ logger.error("Failed to post scm resource files to Octane : " + e.getMessage());
+ return false;
+ }
+
+ //else : the file with the same hash code , so do nothing
+ }
+ }
+ return true;
}
- private static String convertToJsonString(AutomatedTest test) {
+ private static String convertToJsonString(Object data) {
JsonConfig config = getJsonConfig();
- return JSONObject.fromObject(test, config).toString();
+ return JSONObject.fromObject(data, config).toString();
}
private static JsonConfig getJsonConfig() {
@@ -202,6 +250,25 @@ public String processPropertyName(Class className, String fieldName) {
}
});
+ config.registerJsonPropertyNameProcessor(ScmResourceFile.class, new PropertyNameProcessor() {
+
+ @Override
+ public String processPropertyName(Class className, String fieldName) {
+ String result = fieldName;
+ switch (fieldName) {
+ case "relativePath":
+ result = "relative_path";
+ break;
+ case "scmRepository":
+ result = "scm_repository";
+ break;
+ default:
+ break;
+ }
+ return result;
+ }
+ });
+
//filter empty fields
PropertyFilter pf = new PropertyFilter() {
public boolean apply(Object source, String name, Object value) {
@@ -237,42 +304,105 @@ public boolean apply(Object source, String name, Object value) {
}
}*/
- private static boolean updateTests(MqmRestClient client, Collection updateTests, String workspaceId) throws UnsupportedEncodingException {
+ private static boolean setTestsNotExecutable(MqmRestClient client, Collection deletedTest, String workspaceId) throws UnsupportedEncodingException {
long workspaceIdAsLong = Long.parseLong(workspaceId);
try {
+ for (AutomatedTest test : deletedTest) {
+ List conditions = new ArrayList<>();
+ conditions.add(QueryHelper.condition("name", test.getName()));
+ conditions.add(QueryHelper.condition("package", test.getPackage()));
+ PagedList foundTests = client.getEntities(workspaceIdAsLong, TESTS_COLLECTION_NAME, conditions, Arrays.asList("id"));
+ if (foundTests.getItems().size() == 1) {
+ Entity foundTest = foundTests.getItems().get(0);
+ AutomatedTest testForUpdate = new AutomatedTest();
+ testForUpdate.setExecutable(false);
+ testForUpdate.setId(foundTest.getId());
+ String json = convertToJsonString(testForUpdate);
+ client.updateEntity(Long.parseLong(workspaceId), TESTS_COLLECTION_NAME, foundTests.getItems().get(0).getId(), json);
+ }
+ }
+ return true;
+
+ } catch (Exception e) {
+ return false;
+ }
+ }
+
+ private static boolean updateTests(MqmRestClient client, Collection updateTests, String workspaceId, String scmRepositoryId) throws UnsupportedEncodingException {
+ long workspaceIdAsLong = Long.parseLong(workspaceId);
+
+ try {
+ List createAsNewTests = new ArrayList<>();
for (AutomatedTest test : updateTests) {
if (StringUtils.isEmpty(test.getDescription())) {
continue;
}
- Map queryFields = new HashMap<>();
- queryFields.put("name", test.getName());
- queryFields.put("package", test.getPackage());
- PagedList foundTests = client.getTests(workspaceIdAsLong, queryFields, Arrays.asList("id, description"));
+
+ List conditions = new ArrayList<>();
+ conditions.add(QueryHelper.condition("name", test.getName()));
+ conditions.add(QueryHelper.condition("package", test.getPackage()));
+ PagedList foundTests = client.getEntities(workspaceIdAsLong, TESTS_COLLECTION_NAME, conditions, Arrays.asList("id"));
if (foundTests.getItems().size() == 1) {
- Test foundTest = foundTests.getItems().get(0);
+ Entity foundTest = foundTests.getItems().get(0);
AutomatedTest testForUpdate = new AutomatedTest();
- testForUpdate.setSubtype(null);
testForUpdate.setDescription(test.getDescription());
+ testForUpdate.setExecutable(test.getExecutable());
testForUpdate.setId(foundTest.getId());
String json = convertToJsonString(testForUpdate);
- client.updateTest(Long.parseLong(workspaceId), foundTests.getItems().get(0).getId(), json);
+ client.updateEntity(Long.parseLong(workspaceId), TESTS_COLLECTION_NAME, foundTests.getItems().get(0).getId(), json);
+ } else if (foundTests.getItems().size() == 0) {
+ //test not exist in Octane, create it from scratch
+ logger.error(String.format("Test %s\\%s should be updated but wasn't found on Octane, creating test from scratch ", test.getPackage(), test.getName()));
+ createAsNewTests.add(test);
+
}
}
+
+
+ if (!createAsNewTests.isEmpty()) {
+ return postTests(client, createAsNewTests, workspaceId, scmRepositoryId);
+ } else {
+ return true;
+ }
+ } catch (Exception e) {
+ return false;
+ }
+ }
+
+ private boolean deleteScmResources(MqmRestClient client, List deletedResourceFiles, String workspaceId, String scmRepositoryId) {
+
+ long workspaceIdAsLong = Long.parseLong(workspaceId);
+ Set deletedIds = new HashSet<>();
+ try {
+ for (ScmResourceFile scmResource : deletedResourceFiles) {
+ List conditions = new ArrayList<>();
+ conditions.add(QueryHelper.condition("relative_path", scmResource.getRelativePath()));
+ conditions.add(QueryHelper.conditionRef("scm_repository", Long.valueOf(scmRepositoryId)));
+
+ PagedList foundResources = client.getEntities(workspaceIdAsLong, SCM_RESOURCE_FILES_COLLECTION_NAME, conditions, Arrays.asList("id, name"));
+ if (foundResources.getItems().size() == 1) {
+ Entity found = foundResources.getItems().get(0);
+ deletedIds.add(found.getId());
+ }
+ }
+
+ client.deleteEntities(Long.parseLong(workspaceId), SCM_RESOURCE_FILES_COLLECTION_NAME, deletedIds);
return true;
} catch (Exception e) {
return false;
}
+
}
- private static void completeTestProperties(MqmRestClient client, long workspaceId, Collection tests, String scmResourceId) {
+ private static void completeTestProperties(MqmRestClient client, long workspaceId, Collection tests, String scmRepositoryId) {
ListNodeEntity uftTestingTool = getUftTestingTool(client, workspaceId);
ListNodeEntity uftFramework = getUftFramework(client, workspaceId);
ListNodeEntity guiTestType = hasTestsByType(tests, UftTestType.GUI) ? getGuiTestType(client, workspaceId) : null;
ListNodeEntity apiTestType = hasTestsByType(tests, UftTestType.API) ? getApiTestType(client, workspaceId) : null;
- BaseRefEntity scmRepository = StringUtils.isEmpty(scmResourceId) ? null : BaseRefEntity.create("scm_repository", Long.valueOf(scmResourceId));
+ BaseRefEntity scmRepository = StringUtils.isEmpty(scmRepositoryId) ? null : BaseRefEntity.create("scm_repository", Long.valueOf(scmRepositoryId));
for (AutomatedTest test : tests) {
test.setTestingToolType(uftTestingTool);
test.setFramework(uftFramework);
@@ -286,6 +416,13 @@ private static void completeTestProperties(MqmRestClient client, long workspaceI
}
}
+ private static void completeScmResourceProperties(List resources, String scmResourceId) {
+ BaseRefEntity scmRepository = StringUtils.isEmpty(scmResourceId) ? null : BaseRefEntity.create("scm_repository", Long.valueOf(scmResourceId));
+ for (ScmResourceFile resource : resources) {
+ resource.setScmRepository(scmRepository);
+ }
+ }
+
private static ListNodeEntity getUftTestingTool(MqmRestClient client, long workspaceId) {
PagedList testingTools = client.queryListItems("list_node.testing_tool_type", null, workspaceId, 0, 100);
String uftTestingToolLogicalName = "list_node.testing_tool_type.uft";
@@ -334,37 +471,6 @@ private static ListNodeEntity getApiTestType(MqmRestClient client, long workspac
return null;
}
- private static String getServerURL(String workspaceId, String sharedspaceId, String location) {
- return location + "/api/shared_spaces/" + sharedspaceId + "/workspaces/" + workspaceId;
- }
-
- private MqmRestClient createClient(ServerConfiguration serverConfiguration) {
-
- if (!serverConfiguration.isValid()) {
- logger.warn("There are pending discovered UFT tests, but MQM server configuration is not valid, results can't be submitted");
- return null;
- }
-
- MqmRestClient client = clientFactory.obtain(
- serverConfiguration.location,
- serverConfiguration.sharedSpace,
- serverConfiguration.username,
- serverConfiguration.password);
-
- try {
- client.validateConfigurationWithoutLogin();
- return client;
- } catch (SharedSpaceNotExistException e) {
- logger.warn("Invalid shared space");
- } catch (LoginException e) {
- logger.warn("Login failed : " + e.getMessage());
- } catch (RequestException e) {
- logger.warn("Problem with communication with MQM server : " + e.getMessage());
- }
-
- return null;
- }
-
@Override
public long getRecurrencePeriod() {
String value = System.getProperty("UftTestDiscoveryDispatcher.Period"); // let's us config the recurrence period. default is 60 seconds.
@@ -380,8 +486,8 @@ public void setTestResultQueue(UftTestDiscoveryQueue queue) {
}
@Inject
- public void setMqmRestClientFactory(JenkinsMqmRestClientFactoryImpl clientFactory) {
- this.clientFactory = clientFactory;
+ public void setConfigurationService(ConfigurationService configurationService) {
+ this.configurationService = configurationService;
}
private static boolean hasTestsByType(Collection tests, UftTestType uftTestType) {
diff --git a/src/main/java/com/hp/application/automation/tools/octane/tests/build/MavenBuildExtension.java b/src/main/java/com/hp/application/automation/tools/octane/tests/build/MavenBuildExtension.java
index d7dc132f3b..fca4d3be18 100644
--- a/src/main/java/com/hp/application/automation/tools/octane/tests/build/MavenBuildExtension.java
+++ b/src/main/java/com/hp/application/automation/tools/octane/tests/build/MavenBuildExtension.java
@@ -32,7 +32,7 @@ public boolean supports(Run, ?> build) {
@Override
public BuildDescriptor getBuildType(Run, ?> build) {
return new BuildDescriptor(
- ((AbstractBuild)build).getRootBuild().getProject().getName(),
+ BuildHandlerUtils.getJobCiId(build),
((AbstractBuild)build).getProject().getName(),
String.valueOf(build.getNumber()),
String.valueOf(build.getNumber()),
@@ -45,7 +45,7 @@ public String getProjectFullName(Run, ?> build) {
// we don't push individual maven module results (although we create the file)
return null;
} else {
- return ((AbstractBuild)build).getProject().getName();
+ return ((AbstractBuild)build).getProject().getFullName();
}
}
}
diff --git a/src/main/java/com/hp/application/automation/tools/run/RunFromFileBuilder.java b/src/main/java/com/hp/application/automation/tools/run/RunFromFileBuilder.java
index 5764c8e9b3..e7702692a3 100644
--- a/src/main/java/com/hp/application/automation/tools/run/RunFromFileBuilder.java
+++ b/src/main/java/com/hp/application/automation/tools/run/RunFromFileBuilder.java
@@ -329,8 +329,6 @@ public void perform(@Nonnull Run, ?> build, @Nonnull FilePath workspace, @Nonn
throws InterruptedException, IOException {
- runFromFileModel.setWorkspace(workspace);
-
// get the mc server settings
MCServerSettingsModel mcServerSettingsModel = getMCServerSettingsModel();
@@ -365,9 +363,8 @@ public void perform(@Nonnull Run, ?> build, @Nonnull FilePath workspace, @Nonn
}
if (runFromFileModel != null && StringUtils.isNotBlank(runFromFileModel.getFsPassword())) {
- String encPassword = "";
try {
- encPassword = EncryptionUtils.Encrypt(runFromFileModel.getFsPassword(), EncryptionUtils.getSecretKey());
+ String encPassword = EncryptionUtils.Encrypt(runFromFileModel.getFsPassword(), EncryptionUtils.getSecretKey());
mergedProperties.put("MobilePassword", encPassword);
} catch (Exception e) {
build.setResult(Result.FAILURE);
@@ -409,6 +406,21 @@ public void perform(@Nonnull Run, ?> build, @Nonnull FilePath workspace, @Nonn
mergedProperties.put("runType", RunType.FileSystem.toString());
mergedProperties.put("resultsFilename", ResultFilename);
+ //handling mtbx file content :
+ // If we have mtbx content - it is located in Test1 property and there is no other test properties (like Test2 etc)
+ // We save mtbx content in workspace and replace content of Test1 by reference to saved file
+ String firstTestKey = "Test1";
+ String firstTestContent = mergedProperties.getProperty(firstTestKey, "");
+ if (RunFromFileSystemModel.isMtbxContent(firstTestContent)) {
+ try {
+ String mtbxFilePath = createMtbxFileInWs(workspace, firstTestContent);
+ mergedProperties.setProperty(firstTestKey, mtbxFilePath);
+ } catch (IOException | InterruptedException e) {
+ build.setResult(Result.FAILURE);
+ listener.error("Failed to save MTBX file : " + e.getMessage());
+ }
+ }
+
// get properties serialized into a stream
ByteArrayOutputStream stream = new ByteArrayOutputStream();
try {
@@ -483,6 +495,22 @@ public void perform(@Nonnull Run, ?> build, @Nonnull FilePath workspace, @Nonn
}
}
+ private static String createMtbxFileInWs(FilePath workspace, String mtbxContent) throws IOException, InterruptedException {
+ Date now = new Date();
+ Format formatter = new SimpleDateFormat("ddMMyyyyHHmmssSSS");
+ String time = formatter.format(now);
+
+ String fileName = "test_suite_" + time + ".mtbx";
+
+ FilePath remoteFile = workspace.child(fileName);
+
+ String mtbxContentUpdated = mtbxContent.replace("${WORKSPACE}", workspace.getRemote());
+ InputStream in = IOUtils.toInputStream(mtbxContentUpdated, "UTF-8");
+ remoteFile.copyFrom(in);
+
+ return remoteFile.getRemote();
+ }
+
/**
* Gets mc server settings model.
*
diff --git a/src/main/resources/com/hp/application/automation/tools/octane/actions/UFTTestDetectionBuildAction/index.jelly b/src/main/resources/com/hp/application/automation/tools/octane/actions/UFTTestDetectionBuildAction/index.jelly
index c6057b6df5..80d49fc2cf 100644
--- a/src/main/resources/com/hp/application/automation/tools/octane/actions/UFTTestDetectionBuildAction/index.jelly
+++ b/src/main/resources/com/hp/application/automation/tools/octane/actions/UFTTestDetectionBuildAction/index.jelly
@@ -20,6 +20,11 @@
color: #555753;
}
+ .myTable caption{
+ font-weight: bold;
+ padding-bottom: 10px;
+ }
+
.myTable td, .myTable th {
border-left: 1px solid #cbcbcb;
border-width: 0 0 0 1px;
@@ -58,9 +63,20 @@
+
+ New data tables : ${it.results.newScmResourceFiles.size()}
+
+
+
+
+ Deleted data tables : ${it.results.deletedScmResourceFiles.size()}
+
+
+
+
Tests
@@ -96,6 +112,36 @@
+
+
+
+
+
Data tables
+
+
+
Path
+
Status
+
+
+
+
+
+
+
${s.relativePath}
+
new
+
+
+
+
+
${s.relativePath}
+
deleted
+
+
+
+
+
+
+
diff --git a/src/main/resources/com/hp/application/automation/tools/octane/actions/UFTTestDetectionPublisher/config.jelly b/src/main/resources/com/hp/application/automation/tools/octane/actions/UFTTestDetectionPublisher/config.jelly
index 062bff98ec..abbd63e0c4 100644
--- a/src/main/resources/com/hp/application/automation/tools/octane/actions/UFTTestDetectionPublisher/config.jelly
+++ b/src/main/resources/com/hp/application/automation/tools/octane/actions/UFTTestDetectionPublisher/config.jelly
@@ -16,7 +16,7 @@
-
+
From 30a59ea0d327ef1cc38be5e3382aaaa0d209a0ec Mon Sep 17 00:00:00 2001
From: Michael S
Date: Wed, 7 Jun 2017 15:12:33 +0300
Subject: [PATCH 0061/2502] Handling data table and defects (#5) (#197)
1. recognize duplicate entity exception
2. make ConfigurationService.createClient to be static
3. defect 317026 : Jenkins executor job name is not unique
4. user story #305028: Provide data table path for UFT GUI test.
5. fixing building mtbx file : elements starts with Upper case + handling correctly tests without package name
6. update octane dependencies version (mqm & java-sdk to 1.4.4)
7. fix package name detection during test result dispatching
---
HpToolsLauncher/MtbxManager.cs | 7 +
HpToolsLauncher/MtbxSchema.xsd | 5 +
HpToolsLauncher/TestInfo.cs | 7 +
HpToolsLauncher/TestRunners/GuiTestRunner.cs | 11 +-
pom.xml | 4 +-
.../tools/octane/CIJenkinsServicesImpl.java | 3 +-
.../octane/actions/dto/AutomatedTest.java | 5 +
.../octane/actions/dto/ScmResourceFile.java | 10 -
.../configuration/ConfigurationService.java | 22 +-
.../octane/executor/OctaneConstants.java | 56 +++
.../TestExecutionJobCreatorService.java | 62 +--
.../executor/UFTTestDetectionResult.java | 2 +-
.../executor/UFTTestDetectionService.java | 49 +-
.../tools/octane/executor/UftJobCleaner.java | 112 +++--
.../executor/UftTestDiscoveryDispatcher.java | 443 ++++++++++++------
.../octane/tests/junit/JUnitXmlIterator.java | 11 +-
16 files changed, 543 insertions(+), 266 deletions(-)
create mode 100644 src/main/java/com/hp/application/automation/tools/octane/executor/OctaneConstants.java
diff --git a/HpToolsLauncher/MtbxManager.cs b/HpToolsLauncher/MtbxManager.cs
index 11aba14770..489780161d 100644
--- a/HpToolsLauncher/MtbxManager.cs
+++ b/HpToolsLauncher/MtbxManager.cs
@@ -24,6 +24,7 @@ public class MtbxManager
+
@@ -176,6 +177,12 @@ public static List LoadMtbx(string xmlContent, Dictionary
+
+
+
+
+
diff --git a/HpToolsLauncher/TestInfo.cs b/HpToolsLauncher/TestInfo.cs
index 1bbf03b72f..917ec699b9 100644
--- a/HpToolsLauncher/TestInfo.cs
+++ b/HpToolsLauncher/TestInfo.cs
@@ -124,6 +124,7 @@ public TestInfo(string testPath, string testName, string testGroup)
List _paramList = new List();
string _testName;
string _testGroup;
+ string _dataTablePath;
public string TestGroup
{
@@ -149,6 +150,12 @@ public List ParameterList
set { _paramList = value; }
}
+ public string DataTablePath
+ {
+ get { return _dataTablePath; }
+ set { _dataTablePath = value; }
+ }
+
internal Dictionary GetParameterDictionaryForQTP()
{
diff --git a/HpToolsLauncher/TestRunners/GuiTestRunner.cs b/HpToolsLauncher/TestRunners/GuiTestRunner.cs
index 2266e25287..5960b75600 100644
--- a/HpToolsLauncher/TestRunners/GuiTestRunner.cs
+++ b/HpToolsLauncher/TestRunners/GuiTestRunner.cs
@@ -222,7 +222,7 @@ public TestRunResults RunTest(TestInfo testinf, ref string errorReason, RunCance
? tagUnifiedLicenseType.qtUnifiedFunctionalTesting
: tagUnifiedLicenseType.qtNonUnified);
- if (!HandleInputParameters(testPath, ref errorReason, testinf.GetParameterDictionaryForQTP()))
+ if (!HandleInputParameters(testPath, ref errorReason, testinf.GetParameterDictionaryForQTP(), testinf.DataTablePath))
{
runDesc.TestState = TestState.Error;
runDesc.ErrorDesc = errorReason;
@@ -577,7 +577,7 @@ private bool VerifyParameterValueType(object paramValue, qtParameterType type)
return legal;
}
- private bool HandleInputParameters(string fileName, ref string errorReason, Dictionary inputParams)
+ private bool HandleInputParameters(string fileName, ref string errorReason, Dictionary inputParams, string dataTablePath)
{
try
{
@@ -619,6 +619,13 @@ private bool HandleInputParameters(string fileName, ref string errorReason, Dict
}
}
}
+
+ // specify data table path
+ if (dataTablePath != null)
+ {
+ _qtpApplication.Test.Settings.Resources.DataTablePath = dataTablePath;
+ ConsoleWriter.WriteLine("Using external data table: " + dataTablePath);
+ }
}
catch (Exception e)
{
diff --git a/pom.xml b/pom.xml
index abad3cbbeb..6c5b90ee09 100644
--- a/pom.xml
+++ b/pom.xml
@@ -388,14 +388,14 @@
integrations-sdkcom.hpe.adm.octane.ciplugins
- 1.4
+ 1.4.4mqm-rest-clientcom.hpe.adm.octane.ciplugins
- 1.4.1
+ 1.4.4
diff --git a/src/main/java/com/hp/application/automation/tools/octane/CIJenkinsServicesImpl.java b/src/main/java/com/hp/application/automation/tools/octane/CIJenkinsServicesImpl.java
index 9c5a2a935e..b0b5d4e790 100644
--- a/src/main/java/com/hp/application/automation/tools/octane/CIJenkinsServicesImpl.java
+++ b/src/main/java/com/hp/application/automation/tools/octane/CIJenkinsServicesImpl.java
@@ -21,6 +21,7 @@
import com.hp.application.automation.tools.octane.configuration.ServerConfiguration;
import com.hp.application.automation.tools.octane.executor.ExecutorConnectivityService;
import com.hp.application.automation.tools.octane.executor.TestExecutionJobCreatorService;
+import com.hp.application.automation.tools.octane.executor.UftJobCleaner;
import com.hp.application.automation.tools.octane.model.ModelFactory;
import com.hp.application.automation.tools.octane.model.processors.parameters.ParameterProcessors;
import com.hp.application.automation.tools.octane.model.processors.projects.AbstractProjectProcessor;
@@ -555,7 +556,7 @@ public OctaneResponse checkRepositoryConnectivity(TestConnectivityInfo testConne
@Override
public void deleteExecutor(String id) {
- TestExecutionJobCreatorService.deleteExecutor(id);
+ UftJobCleaner.deleteExecutor(id);
}
@Override
diff --git a/src/main/java/com/hp/application/automation/tools/octane/actions/dto/AutomatedTest.java b/src/main/java/com/hp/application/automation/tools/octane/actions/dto/AutomatedTest.java
index 5c4028c970..80f34a4988 100644
--- a/src/main/java/com/hp/application/automation/tools/octane/actions/dto/AutomatedTest.java
+++ b/src/main/java/com/hp/application/automation/tools/octane/actions/dto/AutomatedTest.java
@@ -141,4 +141,9 @@ public Boolean getExecutable() {
public void setExecutable(Boolean executable) {
this.executable = executable;
}
+
+ @Override
+ public String toString() {
+ return "#" + getId() == null ? "0" : getId() + " - " + getPackage() + "@" + getName();
+ }
}
diff --git a/src/main/java/com/hp/application/automation/tools/octane/actions/dto/ScmResourceFile.java b/src/main/java/com/hp/application/automation/tools/octane/actions/dto/ScmResourceFile.java
index 271977585d..f0e4a21145 100644
--- a/src/main/java/com/hp/application/automation/tools/octane/actions/dto/ScmResourceFile.java
+++ b/src/main/java/com/hp/application/automation/tools/octane/actions/dto/ScmResourceFile.java
@@ -36,8 +36,6 @@ public class ScmResourceFile {
private String relativePath;
- private String relativePathPrevious;
-
public String getName() {
return name;
}
@@ -70,14 +68,6 @@ public void setRelativePath(String relativePath) {
this.relativePath = relativePath;
}
- public String getRelativePathPrevious() {
- return relativePathPrevious;
- }
-
- public void setRelativePathPrevious(String relativePathPrevious) {
- this.relativePathPrevious = relativePathPrevious;
- }
-
public BaseRefEntity getScmRepository() {
return scmRepository;
}
diff --git a/src/main/java/com/hp/application/automation/tools/octane/configuration/ConfigurationService.java b/src/main/java/com/hp/application/automation/tools/octane/configuration/ConfigurationService.java
index 5111cc5f90..a5d0e45d90 100644
--- a/src/main/java/com/hp/application/automation/tools/octane/configuration/ConfigurationService.java
+++ b/src/main/java/com/hp/application/automation/tools/octane/configuration/ConfigurationService.java
@@ -16,7 +16,6 @@
package com.hp.application.automation.tools.octane.configuration;
-import com.google.inject.Inject;
import com.hp.application.automation.tools.model.OctaneServerSettingsModel;
import com.hp.application.automation.tools.octane.client.JenkinsMqmRestClientFactoryImpl;
import com.hp.application.automation.tools.settings.OctaneServerSettingsBuilder;
@@ -24,7 +23,6 @@
import com.hp.mqm.client.exception.LoginException;
import com.hp.mqm.client.exception.RequestException;
import com.hp.mqm.client.exception.SharedSpaceNotExistException;
-import hudson.Extension;
import hudson.Plugin;
import jenkins.model.Jenkins;
import org.apache.logging.log4j.LogManager;
@@ -36,10 +34,9 @@
* 2. helps to get Octane configuration and model
* 3. helps to get RestClient based on some configuration
*/
-@Extension
public class ConfigurationService {
- private JenkinsMqmRestClientFactoryImpl clientFactory;
+ private static JenkinsMqmRestClientFactoryImpl clientFactory;
private static Logger logger = LogManager.getLogger(ConfigurationService.class);
@@ -90,14 +87,14 @@ public static String getPluginVersion() {
* @param serverConfiguration
* @return
*/
- public MqmRestClient createClient(ServerConfiguration serverConfiguration) {
+ public static MqmRestClient createClient(ServerConfiguration serverConfiguration) {
if (!serverConfiguration.isValid()) {
logger.warn("MQM server configuration is not valid");
return null;
}
- MqmRestClient client = clientFactory.obtain(
+ MqmRestClient client = getMqmRestClientFactory().obtain(
serverConfiguration.location,
serverConfiguration.sharedSpace,
serverConfiguration.username,
@@ -117,14 +114,11 @@ public MqmRestClient createClient(ServerConfiguration serverConfiguration) {
return null;
}
- /**
- * Inject client factory
- *
- * @param clientFactory
- */
- @Inject
- public void setMqmRestClientFactory(JenkinsMqmRestClientFactoryImpl clientFactory) {
- this.clientFactory = clientFactory;
+ private static JenkinsMqmRestClientFactoryImpl getMqmRestClientFactory() {
+ if (clientFactory == null) {
+ clientFactory = Jenkins.getInstance().getExtensionList(JenkinsMqmRestClientFactoryImpl.class).get(0);
+ }
+ return clientFactory;
}
}
diff --git a/src/main/java/com/hp/application/automation/tools/octane/executor/OctaneConstants.java b/src/main/java/com/hp/application/automation/tools/octane/executor/OctaneConstants.java
new file mode 100644
index 0000000000..f9438cd102
--- /dev/null
+++ b/src/main/java/com/hp/application/automation/tools/octane/executor/OctaneConstants.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2017 Hewlett-Packard Development Company, L.P.
+ * 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.
+ *
+ */
+
+package com.hp.application.automation.tools.octane.executor;
+
+/**
+ * Constants of Octane Entities
+ */
+public class OctaneConstants {
+
+ public static class General{
+
+ public static final String WINDOWS_PATH_SPLITTER = "\\";
+ public static final String LINUX_PATH_SPLITTER = "/";
+ }
+
+ public static class Base {
+ public static final String ID_FIELD = "id";
+ public static final String NAME_FIELD = "name";
+ public static final String LOGICAL_NAME_FIELD = "logical_name";
+ public static final String DESCRIPTION_FIELD = "description";
+ }
+
+ public static class Tests extends Base {
+ public static final String COLLECTION_NAME = "automated_tests";
+ public static final String SCM_REPOSITORY_FIELD = "scm_repository";
+ public static final String TESTING_TOOL_TYPE_FIELD = "testing_tool_type";
+ public static final String TEST_TYPE_FIELD = "test_type";
+ public static final String PACKAGE_FIELD = "package";
+ public static final String EXECUTABLE_FIELD = "executable";
+ }
+
+ public static class DataTables extends Base {
+ public static final String COLLECTION_NAME = "scm_resource_files";
+ public static final String RELATIVE_PATH_FIELD = "relative_path";
+ public static final String SCM_REPOSITORY_FIELD = "scm_repository";
+ }
+
+ public static class Executors extends Base {
+ public static final String COLLECTION_NAME = "executors";
+ }
+
+}
diff --git a/src/main/java/com/hp/application/automation/tools/octane/executor/TestExecutionJobCreatorService.java b/src/main/java/com/hp/application/automation/tools/octane/executor/TestExecutionJobCreatorService.java
index 354d343ca2..e13bf3ebcf 100644
--- a/src/main/java/com/hp/application/automation/tools/octane/executor/TestExecutionJobCreatorService.java
+++ b/src/main/java/com/hp/application/automation/tools/octane/executor/TestExecutionJobCreatorService.java
@@ -59,9 +59,9 @@
*/
public class TestExecutionJobCreatorService {
-
private static final Logger logger = LogManager.getLogger(TestExecutionJobCreatorService.class);
public static final String EXECUTOR_ID_PARAMETER_NAME = "executorId";
+ public static final String EXECUTOR_LOGICAL_NAME_PARAMETER_NAME = "executorLogicalName";
public static final String SUITE_ID_PARAMETER_NAME = "suiteId";
public static final String SUITE_RUN_ID_PARAMETER_NAME = "suiteRunId";
public static final String FULL_SCAN_PARAMETER_NAME = "Full Scan";
@@ -177,6 +177,7 @@ private static String prepareMtbxData(List tests) throws IOEx
/*
+
….
@@ -190,15 +191,21 @@ private static String prepareMtbxData(List tests) throws IOEx
DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
Document doc = docBuilder.newDocument();
- Element rootElement = doc.createElement("mtbx");
+ Element rootElement = doc.createElement("Mtbx");
doc.appendChild(rootElement);
for (TestExecutionInfo test : tests) {
- Element testElement = doc.createElement("test");
+ Element testElement = doc.createElement("Test");
testElement.setAttribute("name", test.getTestName());
-
- String path = "${WORKSPACE}" + File.separator + test.getPackageName() + (StringUtils.isEmpty(test.getPackageName()) ? "" : File.separator) + test.getTestName();
+ String path = "${WORKSPACE}" + (StringUtils.isEmpty(test.getPackageName()) ? "" : OctaneConstants.General.WINDOWS_PATH_SPLITTER + test.getPackageName()) + OctaneConstants.General.WINDOWS_PATH_SPLITTER + test.getTestName();
testElement.setAttribute("path", path);
+
+ if (StringUtils.isNotEmpty(test.getDataTable())) {
+ Element dataTableElement = doc.createElement("DataTable");
+ dataTableElement.setAttribute("path", "${WORKSPACE}" + OctaneConstants.General.WINDOWS_PATH_SPLITTER + test.getDataTable());
+ testElement.appendChild(dataTableElement);
+ }
+
rootElement.appendChild(testElement);
}
@@ -233,6 +240,7 @@ public static void runTestDiscovery(DiscoveryInfo discoveryInfo) {
"url": "git@github.com:radislavB/UftTests.git"
},
"executorId": "1",
+ "executorLogialName": "ABC",
"workspaceId": "1002",
"testingToolType": "uft",
"forceFullDiscovery": true
@@ -255,7 +263,7 @@ public static void runTestDiscovery(DiscoveryInfo discoveryInfo) {
private static FreeStyleProject getDiscoveryJob(DiscoveryInfo discoveryInfo) {
try {
- String discoveryJobName = buildDiscoveryJobName(discoveryInfo.getTestingToolType(), discoveryInfo.getExecutorId());
+ String discoveryJobName = buildDiscoveryJobName(discoveryInfo.getTestingToolType(), discoveryInfo.getExecutorId(), discoveryInfo.getExecutorLogicalName());
//validate creation of job
FreeStyleProject proj = (FreeStyleProject) Jenkins.getInstance().getItem(discoveryJobName);
if (proj == null) {
@@ -268,6 +276,7 @@ private static FreeStyleProject getDiscoveryJob(DiscoveryInfo discoveryInfo) {
setScmRepository(discoveryInfo.getScmRepository(), discoveryInfo.getScmRepositoryCredentialsId(), proj);
setBuildDiscarder(proj, 20);
addConstantParameter(proj, EXECUTOR_ID_PARAMETER_NAME, discoveryInfo.getExecutorId(), "Octane executor id");
+ addConstantParameter(proj, EXECUTOR_LOGICAL_NAME_PARAMETER_NAME, discoveryInfo.getExecutorLogicalName(), "Octane executor logical name");
addBooleanParameter(proj, FULL_SCAN_PARAMETER_NAME, false, "Indicate whether to scan full scm repository to discover all tests or to use changes (Change Sets) to update already existing tests");
//set polling once in two minutes
@@ -298,8 +307,8 @@ private static FreeStyleProject getDiscoveryJob(DiscoveryInfo discoveryInfo) {
}
}
- private static String buildDiscoveryJobName(TestingToolType testingToolType, String executorId) {
- String name = String.format("%s test discovery job - executorId %s", testingToolType.toString(), executorId);
+ private static String buildDiscoveryJobName(TestingToolType testingToolType, String executorId, String executorLogicalName) {
+ String name = String.format("%s test discovery job - executorId %s (%s)", testingToolType.toString(), executorId, executorLogicalName);
return name;
}
@@ -359,43 +368,6 @@ private static void addBooleanParameter(FreeStyleProject proj, String parameterN
}
}
- /**
- * Delete discovery job that related to specific executor in Octane
- *
- * @param id
- */
- public static void deleteExecutor(String id) {
- String jobName = buildDiscoveryJobName(TestingToolType.UFT, id);
- FreeStyleProject proj = (FreeStyleProject) Jenkins.getInstance().getItem(jobName);
- if (proj != null) {
- boolean waitBeforeDelete = false;
-
- if (proj.isBuilding()) {
- proj.getLastBuild().getExecutor().interrupt();
- waitBeforeDelete = true;
- } else if (proj.isInQueue()) {
- Jenkins.getInstance().getQueue().cancel(proj);
- waitBeforeDelete = true;
- }
-
- if (waitBeforeDelete) {
- try {
- //we cancelled building/queue - wait before deleting the job, so Jenkins will be able to complete some IO actions
- Thread.sleep(10000);
- } catch (InterruptedException e) {
- //do nothing
- }
- }
-
- try {
- logger.warn(String.format("Job '%s' is going to be deleted since matching executor in Octane was deleted", proj.getName()));
- proj.delete();
- } catch (IOException | InterruptedException e) {
- logger.error("Failed to delete job " + proj.getName() + " : " + e.getMessage());
- }
- }
- }
-
private static void addAssignedNode(FreeStyleProject proj) {
Computer[] computers = Jenkins.getInstance().getComputers();
Set labels = new HashSet();
diff --git a/src/main/java/com/hp/application/automation/tools/octane/executor/UFTTestDetectionResult.java b/src/main/java/com/hp/application/automation/tools/octane/executor/UFTTestDetectionResult.java
index 7525fa663a..254a63db5a 100644
--- a/src/main/java/com/hp/application/automation/tools/octane/executor/UFTTestDetectionResult.java
+++ b/src/main/java/com/hp/application/automation/tools/octane/executor/UFTTestDetectionResult.java
@@ -103,7 +103,7 @@ public void setFullScan(boolean fullScan) {
public boolean hasChanges() {
return !getNewTests().isEmpty() || !getUpdatedTests().isEmpty() || !getDeletedTests().isEmpty()
- || !getNewScmResourceFiles().isEmpty() || !getDeletedScmResourceFiles().isEmpty() || !getUpdatedScmResourceFiles().isEmpty();
+ || !getNewScmResourceFiles().isEmpty() || !getDeletedScmResourceFiles().isEmpty();
}
public List getNewScmResourceFiles() {
diff --git a/src/main/java/com/hp/application/automation/tools/octane/executor/UFTTestDetectionService.java b/src/main/java/com/hp/application/automation/tools/octane/executor/UFTTestDetectionService.java
index 28b16ef2db..708b33c4f6 100644
--- a/src/main/java/com/hp/application/automation/tools/octane/executor/UFTTestDetectionService.java
+++ b/src/main/java/com/hp/application/automation/tools/octane/executor/UFTTestDetectionService.java
@@ -41,6 +41,9 @@
import java.io.IOException;
import java.util.*;
+/**
+ * Service is responsible to detect changes according to SCM change and to put it to queue of UftTestDiscoveryDispatcher
+ */
public class UFTTestDetectionService {
private static final Logger logger = LogManager.getLogger(UFTTestDetectionService.class);
private static final String INITIAL_DETECTION_FILE = "INITIAL_DETECTION_FILE.txt";
@@ -92,7 +95,10 @@ public static UFTTestDetectionResult startScanning(AbstractBuild, ?> build, St
result.setFullScan(fullScan);
sortTests(result.getNewTests());
sortTests(result.getUpdatedTests());
- publishDetectionResults(build, buildListener, result);
+ sortTests(result.getDeletedTests());
+ sortDataTables(result.getNewScmResourceFiles());
+ sortDataTables(result.getDeletedScmResourceFiles());
+ publishDetectionResults(getReportXmlFile(build), buildListener, result);
if (result.hasChanges()) {
UftTestDiscoveryDispatcher dispatcher = getExtension(UftTestDiscoveryDispatcher.class);
@@ -160,6 +166,15 @@ public int compare(AutomatedTest o1, AutomatedTest o2) {
});
}
+ private static void sortDataTables(List dataTables) {
+ Collections.sort(dataTables, new Comparator() {
+ @Override
+ public int compare(ScmResourceFile o1, ScmResourceFile o2) {
+ return o1.getRelativePath().compareTo(o2.getRelativePath());
+ }
+ });
+ }
+
private static T getExtension(Class clazz) {
ExtensionList items = Jenkins.getInstance().getExtensionList(clazz);
return items.get(0);
@@ -242,11 +257,10 @@ private static UFTTestDetectionResult doChangeSetDetection(Object[] changeSetIte
return result;
}
- private static AutomatedTest createAutomatedTest(FilePath root, FilePath dirPath, UftTestType testType, boolean executable) throws IOException, InterruptedException {
+ private static AutomatedTest createAutomatedTest(FilePath root, FilePath dirPath, UftTestType testType, boolean executable) {
AutomatedTest test = new AutomatedTest();
test.setName(dirPath.getName());
-
String relativePath = getRelativePath(root, dirPath);
String packageName = relativePath.length() != dirPath.getName().length() ? relativePath.substring(0, relativePath.length() - dirPath.getName().length() - 1) : "";
test.setPackage(packageName);
@@ -262,12 +276,12 @@ private static AutomatedTest createAutomatedTest(FilePath root, FilePath dirPath
return test;
}
- private static String getRelativePath(FilePath root, FilePath path) throws IOException, InterruptedException {
+ private static String getRelativePath(FilePath root, FilePath path) {
String testPath = path.getRemote();
String rootPath = root.getRemote();
String relativePath = testPath.replace(rootPath, "");
relativePath = StringUtils.strip(relativePath, windowsPathSplitter + linuxPathSplitter);
- //we want all paths will be in sindows style, because tests are run in windows, therefore we replace all linux splitters (/) by windows one (\)
+ //we want all paths will be in windows style, because tests are run in windows, therefore we replace all linux splitters (/) by windows one (\)
//http://stackoverflow.com/questions/23869613/how-to-replace-one-or-more-in-string-with-just
relativePath = relativePath.replaceAll(linuxPathSplitter, windowsPathSplitter + windowsPathSplitter);//str.replaceAll("/", "\\\\");
return relativePath;
@@ -336,7 +350,7 @@ private static void scanFileSystemRecursively(FilePath root, FilePath dirPath, L
}
}
- private static ScmResourceFile createDataTable(FilePath root, FilePath path) throws IOException, InterruptedException {
+ private static ScmResourceFile createDataTable(FilePath root, FilePath path) {
ScmResourceFile resourceFile = new ScmResourceFile();
resourceFile.setName(path.getName());
resourceFile.setRelativePath(getRelativePath(root, path));
@@ -381,19 +395,26 @@ private static FilePath getTestFolderForTestMainFile(String path) {
return null;
}
- private static void publishDetectionResults(AbstractBuild, ?> build, TaskListener _logger, UFTTestDetectionResult detectionResult) {
+ /**
+ * Serialize detectionResult to file in XML format
+ * @param fileToWriteTo
+ * @param taskListenerLog
+ * @param detectionResult
+ */
+ public static void publishDetectionResults(File fileToWriteTo, TaskListener taskListenerLog, UFTTestDetectionResult detectionResult) {
try {
- File file = getReportXmlFile(build);
JAXBContext jaxbContext = JAXBContext.newInstance(UFTTestDetectionResult.class);
Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
- jaxbMarshaller.marshal(detectionResult, file);
- //jaxbMarshaller.marshal(detectionResult, System.out);
+ jaxbMarshaller.marshal(detectionResult, fileToWriteTo);
} catch (JAXBException e) {
- _logger.error("Failed to persist detection results: " + e);
+ if (taskListenerLog != null) {
+ taskListenerLog.error("Failed to persist detection results: " + e.getMessage());
+ }
+ logger.error("Failed to persist detection results: " + e.getMessage());
}
}
@@ -403,15 +424,13 @@ public static UFTTestDetectionResult readDetectionResults(Run run) {
try {
JAXBContext context = JAXBContext.newInstance(UFTTestDetectionResult.class);
Unmarshaller m = context.createUnmarshaller();
- UFTTestDetectionResult result = (UFTTestDetectionResult) m.unmarshal(new FileReader(file));
- return result;
+ return (UFTTestDetectionResult) m.unmarshal(new FileReader(file));
} catch (JAXBException | FileNotFoundException e) {
return null;
}
}
private static File getReportXmlFile(Run run) {
- File reportXmlFile = new File(run.getRootDir(), DETECTION_RESULT_FILE);
- return reportXmlFile;
+ return new File(run.getRootDir(), DETECTION_RESULT_FILE);
}
}
\ No newline at end of file
diff --git a/src/main/java/com/hp/application/automation/tools/octane/executor/UftJobCleaner.java b/src/main/java/com/hp/application/automation/tools/octane/executor/UftJobCleaner.java
index 858e4dabaf..26f61c2f09 100644
--- a/src/main/java/com/hp/application/automation/tools/octane/executor/UftJobCleaner.java
+++ b/src/main/java/com/hp/application/automation/tools/octane/executor/UftJobCleaner.java
@@ -16,15 +16,12 @@
package com.hp.application.automation.tools.octane.executor;
-import com.google.inject.Inject;
import com.hp.application.automation.tools.octane.actions.UFTTestDetectionPublisher;
import com.hp.application.automation.tools.octane.configuration.ConfigurationService;
import com.hp.application.automation.tools.octane.configuration.ServerConfiguration;
import com.hp.application.automation.tools.octane.tests.AbstractSafeLoggingAsyncPeriodWork;
import com.hp.mqm.client.MqmRestClient;
-import com.hp.mqm.client.QueryHelper;
import com.hp.mqm.client.model.Entity;
-import com.hp.mqm.client.model.PagedList;
import hudson.Extension;
import hudson.model.*;
import jenkins.model.Jenkins;
@@ -45,8 +42,6 @@
public class UftJobCleaner extends AbstractSafeLoggingAsyncPeriodWork {
private static Logger logger = LogManager.getLogger(UftJobCleaner.class);
- private ConfigurationService configurationService;
- private static String EXECUTORS_COLLECTION_NAME = "executors";
public UftJobCleaner() {
super("Uft Job Cleaner");
@@ -55,7 +50,7 @@ public UftJobCleaner() {
@Override
public long getRecurrencePeriod() {
- return HOUR;
+ return DAY;
}
@Override
@@ -106,7 +101,7 @@ private void clearExecutionJobs(List jobs) {
logger.warn(String.format("Cleaner found %s outdated execution job", clearCounter));
}
- private boolean isExecutorJob(FreeStyleProject job) {
+ private static boolean isExecutorJob(FreeStyleProject job) {
ParametersDefinitionProperty parameters = job.getProperty(ParametersDefinitionProperty.class);
boolean isExecutorJob = job.getName().contains("execution job") &&
parameters != null &&
@@ -116,8 +111,7 @@ private boolean isExecutorJob(FreeStyleProject job) {
return isExecutorJob;
}
-
- private boolean isDiscoveryJobJob(FreeStyleProject job) {
+ private static boolean isDiscoveryJobJob(FreeStyleProject job) {
ParametersDefinitionProperty parameters = job.getProperty(ParametersDefinitionProperty.class);
boolean isDiscoveryJob = job.getName().contains("discovery job") &&
parameters != null &&
@@ -128,50 +122,44 @@ private boolean isDiscoveryJobJob(FreeStyleProject job) {
private void clearDiscoveryJobs(List jobs) {
//Generally, after deleting executor in Octane, relevant job in Jenkins is also deleted. But if jenkins was down during delete of executor, job remains
- //This method handle orphan job that doesn't hava mathing executors in Octane
+ //This method handle orphan job that doesn't hava matching executors in Octane
//1. build map of discovery jobs per workspace
//2. Loop by workspace
//2.1 Get from octane executors in workspace
//2.2 If some discovery job exist that doesn't have matching executor - remove it from Jenkins
- Map> workspace2executorId2DiscoveryJobMap = new HashMap<>();
+ Map> workspace2executorLogical2DiscoveryJobMap = new HashMap<>();
for (FreeStyleProject job : jobs) {
if (isDiscoveryJobJob(job)) {
- Long executorId = getExecutorId(job);
+ String executorLogicalName = getExecutorLogicalName(job);
Long workspaceId = getOctaneWorkspaceId(job);
- if (executorId != null && workspaceId != null) {
- if (!workspace2executorId2DiscoveryJobMap.containsKey(workspaceId)) {
- workspace2executorId2DiscoveryJobMap.put(workspaceId, new HashedMap());
+ if (executorLogicalName != null && workspaceId != null) {
+ if (!workspace2executorLogical2DiscoveryJobMap.containsKey(workspaceId)) {
+ workspace2executorLogical2DiscoveryJobMap.put(workspaceId, new HashedMap());
}
- workspace2executorId2DiscoveryJobMap.get(workspaceId).put(executorId, job);
+ workspace2executorLogical2DiscoveryJobMap.get(workspaceId).put(executorLogicalName, job);
}
}
}
- if (!workspace2executorId2DiscoveryJobMap.isEmpty()) {
+ if (!workspace2executorLogical2DiscoveryJobMap.isEmpty()) {
ServerConfiguration serverConfiguration = ConfigurationService.getServerConfiguration();
- MqmRestClient client = configurationService.createClient(serverConfiguration);
+ MqmRestClient client = ConfigurationService.createClient(serverConfiguration);
if (client != null) {
int deleteCounter = 0;
- for (Long workspaceId : workspace2executorId2DiscoveryJobMap.keySet()) {
- Map discoveryJobs = workspace2executorId2DiscoveryJobMap.get(workspaceId);
- List conditions = new ArrayList<>();
- conditions.add(QueryHelper.conditionIn("id", discoveryJobs.keySet(), true));
+ for (Long workspaceId : workspace2executorLogical2DiscoveryJobMap.keySet()) {
try {
- PagedList entities = client.getEntities(workspaceId, EXECUTORS_COLLECTION_NAME, conditions, Arrays.asList("id"));
- Set octaneExecutorIds = new HashSet<>();
- for (Entity executor : entities.getItems()) {
- octaneExecutorIds.add(executor.getId());
- }
- for (Long jobExecutorId : discoveryJobs.keySet()) {
- if (!octaneExecutorIds.contains(jobExecutorId)) {
+ Map discoveryJobs = workspace2executorLogical2DiscoveryJobMap.get(workspaceId);
+ Set octaneExecutorsLogicalNames = getOctaneExecutorsLogicalNames(client, workspaceId);
+ for (String jobExecutorLogical : discoveryJobs.keySet()) {
+ boolean isExistInOctane = octaneExecutorsLogicalNames.contains(jobExecutorLogical);
+ if (!isExistInOctane) {
//found discovery job that is not related to any executor in Octane
- FreeStyleProject job = discoveryJobs.get(jobExecutorId);
+ FreeStyleProject job = discoveryJobs.get(jobExecutorLogical);
try {
logger.warn(String.format("Job %s is going to be deleted as is doesn't have matching executor in Octane in workspace %s", job.getName(), workspaceId));
deleteCounter++;
job.delete();
-
} catch (Exception e) {
logger.warn(String.format("Failed to delete job %s : %s", job.getName(), e.getMessage()));
}
@@ -189,14 +177,30 @@ private void clearDiscoveryJobs(List jobs) {
}
}
+ private Set getOctaneExecutorsLogicalNames(MqmRestClient client, Long workspaceId) {
+ List entities = client.getEntities(workspaceId, OctaneConstants.Executors.COLLECTION_NAME, null,
+ Arrays.asList(OctaneConstants.Base.ID_FIELD, OctaneConstants.Base.LOGICAL_NAME_FIELD));
+ Set octaneExecutorIds = new HashSet<>();
+ for (Entity executor : entities) {
+ octaneExecutorIds.add(executor.getStringValue(OctaneConstants.Base.LOGICAL_NAME_FIELD));
+ }
+ return octaneExecutorIds;
+ }
- private Long getExecutorId(FreeStyleProject job) {
+ private static Long getExecutorId(FreeStyleProject job) {
ParametersDefinitionProperty parameters = job.getProperty(ParametersDefinitionProperty.class);
ParameterDefinition pd = parameters.getParameterDefinition(TestExecutionJobCreatorService.EXECUTOR_ID_PARAMETER_NAME);
String value = (String) pd.getDefaultParameterValue().getValue();
return Long.valueOf(value);
}
+ private static String getExecutorLogicalName(FreeStyleProject job) {
+ ParametersDefinitionProperty parameters = job.getProperty(ParametersDefinitionProperty.class);
+ ParameterDefinition pd = parameters.getParameterDefinition(TestExecutionJobCreatorService.EXECUTOR_LOGICAL_NAME_PARAMETER_NAME);
+ String value = (String) pd.getDefaultParameterValue().getValue();
+ return value;
+ }
+
private Long getOctaneWorkspaceId(FreeStyleProject job) {
UFTTestDetectionPublisher uftTestDetectionPublisher = null;
@@ -212,9 +216,45 @@ private Long getOctaneWorkspaceId(FreeStyleProject job) {
return null;
}
- @Inject
- public void setConfigurationService(ConfigurationService configurationService) {
- this.configurationService = configurationService;
- }
+ /**
+ * Delete discovery job that related to specific executor in Octane
+ *
+ * @param id
+ */
+ public static void deleteExecutor(String id) {
+ long executorToDelete = Long.parseLong(id);
+ List jobs = Jenkins.getInstance().getAllItems(FreeStyleProject.class);
+ for (FreeStyleProject proj : jobs) {
+ if (isDiscoveryJobJob(proj)) {
+ Long executorId = getExecutorId(proj);
+ if (executorId != null && executorId == executorToDelete) {
+ boolean waitBeforeDelete = false;
+
+ if (proj.isBuilding()) {
+ proj.getLastBuild().getExecutor().interrupt();
+ waitBeforeDelete = true;
+ } else if (proj.isInQueue()) {
+ Jenkins.getInstance().getQueue().cancel(proj);
+ waitBeforeDelete = true;
+ }
+ if (waitBeforeDelete) {
+ try {
+ //we cancelled building/queue - wait before deleting the job, so Jenkins will be able to complete some IO actions
+ Thread.sleep(10000);
+ } catch (InterruptedException e) {
+ //do nothing
+ }
+ }
+
+ try {
+ logger.warn(String.format("Job '%s' is going to be deleted since matching executor in Octane was deleted", proj.getName()));
+ proj.delete();
+ } catch (IOException | InterruptedException e) {
+ logger.error("Failed to delete job " + proj.getName() + " : " + e.getMessage());
+ }
+ }
+ }
+ }
+ }
}
diff --git a/src/main/java/com/hp/application/automation/tools/octane/executor/UftTestDiscoveryDispatcher.java b/src/main/java/com/hp/application/automation/tools/octane/executor/UftTestDiscoveryDispatcher.java
index 1b6f20066a..11a26d0c28 100644
--- a/src/main/java/com/hp/application/automation/tools/octane/executor/UftTestDiscoveryDispatcher.java
+++ b/src/main/java/com/hp/application/automation/tools/octane/executor/UftTestDiscoveryDispatcher.java
@@ -31,21 +31,25 @@
import com.hp.mqm.client.model.ListItem;
import com.hp.mqm.client.model.PagedList;
import hudson.Extension;
+import hudson.FilePath;
+import hudson.model.FreeStyleProject;
import hudson.model.Job;
import hudson.model.Run;
import hudson.model.TaskListener;
import hudson.util.TimeUnit2;
import jenkins.model.Jenkins;
+import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import net.sf.json.JsonConfig;
import net.sf.json.processors.PropertyNameProcessor;
import net.sf.json.util.PropertyFilter;
+import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+import java.io.File;
import java.io.IOException;
-import java.io.UnsupportedEncodingException;
import java.util.*;
@@ -59,14 +63,12 @@
@Extension
public class UftTestDiscoveryDispatcher extends AbstractSafeLoggingAsyncPeriodWork {
- private static Logger logger = LogManager.getLogger(UftTestDiscoveryDispatcher.class);
- private final static String TESTS_COLLECTION_NAME = "automated_tests";
- private final static String SCM_RESOURCE_FILES_COLLECTION_NAME = "scm_resource_files";
-
- private final static int BULK_SIZE = 100;
+ private final static Logger logger = LogManager.getLogger(UftTestDiscoveryDispatcher.class);
+ private final static String DUPLICATE_ERROR_CODE = "platform.duplicate_entity_error";
+ private final static int POST_BULK_SIZE = 100;
+ private final static int MAX_DISPATCH_TRIALS = 5;
private UftTestDiscoveryQueue queue;
- private ConfigurationService configurationService;
public UftTestDiscoveryDispatcher() {
super("Uft Test Discovery Dispatcher");
@@ -81,7 +83,7 @@ protected void doExecute(TaskListener listener) throws IOException, InterruptedE
logger.warn("Queue size " + queue.size());
ServerConfiguration serverConfiguration = ConfigurationService.getServerConfiguration();
- MqmRestClient client = configurationService.createClient(serverConfiguration);
+ MqmRestClient client = ConfigurationService.createClient(serverConfiguration);
if (client == null) {
logger.warn("There are pending discovered UFT tests, but MQM server configuration is not valid, results can't be submitted");
@@ -120,16 +122,38 @@ protected void doExecute(TaskListener listener) throws IOException, InterruptedE
} catch (Exception e) {
if (item != null) {
item.incrementFailCount();
- int maxTrial = 5;
- if (item.incrementFailCount() > maxTrial) {
+ if (item.incrementFailCount() > MAX_DISPATCH_TRIALS) {
queue.remove();
- logger.warn("Failed to persist discovery of [" + item.getProjectName() + "#" + item.getBuildNumber() + "] after " + maxTrial + " trials");
+ logger.warn("Failed to persist discovery of [" + item.getProjectName() + "#" + item.getBuildNumber() + "] after " + MAX_DISPATCH_TRIALS + " trials");
}
}
}
}
- private void dispatchDetectionResults(ResultQueue.QueueItem item, MqmRestClient client, UFTTestDetectionResult result) throws UnsupportedEncodingException {
+ private static void dispatchDetectionResults(ResultQueue.QueueItem item, MqmRestClient client, UFTTestDetectionResult result) {
+ //Check if there is diff in discovery and server status
+ //for example : discovery found new test , but it already exist in server , instead of create new tests we will do update test
+ if (result.isFullScan()) {
+ validateTestDiscoveryForFullDetection(client, result);
+ validateDataTablesDiscoveryForFullDetection(client, result);
+ } else {
+ validateTestDiscoveryAndCompleteTestIdsForScmChangeDetection(client, result);
+ //no need to add validation for dataTables, because there is no DTs update and there is no special delete strategy
+ }
+
+ //publish final results
+ FreeStyleProject project = (FreeStyleProject) Jenkins.getInstance().getItemByFullName(item.getProjectName());
+ FilePath subWorkspace = project.getWorkspace().child("_Final_Detection_Results");
+ try {
+ if (!subWorkspace.exists()) {
+ subWorkspace.mkdirs();
+ }
+ File reportXmlFile = new File(subWorkspace.getRemote(), "final_detection_result_build_" + item.getBuildNumber() + ".xml");
+ UFTTestDetectionService.publishDetectionResults(reportXmlFile, null, result);
+ } catch (IOException | InterruptedException e) {
+ logger.error("Failed to write final_detection_result file :" + e.getMessage());
+ }
+
//post new tests
if (!result.getNewTests().isEmpty()) {
boolean posted = postTests(client, result.getNewTests(), result.getWorkspaceId(), result.getScmRepositoryId());
@@ -138,13 +162,13 @@ private void dispatchDetectionResults(ResultQueue.QueueItem item, MqmRestClient
//post test updated
if (!result.getUpdatedTests().isEmpty()) {
- boolean updated = updateTests(client, result.getUpdatedTests(), result.getWorkspaceId(), result.getScmRepositoryId());
+ boolean updated = updateTests(client, result.getUpdatedTests(), result.getWorkspaceId());
logger.warn("Persistence [" + item.getProjectName() + "#" + item.getBuildNumber() + "] : " + result.getUpdatedTests().size() + " updated tests posted successfully = " + updated);
}
//post test deleted
if (!result.getDeletedTests().isEmpty()) {
- boolean updated = setTestsNotExecutable(client, result.getDeletedTests(), result.getWorkspaceId());
+ boolean updated = updateTests(client, result.getDeletedTests(), result.getWorkspaceId());
logger.warn("Persistence [" + item.getProjectName() + "#" + item.getBuildNumber() + "] : " + result.getDeletedTests().size() + " deleted tests set as not executable successfully = " + updated);
}
@@ -159,10 +183,184 @@ private void dispatchDetectionResults(ResultQueue.QueueItem item, MqmRestClient
boolean posted = deleteScmResources(client, result.getDeletedScmResourceFiles(), result.getWorkspaceId(), result.getScmRepositoryId());
logger.warn("Persistence [" + item.getProjectName() + "#" + item.getBuildNumber() + "] : " + result.getDeletedScmResourceFiles().size() + " scmResources deleted successfully = " + posted);
}
+ }
+
+ /**
+ * This method try to find ids of updated and deleted tests for scm change detection
+ * if test is found on server - update id of discovered test
+ * if test is not found and test is marked for update - move it to new tests (possibly test was deleted on server)
+ *
+ * @return true if there were changes comparing to discoverede results
+ */
+ private static boolean validateTestDiscoveryAndCompleteTestIdsForScmChangeDetection(MqmRestClient client, UFTTestDetectionResult result) {
+ boolean hasDiff = false;
+ List allTests = new ArrayList<>();
+ allTests.addAll(result.getUpdatedTests());
+ allTests.addAll(result.getDeletedTests());
+ Set allTestNames = new HashSet<>();
+ for (AutomatedTest test : allTests) {
+ allTestNames.add(test.getName());
+ }
+
+ //GET TESTS FROM OCTANE
+ Map octaneTestsMapByKey = getTestsFromServer(client, Long.parseLong(result.getWorkspaceId()), Long.parseLong(result.getScmRepositoryId()), allTestNames);
+
+
+ //MATCHING
+ for (AutomatedTest test : allTests) {
+ String key = createKey(test.getPackage(), test.getName());
+ Entity octaneTest = octaneTestsMapByKey.get(key);
+ if (octaneTest != null) {
+ test.setId(octaneTest.getId());
+ } else {//no match{
+ hasDiff = true;
+ if (result.getUpdatedTests().remove(test)) {
+ result.getNewTests().add(test);
+ } else {
+ //test that is marked to be deleted - doesn't exist in Octane - do nothing
+ result.getDeletedTests().remove(test);
+ }
+ }
+ }
+ return hasDiff;
}
- private static boolean postTests(MqmRestClient client, List tests, String workspaceId, String scmRepositoryId) throws UnsupportedEncodingException {
+ /**
+ * This method check whether discovered test are already exist on server, and instead of creation - those tests will be updated
+ * Go over discovered and octane tests
+ * 1.if test doesn't exist on octane - this is new test
+ * 2.if test exist
+ * 2.1 if test different from discovered - this is test for update
+ * 2.2 if tests are equal - skip test
+ * 3. all tests that are found in Octane but not discovered - those deleted tests and they will be turned to not executable
+ *
+ * @return true if there were changes comparing to discoverede results
+ */
+ private static boolean validateTestDiscoveryForFullDetection(MqmRestClient client, UFTTestDetectionResult detectionResult) {
+ boolean hasDiff = false;
+ Map octaneTestsMap = getTestsFromServer(client, Long.parseLong(detectionResult.getWorkspaceId()), Long.parseLong(detectionResult.getScmRepositoryId()), null);
+
+ List discoveredTests = new ArrayList(detectionResult.getNewTests());
+ detectionResult.getNewTests().clear();
+ for (AutomatedTest discoveredTest : discoveredTests) {
+ String key = createKey(discoveredTest.getPackage(), discoveredTest.getName());
+ Entity octaneTest = octaneTestsMap.remove(key);
+
+ if (octaneTest == null) {
+ detectionResult.getNewTests().add(discoveredTest);
+ } else {
+ hasDiff = true;//if we get here - there is diff with discovered tests
+ //the only fields that might be different is description and executable
+ boolean octaneExecutable = octaneTest.getBooleanValue(OctaneConstants.Tests.EXECUTABLE_FIELD);
+ String octaneDescription = octaneTest.getStringValue(OctaneConstants.Tests.DESCRIPTION_FIELD);
+ boolean descriptionEquals = ((StringUtils.isEmpty(octaneDescription) || "null".equals(octaneDescription)) && discoveredTest.getDescription() == null) ||
+ octaneDescription.contains(discoveredTest.getDescription());
+ boolean testsEqual = (octaneExecutable && descriptionEquals);
+ if (!testsEqual) { //if equal - skip
+ discoveredTest.setId(octaneTest.getId());
+ detectionResult.getUpdatedTests().add(discoveredTest);
+ }
+ }
+ }
+
+ //go over executable tests that exist in Octane but not discovered and disable them
+ for (Entity octaneTest : octaneTestsMap.values()) {
+ hasDiff = true;//if some test exist - there is diff with discovered tests
+ boolean octaneExecutable = octaneTest.getBooleanValue(OctaneConstants.Tests.EXECUTABLE_FIELD);
+ if (octaneExecutable) {
+ AutomatedTest test = new AutomatedTest();
+ test.setId(octaneTest.getId());
+ test.setExecutable(false);
+ test.setName(octaneTest.getName());
+ test.setPackage(octaneTest.getStringValue(OctaneConstants.Tests.PACKAGE_FIELD));
+ detectionResult.getDeletedTests().add(test);
+ }
+ }
+
+ return hasDiff;
+ }
+
+ /**
+ * Go over discovered and octane data tables
+ * 1.if DT doesn't exist on octane - this is new DT
+ * 2. all DTs that are found in Octane but not discovered - delete those DTs from server
+ */
+ private static boolean validateDataTablesDiscoveryForFullDetection(MqmRestClient client, UFTTestDetectionResult detectionResult) {
+ boolean hasDiff = false;
+ List discoveredDataTables = new ArrayList(detectionResult.getNewScmResourceFiles());
+ detectionResult.getNewScmResourceFiles().clear();
+
+ Map octaneDataTablesMap = getDataTablesFromServer(client, Long.parseLong(detectionResult.getWorkspaceId()), Long.parseLong(detectionResult.getScmRepositoryId()));
+ for (ScmResourceFile dataTable : discoveredDataTables) {
+ Entity octaneDataTable = octaneDataTablesMap.remove(dataTable.getRelativePath());
+ if (octaneDataTable == null) {
+ detectionResult.getNewScmResourceFiles().add(dataTable);
+ } else {
+ hasDiff = true;
+ }
+ }
+
+ //go over DT that exist in Octane but not discovered
+ for (Entity octaneDataTable : octaneDataTablesMap.values()) {
+ hasDiff = true;
+ ScmResourceFile dt = new ScmResourceFile();
+ dt.setId(octaneDataTable.getId());
+ dt.setName(octaneDataTable.getName());
+ dt.setRelativePath(octaneDataTable.getStringValue(OctaneConstants.DataTables.RELATIVE_PATH_FIELD));
+ detectionResult.getDeletedScmResourceFiles().add(dt);
+ }
+
+ return hasDiff;
+ }
+
+ private static Map getTestsFromServer(MqmRestClient client, long workspaceId, long scmRepositoryId, Set allTestNames) {
+ List conditions = new ArrayList<>();
+ if (allTestNames != null && !allTestNames.isEmpty()) {
+ String byNameCondition = QueryHelper.conditionIn(OctaneConstants.Tests.NAME_FIELD, allTestNames, false);
+ int byNameConditionSizeThreshold = 3000;
+ //Query string is part of UR, some servers limit request size by 4K,
+ //Here we limit nameCondition by 3K, if it exceed, we will fetch all tests
+ if (byNameCondition.length() < byNameConditionSizeThreshold) {
+ conditions.add(byNameCondition);
+ }
+ }
+
+ conditions.add(QueryHelper.conditionRef(OctaneConstants.Tests.SCM_REPOSITORY_FIELD, scmRepositoryId));
+ Collection fields = Arrays.asList(OctaneConstants.Tests.ID_FIELD, OctaneConstants.Tests.NAME_FIELD, OctaneConstants.Tests.PACKAGE_FIELD, OctaneConstants.Tests.EXECUTABLE_FIELD, OctaneConstants.Tests.DESCRIPTION_FIELD);
+ List octaneTests = client.getEntities(workspaceId, OctaneConstants.Tests.COLLECTION_NAME, conditions, fields);
+ Map octaneTestsMapByKey = new HashedMap();
+ for (Entity octaneTest : octaneTests) {
+ String key = createKey(octaneTest.getStringValue(OctaneConstants.Tests.PACKAGE_FIELD), octaneTest.getName());
+ octaneTestsMapByKey.put(key, octaneTest);
+ }
+ return octaneTestsMapByKey;
+ }
+
+ private static Map getDataTablesFromServer(MqmRestClient client, long workspaceId, long scmRepositoryId) {
+ List conditionByScmRepository = Arrays.asList(QueryHelper.conditionRef(OctaneConstants.DataTables.SCM_REPOSITORY_FIELD, scmRepositoryId));
+
+ List dataTablesFields = Arrays.asList(OctaneConstants.DataTables.ID_FIELD, OctaneConstants.DataTables.NAME_FIELD, OctaneConstants.DataTables.RELATIVE_PATH_FIELD);
+ List octaneDataTables = client.getEntities(workspaceId, OctaneConstants.DataTables.COLLECTION_NAME, conditionByScmRepository, dataTablesFields);
+
+ Map octaneDataTablesMap = new HashedMap();
+ for (Entity dataTable : octaneDataTables) {
+ octaneDataTablesMap.put(dataTable.getStringValue(OctaneConstants.DataTables.RELATIVE_PATH_FIELD), dataTable);
+ }
+
+ return octaneDataTablesMap;
+ }
+
+ private static String createKey(String... values) {
+ for (int i = 0; i < values.length; i++) {
+ if (values[i] == null || "null".equals(values[i])) {
+ values[i] = "";
+ }
+ }
+ return StringUtils.join(values, "#");
+ }
+
+ private static boolean postTests(MqmRestClient client, List tests, String workspaceId, String scmRepositoryId) {
if (!tests.isEmpty()) {
try {
@@ -172,54 +370,81 @@ private static boolean postTests(MqmRestClient client, List tests
return false;
}
- for (int i = 0; i < tests.size(); i += BULK_SIZE)
+ for (int i = 0; i < tests.size(); i += POST_BULK_SIZE) {
try {
- AutomatedTests data = AutomatedTests.createWithTests(tests.subList(i, Math.min(i + BULK_SIZE, tests.size())));
+ AutomatedTests data = AutomatedTests.createWithTests(tests.subList(i, Math.min(i + POST_BULK_SIZE, tests.size())));
String uftTestJson = convertToJsonString(data);
-
- client.postEntities(Long.parseLong(workspaceId), TESTS_COLLECTION_NAME, uftTestJson);
-
+ client.postEntities(Long.parseLong(workspaceId), OctaneConstants.Tests.COLLECTION_NAME, uftTestJson);
} catch (RequestErrorException e) {
- if (e.getStatusCode() != HttpStatus.CONFLICT.getCode()) {
- logger.error("Failed to postTests to Octane : " + e.getMessage());
- return false;
- }
-
- //else : the test with the same hash code , so do nothing
+ return checkIfExceptionCanBeIgnoredInPOST(e, "Failed to post tests");
}
+ }
}
return true;
}
- private static boolean postScmResources(MqmRestClient client, List resources, String workspaceId, String scmResourceId) throws UnsupportedEncodingException {
+ private static boolean postScmResources(MqmRestClient client, List resources, String workspaceId, String scmResourceId) {
if (!resources.isEmpty()) {
try {
completeScmResourceProperties(resources, scmResourceId);
} catch (RequestErrorException e) {
- logger.error("Failed to completeTestProperties : " + e.getMessage());
+ logger.error("Failed to completeScmResourceProperties : " + e.getMessage());
return false;
}
- for (int i = 0; i < resources.size(); i += BULK_SIZE)
+ for (int i = 0; i < resources.size(); i += POST_BULK_SIZE)
try {
- ScmResources data = ScmResources.createWithItems(resources.subList(i, Math.min(i + BULK_SIZE, resources.size())));
+ ScmResources data = ScmResources.createWithItems(resources.subList(i, Math.min(i + POST_BULK_SIZE, resources.size())));
String uftTestJson = convertToJsonString(data);
-
- client.postEntities(Long.parseLong(workspaceId), SCM_RESOURCE_FILES_COLLECTION_NAME, uftTestJson);
-
+ client.postEntities(Long.parseLong(workspaceId), OctaneConstants.DataTables.COLLECTION_NAME, uftTestJson);
} catch (RequestErrorException e) {
- if (e.getStatusCode() != HttpStatus.CONFLICT.getCode()) {
- logger.error("Failed to post scm resource files to Octane : " + e.getMessage());
- return false;
- }
-
- //else : the file with the same hash code , so do nothing
+ return checkIfExceptionCanBeIgnoredInPOST(e, "Failed to post scm resource files");
}
}
return true;
}
+ /**
+ * Entities might be posted while they already exist in Octane, such POST request will fail with general error code will be 409.
+ * The same error code might be received on other validation error.
+ * In this method we check whether exist other exception than duplicate
+ *
+ * @param e
+ * @param errorPrefix
+ * @return
+ */
+ private static boolean checkIfExceptionCanBeIgnoredInPOST(RequestErrorException e, String errorPrefix) {
+ if (e.getStatusCode() == HttpStatus.CONFLICT.getCode() && e.getJsonObject() != null && e.getJsonObject().containsKey("errors")) {
+ JSONObject error = findFirstErrorDifferThan(e.getJsonObject().getJSONArray("errors"), DUPLICATE_ERROR_CODE);
+ String errorMessage = null;
+ if (error != null) {
+ errorMessage = error.getString("description");
+ logger.error(errorPrefix + " : " + errorMessage);
+ }
+ return errorMessage == null;
+ }
+
+ logger.error(errorPrefix + " : " + e.getMessage());
+ return false;
+ }
+
+ /**
+ * Search for error code that differ from supplied errorCode.
+ */
+ private static JSONObject findFirstErrorDifferThan(JSONArray errors, String excludeErrorCode) {
+ for (int errorIndex = 0; errorIndex < errors.size(); errorIndex++) {
+ JSONObject error = errors.getJSONObject(errorIndex);
+ String errorCode = error.getString("error_code");
+ if (errorCode.equals(excludeErrorCode)) {
+ continue;
+ } else {
+ return error;
+ }
+ }
+ return null;
+ }
+
private static String convertToJsonString(Object data) {
JsonConfig config = getJsonConfig();
return JSONObject.fromObject(data, config).toString();
@@ -235,13 +460,13 @@ public String processPropertyName(Class className, String fieldName) {
String result = fieldName;
switch (fieldName) {
case "scmRepository":
- result = "scm_repository";
+ result = OctaneConstants.Tests.SCM_REPOSITORY_FIELD;
break;
case "testingToolType":
- result = "testing_tool_type";
+ result = OctaneConstants.Tests.TESTING_TOOL_TYPE_FIELD;
break;
case "testTypes":
- result = "test_type";
+ result = OctaneConstants.Tests.TEST_TYPE_FIELD;
break;
default:
break;
@@ -257,10 +482,10 @@ public String processPropertyName(Class className, String fieldName) {
String result = fieldName;
switch (fieldName) {
case "relativePath":
- result = "relative_path";
+ result = OctaneConstants.DataTables.RELATIVE_PATH_FIELD;
break;
case "scmRepository":
- result = "scm_repository";
+ result = OctaneConstants.DataTables.SCM_REPOSITORY_FIELD;
break;
default:
break;
@@ -285,115 +510,64 @@ public boolean apply(Object source, String name, Object value) {
return config;
}
- /*private static void deleteTests(MqmRestClient client, Collection removedTests, String workspaceId) throws UnsupportedEncodingException {
- List idsToDelete = new ArrayList<>();
- long workspaceIdAsLong = Long.parseLong(workspaceId);
- for (AutomatedTest test : removedTests) {
- Map queryFields = new HashMap<>();
- queryFields.put("name", test.getName());
- queryFields.put("package", test.getPackage());
- PagedList foundTests = client.getTests(workspaceIdAsLong, queryFields, Arrays.asList("id"));
- if (foundTests.getItems().size() == 1) {
- idsToDelete.add(foundTests.getItems().get(0).getId());
- }
- }
-
- int BULK_SIZE = 100;
- for (int i = 0; i < idsToDelete.size(); i += BULK_SIZE) {
- client.deleteTests(workspaceIdAsLong, idsToDelete.subList(i, Math.min(i + BULK_SIZE, idsToDelete.size())));
- }
- }*/
-
- private static boolean setTestsNotExecutable(MqmRestClient client, Collection deletedTest, String workspaceId) throws UnsupportedEncodingException {
- long workspaceIdAsLong = Long.parseLong(workspaceId);
+ private static boolean updateTests(MqmRestClient client, Collection tests, String workspaceId) {
try {
- for (AutomatedTest test : deletedTest) {
- List conditions = new ArrayList<>();
- conditions.add(QueryHelper.condition("name", test.getName()));
- conditions.add(QueryHelper.condition("package", test.getPackage()));
- PagedList foundTests = client.getEntities(workspaceIdAsLong, TESTS_COLLECTION_NAME, conditions, Arrays.asList("id"));
- if (foundTests.getItems().size() == 1) {
- Entity foundTest = foundTests.getItems().get(0);
- AutomatedTest testForUpdate = new AutomatedTest();
- testForUpdate.setExecutable(false);
- testForUpdate.setId(foundTest.getId());
- String json = convertToJsonString(testForUpdate);
- client.updateEntity(Long.parseLong(workspaceId), TESTS_COLLECTION_NAME, foundTests.getItems().get(0).getId(), json);
+ //build testsForUpdate
+ List testsForUpdate = new ArrayList<>();
+ for (AutomatedTest test : tests) {
+ AutomatedTest testForUpdate = new AutomatedTest();
+ if (test.getDescription() != null) {
+ testForUpdate.setDescription(test.getDescription());
}
+ testForUpdate.setExecutable(test.getExecutable());
+ testForUpdate.setId(test.getId());
+ testsForUpdate.add(testForUpdate);
}
- return true;
-
- } catch (Exception e) {
- return false;
- }
- }
-
- private static boolean updateTests(MqmRestClient client, Collection updateTests, String workspaceId, String scmRepositoryId) throws UnsupportedEncodingException {
- long workspaceIdAsLong = Long.parseLong(workspaceId);
-
- try {
- List createAsNewTests = new ArrayList<>();
- for (AutomatedTest test : updateTests) {
- if (StringUtils.isEmpty(test.getDescription())) {
- continue;
- }
-
- List conditions = new ArrayList<>();
- conditions.add(QueryHelper.condition("name", test.getName()));
- conditions.add(QueryHelper.condition("package", test.getPackage()));
- PagedList foundTests = client.getEntities(workspaceIdAsLong, TESTS_COLLECTION_NAME, conditions, Arrays.asList("id"));
- if (foundTests.getItems().size() == 1) {
- Entity foundTest = foundTests.getItems().get(0);
- AutomatedTest testForUpdate = new AutomatedTest();
- testForUpdate.setDescription(test.getDescription());
- testForUpdate.setExecutable(test.getExecutable());
- testForUpdate.setId(foundTest.getId());
- String json = convertToJsonString(testForUpdate);
- client.updateEntity(Long.parseLong(workspaceId), TESTS_COLLECTION_NAME, foundTests.getItems().get(0).getId(), json);
- } else if (foundTests.getItems().size() == 0) {
- //test not exist in Octane, create it from scratch
- logger.error(String.format("Test %s\\%s should be updated but wasn't found on Octane, creating test from scratch ", test.getPackage(), test.getName()));
- createAsNewTests.add(test);
+ if (!testsForUpdate.isEmpty()) {
+ for (int i = 0; i < tests.size(); i += POST_BULK_SIZE) {
+ AutomatedTests data = AutomatedTests.createWithTests(testsForUpdate.subList(i, Math.min(i + POST_BULK_SIZE, tests.size())));
+ String uftTestJson = convertToJsonString(data);
+ client.updateEntities(Long.parseLong(workspaceId), OctaneConstants.Tests.COLLECTION_NAME, uftTestJson);
}
}
-
- if (!createAsNewTests.isEmpty()) {
- return postTests(client, createAsNewTests, workspaceId, scmRepositoryId);
- } else {
- return true;
- }
+ return true;
} catch (Exception e) {
+ logger.error("Failed to update tests : " + e.getMessage());
return false;
}
}
- private boolean deleteScmResources(MqmRestClient client, List deletedResourceFiles, String workspaceId, String scmRepositoryId) {
+ private static Entity fetchDataTableFromOctane(MqmRestClient client, long workspaceIdAsLong, long scmRepositoryId, ScmResourceFile scmResource) {
+ List conditions = new ArrayList<>();
+ conditions.add(QueryHelper.condition(OctaneConstants.DataTables.RELATIVE_PATH_FIELD, scmResource.getRelativePath()));
+ conditions.add(QueryHelper.conditionRef(OctaneConstants.DataTables.SCM_REPOSITORY_FIELD, scmRepositoryId));
+ List entities = client.getEntities(workspaceIdAsLong, OctaneConstants.DataTables.COLLECTION_NAME, conditions, Arrays.asList("id, name"));
+
+ return entities.size() == 1 ? entities.get(0) : null;
+ }
+
+ private static boolean deleteScmResources(MqmRestClient client, List deletedResourceFiles, String workspaceId, String scmRepositoryId) {
long workspaceIdAsLong = Long.parseLong(workspaceId);
+ long scmRepositoryIdAsLong = Long.parseLong(scmRepositoryId);
Set deletedIds = new HashSet<>();
try {
for (ScmResourceFile scmResource : deletedResourceFiles) {
- List conditions = new ArrayList<>();
- conditions.add(QueryHelper.condition("relative_path", scmResource.getRelativePath()));
- conditions.add(QueryHelper.conditionRef("scm_repository", Long.valueOf(scmRepositoryId)));
-
- PagedList foundResources = client.getEntities(workspaceIdAsLong, SCM_RESOURCE_FILES_COLLECTION_NAME, conditions, Arrays.asList("id, name"));
- if (foundResources.getItems().size() == 1) {
- Entity found = foundResources.getItems().get(0);
+ Entity found = fetchDataTableFromOctane(client, workspaceIdAsLong, scmRepositoryIdAsLong, scmResource);
+ if (found != null) {
deletedIds.add(found.getId());
}
}
- client.deleteEntities(Long.parseLong(workspaceId), SCM_RESOURCE_FILES_COLLECTION_NAME, deletedIds);
+ client.deleteEntities(Long.parseLong(workspaceId), OctaneConstants.DataTables.COLLECTION_NAME, deletedIds);
return true;
} catch (Exception e) {
return false;
}
-
}
private static void completeTestProperties(MqmRestClient client, long workspaceId, Collection tests, String scmRepositoryId) {
@@ -402,7 +576,7 @@ private static void completeTestProperties(MqmRestClient client, long workspaceI
ListNodeEntity guiTestType = hasTestsByType(tests, UftTestType.GUI) ? getGuiTestType(client, workspaceId) : null;
ListNodeEntity apiTestType = hasTestsByType(tests, UftTestType.API) ? getApiTestType(client, workspaceId) : null;
- BaseRefEntity scmRepository = StringUtils.isEmpty(scmRepositoryId) ? null : BaseRefEntity.create("scm_repository", Long.valueOf(scmRepositoryId));
+ BaseRefEntity scmRepository = StringUtils.isEmpty(scmRepositoryId) ? null : BaseRefEntity.create(OctaneConstants.Tests.SCM_REPOSITORY_FIELD, Long.valueOf(scmRepositoryId));
for (AutomatedTest test : tests) {
test.setTestingToolType(uftTestingTool);
test.setFramework(uftFramework);
@@ -417,14 +591,14 @@ private static void completeTestProperties(MqmRestClient client, long workspaceI
}
private static void completeScmResourceProperties(List resources, String scmResourceId) {
- BaseRefEntity scmRepository = StringUtils.isEmpty(scmResourceId) ? null : BaseRefEntity.create("scm_repository", Long.valueOf(scmResourceId));
+ BaseRefEntity scmRepository = StringUtils.isEmpty(scmResourceId) ? null : BaseRefEntity.create(OctaneConstants.DataTables.SCM_REPOSITORY_FIELD, Long.valueOf(scmResourceId));
for (ScmResourceFile resource : resources) {
resource.setScmRepository(scmRepository);
}
}
private static ListNodeEntity getUftTestingTool(MqmRestClient client, long workspaceId) {
- PagedList testingTools = client.queryListItems("list_node.testing_tool_type", null, workspaceId, 0, 100);
+ PagedList testingTools = client.queryListItems("list_node.testing_tool_type", null, workspaceId, 0, POST_BULK_SIZE);
String uftTestingToolLogicalName = "list_node.testing_tool_type.uft";
for (ListItem item : testingTools.getItems()) {
@@ -436,7 +610,7 @@ private static ListNodeEntity getUftTestingTool(MqmRestClient client, long works
}
private static ListNodeEntity getUftFramework(MqmRestClient client, long workspaceId) {
- PagedList testingTools = client.queryListItems("list_node.je.framework", null, workspaceId, 0, 100);
+ PagedList testingTools = client.queryListItems("list_node.je.framework", null, workspaceId, 0, POST_BULK_SIZE);
String uftTestingToolLogicalName = "list_node.je.framework.uft";
for (ListItem item : testingTools.getItems()) {
@@ -448,7 +622,7 @@ private static ListNodeEntity getUftFramework(MqmRestClient client, long workspa
}
private static ListNodeEntity getGuiTestType(MqmRestClient client, long workspaceId) {
- PagedList testingTools = client.queryListItems("list_node.test_type", null, workspaceId, 0, 100);
+ PagedList testingTools = client.queryListItems("list_node.test_type", null, workspaceId, 0, POST_BULK_SIZE);
String guiLogicalName = "list_node.test_type.gui";
for (ListItem item : testingTools.getItems()) {
@@ -460,7 +634,7 @@ private static ListNodeEntity getGuiTestType(MqmRestClient client, long workspac
}
private static ListNodeEntity getApiTestType(MqmRestClient client, long workspaceId) {
- PagedList testingTools = client.queryListItems("list_node.test_type", null, workspaceId, 0, 100);
+ PagedList testingTools = client.queryListItems("list_node.test_type", null, workspaceId, 0, POST_BULK_SIZE);
String guiLogicalName = "list_node.test_type.api";
for (ListItem item : testingTools.getItems()) {
@@ -485,11 +659,6 @@ public void setTestResultQueue(UftTestDiscoveryQueue queue) {
this.queue = queue;
}
- @Inject
- public void setConfigurationService(ConfigurationService configurationService) {
- this.configurationService = configurationService;
- }
-
private static boolean hasTestsByType(Collection tests, UftTestType uftTestType) {
for (AutomatedTest test : tests) {
if (uftTestType.equals(test.getUftTestType())) {
diff --git a/src/main/java/com/hp/application/automation/tools/octane/tests/junit/JUnitXmlIterator.java b/src/main/java/com/hp/application/automation/tools/octane/tests/junit/JUnitXmlIterator.java
index eb42b8def3..376f798d16 100644
--- a/src/main/java/com/hp/application/automation/tools/octane/tests/junit/JUnitXmlIterator.java
+++ b/src/main/java/com/hp/application/automation/tools/octane/tests/junit/JUnitXmlIterator.java
@@ -16,6 +16,7 @@
package com.hp.application.automation.tools.octane.tests.junit;
+import com.hp.application.automation.tools.octane.executor.OctaneConstants;
import com.hp.application.automation.tools.octane.tests.HPRunnerType;
import com.hp.application.automation.tools.octane.tests.xml.AbstractXmlIterator;
import com.hp.octane.integrations.dto.DTOFactory;
@@ -38,6 +39,9 @@
import java.text.ParseException;
import java.util.List;
+/**
+ * JUnit iterator over test result. Enrich test result before sending to server
+ */
public class JUnitXmlIterator extends AbstractXmlIterator {
private static final Logger logger = LogManager.getLogger(JUnitXmlIterator.class);
@@ -151,11 +155,12 @@ protected void onEvent(XMLEvent event) throws XMLStreamException, IOException, I
// if workspace is prefix of the method name, cut it off
// currently this handling is needed for UFT tests
String path = testName.substring(workspace.getRemote().length());
- path = StringUtils.strip(path, "\\/");
+ path = path.replace(OctaneConstants.General.LINUX_PATH_SPLITTER, OctaneConstants.General.WINDOWS_PATH_SPLITTER);
+ path = StringUtils.strip(path, OctaneConstants.General.WINDOWS_PATH_SPLITTER);
//split path to package and and name fields
- if (path.contains(File.separator)) {
- int testNameStartIndex = path.indexOf(File.separator);
+ if (path.contains(OctaneConstants.General.WINDOWS_PATH_SPLITTER)) {
+ int testNameStartIndex = path.lastIndexOf(OctaneConstants.General.WINDOWS_PATH_SPLITTER);
testName = path.substring(testNameStartIndex + 1);
packageName = path.substring(0, testNameStartIndex);
From c3b8a069342c75210aec76b5c884d79d78706327 Mon Sep 17 00:00:00 2001
From: bamh
Date: Thu, 8 Jun 2017 13:06:43 +0300
Subject: [PATCH 0062/2502] Advanced trending option and Support automatically
finding and creating Test Instance (#198)
* index on master: ab83a3d Merge remote-tracking branch 'remotes/origin/5.0.1-beta-SNAPSHOT'
* Revert pom changes
* Merge branch '5.0.1-beta-SNAPSHOT' of https://github.com/hpsa/hp-application-automation-tools-plugin into development
# Conflicts:
# .github/PULL_REQUEST_TEMPLATE.md
* Added some comments
* changes according to sonarlint
* changes for sonarlint
* Remove some comments
* Comments
* * Fix for supporting SECURITY-170 changes
* https://jenkins.io/blog/2016/05/11/security-update/
* https://issues.jenkins-ci.org/browse/JENKINS-39654
* code changes for sonarlint
* Changes in PC configuration section header
* Adding support for Jenkins using proxy: https://issues.jenkins-ci.org/browse/JENKINS-44314
Changing the HTTPS checkbox position
* Adding link under Test ID text box for browsing to the PC Server
* Added support for creating TESTINSTANCEID before running a test.
Still needs to add:
1. TestSetID is a stub, we need to check if there is one and to create if not exists
2. Need to check if a test instance id is already exists
* Adding support for createTestInstance if test instance is not available.
* SonarLint Changes
* Support auto trending options
https://issues.jenkins-ci.org/browse/JENKINS-44723
* Added Unit Testing for new Tests Rest API
* Minor change in UI
* Small change regarding the flow of the Auto Trending feature
---
.../automation/tools/model/PcModel.java | 28 +++++---
.../automation/tools/model/PostRunAction.java | 2 +-
.../automation/tools/pc/PcClient.java | 71 +++++++++++++++++--
.../automation/tools/pc/PcRestProxy.java | 48 +++++++++++++
.../automation/tools/pc/PcTest.java | 36 ++++++++++
.../automation/tools/pc/PcTestData.java | 71 +++++++++++++++++++
.../automation/tools/pc/PcTestInstance.java | 31 ++++++++
.../automation/tools/pc/PcTestInstances.java | 32 +++++++++
.../automation/tools/pc/PcTestSet.java | 37 ++++++++++
.../automation/tools/pc/PcTestSets.java | 32 +++++++++
.../tools/pc/TestInstanceCreateRequest.java | 56 +++++++++++++++
.../automation/tools/run/PcBuilder.java | 55 ++++++++++----
.../tools/run/PcBuilder/config.jelly | 60 ++++++++++++----
.../automation/tools/pc/MockPcModel.java | 6 +-
.../automation/tools/pc/MockPcRestProxy.java | 4 ++
.../automation/tools/pc/PcTestBase.java | 8 ++-
16 files changed, 534 insertions(+), 43 deletions(-)
create mode 100644 src/main/java/com/hp/application/automation/tools/pc/PcTest.java
create mode 100644 src/main/java/com/hp/application/automation/tools/pc/PcTestData.java
create mode 100644 src/main/java/com/hp/application/automation/tools/pc/PcTestInstance.java
create mode 100644 src/main/java/com/hp/application/automation/tools/pc/PcTestInstances.java
create mode 100644 src/main/java/com/hp/application/automation/tools/pc/PcTestSet.java
create mode 100644 src/main/java/com/hp/application/automation/tools/pc/PcTestSets.java
create mode 100644 src/main/java/com/hp/application/automation/tools/pc/TestInstanceCreateRequest.java
diff --git a/src/main/java/com/hp/application/automation/tools/model/PcModel.java b/src/main/java/com/hp/application/automation/tools/model/PcModel.java
index d5d8b2031b..37c9041c15 100644
--- a/src/main/java/com/hp/application/automation/tools/model/PcModel.java
+++ b/src/main/java/com/hp/application/automation/tools/model/PcModel.java
@@ -11,7 +11,7 @@
public class PcModel {
public static final String COLLATE = "Collate Results";
- public static final String COLLATE_ANALYZE = "Collate And Analyze";
+ public static final String COLLATE_ANALYZE = "Collate and Analyze";
public static final String DO_NOTHING = "Do Not Collate";
private final String pcServerName;
@@ -21,19 +21,21 @@ public class PcModel {
private final String almProject;
private final String testId;
private final String testInstanceId;
+ private final String autoTestInstanceID;
private final TimeslotDuration timeslotDuration;
private final PostRunAction postRunAction;
private final boolean vudsMode;
private final String description;
- private final boolean addRunToTrendReport;
- private final String trendReportId;
+ private final String addRunToTrendReport;
+ private String trendReportId;
private final boolean HTTPSProtocol;
private final String proxyOutURL;
+
@DataBoundConstructor
public PcModel(String pcServerName, String almUserName, String almPassword, String almDomain, String almProject,
- String testId, String testInstanceId, String timeslotDurationHours, String timeslotDurationMinutes,
- PostRunAction postRunAction, boolean vudsMode, String description, boolean addRunToTrendReport, String trendReportId, boolean HTTPSProtocol, String proxyOutURL) {
+ String testId,String autoTestInstanceID, String testInstanceId, String timeslotDurationHours, String timeslotDurationMinutes,
+ PostRunAction postRunAction, boolean vudsMode, String description, String addRunToTrendReport, String trendReportId, boolean HTTPSProtocol, String proxyOutURL) {
this.pcServerName = pcServerName;
this.almUserName = almUserName;
@@ -41,6 +43,7 @@ public PcModel(String pcServerName, String almUserName, String almPassword, Stri
this.almDomain = almDomain;
this.almProject = almProject;
this.testId = testId;
+ this.autoTestInstanceID = autoTestInstanceID;
this.testInstanceId = testInstanceId;
this.timeslotDuration = new TimeslotDuration(timeslotDurationHours, timeslotDurationMinutes);
this.postRunAction = postRunAction;
@@ -90,10 +93,13 @@ public String getTestId() {
}
public String getTestInstanceId() {
-
return this.testInstanceId;
}
+ public String getAutoTestInstanceID(){
+ return this.autoTestInstanceID;
+ }
+
public TimeslotDuration getTimeslotDuration() {
return this.timeslotDuration;
@@ -122,11 +128,11 @@ public String getProxyOutURL(){
return this.proxyOutURL;
}
-
public static List getPostRunActions() {
return Arrays.asList(PostRunAction.values());
}
+
@Override
public String toString() {
@@ -136,7 +142,7 @@ public String toString() {
public String runParamsToString() {
String vudsModeString = (vudsMode) ? ", VUDsMode='true'" : "";
- String trendString = (addRunToTrendReport) ? String.format(", TrendReportID = '%s'",trendReportId) : "";
+ String trendString = ("USE_ID").equals(addRunToTrendReport) ? String.format(", TrendReportID = '%s'",trendReportId) : "";
return String.format("[Domain='%s', Project='%s', TestID='%s', " +
"TestInstanceID='%s', TimeslotDuration='%s', PostRunAction='%s'%s%s]",
@@ -150,7 +156,11 @@ public String getTrendReportId() {
return trendReportId;
}
- public boolean isAddRunToTrendReport() {
+ public void setTrendReportId(String trendReportId){
+ this.trendReportId = trendReportId;
+ }
+
+ public String getAddRunToTrendReport() {
return addRunToTrendReport;
}
diff --git a/src/main/java/com/hp/application/automation/tools/model/PostRunAction.java b/src/main/java/com/hp/application/automation/tools/model/PostRunAction.java
index e1e84de1b9..64d8a1df5d 100644
--- a/src/main/java/com/hp/application/automation/tools/model/PostRunAction.java
+++ b/src/main/java/com/hp/application/automation/tools/model/PostRunAction.java
@@ -3,7 +3,7 @@
public enum PostRunAction {
COLLATE("Collate Results"),
- COLLATE_AND_ANALYZE("Collate And Analyze"),
+ COLLATE_AND_ANALYZE("Collate and Analyze"),
DO_NOTHING("Do Not Collate");
private String value;
diff --git a/src/main/java/com/hp/application/automation/tools/pc/PcClient.java b/src/main/java/com/hp/application/automation/tools/pc/PcClient.java
index 115f239f01..c9b501dd1b 100644
--- a/src/main/java/com/hp/application/automation/tools/pc/PcClient.java
+++ b/src/main/java/com/hp/application/automation/tools/pc/PcClient.java
@@ -73,7 +73,7 @@ public PcClient(PcModel pcModel, PrintStream logger, T p
public boolean login() {
try {
String user = model.getAlmUserName();
- logger.println(String.format("Trying to login\n[PCServer='%s', User='%s']", model.getPcServerName(), user));
+ logger.println(String.format("Trying to login\n[PCServer='%s://%s', User='%s']",model.isHTTPSProtocol(), model.getPcServerName(), user));
loggedIn = restProxy.authenticate(user, model.getAlmPassword().toString());
} catch (PcException e) {
logger.println(e.getMessage());
@@ -102,9 +102,17 @@ public boolean isLoggedIn() {
public int startRun() throws NumberFormatException, ClientProtocolException, PcException, IOException {
+
+
+
+ int testID = Integer.parseInt(model.getTestId());
+ int testInstance = getCorrectTestInstanceID(testID);
+ setCorrectTrendReportID();
+
+ logger.println(String.format("\nExecuting Load Test: \n====================\nTest ID: %s \nTest Instance ID: %s \nTimeslot Duration: %s \nPost Run Action: %s \nUse VUDS: %s\n====================\n", Integer.parseInt(model.getTestId()), testInstance, model.getTimeslotDuration() ,model.getPostRunAction().getValue(),model.isVudsMode()));
// logger.println("Sending run request:\n" + model.runParamsToString());
- PcRunResponse response = restProxy.startRun(Integer.parseInt(model.getTestId()),
- Integer.parseInt(model.getTestInstanceId()),
+ PcRunResponse response = restProxy.startRun(testID,
+ testInstance,
model.getTimeslotDuration(),
model.getPostRunAction().getValue(),
model.isVudsMode());
@@ -113,6 +121,60 @@ public int startRun() throws NumberFormatException, ClientProtocolException, PcE
return response.getID();
}
+ private int getCorrectTestInstanceID(int testID) throws IOException, PcException {
+ if("AUTO".equals(model.getAutoTestInstanceID())){
+ try {
+
+
+ logger.println("Searching for available Test Instance");
+ PcTestInstances pcTestInstances = restProxy.getTestInstancesByTestId(testID);
+ int testInstanceID = 0;
+ if (pcTestInstances != null && pcTestInstances.getTestInstancesList() != null){
+ PcTestInstance pcTestInstance = pcTestInstances.getTestInstancesList().get(pcTestInstances.getTestInstancesList().size()-1);
+ testInstanceID = pcTestInstance.getInstanceId();
+ logger.println("Found testInstanceId: " + testInstanceID);
+ }else{
+ logger.println("Could not find available TestInstanceID, Creating Test Instance.");
+ logger.println("Searching for available TestSet");
+ // Get a random TestSet
+ PcTestSets pcTestSets = restProxy.GetAllTestSets();
+ if (pcTestSets !=null && pcTestSets.getPcTestSetsList() !=null){
+ PcTestSet pcTestSet = pcTestSets.getPcTestSetsList().get(pcTestSets.getPcTestSetsList().size()-1);
+ int testSetID = pcTestSet.TestSetID;
+ logger.println(String.format("Creating Test Instance with testID: %s and TestSetID: %s", testID,testSetID));
+ testInstanceID = restProxy.createTestInstance(testID,testSetID);
+ logger.println(String.format("Test Instance with ID : %s has been created successfully.", testInstanceID));
+ }else{
+ String msg = "No TestSetID available in project, please create a testset from Performance Center UI";
+ logger.println(msg);
+ throw new PcException(msg);
+ }
+ }
+ return testInstanceID;
+ } catch (Exception e){
+ logger.println(String.format("getCorrectTestInstanceID failed, reason: %s",e));
+ return Integer.parseInt(null);
+ }
+ }
+ return Integer.parseInt(model.getTestInstanceId());
+ }
+
+ private void setCorrectTrendReportID() throws IOException, PcException {
+ // If the user selected "Use trend report associated with the test" we want the report ID to be the one from the test
+ if (("ASSOCIATED").equals(model.getAddRunToTrendReport())){
+ PcTest pcTest = restProxy.getTestData(Integer.parseInt(model.getTestId()));
+ if (pcTest.getTrendReportId() > -1)
+ model.setTrendReportId(String.valueOf(pcTest.getTrendReportId()));
+ else{
+ String msg = "No trend report ID is associated with the test.\n" +
+ "Please turn Automatic Trending on for the test through Performance Center UI.\n" +
+ "Alternatively you can check 'Add run to trend report with ID' on Jenkins job configuration.";
+ throw new PcException(msg);
+ }
+ }
+
+ }
+
public PcRunResponse waitForRunCompletion(int runId) throws InterruptedException, ClientProtocolException, PcException, IOException {
return waitForRunCompletion(runId, 5000);
@@ -232,7 +294,8 @@ public PcRunEventLog getRunEventLog(int runId){
return null;
}
- public void addRunToTrendReport(int runId, String trendReportId){
+ public void addRunToTrendReport(int runId, String trendReportId)
+ {
TrendReportRequest trRequest = new TrendReportRequest(model.getAlmProject(), runId, null);
logger.println("Adding run: " + runId + " to trend report: " + trendReportId);
diff --git a/src/main/java/com/hp/application/automation/tools/pc/PcRestProxy.java b/src/main/java/com/hp/application/automation/tools/pc/PcRestProxy.java
index fd10aa7fa7..e2371da70c 100644
--- a/src/main/java/com/hp/application/automation/tools/pc/PcRestProxy.java
+++ b/src/main/java/com/hp/application/automation/tools/pc/PcRestProxy.java
@@ -49,11 +49,14 @@
import org.apache.http.impl.conn.SchemeRegistryFactory;
import org.apache.http.protocol.BasicHttpContext;
import org.apache.http.protocol.HttpContext;
+import org.xml.sax.SAXException;
+import javax.xml.parsers.ParserConfigurationException;
import java.io.OutputStream;
import java.io.InputStream;
import java.io.IOException;
import java.io.FileOutputStream;
+import java.net.URLEncoder;
import java.util.*;
import java.io.PrintStream;
@@ -69,6 +72,9 @@ public class PcRestProxy {
protected static final String AUTHENTICATION_LOGOUT_URL = BASE_PC_API_AUTHENTICATION_URL + "/logout";
protected static final String PC_API_RESOURCES_TEMPLATE = BASE_PC_API_URL + "/domains/%s/projects/%s";
protected static final String RUNS_RESOURCE_NAME = "Runs";
+ protected static final String TESTS_RESOURCE_NAME = "tests";
+ protected static final String TEST_INSTANCES_NAME = "testinstances";
+ protected static final String TEST_SETS_NAME = "testsets";
protected static final String RESULTS_RESOURCE_NAME = "Results";
protected static final String EVENTLOG_RESOURCE_NAME = "EventLog";
protected static final String TREND_REPORT_RESOURCE_NAME = "TrendReports";
@@ -164,6 +170,40 @@ public PcRunResponse startRun(int testId, int testInstaceId, TimeslotDuration ti
return PcRunResponse.xmlToObject(startRunResponse);
}
+
+ public int createTestInstance(int testId, int testSetId) throws PcException, ClientProtocolException, IOException {
+ HttpPost createTestInstanceRequest = new HttpPost(String.format(baseURL + "/%s", TEST_INSTANCES_NAME));
+ TestInstanceCreateRequest testInstanceCreateRequest = new TestInstanceCreateRequest(testId,testSetId);
+ createTestInstanceRequest.setEntity(new StringEntity(testInstanceCreateRequest.objectToXML(), ContentType.APPLICATION_XML));
+ createTestInstanceRequest.addHeader(RESTConstants.CONTENT_TYPE, CONTENT_TYPE_XML);
+ HttpResponse response = executeRequest(createTestInstanceRequest);
+ String responseXml = IOUtils.toString(response.getEntity().getContent());
+ int testInstanceID = 0;
+ try {
+ testInstanceID = testInstanceCreateRequest.getTestInstanceIDFromResponse(responseXml,"TestInstanceID");
+ } catch (SAXException|ParserConfigurationException e) {
+ throw new PcException("createTestInstance exception: " + e);
+ }
+ return testInstanceID;
+ }
+
+ public PcTestSets GetAllTestSets()throws IOException,PcException{
+ String getTestSetsUrl = String.format(baseURL + "/%s", TEST_SETS_NAME);
+ HttpGet getTestSetsRequest = new HttpGet(getTestSetsUrl);
+ HttpResponse response = executeRequest(getTestSetsRequest);
+ String testSets = IOUtils.toString(response.getEntity().getContent());
+ return PcTestSets.xmlToObject(testSets);
+ }
+
+ public PcTestInstances getTestInstancesByTestId(int testId)throws PcException,IOException{
+ String uri = String.format(baseURL + "/%s?%s=%s", TEST_INSTANCES_NAME,"query",URLEncoder.encode("{test-id[" + testId + "]}","UTF-8"));
+ HttpGet getFirtstTestInstanceByTestID = new HttpGet(uri);
+ HttpResponse response = executeRequest(getFirtstTestInstanceByTestID);
+ String testInstances = IOUtils.toString(response.getEntity().getContent());
+ return PcTestInstances.xmlToObject(testInstances);
+
+ }
+
public boolean stopRun(int runId, String stopMode) throws PcException, ClientProtocolException, IOException {
String stopUrl = String.format(baseURL + "/%s/%s/%s", RUNS_RESOURCE_NAME, runId, stopMode);
HttpPost stopRunRequest = new HttpPost(stopUrl);
@@ -181,6 +221,13 @@ public PcRunResponse getRunData(int runId) throws PcException, ClientProtocolExc
return PcRunResponse.xmlToObject(runData);
}
+ public PcTest getTestData(int testId) throws IOException, PcException {
+ HttpGet getTestDataRequest = new HttpGet(String.format(baseURL + "/%s/%s",TESTS_RESOURCE_NAME,testId ));
+ HttpResponse response = executeRequest(getTestDataRequest);
+ String testData = IOUtils.toString(response.getEntity().getContent());
+ return PcTestData.xmlToObject(testData);
+ }
+
public PcRunResults getRunResults(int runId) throws PcException, ClientProtocolException, IOException {
String getRunResultsUrl = String
.format(baseURL + "/%s/%s/%s", RUNS_RESOURCE_NAME, runId, RESULTS_RESOURCE_NAME);
@@ -278,4 +325,5 @@ public static boolean isOk (HttpResponse response) {
protected String getBaseURL() {
return baseURL;
}
+
}
diff --git a/src/main/java/com/hp/application/automation/tools/pc/PcTest.java b/src/main/java/com/hp/application/automation/tools/pc/PcTest.java
new file mode 100644
index 0000000000..2886be759d
--- /dev/null
+++ b/src/main/java/com/hp/application/automation/tools/pc/PcTest.java
@@ -0,0 +1,36 @@
+package com.hp.application.automation.tools.pc;
+
+/**
+ * Created by bemh on 6/5/2017.
+ * Partial implementation of the test xml structure
+ */
+public class PcTest {
+
+
+ private int testId;
+ private String testName;
+
+ private int trendReportId = -1;
+
+
+
+ public int getTestId() {
+ return testId;
+ }
+
+ public String getTestName() {
+ return testName;
+ }
+
+ public void setTrendReportId(int trendReportId) {
+ this.trendReportId = trendReportId;
+ }
+
+ public int getTrendReportId() {
+ return trendReportId;
+ }
+
+ public void setTestId(int testId){this.testId = testId;}
+
+ public void setTestName(String testName){this.testName = testName;}
+}
diff --git a/src/main/java/com/hp/application/automation/tools/pc/PcTestData.java b/src/main/java/com/hp/application/automation/tools/pc/PcTestData.java
new file mode 100644
index 0000000000..7f98bdc392
--- /dev/null
+++ b/src/main/java/com/hp/application/automation/tools/pc/PcTestData.java
@@ -0,0 +1,71 @@
+package com.hp.application.automation.tools.pc;
+
+import com.thoughtworks.xstream.XStream;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.StringReader;
+
+/**
+ * Created by bemh on 6/5/2017.
+ * Partial implementation of the test xml structure
+ */
+public class PcTestData {
+
+
+
+
+ static Document dom;
+ static DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+
+
+ public static PcTest xmlToObject(String xml){
+
+ PcTest pcTest = new PcTest();
+
+ try {
+ DocumentBuilder db = dbf.newDocumentBuilder();
+ dom = db.parse(new InputSource(new StringReader(xml)));
+ Element doc = dom.getDocumentElement();
+ NodeList nListTestNodes = doc.getElementsByTagName("AutomaticTrending");
+ if (nListTestNodes.getLength() >0 )
+ {
+ NodeList nListChild = nListTestNodes.item(0).getChildNodes();
+ for (int j=0;j < nListChild.getLength();j++) {
+ if (nListChild.item(j).getNodeName().equals("ReportId")){
+ pcTest.setTrendReportId(Integer.parseInt(nListChild.item(j).getTextContent()));
+ break;
+ }
+ }
+ }
+
+ nListTestNodes = doc.getElementsByTagName("ID");
+ pcTest.setTestId(Integer.parseInt(nListTestNodes.item(0).getFirstChild().getNodeValue()));
+
+ nListTestNodes = doc.getElementsByTagName("Name");
+ pcTest.setTestName(nListTestNodes.item(0).getFirstChild().getNodeValue());
+
+
+
+
+ }catch (ParserConfigurationException pce) {
+ System.out.println(pce.getMessage());
+ } catch (SAXException se) {
+ System.out.println(se.getMessage());
+ } catch (IOException ioe) {
+ System.err.println(ioe.getMessage());
+ }
+
+ return pcTest;
+ }
+
+}
diff --git a/src/main/java/com/hp/application/automation/tools/pc/PcTestInstance.java b/src/main/java/com/hp/application/automation/tools/pc/PcTestInstance.java
new file mode 100644
index 0000000000..ba02002e45
--- /dev/null
+++ b/src/main/java/com/hp/application/automation/tools/pc/PcTestInstance.java
@@ -0,0 +1,31 @@
+package com.hp.application.automation.tools.pc;
+
+import com.thoughtworks.xstream.XStream;
+
+/**
+ * Created by bemh on 6/1/2017.
+ */
+public class PcTestInstance {
+ public int TestID;
+ public int TestSetID;
+ public int TestInstanceID;
+
+ public static PcTestInstance xmlToObject(String xml)
+ {
+ XStream xstream = new XStream();
+ xstream.alias("TestInstanceID" , PcRunResult.class);
+ return (PcTestInstance)xstream.fromXML(xml);
+ }
+
+ public int getInstanceId() {
+ return TestInstanceID;
+ }
+
+ public int getTestId(){
+ return TestID;
+ }
+
+ public int getTestSetId(){
+ return TestSetID;
+ }
+}
diff --git a/src/main/java/com/hp/application/automation/tools/pc/PcTestInstances.java b/src/main/java/com/hp/application/automation/tools/pc/PcTestInstances.java
new file mode 100644
index 0000000000..90a088b457
--- /dev/null
+++ b/src/main/java/com/hp/application/automation/tools/pc/PcTestInstances.java
@@ -0,0 +1,32 @@
+package com.hp.application.automation.tools.pc;
+
+import com.thoughtworks.xstream.XStream;
+
+import java.util.ArrayList;
+
+/**
+ * Created by bemh on 6/1/2017.
+ */
+public class PcTestInstances {
+
+
+ private ArrayList TestInstancesList;
+
+ public PcTestInstances() {
+ TestInstancesList = new ArrayList();
+ }
+
+ public static PcTestInstances xmlToObject(String xml)
+ {
+ XStream xstream = new XStream();
+ xstream.alias("TestInstance" , PcTestInstance.class);
+ xstream.alias("TestInstances" , PcTestInstances.class);
+ xstream.addImplicitCollection(PcTestInstances.class, "TestInstancesList");
+ xstream.setClassLoader(PcTestInstances.class.getClassLoader());
+ return (PcTestInstances)xstream.fromXML(xml);
+ }
+
+ public ArrayList getTestInstancesList() {
+ return TestInstancesList;
+ }
+}
diff --git a/src/main/java/com/hp/application/automation/tools/pc/PcTestSet.java b/src/main/java/com/hp/application/automation/tools/pc/PcTestSet.java
new file mode 100644
index 0000000000..16e30529fb
--- /dev/null
+++ b/src/main/java/com/hp/application/automation/tools/pc/PcTestSet.java
@@ -0,0 +1,37 @@
+package com.hp.application.automation.tools.pc;
+
+import com.thoughtworks.xstream.XStream;
+
+/**
+ * Created by bemh on 6/1/2017.
+ */
+public class PcTestSet {
+
+ String TestSetName;
+ String TestSetComment;
+ int TestSetParentId;
+ int TestSetID;
+
+ public static PcTestSet xmlToObject(String xml){
+ XStream xstream = new XStream();
+ xstream.alias("TestSetID" , PcRunResult.class);
+ return (PcTestSet)xstream.fromXML(xml);
+ }
+
+
+ public String getTestSetName(){
+ return TestSetName;
+ }
+ public String getTestSetComment(){
+ return TestSetComment;
+ }
+
+ public int getTestSetParentId(){
+ return TestSetParentId;
+ }
+
+ public int getTestSetID(){
+ return TestSetID;
+ }
+
+}
diff --git a/src/main/java/com/hp/application/automation/tools/pc/PcTestSets.java b/src/main/java/com/hp/application/automation/tools/pc/PcTestSets.java
new file mode 100644
index 0000000000..63f09a847f
--- /dev/null
+++ b/src/main/java/com/hp/application/automation/tools/pc/PcTestSets.java
@@ -0,0 +1,32 @@
+package com.hp.application.automation.tools.pc;
+
+import com.thoughtworks.xstream.XStream;
+
+import java.util.ArrayList;
+
+/**
+ * Created by bemh on 6/1/2017.
+ */
+public class PcTestSets {
+
+ private ArrayList pcTestSetsList;
+
+ public PcTestSets(){
+ pcTestSetsList = new ArrayList();
+ }
+
+
+ public static PcTestSets xmlToObject(String xml)
+ {
+ XStream xstream = new XStream();
+ xstream.alias("TestSet" , PcTestSet.class);
+ xstream.alias("TestSets" , PcTestSets.class);
+ xstream.addImplicitCollection(PcTestSets.class, "pcTestSetsList");
+ xstream.setClassLoader(PcTestSets.class.getClassLoader());
+ return (PcTestSets)xstream.fromXML(xml);
+ }
+
+ public ArrayList getPcTestSetsList() {
+ return pcTestSetsList;
+ }
+}
diff --git a/src/main/java/com/hp/application/automation/tools/pc/TestInstanceCreateRequest.java b/src/main/java/com/hp/application/automation/tools/pc/TestInstanceCreateRequest.java
new file mode 100644
index 0000000000..705c13c9e4
--- /dev/null
+++ b/src/main/java/com/hp/application/automation/tools/pc/TestInstanceCreateRequest.java
@@ -0,0 +1,56 @@
+package com.hp.application.automation.tools.pc;
+
+import com.thoughtworks.xstream.XStream;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.StringReader;
+
+/**
+ * Created by bemh on 5/23/2017.
+ */
+public class TestInstanceCreateRequest {
+
+ private String xmlns = PcRestProxy.PC_API_XMLNS;
+
+ private int testId;
+ private int testSetId;
+
+ public TestInstanceCreateRequest(int testId, int testSetId) {
+ this.testId = testId;
+ this.testSetId = testSetId;
+ }
+
+ public String objectToXML() {
+ XStream xstream = new XStream();
+ xstream.useAttributeFor(TestInstanceCreateRequest.class, "xmlns");
+ xstream.alias("TestInstance", TestInstanceCreateRequest.class);
+ xstream.aliasField("TestID", TestInstanceCreateRequest.class, "testId");
+ xstream.aliasField("TestSetID", TestInstanceCreateRequest.class, "testSetId");
+ return xstream.toXML(this);
+ }
+
+ public int getTestInstanceIDFromResponse(String xml, String getTestInstanceID) throws IOException, SAXException, ParserConfigurationException {
+
+
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ DocumentBuilder builder = factory.newDocumentBuilder();
+ InputSource is = new InputSource(new ByteArrayInputStream(xml.getBytes("utf-8")));
+ Document doc = builder.parse(is);
+ Element element = doc.getDocumentElement();
+
+
+ NodeList nListTrendedRun = doc.getElementsByTagName("TestInstanceID");
+ return Integer.parseInt(nListTrendedRun.item(0).getTextContent());
+
+ }
+}
diff --git a/src/main/java/com/hp/application/automation/tools/run/PcBuilder.java b/src/main/java/com/hp/application/automation/tools/run/PcBuilder.java
index 812ca2a5b0..c01cd165c8 100644
--- a/src/main/java/com/hp/application/automation/tools/run/PcBuilder.java
+++ b/src/main/java/com/hp/application/automation/tools/run/PcBuilder.java
@@ -102,13 +102,14 @@ public PcBuilder(
String almProject,
String testId,
String testInstanceId,
+ String autoTestInstanceID,
String timeslotDurationHours,
String timeslotDurationMinutes,
PostRunAction postRunAction,
boolean vudsMode,
boolean statusBySLA,
String description,
- boolean addRunToTrendReport,
+ String addRunToTrendReport,
String trendReportId,
boolean HTTPSProtocol,
String proxyOutURL) {
@@ -126,6 +127,7 @@ public PcBuilder(
almDomain.trim(),
almProject.trim(),
testId.trim(),
+ autoTestInstanceID,
testInstanceId.trim(),
timeslotDurationHours.trim(),
timeslotDurationMinutes.trim(),
@@ -235,8 +237,16 @@ private Testsuites run(PcClient pcClient, Run, ?> build)
if (response != null && RunState.get(response.getRunState()) == FINISHED) {
pcReportFile = pcClient.publishRunReport(runId, getReportDirectory(build));
- // Adding the trend report section
- if(pcModel.isAddRunToTrendReport() && pcModel.getTrendReportId() != null && RunState.get(response.getRunState()) != RUN_FAILURE){
+ // Adding the trend report section if ID has been set
+ if(("USE_ID").equals(pcModel.getAddRunToTrendReport()) && pcModel.getTrendReportId() != null && RunState.get(response.getRunState()) != RUN_FAILURE){
+ pcClient.addRunToTrendReport(this.runId, pcModel.getTrendReportId());
+ pcClient.waitForRunToPublishOnTrendReport(this.runId, pcModel.getTrendReportId());
+ pcClient.downloadTrendReportAsPdf(pcModel.getTrendReportId(), getTrendReportsDirectory(build));
+ trendReportReady = true;
+ }
+
+ // Adding the trend report if the Associated Trend report is selected.
+ if(("ASSOCIATED").equals(pcModel.getAddRunToTrendReport()) && RunState.get(response.getRunState()) != RUN_FAILURE){
pcClient.addRunToTrendReport(this.runId, pcModel.getTrendReportId());
pcClient.waitForRunToPublishOnTrendReport(this.runId, pcModel.getTrendReportId());
pcClient.downloadTrendReportAsPdf(pcModel.getTrendReportId(), getTrendReportsDirectory(build));
@@ -311,8 +321,10 @@ private boolean validatePcForm() {
String modelMethodName = modelMethod.getName();
if (modelMethodName.toLowerCase().equals("get" + name)) {
try {
- Object obj =
- method.invoke(getDescriptor(), modelMethod.invoke(getPcModel()));
+ Object obj = FormValidation.ok();
+ if (!(name.equals("testinstanceid")&& pcModel.getAutoTestInstanceID().equals("AUTO"))){
+ obj = method.invoke(getDescriptor(), modelMethod.invoke(getPcModel()));
+ }
if (!obj.equals(FormValidation.ok())) {
logger.println(obj);
ret = false;
@@ -326,14 +338,15 @@ private boolean validatePcForm() {
}
}
- boolean isTrendReportIdValid = validateTrendReportIdIsNumeric(getPcModel().getTrendReportId(),
- getPcModel().isAddRunToTrendReport());
+ boolean isTrendReportIdValid = validateTrendReportIdIsNumeric(getPcModel().getTrendReportId(),("USE_ID").equals(getPcModel().getAddRunToTrendReport()));
ret &= isTrendReportIdValid;
return ret;
}
+
+
private boolean validateTrendReportIdIsNumeric(String trendReportId, boolean addRunToTrendReport){
FormValidation res = FormValidation.ok();
@@ -587,15 +600,19 @@ public String getTrendReportId()
return getPcModel().getTrendReportId();
}
+ public String autoTestInstanceID()
+ {
+ return getPcModel().getAutoTestInstanceID();
+ }
public String getTestInstanceId()
{
return getPcModel().getTestInstanceId();
}
- public boolean isAddRunToTrendReport()
+ public String getAddRunToTrendReport()
{
- return getPcModel().isAddRunToTrendReport();
+ return getPcModel().getAddRunToTrendReport();
}
@@ -677,11 +694,23 @@ public FormValidation doCheckTestId(@QueryParameter String value) {
return validateHigherThanInt(value, "Test ID", 0, true);
}
-
- public FormValidation doCheckTestInstanceId(@QueryParameter String value) {
-
+
+
+ // if autoTestInstanceID is selected we don't need to check the validation of the test instance
+// public static FormValidation CheckOnlyAutoTestInstanceId(String autoTestInstanceID){
+// if(autoTestInstanceID.equals("AUTO"))
+// return FormValidation.ok();
+// else
+// return FormValidation.error("Error ");
+// }
+
+
+
+ public FormValidation doCheckTestInstanceId(@QueryParameter String value){
return validateHigherThanInt(value, "Test Instance ID", 0, true);
}
+
+
public FormValidation doCheckTimeslotDuration(@QueryParameter TimeslotDuration value) {
@@ -737,12 +766,12 @@ private FormValidation validateString(String value, String field) {
return ret;
}
-
public List getPostRunActions() {
return PcModel.getPostRunActions();
}
+
}
diff --git a/src/main/resources/com/hp/application/automation/tools/run/PcBuilder/config.jelly b/src/main/resources/com/hp/application/automation/tools/run/PcBuilder/config.jelly
index 15bf085df5..b61e4b9ff7 100644
--- a/src/main/resources/com/hp/application/automation/tools/run/PcBuilder/config.jelly
+++ b/src/main/resources/com/hp/application/automation/tools/run/PcBuilder/config.jelly
@@ -14,7 +14,7 @@
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE. -->
-
+
+
+
+
diff --git a/src/test/java/com/hpe/application/automation/tools/pc/MockPcModel.java b/src/test/java/com/hpe/application/automation/tools/pc/MockPcModel.java
index 770522d5b2..6283bf6b24 100644
--- a/src/test/java/com/hpe/application/automation/tools/pc/MockPcModel.java
+++ b/src/test/java/com/hpe/application/automation/tools/pc/MockPcModel.java
@@ -8,10 +8,10 @@
public class MockPcModel extends PcModel {
- public MockPcModel(String pcServerName, String almUserName, String almPassword, String almDomain,
+ public MockPcModel(String serverandport, String pcServerName, String almUserName, String almPassword, String almDomain,
String almProject, String testId, String autoTestInstanceID, String testInstanceId, String timeslotDurationHours,
String timeslotDurationMinutes, PostRunAction postRunAction, boolean vudsMode, String description, boolean webProtocol) {
- super(pcServerName, almUserName, almPassword, almDomain, almProject, testId, autoTestInstanceID, testInstanceId, timeslotDurationHours,
+ super(serverandport, pcServerName, almUserName, almPassword, almDomain, almProject, testId, autoTestInstanceID, testInstanceId, timeslotDurationHours,
timeslotDurationMinutes, postRunAction, vudsMode, description, "NO_TREND", null,false,null
);
}
diff --git a/src/test/java/com/hpe/application/automation/tools/pc/PcTestBase.java b/src/test/java/com/hpe/application/automation/tools/pc/PcTestBase.java
index f2a84b2057..b9181d5984 100644
--- a/src/test/java/com/hpe/application/automation/tools/pc/PcTestBase.java
+++ b/src/test/java/com/hpe/application/automation/tools/pc/PcTestBase.java
@@ -22,7 +22,8 @@
public interface PcTestBase {
- public static final String PC_SERVER_NAME = "pcServer.hp.com";
+ public static final String SERVER_AND_PORT = "jenkins.server:8082";
+ public static final String PC_SERVER_NAME = "pcServer.hp.com";
public static final String ALM_USER_NAME = "sa";
public static final String ALM_PASSWORD = "pwd";
public static final String ALM_DOMAIN = "ALMDOM";
@@ -44,7 +45,7 @@ public interface PcTestBase {
public static final String TESTINSTANCEID = "MANUAL";
public static final PrintStream LOGGER = null;
- public static final MockPcModel pcModel = new MockPcModel(PC_SERVER_NAME, ALM_USER_NAME,
+ public static final MockPcModel pcModel = new MockPcModel(SERVER_AND_PORT,PC_SERVER_NAME, ALM_USER_NAME,
ALM_PASSWORD, ALM_DOMAIN, ALM_PROJECT,
TEST_ID,TESTINSTANCEID, TEST_INSTANCE_ID,
TIMESLOT_DURATION_HOURS,
From 155206c81c0b3c9e4bc8cff1b354c872c1f15827 Mon Sep 17 00:00:00 2001
From: "Hanan.Bem"
Date: Wed, 13 Sep 2017 15:55:26 +0300
Subject: [PATCH 0140/2502] serverandport changed to serverAndPort
---
.../application/automation/tools/model/PcModel.java | 10 +++++-----
.../application/automation/tools/run/PcBuilder.java | 6 +++---
.../automation/tools/run/PcBuilder/config.jelly | 6 +++---
.../application/automation/tools/pc/MockPcModel.java | 4 ++--
4 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/src/main/java/com/hpe/application/automation/tools/model/PcModel.java b/src/main/java/com/hpe/application/automation/tools/model/PcModel.java
index cb6b62e9f4..4189190840 100644
--- a/src/main/java/com/hpe/application/automation/tools/model/PcModel.java
+++ b/src/main/java/com/hpe/application/automation/tools/model/PcModel.java
@@ -14,7 +14,7 @@ public class PcModel {
public static final String COLLATE_ANALYZE = "Collate and Analyze";
public static final String DO_NOTHING = "Do Not Collate";
- private final String serverandport;
+ private final String serverAndPort;
private final String pcServerName;
private final String almUserName;
private final SecretContainer almPassword;
@@ -34,11 +34,11 @@ public class PcModel {
@DataBoundConstructor
- public PcModel(String serverandport, String pcServerName, String almUserName, String almPassword, String almDomain, String almProject,
+ public PcModel(String serverAndPort, String pcServerName, String almUserName, String almPassword, String almDomain, String almProject,
String testId,String autoTestInstanceID, String testInstanceId, String timeslotDurationHours, String timeslotDurationMinutes,
PostRunAction postRunAction, boolean vudsMode, String description, String addRunToTrendReport, String trendReportId, boolean HTTPSProtocol, String proxyOutURL) {
- this.serverandport = serverandport;
+ this.serverAndPort = serverAndPort;
this.pcServerName = pcServerName;
this.almUserName = almUserName;
this.almPassword = setPassword(almPassword);
@@ -64,8 +64,8 @@ protected SecretContainer setPassword(String almPassword) {
return secretContainer;
}
- public String getserverandport(){
- return this.serverandport;
+ public String getserverAndPort(){
+ return this.serverAndPort;
}
public String getPcServerName() {
diff --git a/src/main/java/com/hpe/application/automation/tools/run/PcBuilder.java b/src/main/java/com/hpe/application/automation/tools/run/PcBuilder.java
index 6c6bcf6d32..3c23a54e40 100644
--- a/src/main/java/com/hpe/application/automation/tools/run/PcBuilder.java
+++ b/src/main/java/com/hpe/application/automation/tools/run/PcBuilder.java
@@ -107,7 +107,7 @@ public class PcBuilder extends Builder implements SimpleBuildStep{
@DataBoundConstructor
public PcBuilder(
- String serverandport,
+ String serverAndPort,
String pcServerName,
String almUserName,
String almPassword,
@@ -134,7 +134,7 @@ public PcBuilder(
pcModel =
new PcModel(
- serverandport.trim(),
+ serverAndPort.trim(),
pcServerName.trim(),
almUserName.trim(),
almPassword,
@@ -590,7 +590,7 @@ private String getOutputForReportLinks(Run, ?> build) {
String downloadUrl = String.format(urlPattern + "/%s", "*zip*/pcRun");
logger.println(HyperlinkNote.encodeTo(viewUrl, "View analysis report of run " + runId));
- return String.format("Load Test Run ID: %s\n\nView analysis report:\n%s\n\nDownload Report:\n%s", runId, pcModel.getserverandport() + "/" + build.getUrl() + viewUrl, pcModel.getserverandport() + "/" + build.getUrl() + downloadUrl);
+ return String.format("Load Test Run ID: %s\n\nView analysis report:\n%s\n\nDownload Report:\n%s", runId, pcModel.getserverAndPort() + "/" + build.getUrl() + viewUrl, pcModel.getserverAndPort() + "/" + build.getUrl() + downloadUrl);
}
private String getArtifactsUrlPattern(Run, ?> build) {
diff --git a/src/main/resources/com/hpe/application/automation/tools/run/PcBuilder/config.jelly b/src/main/resources/com/hpe/application/automation/tools/run/PcBuilder/config.jelly
index 7a921ca21a..b12bc30a1c 100644
--- a/src/main/resources/com/hpe/application/automation/tools/run/PcBuilder/config.jelly
+++ b/src/main/resources/com/hpe/application/automation/tools/run/PcBuilder/config.jelly
@@ -44,7 +44,7 @@
var href = window.location.href;
var splitter = href.split("/job");
var baseurl = splitter[0];
- var p = document.getElementById('serverandport');
+ var p = document.getElementById('serverAndPort');
if(p){
p.value = baseurl;
}
@@ -127,8 +127,8 @@
-
-
+
+
diff --git a/src/test/java/com/hpe/application/automation/tools/pc/MockPcModel.java b/src/test/java/com/hpe/application/automation/tools/pc/MockPcModel.java
index 6283bf6b24..662431c1e9 100644
--- a/src/test/java/com/hpe/application/automation/tools/pc/MockPcModel.java
+++ b/src/test/java/com/hpe/application/automation/tools/pc/MockPcModel.java
@@ -8,10 +8,10 @@
public class MockPcModel extends PcModel {
- public MockPcModel(String serverandport, String pcServerName, String almUserName, String almPassword, String almDomain,
+ public MockPcModel(String serverAndPort, String pcServerName, String almUserName, String almPassword, String almDomain,
String almProject, String testId, String autoTestInstanceID, String testInstanceId, String timeslotDurationHours,
String timeslotDurationMinutes, PostRunAction postRunAction, boolean vudsMode, String description, boolean webProtocol) {
- super(serverandport, pcServerName, almUserName, almPassword, almDomain, almProject, testId, autoTestInstanceID, testInstanceId, timeslotDurationHours,
+ super(serverAndPort, pcServerName, almUserName, almPassword, almDomain, almProject, testId, autoTestInstanceID, testInstanceId, timeslotDurationHours,
timeslotDurationMinutes, postRunAction, vudsMode, description, "NO_TREND", null,false,null
);
}
From dcb77d668345af5ca55d96ce7d2b0e6e75260b3d Mon Sep 17 00:00:00 2001
From: radislavB
Date: Thu, 14 Sep 2017 11:17:11 +0300
Subject: [PATCH 0141/2502] expose jenkins user + Octane user/APIKey for
DevOps Admin (#39)
* tech: modify jenkins user help text
* tech: protect thread from unexpected termination
* defect #443021 :expose jenkins user + Octane user/APIKey for DevOps Admin
---
pom.xml | 4 +-
.../tools/octane/CIJenkinsServicesImpl.java | 3 +-
.../tools/octane/bridge/BridgeClient.java | 42 ++++++++++++-------
src/main/webapp/help/impersonatedUser.html | 2 +-
4 files changed, 31 insertions(+), 20 deletions(-)
diff --git a/pom.xml b/pom.xml
index 5394d96992..933e9e4fd3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -386,14 +386,14 @@
integrations-sdkcom.hpe.adm.octane.ciplugins
- 1.4.4
+ 1.4.7mqm-rest-clientcom.hpe.adm.octane.ciplugins
- 1.4.13
+ 1.4.14
diff --git a/src/main/java/com/hpe/application/automation/tools/octane/CIJenkinsServicesImpl.java b/src/main/java/com/hpe/application/automation/tools/octane/CIJenkinsServicesImpl.java
index 2cd4f56d6a..0478654201 100644
--- a/src/main/java/com/hpe/application/automation/tools/octane/CIJenkinsServicesImpl.java
+++ b/src/main/java/com/hpe/application/automation/tools/octane/CIJenkinsServicesImpl.java
@@ -94,7 +94,8 @@ public CIServerInfo getServerInfo() {
.setUrl(serverUrl)
.setInstanceId(model.getIdentity())
.setInstanceIdFrom(model.getIdentityFrom())
- .setSendingTime(System.currentTimeMillis());
+ .setSendingTime(System.currentTimeMillis())
+ .setImpersonatedUser(model.getImpersonatedUser());
return result;
}
diff --git a/src/main/java/com/hpe/application/automation/tools/octane/bridge/BridgeClient.java b/src/main/java/com/hpe/application/automation/tools/octane/bridge/BridgeClient.java
index d068d285f6..a2dcff9000 100644
--- a/src/main/java/com/hpe/application/automation/tools/octane/bridge/BridgeClient.java
+++ b/src/main/java/com/hpe/application/automation/tools/octane/bridge/BridgeClient.java
@@ -20,6 +20,7 @@
import com.hp.mqm.client.exception.AuthenticationException;
import com.hp.mqm.client.exception.ServerException;
import com.hp.mqm.client.exception.TemporarilyUnavailableException;
+import com.hp.mqm.client.model.AbridgedTaskPluginInfo;
import com.hp.octane.integrations.OctaneSDK;
import com.hp.octane.integrations.spi.CIPluginServices;
import com.hp.octane.integrations.api.TasksProcessor;
@@ -27,6 +28,7 @@
import com.hp.octane.integrations.dto.connectivity.OctaneResultAbridged;
import com.hp.octane.integrations.dto.connectivity.OctaneTaskAbridged;
import com.hpe.application.automation.tools.octane.client.JenkinsMqmRestClientFactory;
+import com.hpe.application.automation.tools.octane.configuration.ConfigurationService;
import com.hpe.application.automation.tools.octane.configuration.ServerConfiguration;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -75,13 +77,16 @@ public void run() {
CIPluginServices pluginServices = OctaneSDK.getInstance().getPluginServices();
try {
MqmRestClient restClient = restClientFactory.obtain(mqmConfig.location, mqmConfig.sharedSpace, mqmConfig.username, mqmConfig.password);
- tasksJSON = restClient.getAbridgedTasks(
- serverInstanceId,
- pluginServices.getServerInfo().getType().value(),
- pluginServices.getServerInfo().getUrl(),
- OctaneSDK.API_VERSION,
- OctaneSDK.SDK_VERSION,
- OctaneSDK.getInstance().getPluginServices().getPluginInfo().getVersion());
+ AbridgedTaskPluginInfo info = new AbridgedTaskPluginInfo()
+ .setSelfIdentity(serverInstanceId)
+ .setSelfType(pluginServices.getServerInfo().getType().value())
+ .setSelfLocation(pluginServices.getServerInfo().getUrl())
+ .setApiVersion(OctaneSDK.API_VERSION)
+ .setSdkVersion(OctaneSDK.SDK_VERSION)
+ .setPluginVersion(OctaneSDK.getInstance().getPluginServices().getPluginInfo().getVersion())
+ .setOctaneUser(pluginServices.getOctaneConfiguration().getApiKey())
+ .setCiServerUser(ConfigurationService.getModel().getImpersonatedUser());
+ tasksJSON = restClient.getAbridgedTasks(info);
isConnected = false;
connect();
if (tasksJSON != null && !tasksJSON.isEmpty()) {
@@ -145,18 +150,23 @@ private void dispatchTasks(String tasksJSON) {
taskProcessingExecutors.execute(new Runnable() {
@Override
public void run() {
- TasksProcessor TasksProcessor = OctaneSDK.getInstance().getTasksProcessor();
- OctaneResultAbridged result = TasksProcessor.execute(task);
- MqmRestClient restClient = restClientFactory.obtain(
- mqmConfig.location,
- mqmConfig.sharedSpace,
- mqmConfig.username,
- mqmConfig.password);
- int submitStatus = restClient.putAbridgedResult(
+ try {
+ TasksProcessor TasksProcessor = OctaneSDK.getInstance().getTasksProcessor();
+ OctaneResultAbridged result = TasksProcessor.execute(task);
+ MqmRestClient restClient = restClientFactory.obtain(
+ mqmConfig.location,
+ mqmConfig.sharedSpace,
+ mqmConfig.username,
+ mqmConfig.password);
+
+ int submitStatus = restClient.putAbridgedResult(
serverInstanceId,
result.getId(),
dtoFactory.dtoToJson(result));
- logger.info("result for task '" + result.getId() + "' submitted with status " + submitStatus);
+ logger.info("result for task '" + result.getId() + "' submitted with status " + submitStatus);
+ } catch (Exception e) {
+ logger.error("failed to submit task '" + task.getId(), e);
+ }
}
});
}
diff --git a/src/main/webapp/help/impersonatedUser.html b/src/main/webapp/help/impersonatedUser.html
index 0262dce1b7..2d16ae8ee1 100644
--- a/src/main/webapp/help/impersonatedUser.html
+++ b/src/main/webapp/help/impersonatedUser.html
@@ -5,7 +5,7 @@
Make sure the user exists in Jenkins.
- We strongly recommend specifying a Jenkins user for ALM Octane. Set this user's permissions to the minimum required for this integration: Job Build permissions.
+ We strongly recommend specifying a Jenkins user for ALM Octane. Set this user's permissions to the minimum required for this integration: Job Build and Read permissions.
\ No newline at end of file
diff --git a/src/main/resources/com/hpe/application/automation/tools/results/SrfRunResultRecorder/config.jelly b/src/main/resources/com/hpe/application/automation/tools/results/SrfRunResultRecorder/config.jelly
new file mode 100644
index 0000000000..ffa465c323
--- /dev/null
+++ b/src/main/resources/com/hpe/application/automation/tools/results/SrfRunResultRecorder/config.jelly
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+ ${archiveMode.description}
+
+
+
+
+
+
+
diff --git a/src/main/resources/com/hpe/application/automation/tools/results/SrfRunResultRecorder/help-archiveTestResultsMode.html b/src/main/resources/com/hpe/application/automation/tools/results/SrfRunResultRecorder/help-archiveTestResultsMode.html
new file mode 100644
index 0000000000..b1cc1dd440
--- /dev/null
+++ b/src/main/resources/com/hpe/application/automation/tools/results/SrfRunResultRecorder/help-archiveTestResultsMode.html
@@ -0,0 +1,8 @@
+
+To view the run results, do one of the following:
+1) In the left pane, click the Report and Summary link to display the report link and the link to the report folder. From this link, you can open the run results directly in your browser or open the artifacts
+2) From the Build Artifacts:
+• Open the run_results.html to view the run results.
+• Download the zipped report to your desired location and unzip it. In the HP Run Results Viewer, select the Results.xml file found inside the unzipped folder.
+Note that this option is valid only when using the “Execute HP test from file system†build step.
+
- Add your local proxy as following: http(s)://<host>:<port>
+ Add your local proxy as following: http(s)://<host>:<port> or http(s)://<proxyuser>:<proxypassword>@<host>:<port>or
Leave empty if not using a local proxy.
PAC (proxy auto-config) or Automatic configuration script are not supported.
\ No newline at end of file
From d0b8a9cae6a42ebd212ae50d18d924693bcf9146 Mon Sep 17 00:00:00 2001
From: radislavB
Date: Wed, 27 Sep 2017 15:10:48 +0300
Subject: [PATCH 0154/2502] restricting activation of contributor for
UFT-related jobs only (#45)
* restricting activation of contributor for UFT-related jobs only
* fixing check for isExecutorJob
* fixing getSharedCheckOutDirectory
* fixing getSharedCheckOutDirectory
---
.../CheckOutSubDirEnvContributor.java | 7 +++--
.../TestExecutionJobCreatorService.java | 30 ++++++++++++++-----
.../tools/octane/executor/UftJobCleaner.java | 24 ++-------------
3 files changed, 30 insertions(+), 31 deletions(-)
diff --git a/src/main/java/com/hpe/application/automation/tools/octane/executor/CheckOutSubDirEnvContributor.java b/src/main/java/com/hpe/application/automation/tools/octane/executor/CheckOutSubDirEnvContributor.java
index 3935b6f6d7..cc37ed95e6 100644
--- a/src/main/java/com/hpe/application/automation/tools/octane/executor/CheckOutSubDirEnvContributor.java
+++ b/src/main/java/com/hpe/application/automation/tools/octane/executor/CheckOutSubDirEnvContributor.java
@@ -16,6 +16,7 @@
package com.hpe.application.automation.tools.octane.executor;
+import com.hpe.application.automation.tools.octane.configuration.ConfigurationService;
import hudson.EnvVars;
import hudson.Extension;
import hudson.model.EnvironmentContributor;
@@ -34,7 +35,7 @@
@Extension
public class CheckOutSubDirEnvContributor extends EnvironmentContributor {
- public static final String CHECKOUT_SUBDIR_ENV_NAME = "CHECKOUT_SUBDIR";
+ public static final String CHECKOUT_SUBDIR_ENV_NAME = "CHECKOUT_SUBDIR";
@Override
public void buildEnvironmentFor(Job j, EnvVars envs, TaskListener listener) throws IOException, InterruptedException {
@@ -45,7 +46,7 @@ public void buildEnvironmentFor(Job j, EnvVars envs, TaskListener listener) thro
}
public static String getSharedCheckOutDirectory(Job j) {
- if (j instanceof FreeStyleProject) {
+ if (j instanceof FreeStyleProject && TestExecutionJobCreatorService.isExecutorJob((FreeStyleProject) j) && ConfigurationService.getServerConfiguration().isValid()) {
SCM scm = ((FreeStyleProject) j).getScm();
if (scm != null && scm instanceof GitSCM) {
GitSCM gitScm = (GitSCM) scm;
@@ -54,8 +55,8 @@ public static String getSharedCheckOutDirectory(Job j) {
return sharedCheckOutDirectory.getRelativeTargetDir();
}
}
-
}
+
return null;
}
diff --git a/src/main/java/com/hpe/application/automation/tools/octane/executor/TestExecutionJobCreatorService.java b/src/main/java/com/hpe/application/automation/tools/octane/executor/TestExecutionJobCreatorService.java
index 8754a7a59b..9084ae569a 100644
--- a/src/main/java/com/hpe/application/automation/tools/octane/executor/TestExecutionJobCreatorService.java
+++ b/src/main/java/com/hpe/application/automation/tools/octane/executor/TestExecutionJobCreatorService.java
@@ -63,8 +63,8 @@ public class TestExecutionJobCreatorService {
private static final Logger logger = LogManager.getLogger(TestExecutionJobCreatorService.class);
public static final String EXECUTOR_ID_PARAMETER_NAME = "Connection ID";
public static final String EXECUTOR_LOGICAL_NAME_PARAMETER_NAME = "Connection logical name";
- public static final String SUITE_ID_PARAMETER_NAME = "suiteId";//"Suite ID";
- public static final String SUITE_RUN_ID_PARAMETER_NAME = "suiteRunId";//"Suite run ID";
+ public static final String SUITE_ID_PARAMETER_NAME = "suiteId";
+ public static final String SUITE_RUN_ID_PARAMETER_NAME = "suiteRunId";
public static final String FULL_SCAN_PARAMETER_NAME = "Full sync";
public static final String EXECUTION_JOB_MIDDLE_NAME = "test run job - Suite ID";
@@ -230,8 +230,7 @@ private static String prepareMtbxData(List tests) throws IOEx
StringWriter writer = new StringWriter();
transformer.transform(new DOMSource(doc), new StreamResult(writer));
- String str = writer.toString();
- return str;
+ return writer.toString();
} catch (Exception e) {
throw new IOException("Failed to build MTBX content : " + e.getMessage());
}
@@ -325,8 +324,8 @@ private static String buildDiscoveryJobName(TestingToolType testingToolType, Str
}
private static void setBuildDiscarder(FreeStyleProject proj, int numBuildsToKeep) throws IOException {
- int IRRELEVANT = -1;
- BuildDiscarder bd = new LogRotator(IRRELEVANT, numBuildsToKeep, IRRELEVANT, IRRELEVANT);
+ int irrelevant = -1;
+ BuildDiscarder bd = new LogRotator(irrelevant, numBuildsToKeep, irrelevant, irrelevant);
proj.setBuildDiscarder(bd);
}
@@ -337,7 +336,7 @@ private static void setBuildDiscarder(FreeStyleProject proj, int numBuildsToKeep
* @param scmTrigger
*/
private static void delayPollingStart(final FreeStyleProject proj, final SCMTrigger scmTrigger) {
- long delayStartPolling = 1000 * 60 * 5;//5 minute
+ long delayStartPolling = 1000L * 60 * 5;//5 minute
Timer timer = new Timer();
timer.schedule(new TimerTask() {
@Override
@@ -415,4 +414,21 @@ private static void addAssignedNode(FreeStyleProject proj) {
logger.error("Failed to set addAssignedNode : " + e.getMessage());
}
}
+
+ public static boolean isExecutorJob(FreeStyleProject job) {
+ ParametersDefinitionProperty parameters = job.getProperty(ParametersDefinitionProperty.class);
+ boolean isExecutorJob = job.getName().contains(TestExecutionJobCreatorService.EXECUTION_JOB_MIDDLE_NAME) &&
+ parameters != null &&
+ parameters.getParameterDefinition(TestExecutionJobCreatorService.SUITE_ID_PARAMETER_NAME) != null;
+
+ return isExecutorJob;
+ }
+
+ public static boolean isDiscoveryJobJob(FreeStyleProject job) {
+ ParametersDefinitionProperty parameters = job.getProperty(ParametersDefinitionProperty.class);
+ boolean isDiscoveryJob = job.getName().contains(TestExecutionJobCreatorService.DISCOVERY_JOB_MIDDLE_NAME) &&
+ parameters != null &&
+ parameters.getParameterDefinition(TestExecutionJobCreatorService.EXECUTOR_ID_PARAMETER_NAME) != null;
+ return isDiscoveryJob;
+ }
}
diff --git a/src/main/java/com/hpe/application/automation/tools/octane/executor/UftJobCleaner.java b/src/main/java/com/hpe/application/automation/tools/octane/executor/UftJobCleaner.java
index 80a17d2ed4..3ae43abb44 100644
--- a/src/main/java/com/hpe/application/automation/tools/octane/executor/UftJobCleaner.java
+++ b/src/main/java/com/hpe/application/automation/tools/octane/executor/UftJobCleaner.java
@@ -84,7 +84,7 @@ private void clearExecutionJobs(List jobs) {
long thresholdTimeInMillis = new Date().getTime() - PeriodicWork.DAY * getOutdateThreshold();
int clearCounter = 0;
for (FreeStyleProject job : jobs) {
- if (isExecutorJob(job) && job.getLastBuild() != null && !job.isBuilding()) {
+ if (TestExecutionJobCreatorService.isExecutorJob(job) && job.getLastBuild() != null && !job.isBuilding()) {
if (thresholdTimeInMillis > job.getLastBuild().getTimeInMillis()) {
try {
logger.warn(String.format("Job %s is going to be deleted as outdated job, last build was executed at %s", job.getName(), job.getLastBuild().getTimestampString2()));
@@ -101,24 +101,6 @@ private void clearExecutionJobs(List jobs) {
logger.warn(String.format("Cleaner found %s outdated execution job", clearCounter));
}
- private static boolean isExecutorJob(FreeStyleProject job) {
- ParametersDefinitionProperty parameters = job.getProperty(ParametersDefinitionProperty.class);
- boolean isExecutorJob = job.getName().contains(TestExecutionJobCreatorService.EXECUTION_JOB_MIDDLE_NAME) &&
- parameters != null &&
- parameters.getParameterDefinition(TestExecutionJobCreatorService.SUITE_ID_PARAMETER_NAME) != null &&
- parameters.getParameterDefinition(TestExecutionJobCreatorService.SUITE_RUN_ID_PARAMETER_NAME) != null;
-
- return isExecutorJob;
- }
-
- private static boolean isDiscoveryJobJob(FreeStyleProject job) {
- ParametersDefinitionProperty parameters = job.getProperty(ParametersDefinitionProperty.class);
- boolean isDiscoveryJob = job.getName().contains(TestExecutionJobCreatorService.DISCOVERY_JOB_MIDDLE_NAME) &&
- parameters != null &&
- parameters.getParameterDefinition(TestExecutionJobCreatorService.EXECUTOR_ID_PARAMETER_NAME) != null;
- return isDiscoveryJob;
- }
-
private void clearDiscoveryJobs(List jobs) {
//Generally, after deleting executor in Octane, relevant job in Jenkins is also deleted. But if jenkins was down during delete of executor, job remains
@@ -130,7 +112,7 @@ private void clearDiscoveryJobs(List jobs) {
Map> workspace2executorLogical2DiscoveryJobMap = new HashMap<>();
for (FreeStyleProject job : jobs) {
- if (isDiscoveryJobJob(job)) {
+ if (TestExecutionJobCreatorService.isDiscoveryJobJob(job)) {
String executorLogicalName = getExecutorLogicalName(job);
Long workspaceId = getOctaneWorkspaceId(job);
if (executorLogicalName != null && workspaceId != null) {
@@ -225,7 +207,7 @@ public static void deleteExecutor(String id) {
long executorToDelete = Long.parseLong(id);
List jobs = Jenkins.getInstance().getAllItems(FreeStyleProject.class);
for (FreeStyleProject proj : jobs) {
- if (isDiscoveryJobJob(proj)) {
+ if (TestExecutionJobCreatorService.isDiscoveryJobJob(proj)) {
Long executorId = getExecutorId(proj);
if (executorId != null && executorId == executorToDelete) {
boolean waitBeforeDelete = false;
From 5df5001d7b6da116ec70f88ea0f5cd99e2f298f0 Mon Sep 17 00:00:00 2001
From: Vladimir
Date: Wed, 27 Sep 2017 15:17:22 +0300
Subject: [PATCH 0155/2502] use new execution api for srf
---
.../tools/run/RunFromSrfBuilder.java | 46 ++++++++++---------
1 file changed, 25 insertions(+), 21 deletions(-)
diff --git a/src/main/java/com/hpe/application/automation/tools/run/RunFromSrfBuilder.java b/src/main/java/com/hpe/application/automation/tools/run/RunFromSrfBuilder.java
index 04c3330cf0..e41aa7f261 100644
--- a/src/main/java/com/hpe/application/automation/tools/run/RunFromSrfBuilder.java
+++ b/src/main/java/com/hpe/application/automation/tools/run/RunFromSrfBuilder.java
@@ -280,8 +280,7 @@ private JSONArray GetTestResults(JSONArray tests) throws IOException {
url=url.concat(_token);
url=url.concat("&");
- JSONObject obj = JSONObject.fromObject(tests.get(i));
- String runId = obj.getString("id");
+ String runId = tests.get(i).toString();
url = url.concat(String.format("id=%1s", runId));
url = url.concat("&include=resource,script-runs,script-steps");
@@ -340,8 +339,7 @@ private HttpURLConnection Connect(String path, String method){
_token = LoginToSrf();
}
reqUrl = reqUrl.concat("?access-token=");
- reqUrl = reqUrl.concat(_token);
- //.concat("&TENANTID="+_tenant);
+ reqUrl = reqUrl.concat(_token).concat("&TENANTID="+_tenant);
URL srvUrl = new URL(reqUrl);
HttpURLConnection con = (HttpURLConnection) srvUrl.openConnection();
@@ -382,10 +380,10 @@ private void FillExecutionReqBody() throws IOException{
String buildNumber = ApplyJobParams(srfBuildNumber);
String releaseNumber = ApplyJobParams(srfReleaseNumber);
if (buildNumber != null && buildNumber.length() > 0) {
- ciProps.put("Build", buildNumber);
+ data.put("build", buildNumber);
}
if (releaseNumber != null && releaseNumber.length() > 0)
- ciProps.put("Release", releaseNumber);
+ data.put("release", releaseNumber);
this.logger.print(String.format("Required build & release: %1s %2s\n\r", buildNumber, releaseNumber));
HashMap paramObj = new HashMap();
@@ -402,18 +400,16 @@ private void FillExecutionReqBody() throws IOException{
logger.print(String.format("%1s : %2s\n\r", name, val));
}
}
- if (ciProps.size() > 0) {
- testParams.put("ciParameters", ciProps);
- }
+
if (cnt > 0)
- testParams.put("parameters", paramObj);
+ data.put("params", paramObj);
//add request header
// con.setRequestProperty("session-context", context);
try {
OutputStream out = _con.getOutputStream();
OutputStreamWriter writer = new OutputStreamWriter(out);
- writer.write(testParams.toString());
+ writer.write(data.toString());
writer.flush();
out.flush();
out.close();
@@ -426,7 +422,7 @@ private JSONArray GetTestsSet() throws MalformedURLException, AuthenticationExce
StringBuffer response = new StringBuffer();
JSONArray ar = new JSONArray();
- _con = Connect("/rest/test-manager/executions", "POST");
+ _con = Connect("/rest/jobmanager/v1/execution/jobs", "POST");
try {
FillExecutionReqBody();
}
@@ -457,11 +453,12 @@ private JSONArray GetTestsSet() throws MalformedURLException, AuthenticationExce
if (responseCode != 200) {
try{
- JSONArray tests = JSONArray.fromObject(response.toString());
+ JSONArray tests = JSONObject.fromObject(response.toString()).getJSONArray("jobs");
+ JSONArray.fromObject(response.toString());
int len = tests.size();
for (int i= 0; i < len; i++) {
JSONObject jo = tests.getJSONObject(i);
- if(jo.containsKey("id") && ( jo.size() == 1)) {
+ if(jo.containsKey("testId") && ( jo.size() == 1)) {
ar.add(jo);
}
else {
@@ -483,8 +480,13 @@ private JSONArray GetTestsSet() throws MalformedURLException, AuthenticationExce
}
}
else
- ar = JSONArray.fromObject(response.toString());
- return ar;
+ ar = JSONObject.fromObject(response.toString()).getJSONArray("jobs");
+ JSONArray testAr = new JSONArray();
+ int cnt = ar.size();
+ for (int k = 0; k < cnt; k++ ){
+ testAr.add(ar.getJSONObject(k).getString("jobId"));
+ }
+ return testAr;
}
@@ -618,7 +620,7 @@ public void onEvent(InboundEvent inboundEvent) {
boolean skip = true;
String id = obj.getJSONObject("testRun").getString("id");
for(int i = 0; i < testsCnt; i++){
- if(id.compareTo(tests.getJSONObject(i).getString("id") ) == 0){
+ if(id.compareTo(tests.getString(i)) == 0){
skip = false;
break;
}
@@ -836,10 +838,12 @@ public boolean perform(final AbstractBuild, ?> build, final Launcher launcher,
}
return _success;
}
- private synchronized void dowait(long time)
- {
- try{ wait(time);}
- catch (InterruptedException e){}
+ private synchronized void dowait(long time) throws InterruptedException {
+ try {
+ wait(time);
+ } catch (InterruptedException e) {
+ throw e;
+ }
}
String Convert2Xml(JSONArray report) throws ParserConfigurationException{
From e733255a0499cd594cee623cb5b7e1468e8c8ce4 Mon Sep 17 00:00:00 2001
From: "Hanan.Bem"
Date: Wed, 27 Sep 2017 16:08:30 +0300
Subject: [PATCH 0156/2502] second fix defect: Snippet Generator fails to
create snippet fixing defect:
https://issues.jenkins-ci.org/browse/JENKINS-46423 For the second time after
another fix (45863) caused the same issue
---
.../com/hpe/application/automation/tools/run/PcBuilder.java | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/main/java/com/hpe/application/automation/tools/run/PcBuilder.java b/src/main/java/com/hpe/application/automation/tools/run/PcBuilder.java
index 3c23a54e40..a6401e97e8 100644
--- a/src/main/java/com/hpe/application/automation/tools/run/PcBuilder.java
+++ b/src/main/java/com/hpe/application/automation/tools/run/PcBuilder.java
@@ -691,6 +691,10 @@ public void perform(@Nonnull Run, ?> build, @Nonnull FilePath workspace, @Nonn
}
+ public String getServerAndPort()
+ {
+ return getPcModel().getserverAndPort();
+ }
public String getPcServerName()
{
return getPcModel().getPcServerName();
From 795f0a91a10d6338202d453bd6b8b9d1830571ad Mon Sep 17 00:00:00 2001
From: radislavB
Date: Thu, 28 Sep 2017 11:34:44 +0300
Subject: [PATCH 0157/2502] fixing getSharedCheckOutDirectory - separating
classes that contains ref to GitScm to different classes (#47)
---
.../CheckOutSubDirEnvContributor.java | 14 +----
.../executor/CheckOutSubDirEnvService.java | 46 ++++++++++++++++
.../TestExecutionJobCreatorService.java | 46 ++++------------
.../executor/UFTTestDetectionService.java | 2 +-
.../tools/octane/executor/UftConstants.java | 31 +++++++++++
.../tools/octane/executor/UftJobCleaner.java | 10 ++--
.../octane/executor/UftJobRecognizer.java | 54 +++++++++++++++++++
7 files changed, 150 insertions(+), 53 deletions(-)
create mode 100644 src/main/java/com/hpe/application/automation/tools/octane/executor/CheckOutSubDirEnvService.java
create mode 100644 src/main/java/com/hpe/application/automation/tools/octane/executor/UftConstants.java
create mode 100644 src/main/java/com/hpe/application/automation/tools/octane/executor/UftJobRecognizer.java
diff --git a/src/main/java/com/hpe/application/automation/tools/octane/executor/CheckOutSubDirEnvContributor.java b/src/main/java/com/hpe/application/automation/tools/octane/executor/CheckOutSubDirEnvContributor.java
index cc37ed95e6..e39ae58e0d 100644
--- a/src/main/java/com/hpe/application/automation/tools/octane/executor/CheckOutSubDirEnvContributor.java
+++ b/src/main/java/com/hpe/application/automation/tools/octane/executor/CheckOutSubDirEnvContributor.java
@@ -23,9 +23,6 @@
import hudson.model.FreeStyleProject;
import hudson.model.Job;
import hudson.model.TaskListener;
-import hudson.plugins.git.GitSCM;
-import hudson.plugins.git.extensions.impl.RelativeTargetDirectory;
-import hudson.scm.SCM;
import java.io.IOException;
@@ -46,15 +43,8 @@ public void buildEnvironmentFor(Job j, EnvVars envs, TaskListener listener) thro
}
public static String getSharedCheckOutDirectory(Job j) {
- if (j instanceof FreeStyleProject && TestExecutionJobCreatorService.isExecutorJob((FreeStyleProject) j) && ConfigurationService.getServerConfiguration().isValid()) {
- SCM scm = ((FreeStyleProject) j).getScm();
- if (scm != null && scm instanceof GitSCM) {
- GitSCM gitScm = (GitSCM) scm;
- RelativeTargetDirectory sharedCheckOutDirectory = gitScm.getExtensions().get(RelativeTargetDirectory.class);
- if (sharedCheckOutDirectory != null) {
- return sharedCheckOutDirectory.getRelativeTargetDir();
- }
- }
+ if (j instanceof FreeStyleProject && UftJobRecognizer.isExecutorJob((FreeStyleProject) j) && !ConfigurationService.getServerConfiguration().isValid()) {
+ return CheckOutSubDirEnvService.getSharedCheckOutDirectory(j);
}
return null;
diff --git a/src/main/java/com/hpe/application/automation/tools/octane/executor/CheckOutSubDirEnvService.java b/src/main/java/com/hpe/application/automation/tools/octane/executor/CheckOutSubDirEnvService.java
new file mode 100644
index 0000000000..4eb2991cac
--- /dev/null
+++ b/src/main/java/com/hpe/application/automation/tools/octane/executor/CheckOutSubDirEnvService.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2017 Hewlett-Packard Development Company, L.P.
+ * 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.
+ *
+ */
+
+package com.hpe.application.automation.tools.octane.executor;
+
+import hudson.model.FreeStyleProject;
+import hudson.model.Job;
+import hudson.plugins.git.GitSCM;
+import hudson.plugins.git.extensions.impl.RelativeTargetDirectory;
+import hudson.scm.SCM;
+
+/**
+ * Compute SharedCheckOutDirectory
+ */
+
+public class CheckOutSubDirEnvService {
+
+
+ public static String getSharedCheckOutDirectory(Job j) {
+ SCM scm = ((FreeStyleProject) j).getScm();
+ if (scm != null && scm instanceof GitSCM) {
+ GitSCM gitScm = (GitSCM) scm;
+ RelativeTargetDirectory sharedCheckOutDirectory = gitScm.getExtensions().get(RelativeTargetDirectory.class);
+ if (sharedCheckOutDirectory != null) {
+ return sharedCheckOutDirectory.getRelativeTargetDir();
+ }
+ }
+
+ return null;
+ }
+
+}
+
diff --git a/src/main/java/com/hpe/application/automation/tools/octane/executor/TestExecutionJobCreatorService.java b/src/main/java/com/hpe/application/automation/tools/octane/executor/TestExecutionJobCreatorService.java
index 9084ae569a..6ea2ce75e1 100644
--- a/src/main/java/com/hpe/application/automation/tools/octane/executor/TestExecutionJobCreatorService.java
+++ b/src/main/java/com/hpe/application/automation/tools/octane/executor/TestExecutionJobCreatorService.java
@@ -61,14 +61,7 @@
public class TestExecutionJobCreatorService {
private static final Logger logger = LogManager.getLogger(TestExecutionJobCreatorService.class);
- public static final String EXECUTOR_ID_PARAMETER_NAME = "Connection ID";
- public static final String EXECUTOR_LOGICAL_NAME_PARAMETER_NAME = "Connection logical name";
- public static final String SUITE_ID_PARAMETER_NAME = "suiteId";
- public static final String SUITE_RUN_ID_PARAMETER_NAME = "suiteRunId";
- public static final String FULL_SCAN_PARAMETER_NAME = "Full sync";
- public static final String EXECUTION_JOB_MIDDLE_NAME = "test run job - Suite ID";
- public static final String DISCOVERY_JOB_MIDDLE_NAME = "test discovery job - Connection ID";
/**
* Create (if needed) and run test execution
@@ -101,8 +94,8 @@ public static void runTestSuiteExecution(TestSuiteExecutionInfo suiteExecutionIn
//start job
if (proj != null) {
- ParameterValue suiteRunIdParam = new StringParameterValue(SUITE_RUN_ID_PARAMETER_NAME, suiteExecutionInfo.getSuiteRunId());
- ParameterValue suiteIdParam = new StringParameterValue(SUITE_ID_PARAMETER_NAME, suiteExecutionInfo.getSuiteId());
+ ParameterValue suiteRunIdParam = new StringParameterValue(UftConstants.SUITE_RUN_ID_PARAMETER_NAME, suiteExecutionInfo.getSuiteRunId());
+ ParameterValue suiteIdParam = new StringParameterValue(UftConstants.SUITE_ID_PARAMETER_NAME, suiteExecutionInfo.getSuiteId());
ParametersAction parameters = new ParametersAction(suiteRunIdParam, suiteIdParam);
Cause cause = StringUtils.isNotEmpty(suiteExecutionInfo.getSuiteRunId()) ? TriggeredBySuiteRunCause.create(suiteExecutionInfo.getSuiteRunId()) : new Cause.UserIdCause();
@@ -116,7 +109,7 @@ private static FreeStyleProject getExecutionJob(TestSuiteExecutionInfo suiteExec
try {
String projectName = String.format("%s %s %s",
suiteExecutionInfo.getTestingToolType().toString(),
- EXECUTION_JOB_MIDDLE_NAME,
+ UftConstants.EXECUTION_JOB_MIDDLE_NAME,
suiteExecutionInfo.getSuiteId());
//validate creation of job
@@ -129,8 +122,8 @@ private static FreeStyleProject getExecutionJob(TestSuiteExecutionInfo suiteExec
setScmRepository(suiteExecutionInfo.getScmRepository(), suiteExecutionInfo.getScmRepositoryCredentialsId(), proj, true);
setBuildDiscarder(proj, 40);
- addConstantParameter(proj, SUITE_ID_PARAMETER_NAME, suiteExecutionInfo.getSuiteId(), "ALM Octane test suite ID");
- addStringParameter(proj, SUITE_RUN_ID_PARAMETER_NAME, "", "The ID of the ALM Octane test suite run to associate with the test run results. Provided by ALM Octane when running a planned suite run.\nOtherwise, leave this parameter empty. ALM Octane creates a new test suite run for the new results.");
+ addConstantParameter(proj, UftConstants.SUITE_ID_PARAMETER_NAME, suiteExecutionInfo.getSuiteId(), "ALM Octane test suite ID");
+ addStringParameter(proj, UftConstants.SUITE_RUN_ID_PARAMETER_NAME, "", "The ID of the ALM Octane test suite run to associate with the test run results. Provided by ALM Octane when running a planned suite run.\nOtherwise, leave this parameter empty. ALM Octane creates a new test suite run for the new results.");
addAssignedNode(proj);
//add build action
@@ -261,8 +254,8 @@ public static void runTestDiscovery(DiscoveryInfo discoveryInfo) {
//start job
if (proj != null) {
- ParameterValue executorIdParam = new StringParameterValue(EXECUTOR_ID_PARAMETER_NAME, discoveryInfo.getExecutorId());
- ParameterValue fullScanParam = new BooleanParameterValue(FULL_SCAN_PARAMETER_NAME, discoveryInfo.isForceFullDiscovery());
+ ParameterValue executorIdParam = new StringParameterValue(UftConstants.EXECUTOR_ID_PARAMETER_NAME, discoveryInfo.getExecutorId());
+ ParameterValue fullScanParam = new BooleanParameterValue(UftConstants.FULL_SCAN_PARAMETER_NAME, discoveryInfo.isForceFullDiscovery());
ParametersAction parameters = new ParametersAction(executorIdParam, fullScanParam);
Cause cause = new Cause.UserIdCause();
@@ -286,9 +279,9 @@ private static FreeStyleProject getDiscoveryJob(DiscoveryInfo discoveryInfo) {
setScmRepository(discoveryInfo.getScmRepository(), discoveryInfo.getScmRepositoryCredentialsId(), proj, false);
setBuildDiscarder(proj, 20);
- addConstantParameter(proj, EXECUTOR_ID_PARAMETER_NAME, discoveryInfo.getExecutorId(), "ALM Octane testing tool connection ID");
- addConstantParameter(proj, EXECUTOR_LOGICAL_NAME_PARAMETER_NAME, discoveryInfo.getExecutorLogicalName(), "ALM Octane testing tool connection logical name");
- addBooleanParameter(proj, FULL_SCAN_PARAMETER_NAME, false, "Specify whether to synchronize the set of tests on ALM Octane with the whole SCM repository or to update the set of tests on ALM Octane based on the latest commits.");
+ addConstantParameter(proj, UftConstants.EXECUTOR_ID_PARAMETER_NAME, discoveryInfo.getExecutorId(), "ALM Octane testing tool connection ID");
+ addConstantParameter(proj, UftConstants.EXECUTOR_LOGICAL_NAME_PARAMETER_NAME, discoveryInfo.getExecutorLogicalName(), "ALM Octane testing tool connection logical name");
+ addBooleanParameter(proj, UftConstants.FULL_SCAN_PARAMETER_NAME, false, "Specify whether to synchronize the set of tests on ALM Octane with the whole SCM repository or to update the set of tests on ALM Octane based on the latest commits.");
//set polling once in two minutes
SCMTrigger scmTrigger = new SCMTrigger("H/2 * * * *");//H/2 * * * * : once in two minutes
@@ -319,7 +312,7 @@ private static FreeStyleProject getDiscoveryJob(DiscoveryInfo discoveryInfo) {
}
private static String buildDiscoveryJobName(TestingToolType testingToolType, String executorId, String executorLogicalName) {
- String name = String.format("%s %s %s (%s)", testingToolType.toString(), DISCOVERY_JOB_MIDDLE_NAME, executorId, executorLogicalName);
+ String name = String.format("%s %s %s (%s)", testingToolType.toString(), UftConstants.DISCOVERY_JOB_MIDDLE_NAME, executorId, executorLogicalName);
return name;
}
@@ -414,21 +407,4 @@ private static void addAssignedNode(FreeStyleProject proj) {
logger.error("Failed to set addAssignedNode : " + e.getMessage());
}
}
-
- public static boolean isExecutorJob(FreeStyleProject job) {
- ParametersDefinitionProperty parameters = job.getProperty(ParametersDefinitionProperty.class);
- boolean isExecutorJob = job.getName().contains(TestExecutionJobCreatorService.EXECUTION_JOB_MIDDLE_NAME) &&
- parameters != null &&
- parameters.getParameterDefinition(TestExecutionJobCreatorService.SUITE_ID_PARAMETER_NAME) != null;
-
- return isExecutorJob;
- }
-
- public static boolean isDiscoveryJobJob(FreeStyleProject job) {
- ParametersDefinitionProperty parameters = job.getProperty(ParametersDefinitionProperty.class);
- boolean isDiscoveryJob = job.getName().contains(TestExecutionJobCreatorService.DISCOVERY_JOB_MIDDLE_NAME) &&
- parameters != null &&
- parameters.getParameterDefinition(TestExecutionJobCreatorService.EXECUTOR_ID_PARAMETER_NAME) != null;
- return isDiscoveryJob;
- }
}
diff --git a/src/main/java/com/hpe/application/automation/tools/octane/executor/UFTTestDetectionService.java b/src/main/java/com/hpe/application/automation/tools/octane/executor/UFTTestDetectionService.java
index ea01e15958..a4024cf20c 100644
--- a/src/main/java/com/hpe/application/automation/tools/octane/executor/UFTTestDetectionService.java
+++ b/src/main/java/com/hpe/application/automation/tools/octane/executor/UFTTestDetectionService.java
@@ -144,7 +144,7 @@ private static void removeFalsePositiveDeletedDataTables(List del
private static boolean isFullScan(AbstractBuild, ?> build) {
ParametersAction parameters = build.getAction(ParametersAction.class);
if (parameters != null) {
- ParameterValue parameterValue = parameters.getParameter(TestExecutionJobCreatorService.FULL_SCAN_PARAMETER_NAME);
+ ParameterValue parameterValue = parameters.getParameter(UftConstants.FULL_SCAN_PARAMETER_NAME);
if (parameterValue != null) {
return (Boolean) parameterValue.getValue();
}
diff --git a/src/main/java/com/hpe/application/automation/tools/octane/executor/UftConstants.java b/src/main/java/com/hpe/application/automation/tools/octane/executor/UftConstants.java
new file mode 100644
index 0000000000..09df5e8084
--- /dev/null
+++ b/src/main/java/com/hpe/application/automation/tools/octane/executor/UftConstants.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2017 Hewlett-Packard Development Company, L.P.
+ * 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.
+ *
+ */
+package com.hpe.application.automation.tools.octane.executor;
+
+/**
+ * Constants for UFT executors jobs
+ */
+public class UftConstants {
+
+ public static final String EXECUTOR_ID_PARAMETER_NAME = "Connection ID";
+ public static final String EXECUTOR_LOGICAL_NAME_PARAMETER_NAME = "Connection logical name";
+ public static final String SUITE_ID_PARAMETER_NAME = "suiteId";
+ public static final String SUITE_RUN_ID_PARAMETER_NAME = "suiteRunId";
+ public static final String FULL_SCAN_PARAMETER_NAME = "Full sync";
+
+ public static final String EXECUTION_JOB_MIDDLE_NAME = "test run job - Suite ID";
+ public static final String DISCOVERY_JOB_MIDDLE_NAME = "test discovery job - Connection ID";
+}
diff --git a/src/main/java/com/hpe/application/automation/tools/octane/executor/UftJobCleaner.java b/src/main/java/com/hpe/application/automation/tools/octane/executor/UftJobCleaner.java
index 3ae43abb44..e53daa7f89 100644
--- a/src/main/java/com/hpe/application/automation/tools/octane/executor/UftJobCleaner.java
+++ b/src/main/java/com/hpe/application/automation/tools/octane/executor/UftJobCleaner.java
@@ -84,7 +84,7 @@ private void clearExecutionJobs(List jobs) {
long thresholdTimeInMillis = new Date().getTime() - PeriodicWork.DAY * getOutdateThreshold();
int clearCounter = 0;
for (FreeStyleProject job : jobs) {
- if (TestExecutionJobCreatorService.isExecutorJob(job) && job.getLastBuild() != null && !job.isBuilding()) {
+ if (UftJobRecognizer.isExecutorJob(job) && job.getLastBuild() != null && !job.isBuilding()) {
if (thresholdTimeInMillis > job.getLastBuild().getTimeInMillis()) {
try {
logger.warn(String.format("Job %s is going to be deleted as outdated job, last build was executed at %s", job.getName(), job.getLastBuild().getTimestampString2()));
@@ -112,7 +112,7 @@ private void clearDiscoveryJobs(List jobs) {
Map> workspace2executorLogical2DiscoveryJobMap = new HashMap<>();
for (FreeStyleProject job : jobs) {
- if (TestExecutionJobCreatorService.isDiscoveryJobJob(job)) {
+ if (UftJobRecognizer.isDiscoveryJobJob(job)) {
String executorLogicalName = getExecutorLogicalName(job);
Long workspaceId = getOctaneWorkspaceId(job);
if (executorLogicalName != null && workspaceId != null) {
@@ -171,14 +171,14 @@ private Set getOctaneExecutorsLogicalNames(MqmRestClient client, Long wo
private static Long getExecutorId(FreeStyleProject job) {
ParametersDefinitionProperty parameters = job.getProperty(ParametersDefinitionProperty.class);
- ParameterDefinition pd = parameters.getParameterDefinition(TestExecutionJobCreatorService.EXECUTOR_ID_PARAMETER_NAME);
+ ParameterDefinition pd = parameters.getParameterDefinition(UftConstants.EXECUTOR_ID_PARAMETER_NAME);
String value = (String) pd.getDefaultParameterValue().getValue();
return Long.valueOf(value);
}
private static String getExecutorLogicalName(FreeStyleProject job) {
ParametersDefinitionProperty parameters = job.getProperty(ParametersDefinitionProperty.class);
- ParameterDefinition pd = parameters.getParameterDefinition(TestExecutionJobCreatorService.EXECUTOR_LOGICAL_NAME_PARAMETER_NAME);
+ ParameterDefinition pd = parameters.getParameterDefinition(UftConstants.EXECUTOR_LOGICAL_NAME_PARAMETER_NAME);
String value = (String) pd.getDefaultParameterValue().getValue();
return value;
}
@@ -207,7 +207,7 @@ public static void deleteExecutor(String id) {
long executorToDelete = Long.parseLong(id);
List jobs = Jenkins.getInstance().getAllItems(FreeStyleProject.class);
for (FreeStyleProject proj : jobs) {
- if (TestExecutionJobCreatorService.isDiscoveryJobJob(proj)) {
+ if (UftJobRecognizer.isDiscoveryJobJob(proj)) {
Long executorId = getExecutorId(proj);
if (executorId != null && executorId == executorToDelete) {
boolean waitBeforeDelete = false;
diff --git a/src/main/java/com/hpe/application/automation/tools/octane/executor/UftJobRecognizer.java b/src/main/java/com/hpe/application/automation/tools/octane/executor/UftJobRecognizer.java
new file mode 100644
index 0000000000..fe2e0dec52
--- /dev/null
+++ b/src/main/java/com/hpe/application/automation/tools/octane/executor/UftJobRecognizer.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2017 Hewlett-Packard Development Company, L.P.
+ * 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.
+ *
+ */
+
+package com.hpe.application.automation.tools.octane.executor;
+
+import hudson.model.FreeStyleProject;
+import hudson.model.ParametersDefinitionProperty;
+
+
+/***
+ * Recognizer for UFT related jobs
+ */
+public class UftJobRecognizer {
+
+ /**
+ * Check if current jos is EXECUTOR
+ * @param job
+ * @return
+ */
+ public static boolean isExecutorJob(FreeStyleProject job) {
+ ParametersDefinitionProperty parameters = job.getProperty(ParametersDefinitionProperty.class);
+ boolean isExecutorJob = job.getName().contains(UftConstants.EXECUTION_JOB_MIDDLE_NAME) &&
+ parameters != null &&
+ parameters.getParameterDefinition(UftConstants.SUITE_ID_PARAMETER_NAME) != null;
+
+ return isExecutorJob;
+ }
+
+ /**
+ *
+ * @param job
+ * @return
+ */
+ public static boolean isDiscoveryJobJob(FreeStyleProject job) {
+ ParametersDefinitionProperty parameters = job.getProperty(ParametersDefinitionProperty.class);
+ boolean isDiscoveryJob = job.getName().contains(UftConstants.DISCOVERY_JOB_MIDDLE_NAME) &&
+ parameters != null &&
+ parameters.getParameterDefinition(UftConstants.EXECUTOR_ID_PARAMETER_NAME) != null;
+ return isDiscoveryJob;
+ }
+}
From 26f467bad378bb131acfc72f5ebb15a551864a32 Mon Sep 17 00:00:00 2001
From: radislavB
Date: Thu, 28 Sep 2017 14:35:26 +0300
Subject: [PATCH 0158/2502] fix errata (#48)
---
.../tools/octane/executor/CheckOutSubDirEnvContributor.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/main/java/com/hpe/application/automation/tools/octane/executor/CheckOutSubDirEnvContributor.java b/src/main/java/com/hpe/application/automation/tools/octane/executor/CheckOutSubDirEnvContributor.java
index e39ae58e0d..cc6fc02e29 100644
--- a/src/main/java/com/hpe/application/automation/tools/octane/executor/CheckOutSubDirEnvContributor.java
+++ b/src/main/java/com/hpe/application/automation/tools/octane/executor/CheckOutSubDirEnvContributor.java
@@ -43,7 +43,7 @@ public void buildEnvironmentFor(Job j, EnvVars envs, TaskListener listener) thro
}
public static String getSharedCheckOutDirectory(Job j) {
- if (j instanceof FreeStyleProject && UftJobRecognizer.isExecutorJob((FreeStyleProject) j) && !ConfigurationService.getServerConfiguration().isValid()) {
+ if (j instanceof FreeStyleProject && UftJobRecognizer.isExecutorJob((FreeStyleProject) j) && ConfigurationService.getServerConfiguration().isValid()) {
return CheckOutSubDirEnvService.getSharedCheckOutDirectory(j);
}
From 96ec4b39663c2a8e36c4388251cc6048ee59f51e Mon Sep 17 00:00:00 2001
From: radislavB
Date: Sun, 1 Oct 2017 13:23:36 +0300
Subject: [PATCH 0159/2502] When UFT execution job fails before the test runs -
we don't see it on Octane and suite run stays in Progress (#49)
* user story #444126 : When UFT execution job fails before the test runs - we don't see it on Octane and suite run stays in Progress instead of "Failed" status
---
.../tools/octane/events/RunListenerImpl.java | 50 +++++++++++++++----
.../tools/octane/events/TestListenerImpl.java | 40 +++++++++++++++
.../tools/octane/tests/TestListener.java | 14 ++++--
.../octane/tests/junit/JUnitXmlIterator.java | 2 +-
4 files changed, 89 insertions(+), 17 deletions(-)
create mode 100644 src/main/java/com/hpe/application/automation/tools/octane/events/TestListenerImpl.java
diff --git a/src/main/java/com/hpe/application/automation/tools/octane/events/RunListenerImpl.java b/src/main/java/com/hpe/application/automation/tools/octane/events/RunListenerImpl.java
index c94e4f0c8a..2aaeec88a5 100644
--- a/src/main/java/com/hpe/application/automation/tools/octane/events/RunListenerImpl.java
+++ b/src/main/java/com/hpe/application/automation/tools/octane/events/RunListenerImpl.java
@@ -16,10 +16,6 @@
package com.hpe.application.automation.tools.octane.events;
-import com.google.inject.Inject;
-import com.hpe.application.automation.tools.octane.configuration.ConfigurationService;
-import com.hpe.application.automation.tools.octane.tests.TestListener;
-import com.hpe.application.automation.tools.octane.tests.build.BuildHandlerUtils;
import com.hp.octane.integrations.dto.DTOFactory;
import com.hp.octane.integrations.dto.events.CIEvent;
import com.hp.octane.integrations.dto.events.CIEventType;
@@ -27,10 +23,16 @@
import com.hp.octane.integrations.dto.pipelines.PipelineNode;
import com.hp.octane.integrations.dto.pipelines.PipelinePhase;
import com.hp.octane.integrations.dto.snapshots.CIBuildResult;
+import com.hpe.application.automation.tools.octane.configuration.ConfigurationService;
+import com.hpe.application.automation.tools.octane.executor.UftJobRecognizer;
import com.hpe.application.automation.tools.octane.model.CIEventCausesFactory;
import com.hpe.application.automation.tools.octane.model.processors.builders.WorkFlowRunProcessor;
import com.hpe.application.automation.tools.octane.model.processors.parameters.ParameterProcessors;
import com.hpe.application.automation.tools.octane.model.processors.projects.JobProcessorFactory;
+import com.hpe.application.automation.tools.octane.tests.HPRunnerType;
+import com.hpe.application.automation.tools.octane.tests.MqmTestsExtension;
+import com.hpe.application.automation.tools.octane.tests.TestResultContainer;
+import com.hpe.application.automation.tools.octane.tests.build.BuildHandlerUtils;
import hudson.Extension;
import hudson.matrix.MatrixConfiguration;
import hudson.matrix.MatrixRun;
@@ -58,9 +60,6 @@ public final class RunListenerImpl extends RunListener {
private static final DTOFactory dtoFactory = DTOFactory.getInstance();
private ExecutorService executor = new ThreadPoolExecutor(0, 5, 10L, TimeUnit.SECONDS, new LinkedBlockingQueue());
- @Inject
- private TestListener testListener;
-
@Override
public void onStarted(final Run r, TaskListener listener) {
if(!ConfigurationService.getServerConfiguration().isValid()){
@@ -129,8 +128,6 @@ public void onFinalized(Run r)
return;
}
- boolean hasTests = testListener.processBuild(r);
-
CIBuildResult result;
if (r.getResult() == Result.SUCCESS) {
result = CIBuildResult.SUCCESS;
@@ -152,8 +149,12 @@ public void onFinalized(Run r)
.setEstimatedDuration(r.getEstimatedDuration())
.setCauses(CIEventCausesFactory.processCauses(extractCauses(r)))
.setResult(result)
- .setDuration(r.getDuration())
- .setTestResultExpected(hasTests);
+ .setDuration(r.getDuration());
+
+ if (r.getResult() == Result.FAILURE) {
+ boolean b = hasUftTests(r);
+ event.setTestResultExpected(b);
+ }
if(r instanceof AbstractBuild){
event.setParameters(ParameterProcessors.getInstances(r))
@@ -205,6 +206,33 @@ private boolean isInternal(Run r) {
return result;
}
+ private static Boolean hasUftTests(Run build) {
+ if (build.getParent() instanceof FreeStyleProject && UftJobRecognizer.isExecutorJob((FreeStyleProject) build.getParent())) {
+ try {
+ boolean hasTests = false;
+ for (MqmTestsExtension ext : MqmTestsExtension.all()) {
+ if (ext.supports(build)) {
+ String jenkinsRootUrl = Jenkins.getInstance().getRootUrl();
+ List buildsList = BuildHandlerUtils.getBuildPerWorkspaces(build);
+
+ for (Run buildX : buildsList) {
+ TestResultContainer testResultContainer = ext.getTestResults(buildX, HPRunnerType.UFT, jenkinsRootUrl);
+ if (testResultContainer != null && testResultContainer.getIterator().hasNext()) {
+ hasTests = true;
+ }
+ }
+ }
+ }
+ return hasTests;
+ } catch (Exception e) {
+ //do nothing
+ }
+
+ }
+
+ return null;
+ }
+
private static TopLevelItem getJobFromFolder(String causeJobName) {
String newJobRefId = causeJobName.substring(0, causeJobName.indexOf('/'));
TopLevelItem item = Jenkins.getInstance().getItem(newJobRefId);
diff --git a/src/main/java/com/hpe/application/automation/tools/octane/events/TestListenerImpl.java b/src/main/java/com/hpe/application/automation/tools/octane/events/TestListenerImpl.java
new file mode 100644
index 0000000000..970501cb36
--- /dev/null
+++ b/src/main/java/com/hpe/application/automation/tools/octane/events/TestListenerImpl.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2017 Hewlett-Packard Development Company, L.P.
+ * 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.
+ *
+ */
+
+package com.hpe.application.automation.tools.octane.events;
+
+import com.google.inject.Inject;
+import com.hpe.application.automation.tools.octane.tests.TestListener;
+import hudson.Extension;
+import hudson.model.*;
+import hudson.model.listeners.RunListener;
+
+import javax.annotation.Nonnull;
+
+/**
+ * Listener on job complete event
+ */
+@Extension
+public class TestListenerImpl extends RunListener {
+
+ @Inject
+ private TestListener testListener;
+
+ @Override
+ public void onCompleted(Run r, @Nonnull TaskListener listener) {
+ testListener.processBuild(r, listener);
+ }
+}
diff --git a/src/main/java/com/hpe/application/automation/tools/octane/tests/TestListener.java b/src/main/java/com/hpe/application/automation/tools/octane/tests/TestListener.java
index efbe6d409d..b4041d3f70 100644
--- a/src/main/java/com/hpe/application/automation/tools/octane/tests/TestListener.java
+++ b/src/main/java/com/hpe/application/automation/tools/octane/tests/TestListener.java
@@ -26,6 +26,7 @@
import hudson.FilePath;
import hudson.model.Result;
import hudson.model.Run;
+import hudson.model.TaskListener;
import hudson.tasks.Builder;
import jenkins.model.Jenkins;
import org.apache.logging.log4j.LogManager;
@@ -43,13 +44,14 @@ public class TestListener {
private static Logger logger = LogManager.getLogger(TestListener.class);
public static final String TEST_RESULT_FILE = "mqmTests.xml";
- private static final String JENKINS_STORM_TEST_RUNNER_CLASS = "com.hpe.sr.plugins.jenkins.StormTestRunner";
- private static final String JENKINS_PERFORMANCE_CENTER_TEST_RUNNER_CLASS = "com.hpe.application.automation.tools.run.PcBuilder";
+ public static final String JENKINS_STORM_TEST_RUNNER_CLASS = "com.hpe.sr.plugins.jenkins.StormTestRunner";
+ public static final String JENKINS_PERFORMANCE_CENTER_TEST_RUNNER_CLASS = "com.hpe.application.automation.tools.run.PcBuilder";
private ResultQueue queue;
- public boolean processBuild(Run build) {
+ public void processBuild(Run build, TaskListener listener) {
+
FilePath resultPath = new FilePath(new FilePath(build.getRootDir()), TEST_RESULT_FILE);
TestResultXmlWriter resultWriter = new TestResultXmlWriter(resultPath, build);
boolean success = false;
@@ -89,16 +91,19 @@ public boolean processBuild(Run build) {
}
}
} catch (IllegalArgumentException e) {
- logger.error(e.getMessage());
+ listener.error(e.getMessage());
if (!build.getResult().isWorseOrEqualTo(Result.UNSTABLE)) {
build.setResult(Result.UNSTABLE);
}
+ return;
} catch (InterruptedException ie) {
logger.error("Interrupted processing test results in " + ext.getClass().getName(), ie);
Thread.currentThread().interrupt();
+ return;
} catch (Exception e) {
// extensibility involved: catch both checked and RuntimeExceptions
logger.error("Error processing test results in " + ext.getClass().getName(), e);
+ return;
}
}
success = true;
@@ -115,7 +120,6 @@ public boolean processBuild(Run build) {
logger.error("Error processing test results", xmlse);
}
}
- return success && hasTests;//test results expected
}
@Inject
diff --git a/src/main/java/com/hpe/application/automation/tools/octane/tests/junit/JUnitXmlIterator.java b/src/main/java/com/hpe/application/automation/tools/octane/tests/junit/JUnitXmlIterator.java
index 2cbb9b176d..e5bfe19030 100644
--- a/src/main/java/com/hpe/application/automation/tools/octane/tests/junit/JUnitXmlIterator.java
+++ b/src/main/java/com/hpe/application/automation/tools/octane/tests/junit/JUnitXmlIterator.java
@@ -256,7 +256,7 @@ private String jenkinsTestNameFormat(String testName) {
if (StringUtils.isEmpty(testName)) {
return testName;
}
- return testName.trim().replaceAll("[-:\\ ,()/\\[\\]]", "_").replace('#', '_').replace('\\', '_');
+ return testName.trim().replaceAll("[-:\\ ,()/\\[\\]]", "_").replace('#', '_').replace('\\', '_').replace('.', '_');
}
private String jenkinsTestClassFormat(String className) {
From 36b74417002ae5259b42ceb1975ead7c7ea46882 Mon Sep 17 00:00:00 2001
From: radislavB
Date: Mon, 2 Oct 2017 12:01:10 +0300
Subject: [PATCH 0160/2502] user story #444126 : When UFT execution job fails
before the test runs - we don't see it on Octane and suite run stays in
Progress instead of "Failed" status (#50)
---
.../tools/octane/events/RunListenerImpl.java | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/src/main/java/com/hpe/application/automation/tools/octane/events/RunListenerImpl.java b/src/main/java/com/hpe/application/automation/tools/octane/events/RunListenerImpl.java
index 2aaeec88a5..1970985dfa 100644
--- a/src/main/java/com/hpe/application/automation/tools/octane/events/RunListenerImpl.java
+++ b/src/main/java/com/hpe/application/automation/tools/octane/events/RunListenerImpl.java
@@ -151,10 +151,16 @@ public void onFinalized(Run r)
.setResult(result)
.setDuration(r.getDuration());
- if (r.getResult() == Result.FAILURE) {
- boolean b = hasUftTests(r);
- event.setTestResultExpected(b);
- }
+ try {
+ if (r.getResult() == Result.FAILURE) {
+ Boolean hasTests = hasUftTests(r);
+ if (hasTests != null) {
+ event.setTestResultExpected(hasTests);
+ }
+ }
+ } catch (Exception e) {
+ //do nothing
+ }
if(r instanceof AbstractBuild){
event.setParameters(ParameterProcessors.getInstances(r))
From 9518b4769010fd4858c326c454af3d885c0e971a Mon Sep 17 00:00:00 2001
From: "Hanan.Bem"
Date: Mon, 2 Oct 2017 13:37:11 +0300
Subject: [PATCH 0161/2502] Supporting credentials for proxy.
https://issues.jenkins-ci.org/browse/JENKINS-44314
---
.../automation/tools/model/PcModel.java | 15 ++-
.../automation/tools/pc/PcClient.java | 2 +-
.../automation/tools/pc/PcRestProxy.java | 18 +--
.../automation/tools/run/PcBuilder.java | 10 +-
.../tools/run/PcBuilder/config.jelly | 103 +++++++++++++++++-
.../tools/run/PcBuilder/help-proxyOutURL.html | 2 +-
.../automation/tools/pc/MockPcModel.java | 2 +-
.../automation/tools/pc/MockPcRestProxy.java | 2 +-
.../tools/pc/MockPcRestProxyBadResponses.java | 2 +-
9 files changed, 134 insertions(+), 22 deletions(-)
diff --git a/src/main/java/com/hpe/application/automation/tools/model/PcModel.java b/src/main/java/com/hpe/application/automation/tools/model/PcModel.java
index 4189190840..512a9f627a 100644
--- a/src/main/java/com/hpe/application/automation/tools/model/PcModel.java
+++ b/src/main/java/com/hpe/application/automation/tools/model/PcModel.java
@@ -31,12 +31,14 @@ public class PcModel {
private String trendReportId;
private final boolean HTTPSProtocol;
private final String proxyOutURL;
+ private final String proxyOutUser;
+ private final String proxyOutPassword;
@DataBoundConstructor
public PcModel(String serverAndPort, String pcServerName, String almUserName, String almPassword, String almDomain, String almProject,
String testId,String autoTestInstanceID, String testInstanceId, String timeslotDurationHours, String timeslotDurationMinutes,
- PostRunAction postRunAction, boolean vudsMode, String description, String addRunToTrendReport, String trendReportId, boolean HTTPSProtocol, String proxyOutURL) {
+ PostRunAction postRunAction, boolean vudsMode, String description, String addRunToTrendReport, String trendReportId, boolean HTTPSProtocol, String proxyOutURL, String proxyOutUser, String proxyOutPassword) {
this.serverAndPort = serverAndPort;
this.pcServerName = pcServerName;
@@ -55,6 +57,9 @@ public PcModel(String serverAndPort, String pcServerName, String almUserName, St
this.HTTPSProtocol = HTTPSProtocol;
this.trendReportId = trendReportId;
this.proxyOutURL = proxyOutURL;
+ this.proxyOutUser = proxyOutUser;
+ this.proxyOutPassword = proxyOutPassword;
+
}
protected SecretContainer setPassword(String almPassword) {
@@ -134,6 +139,14 @@ public String getProxyOutURL(){
return this.proxyOutURL;
}
+ public String getProxyOutUser(){
+ return this.proxyOutUser;
+ }
+
+ public String getProxyOutPassword(){
+ return this.proxyOutPassword;
+ }
+
public static List getPostRunActions() {
return Arrays.asList(PostRunAction.values());
}
diff --git a/src/main/java/com/hpe/application/automation/tools/pc/PcClient.java b/src/main/java/com/hpe/application/automation/tools/pc/PcClient.java
index 149cc62c83..3d8d3cb384 100644
--- a/src/main/java/com/hpe/application/automation/tools/pc/PcClient.java
+++ b/src/main/java/com/hpe/application/automation/tools/pc/PcClient.java
@@ -60,7 +60,7 @@ public PcClient(PcModel pcModel, PrintStream logger) {
if(model.getProxyOutURL() != null && !model.getProxyOutURL().isEmpty()){
logger.println("Using proxy: " + model.getProxyOutURL());
}
- restProxy = new PcRestProxy(model.isHTTPSProtocol(),model.getPcServerName(), model.getAlmDomain(), model.getAlmProject(),logger, model.getProxyOutURL());
+ restProxy = new PcRestProxy(model.isHTTPSProtocol(),model.getPcServerName(), model.getAlmDomain(), model.getAlmProject(),logger, model.getProxyOutURL(),model.getProxyOutUser(),model.getProxyOutPassword());
this.logger = logger;
}catch (PcException e){
logger.println(e.getMessage());
diff --git a/src/main/java/com/hpe/application/automation/tools/pc/PcRestProxy.java b/src/main/java/com/hpe/application/automation/tools/pc/PcRestProxy.java
index d68585b9c5..8b358f62fe 100644
--- a/src/main/java/com/hpe/application/automation/tools/pc/PcRestProxy.java
+++ b/src/main/java/com/hpe/application/automation/tools/pc/PcRestProxy.java
@@ -107,7 +107,7 @@ public class PcRestProxy {
private CookieStore cookieStore;
// private PrintStream logger;
- public PcRestProxy(String webProtocolName, String pcServerName, String almDomain, String almProject,PrintStream mainLogger, String proxyOutURL) throws PcException {
+ public PcRestProxy(String webProtocolName, String pcServerName, String almDomain, String almProject,PrintStream mainLogger, String proxyOutURL, String proxyUser, String proxyPassword) throws PcException {
// logger = mainLogger;
pcServer = pcServerName;
@@ -127,6 +127,8 @@ public PcRestProxy(String webProtocolName, String pcServerName, String almDomain
// we should get the full proxy URL from the user: http(s)://:
// PAC (proxy auto-config) or Automatic configuration script is not supported (for example our proxy: http://autocache.hpecorp.net/)
getProxyDataFromURL(proxyOutURL);
+ this.proxyUser = proxyUser;
+ this.proxyPassword = proxyPassword;
HttpHost proxy = new HttpHost(proxyHostName, proxyPort, proxyScheme);
if (proxyUser != null && !proxyUser.isEmpty()) {
@@ -151,14 +153,14 @@ private void getProxyDataFromURL(String proxyURL) throws PcException{
String[] urlSplit = proxyURL.split("://");
proxyScheme = urlSplit[0];
- if (urlSplit[1].indexOf("@") != -1){
- String Credentials = urlSplit[1].split("@")[0];
- mainStr = urlSplit[1].split("@")[1];
- proxyUser = Credentials.split(":")[0];
- proxyPassword = Credentials.split(":")[1];
- }else{
+// if (urlSplit[1].indexOf("@") != -1){
+// String Credentials = urlSplit[1].split("@")[0];
+// mainStr = urlSplit[1].split("@")[1];
+// proxyUser = Credentials.split(":")[0];
+// proxyPassword = Credentials.split(":")[1];
+// }else{
mainStr = urlSplit[1];
- }
+// }
if (mainStr.contains(":")){
//proxyPort = Integer.parseInt(proxyURL.split("://")[1].split(":")[1]);
proxyHostName = mainStr.split(":")[0];
diff --git a/src/main/java/com/hpe/application/automation/tools/run/PcBuilder.java b/src/main/java/com/hpe/application/automation/tools/run/PcBuilder.java
index a6401e97e8..7d0bc981aa 100644
--- a/src/main/java/com/hpe/application/automation/tools/run/PcBuilder.java
+++ b/src/main/java/com/hpe/application/automation/tools/run/PcBuilder.java
@@ -125,7 +125,9 @@ public PcBuilder(
String addRunToTrendReport,
String trendReportId,
boolean HTTPSProtocol,
- String proxyOutURL) {
+ String proxyOutURL,
+ String proxyOutUser,
+ String proxyOutPassword) {
this.almUserName = almUserName;
this.almPassword = almPassword;
this.timeslotDurationHours = timeslotDurationHours;
@@ -151,7 +153,9 @@ public PcBuilder(
addRunToTrendReport,
trendReportId,
HTTPSProtocol,
- proxyOutURL);
+ proxyOutURL,
+ proxyOutUser,
+ proxyOutPassword);
}
@Override
@@ -775,6 +779,8 @@ public boolean isStatusBySLA() {
}
public String getProxyOutURL(){ return getPcModel().getProxyOutURL();}
+ public String getProxyOutUser(){ return getPcModel().getProxyOutUser();}
+ public String getProxyOutPassword(){ return getPcModel().getProxyOutPassword();}
// This indicates to Jenkins that this is an implementation of an extension
// point
diff --git a/src/main/resources/com/hpe/application/automation/tools/run/PcBuilder/config.jelly b/src/main/resources/com/hpe/application/automation/tools/run/PcBuilder/config.jelly
index b12bc30a1c..30420ef594 100644
--- a/src/main/resources/com/hpe/application/automation/tools/run/PcBuilder/config.jelly
+++ b/src/main/resources/com/hpe/application/automation/tools/run/PcBuilder/config.jelly
@@ -34,6 +34,53 @@
.myClass{
border: 5px solid red;
}
+
+
+ /* Tooltip container */
+ .tooltip {
+ position: relative;
+ display: inline-block;
+ border-bottom: 1px dotted black; /* If you want dots under the hoverable text */
+ }
+
+ /* Tooltip text */
+ .tooltip .tooltiptext {
+ visibility: hidden;
+ width: 350px;
+ background-color: #555;
+ color: #fff;
+ padding: 5px;
+ border-radius: 6px;
+
+ /* Position the tooltip text */
+ position: absolute;
+ z-index: 1;
+ bottom: 125%;
+ left: 50%;
+ margin-left: -60px;
+
+ /* Fade in tooltip */
+ opacity: 0;
+ transition: opacity 1s;
+ }
+
+ /* Tooltip arrow */
+ .tooltip .tooltiptext::after {
+ content: "";
+ position: absolute;
+ top: 100%;
+ left: 50%;
+ margin-left: -5px;
+ border-width: 5px;
+ border-style: solid;
+ border-color: #555 transparent transparent transparent;
+ }
+
+ /* Show the tooltip text when you mouse over the tooltip container */
+ .tooltip:hover .tooltiptext {
+ visibility: visible;
+ opacity: 1;
+ }
@@ -162,9 +210,52 @@
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Local Proxy
(?) Add your local proxy as following: http(s)://host:port or
+ Leave empty if not using a local proxy.
+ PAC (proxy auto-config) or Automatic configuration script are not supported.
- Add your local proxy as following: http(s)://<host>:<port> or http(s)://<proxyuser>:<proxypassword>@<host>:<port>or
+ Add your local proxy as following: http(s)://<host>:<port> or
Leave empty if not using a local proxy.
PAC (proxy auto-config) or Automatic configuration script are not supported.
\ No newline at end of file
diff --git a/src/test/java/com/hpe/application/automation/tools/pc/MockPcModel.java b/src/test/java/com/hpe/application/automation/tools/pc/MockPcModel.java
index 662431c1e9..679086a788 100644
--- a/src/test/java/com/hpe/application/automation/tools/pc/MockPcModel.java
+++ b/src/test/java/com/hpe/application/automation/tools/pc/MockPcModel.java
@@ -12,7 +12,7 @@ public MockPcModel(String serverAndPort, String pcServerName, String almUserName
String almProject, String testId, String autoTestInstanceID, String testInstanceId, String timeslotDurationHours,
String timeslotDurationMinutes, PostRunAction postRunAction, boolean vudsMode, String description, boolean webProtocol) {
super(serverAndPort, pcServerName, almUserName, almPassword, almDomain, almProject, testId, autoTestInstanceID, testInstanceId, timeslotDurationHours,
- timeslotDurationMinutes, postRunAction, vudsMode, description, "NO_TREND", null,false,null
+ timeslotDurationMinutes, postRunAction, vudsMode, description, "NO_TREND", null,false,null,null,null
);
}
diff --git a/src/test/java/com/hpe/application/automation/tools/pc/MockPcRestProxy.java b/src/test/java/com/hpe/application/automation/tools/pc/MockPcRestProxy.java
index b0b731c184..14d368b704 100644
--- a/src/test/java/com/hpe/application/automation/tools/pc/MockPcRestProxy.java
+++ b/src/test/java/com/hpe/application/automation/tools/pc/MockPcRestProxy.java
@@ -26,7 +26,7 @@ public class MockPcRestProxy extends PcRestProxy {
private static Iterator runState = initializeRunStateIterator();
public MockPcRestProxy(String webProtocol, String pcServerName, String almDomain, String almProject,PrintStream logger) throws PcException {
- super(webProtocol, pcServerName, almDomain, almProject,logger,null);
+ super(webProtocol, pcServerName, almDomain, almProject,logger,null,null,null);
}
@Override
diff --git a/src/test/java/com/hpe/application/automation/tools/pc/MockPcRestProxyBadResponses.java b/src/test/java/com/hpe/application/automation/tools/pc/MockPcRestProxyBadResponses.java
index 993f76c12d..411ef60953 100644
--- a/src/test/java/com/hpe/application/automation/tools/pc/MockPcRestProxyBadResponses.java
+++ b/src/test/java/com/hpe/application/automation/tools/pc/MockPcRestProxyBadResponses.java
@@ -22,7 +22,7 @@ public class MockPcRestProxyBadResponses extends PcRestProxy {
private static Iterator runState = initializeRunStateIterator();
public MockPcRestProxyBadResponses(String webProtocol, String pcServerName, String almDomain, String almProject,PrintStream logger) throws PcException {
- super(webProtocol, pcServerName, almDomain, almProject,logger,null);
+ super(webProtocol, pcServerName, almDomain, almProject,logger,null,null,null);
}
@Override
From 97f341c1f30f36099acd3c7fefb9c33493f905e1 Mon Sep 17 00:00:00 2001
From: Michael Seldin
Date: Mon, 2 Oct 2017 15:37:34 +0300
Subject: [PATCH 0162/2502] sonar issues fix
---
.../tools/octane/events/RunListenerImpl.java | 10 ++++++----
.../tools/octane/events/TestListenerImpl.java | 2 ++
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/src/main/java/com/hpe/application/automation/tools/octane/events/RunListenerImpl.java b/src/main/java/com/hpe/application/automation/tools/octane/events/RunListenerImpl.java
index 1970985dfa..f733d2ce7c 100644
--- a/src/main/java/com/hpe/application/automation/tools/octane/events/RunListenerImpl.java
+++ b/src/main/java/com/hpe/application/automation/tools/octane/events/RunListenerImpl.java
@@ -33,12 +33,15 @@
import com.hpe.application.automation.tools.octane.tests.MqmTestsExtension;
import com.hpe.application.automation.tools.octane.tests.TestResultContainer;
import com.hpe.application.automation.tools.octane.tests.build.BuildHandlerUtils;
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.Logger;
import hudson.Extension;
import hudson.matrix.MatrixConfiguration;
import hudson.matrix.MatrixRun;
import hudson.model.*;
import hudson.model.listeners.RunListener;
import jenkins.model.Jenkins;
+import org.apache.logging.log4j.LogManager;
import java.util.Collection;
import java.util.List;
@@ -59,7 +62,7 @@
public final class RunListenerImpl extends RunListener {
private static final DTOFactory dtoFactory = DTOFactory.getInstance();
private ExecutorService executor = new ThreadPoolExecutor(0, 5, 10L, TimeUnit.SECONDS, new LinkedBlockingQueue());
-
+ private static final Logger logger = LogManager.getLogger(RunListenerImpl.class);
@Override
public void onStarted(final Run r, TaskListener listener) {
if(!ConfigurationService.getServerConfiguration().isValid()){
@@ -159,7 +162,7 @@ public void onFinalized(Run r)
}
}
} catch (Exception e) {
- //do nothing
+ logger.log(Level.WARN,"hasUftTests error",e);
}
if(r instanceof AbstractBuild){
@@ -231,9 +234,8 @@ private static Boolean hasUftTests(Run build) {
}
return hasTests;
} catch (Exception e) {
- //do nothing
+ logger.log(Level.WARN,"Could not check uft tests exists",e);
}
-
}
return null;
diff --git a/src/main/java/com/hpe/application/automation/tools/octane/events/TestListenerImpl.java b/src/main/java/com/hpe/application/automation/tools/octane/events/TestListenerImpl.java
index 970501cb36..2f5e69be0c 100644
--- a/src/main/java/com/hpe/application/automation/tools/octane/events/TestListenerImpl.java
+++ b/src/main/java/com/hpe/application/automation/tools/octane/events/TestListenerImpl.java
@@ -30,6 +30,8 @@
@Extension
public class TestListenerImpl extends RunListener {
+ public TestListenerImpl(){}
+
@Inject
private TestListener testListener;
From 774c75fd8a09106e1cce785d5a553494a345b2d8 Mon Sep 17 00:00:00 2001
From: Michael Seldin
Date: Mon, 2 Oct 2017 16:21:03 +0300
Subject: [PATCH 0163/2502] codacy fix
---
.../automation/tools/octane/events/TestListenerImpl.java | 3 ---
1 file changed, 3 deletions(-)
diff --git a/src/main/java/com/hpe/application/automation/tools/octane/events/TestListenerImpl.java b/src/main/java/com/hpe/application/automation/tools/octane/events/TestListenerImpl.java
index 2f5e69be0c..e468c646c3 100644
--- a/src/main/java/com/hpe/application/automation/tools/octane/events/TestListenerImpl.java
+++ b/src/main/java/com/hpe/application/automation/tools/octane/events/TestListenerImpl.java
@@ -29,9 +29,6 @@
*/
@Extension
public class TestListenerImpl extends RunListener {
-
- public TestListenerImpl(){}
-
@Inject
private TestListener testListener;
From ca3abade51e3ddc821fe4e7ddd4ecf7031116e3f Mon Sep 17 00:00:00 2001
From: "Hanan.Bem"
Date: Tue, 3 Oct 2017 09:08:28 +0300
Subject: [PATCH 0164/2502] Removed unnecessary imports
---
.../com/hpe/application/automation/tools/pc/PcRestProxy.java | 2 --
1 file changed, 2 deletions(-)
diff --git a/src/main/java/com/hpe/application/automation/tools/pc/PcRestProxy.java b/src/main/java/com/hpe/application/automation/tools/pc/PcRestProxy.java
index 8b358f62fe..01d2f5c98c 100644
--- a/src/main/java/com/hpe/application/automation/tools/pc/PcRestProxy.java
+++ b/src/main/java/com/hpe/application/automation/tools/pc/PcRestProxy.java
@@ -40,7 +40,6 @@
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.CookieStore;
import org.apache.http.client.CredentialsProvider;
-import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpRequestBase;
@@ -51,7 +50,6 @@
import org.apache.http.impl.client.BasicCookieStore;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.client.DefaultHttpClient;
-import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.conn.PoolingClientConnectionManager;
import org.apache.http.impl.conn.SchemeRegistryFactory;
import org.apache.http.protocol.BasicHttpContext;
From eed637a61ecf139aa5091fce0f936474a3a9c872 Mon Sep 17 00:00:00 2001
From: "Hanan.Bem"
Date: Tue, 3 Oct 2017 09:29:11 +0300
Subject: [PATCH 0165/2502] More SonarCube Fixes
---
.../hpe/application/automation/tools/pc/PcRestProxy.java | 8 --------
1 file changed, 8 deletions(-)
diff --git a/src/main/java/com/hpe/application/automation/tools/pc/PcRestProxy.java b/src/main/java/com/hpe/application/automation/tools/pc/PcRestProxy.java
index 01d2f5c98c..85843fd261 100644
--- a/src/main/java/com/hpe/application/automation/tools/pc/PcRestProxy.java
+++ b/src/main/java/com/hpe/application/automation/tools/pc/PcRestProxy.java
@@ -151,16 +151,8 @@ private void getProxyDataFromURL(String proxyURL) throws PcException{
String[] urlSplit = proxyURL.split("://");
proxyScheme = urlSplit[0];
-// if (urlSplit[1].indexOf("@") != -1){
-// String Credentials = urlSplit[1].split("@")[0];
-// mainStr = urlSplit[1].split("@")[1];
-// proxyUser = Credentials.split(":")[0];
-// proxyPassword = Credentials.split(":")[1];
-// }else{
mainStr = urlSplit[1];
-// }
if (mainStr.contains(":")){
- //proxyPort = Integer.parseInt(proxyURL.split("://")[1].split(":")[1]);
proxyHostName = mainStr.split(":")[0];
proxyPort = Integer.parseInt(mainStr.split(":")[1]);
}else{
From 82fcd4f641d875b87355f7f2c4c3b2fbaff0c8f1 Mon Sep 17 00:00:00 2001
From: Vladimir
Date: Tue, 3 Oct 2017 14:33:58 +0300
Subject: [PATCH 0166/2502] Jenkins plugin should use the tunnel config file
---
.../tools/run/CreateTunnelBuilder.java | 28 ++++++++-----------
.../run/CreateTunnelBuilder/config.jelly | 2 +-
2 files changed, 12 insertions(+), 18 deletions(-)
diff --git a/src/main/java/com/hpe/application/automation/tools/run/CreateTunnelBuilder.java b/src/main/java/com/hpe/application/automation/tools/run/CreateTunnelBuilder.java
index 825d8b857b..e07820977c 100644
--- a/src/main/java/com/hpe/application/automation/tools/run/CreateTunnelBuilder.java
+++ b/src/main/java/com/hpe/application/automation/tools/run/CreateTunnelBuilder.java
@@ -5,18 +5,13 @@
import hudson.Launcher;
import hudson.model.AbstractBuild;
import hudson.model.AbstractProject;
-import hudson.model.Run;
-import hudson.model.TaskListener;
+import hudson.model.BuildListener;
import hudson.tasks.BuildStepDescriptor;
import hudson.tasks.Builder;
-import jenkins.tasks.SimpleBuildStep;
import net.sf.json.JSONObject;
-import org.jenkinsci.Symbol;
import org.kohsuke.stapler.DataBoundConstructor;
-
import org.xml.sax.SAXException;
-import javax.annotation.Nonnull;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLSession;
import javax.xml.parsers.DocumentBuilder;
@@ -29,7 +24,7 @@
import java.util.Properties;
import java.util.Timer;
-public class CreateTunnelBuilder extends Builder implements SimpleBuildStep {
+public class CreateTunnelBuilder extends Builder {
private PrintStream logger;
private String srfTunnelName;
private AbstractBuild, ?> build;
@@ -52,10 +47,10 @@ public CreateTunnelBuilder.DescriptorImpl getDescriptor() {
@Override
- public void perform( @Nonnull Run, ?> run, @Nonnull FilePath workspace, @Nonnull Launcher launcher, @Nonnull TaskListener listener ) throws InterruptedException, IOException {
+ public boolean perform(final AbstractBuild, ?> build, final Launcher launcher, BuildListener listener)
+ throws InterruptedException, IOException {
logger = listener.getLogger();
- Run,?> r = run.getParent().getBuild(run.getId());
- JSONObject connectionData = RunFromSrfBuilder.GetSrfConnectionData((AbstractBuild,?>)r, logger);
+ JSONObject connectionData = RunFromSrfBuilder.GetSrfConnectionData(build, logger);
String[] s = new String[5] ;
URL url = new URL(connectionData.getString("server"));
//check if tunnel exist
@@ -73,7 +68,7 @@ public void perform( @Nonnull Run, ?> run, @Nonnull FilePath workspace, @Nonnu
String name = "-name=" + srfTunnelName;
-
+ String config = "\"-config="+srfTunnelName+"\"";
URL proxyUrl ;
try {
@@ -88,8 +83,8 @@ public void perform( @Nonnull Run, ?> run, @Nonnull FilePath workspace, @Nonnu
- ProcessBuilder pb = new ProcessBuilder(path, server, client, name, proxy, secret, "\"-log-level=INFO\"","\"-log=stdout\"");
- logger.println("Launching "+path );
+ ProcessBuilder pb = new ProcessBuilder(path, config, "\"-log-level=INFO\"","\"-log=stdout\"");
+ logger.println("Launching "+path + " " + config );
Process p = pb.start();
TunnelTracker tracker = new TunnelTracker(logger, p);
@@ -109,7 +104,7 @@ public void perform( @Nonnull Run, ?> run, @Nonnull FilePath workspace, @Nonnu
p.destroy();
logger.println("Failed to launch "+path);
Tunnels.remove(p);
- return ;
+ return false;
}
while ((line = br.readLine()) != null) {
@@ -121,7 +116,7 @@ public void perform( @Nonnull Run, ?> run, @Nonnull FilePath workspace, @Nonnu
if(diffSeconds > 30){
p.destroy();
logger.println("Failed to launch "+path);
- return ;
+ return false;
}
}
break;
@@ -132,13 +127,12 @@ public void perform( @Nonnull Run, ?> run, @Nonnull FilePath workspace, @Nonnu
- return ;
+ return true;
}
private JSONObject GetSrfConnectionData(){
return new JSONObject();
}
@Extension
- @Symbol("CreateTunnelBuilder")
public static final class DescriptorImpl extends BuildStepDescriptor {
private String srfTunnelName;
@DataBoundConstructor
diff --git a/src/main/resources/com/hpe/application/automation/tools/run/CreateTunnelBuilder/config.jelly b/src/main/resources/com/hpe/application/automation/tools/run/CreateTunnelBuilder/config.jelly
index e47d00d15f..7c1976456e 100644
--- a/src/main/resources/com/hpe/application/automation/tools/run/CreateTunnelBuilder/config.jelly
+++ b/src/main/resources/com/hpe/application/automation/tools/run/CreateTunnelBuilder/config.jelly
@@ -21,7 +21,7 @@
-
+
From 10f651590db21116b41e11f22f7cc3b66eefc96c Mon Sep 17 00:00:00 2001
From: Pavel Chuchma
Date: Mon, 9 Oct 2017 17:56:00 +0200
Subject: [PATCH 0167/2502] - using SVConfigurator 4.10.1.4821 to fix
connectivity to SV 4.10
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index f64cdd68a1..726db61d86 100644
--- a/pom.xml
+++ b/pom.xml
@@ -370,7 +370,7 @@
com.hp.svSVConfigurator
- 4.00.1.46729
+ 4.10.1.48219commons-io
From 34bde2a6cd463cec0501158ee8ea17fb16be68e0 Mon Sep 17 00:00:00 2001
From: "Hanan.Bem"
Date: Sun, 15 Oct 2017 11:57:56 +0300
Subject: [PATCH 0168/2502] Additional fix for publishing trending timeout
issue https://issues.jenkins-ci.org/browse/JENKINS-47135
---
.../com/hpe/application/automation/tools/pc/PcClient.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/main/java/com/hpe/application/automation/tools/pc/PcClient.java b/src/main/java/com/hpe/application/automation/tools/pc/PcClient.java
index 3d8d3cb384..9eda3ecefc 100644
--- a/src/main/java/com/hpe/application/automation/tools/pc/PcClient.java
+++ b/src/main/java/com/hpe/application/automation/tools/pc/PcClient.java
@@ -343,8 +343,8 @@ public void waitForRunToPublishOnTrendReport(int runId, String trendReportId) th
Thread.sleep(5000);
counter++;
if(counter >= 120){
- logger.println("Error: Publishing didn't ended after 10 minutes, aborting...");
- break;
+ String msg = "Error: Publishing didn't ended after 10 minutes, aborting...";
+ throw new PcException(msg);
}
}
}
From 7f447c1363322fa898332a61177497bd8b06b41e Mon Sep 17 00:00:00 2001
From: Vladimir
Date: Wed, 18 Oct 2017 12:53:10 +0300
Subject: [PATCH 0169/2502] SRF fix deep link in test results
---
.../tools/results/SrfResultsReport.java | 40 +++++++++++++------
1 file changed, 28 insertions(+), 12 deletions(-)
diff --git a/src/main/java/com/hpe/application/automation/tools/results/SrfResultsReport.java b/src/main/java/com/hpe/application/automation/tools/results/SrfResultsReport.java
index 4e75cee75e..de39115ada 100644
--- a/src/main/java/com/hpe/application/automation/tools/results/SrfResultsReport.java
+++ b/src/main/java/com/hpe/application/automation/tools/results/SrfResultsReport.java
@@ -11,6 +11,7 @@
import hudson.model.*;
import hudson.remoting.VirtualChannel;
import hudson.tasks.*;
+import hudson.tasks.junit.CaseResult;
import hudson.tasks.junit.TestResult;
import hudson.tasks.junit.TestResultAction;
import hudson.tasks.test.TestObject;
@@ -84,7 +85,31 @@ public TestResult getResult(){
public Object getWrappedTarget(){
return _target;
}
+ private void getBuildInfo(CaseResult p){
+ String data = null;
+ BufferedReader reader = null;
+ try {
+ String path = p.getRun().getRootDir().getPath().concat("/report.json");
+ reader = new BufferedReader(new FileReader(path));
+ String line = null;
+ StringBuffer buf = new StringBuffer();
+ while ( (line = reader.readLine() ) != null){
+ buf.append(line);
+ }
+ data = buf.toString();
+ }
+ catch (Exception e) {
+ }
+ finally {
+ try {
+ if(reader != null)
+ reader.close();
+ } catch (IOException e) {
+ }
+ }
+ _buildInfo = JSONArray.fromObject(data);
+ }
public SrfTestResultAction(AbstractBuild owner, TestResult result, BuildListener listener) {
super(owner, result, listener);
String data = null;
@@ -120,18 +145,8 @@ public void startLoop(){
public String getDeepLink(Object p){
String testName = "";
int idx = ++_idx;
- try{
- testName = p.getClass().getMethod("getClassName").invoke(p).toString().toLowerCase();
- }
- catch (NoSuchMethodException e){
- return "NoSuchMethodException";
- }
- catch (IllegalAccessException e){
- return "IllegalAccessException";
- }
- catch(InvocationTargetException e){
- return "InvocationTargetException";
- }
+ testName = ((CaseResult) p).getClassName().toLowerCase();
+ getBuildInfo((CaseResult)p);
int cnt = _buildInfo.size();
String srfUrl = "";
for (int i = 0; i < cnt; i++) {
@@ -150,6 +165,7 @@ public String getDeepLink(Object p){
String tenant = jTest.getString("tenantid");
srfUrl = srfUrl.concat("&TENANTID=").concat(tenant);
}
+ _logger.println(srfUrl);
return srfUrl;
}
public String getEnvString(Object p){
From b5d9589901bc18ee56b8ce776718a3320e3106eb Mon Sep 17 00:00:00 2001
From: Gennady Korpachev
Date: Tue, 31 Oct 2017 20:00:53 +0200
Subject: [PATCH 0170/2502] Remove HPE Network Virtualization plugin
---
pom.xml | 37 --
.../nv/common/NvNetworkProfileRegistry.java | 147 -------
.../tools/nv/common/NvTestUtils.java | 86 ----
.../tools/nv/common/NvValidatorUtils.java | 103 -----
.../tools/nv/model/BandwidthEnum.java | 57 ---
.../automation/tools/nv/model/NvContext.java | 51 ---
.../tools/nv/model/NvDataHolder.java | 50 ---
.../automation/tools/nv/model/NvModel.java | 100 -----
.../tools/nv/model/NvNetworkProfile.java | 200 ---------
.../tools/nv/model/NvProfileDTO.java | 74 ----
.../automation/tools/nv/model/NvServer.java | 173 --------
.../nv/plugin/NetworkProfileSelector.java | 130 ------
.../tools/nv/plugin/NvEmulationBuilder.java | 294 -------------
.../tools/nv/plugin/NvEmulationInvoker.java | 387 ------------------
.../nv/plugin/NvEmulationRunListener.java | 50 ---
.../nv/plugin/VariableInjectionAction.java | 50 ---
.../nv/plugin/results/CountableResult.java | 85 ----
.../plugin/results/CountableResultParent.java | 96 -----
.../nv/plugin/results/JUnitXmlConstants.java | 43 --
.../nv/plugin/results/NvClassResult.java | 40 --
.../nv/plugin/results/NvJUnitResult.java | 73 ----
.../plugin/results/NvJUnitResultsHandler.java | 68 ---
.../nv/plugin/results/NvProfileResult.java | 40 --
.../nv/plugin/results/NvResultsBuilder.java | 134 ------
.../nv/plugin/results/NvResultsMerger.java | 170 --------
.../nv/plugin/results/NvTestCaseResult.java | 113 -----
.../nv/plugin/results/NvTestSuiteResult.java | 40 --
.../results/XmlTestCaseElementCreator.java | 69 ----
.../nv/model/NvNetworkProfile/config.jelly | 26 --
.../NvNetworkProfile/help-bandwidthIn.html | 1 -
.../NvNetworkProfile/help-bandwidthOut.html | 1 -
.../model/NvNetworkProfile/help-latency.html | 1 -
.../model/NvNetworkProfile/help-packet.html | 1 -
.../NvNetworkProfile/help-profileName.html | 1 -
.../tools/nv/model/NvServer/config.jelly | 29 --
.../tools/nv/model/NvServer/help-nvPort.html | 1 -
.../nv/model/NvServer/help-password.html | 1 -
.../nv/model/NvServer/help-proxyPort.html | 1 -
.../nv/model/NvServer/help-serverIp.html | 1 -
.../nv/model/NvServer/help-serverName.html | 1 -
.../nv/model/NvServer/help-username.html | 1 -
.../NetworkProfileSelector/config.jelly | 31 --
.../nv/plugin/NvEmulationBuilder/config.jelly | 78 ----
.../nv/plugin/NvEmulationBuilder/global.jelly | 31 --
.../NvEmulationBuilder/help-envVariable.html | 1 -
.../help-excludeServerIPs.html | 1 -
.../help-includeClientIPs.html | 1 -
.../NvEmulationBuilder/help-profileNames.html | 1 -
.../NvEmulationBuilder/help-reportFiles.html | 1 -
.../help-thresholdsFile.html | 3 -
.../help-useProxyCheckbox.html | 1 -
.../nv/plugin/NvEmulationBuilder/help.html | 1 -
.../resources/lib/nv/default_profiles.txt | 39 --
53 files changed, 3215 deletions(-)
delete mode 100644 src/main/java/com/hpe/application/automation/tools/nv/common/NvNetworkProfileRegistry.java
delete mode 100644 src/main/java/com/hpe/application/automation/tools/nv/common/NvTestUtils.java
delete mode 100644 src/main/java/com/hpe/application/automation/tools/nv/common/NvValidatorUtils.java
delete mode 100644 src/main/java/com/hpe/application/automation/tools/nv/model/BandwidthEnum.java
delete mode 100644 src/main/java/com/hpe/application/automation/tools/nv/model/NvContext.java
delete mode 100644 src/main/java/com/hpe/application/automation/tools/nv/model/NvDataHolder.java
delete mode 100644 src/main/java/com/hpe/application/automation/tools/nv/model/NvModel.java
delete mode 100644 src/main/java/com/hpe/application/automation/tools/nv/model/NvNetworkProfile.java
delete mode 100644 src/main/java/com/hpe/application/automation/tools/nv/model/NvProfileDTO.java
delete mode 100644 src/main/java/com/hpe/application/automation/tools/nv/model/NvServer.java
delete mode 100644 src/main/java/com/hpe/application/automation/tools/nv/plugin/NetworkProfileSelector.java
delete mode 100644 src/main/java/com/hpe/application/automation/tools/nv/plugin/NvEmulationBuilder.java
delete mode 100644 src/main/java/com/hpe/application/automation/tools/nv/plugin/NvEmulationInvoker.java
delete mode 100644 src/main/java/com/hpe/application/automation/tools/nv/plugin/NvEmulationRunListener.java
delete mode 100644 src/main/java/com/hpe/application/automation/tools/nv/plugin/VariableInjectionAction.java
delete mode 100644 src/main/java/com/hpe/application/automation/tools/nv/plugin/results/CountableResult.java
delete mode 100644 src/main/java/com/hpe/application/automation/tools/nv/plugin/results/CountableResultParent.java
delete mode 100644 src/main/java/com/hpe/application/automation/tools/nv/plugin/results/JUnitXmlConstants.java
delete mode 100644 src/main/java/com/hpe/application/automation/tools/nv/plugin/results/NvClassResult.java
delete mode 100644 src/main/java/com/hpe/application/automation/tools/nv/plugin/results/NvJUnitResult.java
delete mode 100644 src/main/java/com/hpe/application/automation/tools/nv/plugin/results/NvJUnitResultsHandler.java
delete mode 100644 src/main/java/com/hpe/application/automation/tools/nv/plugin/results/NvProfileResult.java
delete mode 100644 src/main/java/com/hpe/application/automation/tools/nv/plugin/results/NvResultsBuilder.java
delete mode 100644 src/main/java/com/hpe/application/automation/tools/nv/plugin/results/NvResultsMerger.java
delete mode 100644 src/main/java/com/hpe/application/automation/tools/nv/plugin/results/NvTestCaseResult.java
delete mode 100644 src/main/java/com/hpe/application/automation/tools/nv/plugin/results/NvTestSuiteResult.java
delete mode 100644 src/main/java/com/hpe/application/automation/tools/nv/plugin/results/XmlTestCaseElementCreator.java
delete mode 100644 src/main/resources/com/hpe/application/automation/tools/nv/model/NvNetworkProfile/config.jelly
delete mode 100644 src/main/resources/com/hpe/application/automation/tools/nv/model/NvNetworkProfile/help-bandwidthIn.html
delete mode 100644 src/main/resources/com/hpe/application/automation/tools/nv/model/NvNetworkProfile/help-bandwidthOut.html
delete mode 100644 src/main/resources/com/hpe/application/automation/tools/nv/model/NvNetworkProfile/help-latency.html
delete mode 100644 src/main/resources/com/hpe/application/automation/tools/nv/model/NvNetworkProfile/help-packet.html
delete mode 100644 src/main/resources/com/hpe/application/automation/tools/nv/model/NvNetworkProfile/help-profileName.html
delete mode 100644 src/main/resources/com/hpe/application/automation/tools/nv/model/NvServer/config.jelly
delete mode 100644 src/main/resources/com/hpe/application/automation/tools/nv/model/NvServer/help-nvPort.html
delete mode 100644 src/main/resources/com/hpe/application/automation/tools/nv/model/NvServer/help-password.html
delete mode 100644 src/main/resources/com/hpe/application/automation/tools/nv/model/NvServer/help-proxyPort.html
delete mode 100644 src/main/resources/com/hpe/application/automation/tools/nv/model/NvServer/help-serverIp.html
delete mode 100644 src/main/resources/com/hpe/application/automation/tools/nv/model/NvServer/help-serverName.html
delete mode 100644 src/main/resources/com/hpe/application/automation/tools/nv/model/NvServer/help-username.html
delete mode 100644 src/main/resources/com/hpe/application/automation/tools/nv/plugin/NetworkProfileSelector/config.jelly
delete mode 100644 src/main/resources/com/hpe/application/automation/tools/nv/plugin/NvEmulationBuilder/config.jelly
delete mode 100644 src/main/resources/com/hpe/application/automation/tools/nv/plugin/NvEmulationBuilder/global.jelly
delete mode 100644 src/main/resources/com/hpe/application/automation/tools/nv/plugin/NvEmulationBuilder/help-envVariable.html
delete mode 100644 src/main/resources/com/hpe/application/automation/tools/nv/plugin/NvEmulationBuilder/help-excludeServerIPs.html
delete mode 100644 src/main/resources/com/hpe/application/automation/tools/nv/plugin/NvEmulationBuilder/help-includeClientIPs.html
delete mode 100644 src/main/resources/com/hpe/application/automation/tools/nv/plugin/NvEmulationBuilder/help-profileNames.html
delete mode 100644 src/main/resources/com/hpe/application/automation/tools/nv/plugin/NvEmulationBuilder/help-reportFiles.html
delete mode 100644 src/main/resources/com/hpe/application/automation/tools/nv/plugin/NvEmulationBuilder/help-thresholdsFile.html
delete mode 100644 src/main/resources/com/hpe/application/automation/tools/nv/plugin/NvEmulationBuilder/help-useProxyCheckbox.html
delete mode 100644 src/main/resources/com/hpe/application/automation/tools/nv/plugin/NvEmulationBuilder/help.html
delete mode 100644 src/main/resources/lib/nv/default_profiles.txt
diff --git a/pom.xml b/pom.xml
index 726db61d86..0c1e8a7285 100644
--- a/pom.xml
+++ b/pom.xml
@@ -30,10 +30,6 @@
2.2false1.0.4a
- 2.5
- 1.5.0
- 2.7.0
- 2.0.6
@@ -394,39 +390,6 @@
1.4.13
-
-
-
- com.hpe.nv
- hpe-nv-java-api
- 1.0.0
-
-
- com.google.code.gson
- gson
- ${google.gson.version}
-
-
- commons-validator
- commons-validator
- ${apache.commons.validator.version}
-
-
- com.fasterxml.jackson.core
- jackson-annotations
- ${jackson.version}
-
-
- com.fasterxml.jackson.core
- jackson-core
- ${jackson.version}
-
-
- com.fasterxml.jackson.core
- jackson-databind
- ${jackson.version}
-
-
mqm-rest-client
diff --git a/src/main/java/com/hpe/application/automation/tools/nv/common/NvNetworkProfileRegistry.java b/src/main/java/com/hpe/application/automation/tools/nv/common/NvNetworkProfileRegistry.java
deleted file mode 100644
index 3794780e38..0000000000
--- a/src/main/java/com/hpe/application/automation/tools/nv/common/NvNetworkProfileRegistry.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- (c) Copyright [2016] Hewlett Packard Enterprise Development LP
-
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
- documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
- rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
- persons to whom the Software is furnished to do so, subject to the following conditions:
-
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
- Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
- WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
- COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-package com.hpe.application.automation.tools.nv.common;
-
-import com.fasterxml.jackson.core.type.TypeReference;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.hpe.application.automation.tools.nv.model.NvNetworkProfile;
-import hudson.util.ListBoxModel;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Serializable;
-import java.util.*;
-
-public class NvNetworkProfileRegistry {
- public static final String DEFAULT_PROFILES_FILE_NAME = "lib/nv/default_profiles.txt";
- public static final String NONE_PROFILE_NAME = "No Emulation";
-
- private static NvNetworkProfileRegistry instance;
- private Map profiles = new HashMap<>();
- private Comparator profileNameComparator = new ProfileNameComparator();
-
- public static NvNetworkProfileRegistry getInstance() {
- if (null == instance) {
- synchronized (NvNetworkProfileRegistry.class) {
- if (null == instance) {
- instance = new NvNetworkProfileRegistry();
- }
- }
- }
-
- return instance;
- }
-
- private NvNetworkProfileRegistry() {
- registerDefaultProfiles();
- }
-
- private void registerDefaultProfiles() {
- InputStream is = NvNetworkProfileRegistry.class.getClassLoader().getResourceAsStream(DEFAULT_PROFILES_FILE_NAME);
- try {
- register(is);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
-
- private void register(InputStream is) throws IOException {
- List profiles = new ObjectMapper().readValue(is, new TypeReference>() {
- });
- for (NvNetworkProfile profile : profiles) {
- profile.setCustom(false);
- this.profiles.put(profile.getProfileName(), profile);
- }
- }
-
- public synchronized void register(Collection profiles) {
- if (null != profiles) {
- NvNetworkProfile existing;
- for (NvNetworkProfile profile : profiles) {
- existing = getNetworkProfile(profile.getProfileName());
- if (null == existing || existing.isCustom()) { // make sure to override only custom profiles
- profile.setCustom(true);
- this.profiles.put(profile.getProfileName(), profile);
- }
- }
- }
- }
-
- public void unregisterCustom() {
- List profilesToRemove = new ArrayList<>();
- for (NvNetworkProfile profile : profiles.values()) {
- if (profile.isCustom()) {
- profilesToRemove.add(profile.getProfileName());
- }
- }
-
- for (String profileName : profilesToRemove) {
- profiles.remove(profileName);
- }
- }
-
- public ListBoxModel getNetworkProfilesAsListModel() {
- ListBoxModel items = new ListBoxModel();
- List names = new ArrayList<>(profiles.keySet());
- Collections.sort(names, profileNameComparator);
- items.add(NONE_PROFILE_NAME, NONE_PROFILE_NAME); // adding None as first element
- for (String name : names) {
- if (!name.equals(NONE_PROFILE_NAME)) {
- items.add(name, name);
- }
- }
-
- return items;
- }
-
- public NvNetworkProfile getNetworkProfile(String profileName) {
- return profiles.get(profileName);
- }
-
- public List getNetworkProfiles(Collection profileNames) {
- List result = new ArrayList<>();
- if (null != profileNames) {
- for (String profileName : profileNames) {
- result.add(profiles.get(profileName));
- }
-
- }
- return result;
- }
-
- public boolean exists(String profileName) {
- return null != profiles.get(profileName);
- }
-
- private static class ProfileNameComparator implements Comparator, Serializable {
- private static final long serialVersionUID = 1;
- @Override
- public int compare(String o1, String o2) {
- if (o1 == o2) {
- return 0;
- }
- if (o1 == null) {
- return -1;
- }
- if (o2 == null) {
- return 1;
- }
- return o1.compareToIgnoreCase(o2);
- }
- }
-}
diff --git a/src/main/java/com/hpe/application/automation/tools/nv/common/NvTestUtils.java b/src/main/java/com/hpe/application/automation/tools/nv/common/NvTestUtils.java
deleted file mode 100644
index cce23484a3..0000000000
--- a/src/main/java/com/hpe/application/automation/tools/nv/common/NvTestUtils.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- (c) Copyright [2016] Hewlett Packard Enterprise Development LP
-
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
- documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
- rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
- persons to whom the Software is furnished to do so, subject to the following conditions:
-
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
- Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
- WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
- COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-package com.hpe.application.automation.tools.nv.common;
-
-import com.hpe.nv.api.NVExceptions;
-import com.hpe.nv.api.Test;
-import com.hpe.nv.api.Transaction;
-import hudson.AbortException;
-import hudson.model.Run;
-import hudson.model.TaskListener;
-import com.hpe.application.automation.tools.nv.model.NvContext;
-import com.hpe.application.automation.tools.nv.model.NvDataHolder;
-
-import java.io.IOException;
-
-public class NvTestUtils {
- private static final String JOB_NAME = "JOB_NAME";
-
- public static String getBuildKey(Run, ?> build) {
- return build.getCharacteristicEnvVars().get(JOB_NAME) + "_" + build.getId();
- }
-
- public static String getNvTestId(Run, ?> build) {
- return getBuildKey(build) + "_Test";
- }
-
- public static void stopTestEmulation(Run, ?> run, TaskListener listener) throws AbortException {
- NvContext nvContext = NvDataHolder.getInstance().get(getBuildKey(run));
- if (null != nvContext) {
- boolean txStopped = true;
- boolean testStopped = true;
- String errorMessage = "";
-
- // stop the current transaction
- Transaction transaction = nvContext.getTransaction();
- if (null != transaction) {
- try {
- transaction.stop();
- } catch (IOException | NVExceptions.ServerErrorException e) {
- txStopped = false;
- e.printStackTrace(listener.getLogger());
- errorMessage = "Failed to stop transaction. Error: " + e.getMessage() + "\n";
- }
- if (txStopped) {
- listener.getLogger().println("Successfully stopped transaction.");
- }
- }
-
- // stop the current test
- Test test = nvContext.getTest();
- if (null != test) {
- try {
- test.stop();
- NvDataHolder.getInstance().clear(NvTestUtils.getBuildKey(run));
- } catch (IOException | NVExceptions.ServerErrorException e) {
- testStopped = false;
- e.printStackTrace(listener.getLogger());
- errorMessage += "Failed to stop Network Virtualization emulation. Error: " + e.getMessage();
- }
-
- if (testStopped) {
- listener.getLogger().println("Network Virtualization emulation was stopped successfully.");
- }
- }
-
- if (!txStopped || !testStopped) {
- throw new AbortException(errorMessage);
- }
- }
- }
-}
diff --git a/src/main/java/com/hpe/application/automation/tools/nv/common/NvValidatorUtils.java b/src/main/java/com/hpe/application/automation/tools/nv/common/NvValidatorUtils.java
deleted file mode 100644
index a57f02fd20..0000000000
--- a/src/main/java/com/hpe/application/automation/tools/nv/common/NvValidatorUtils.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- (c) Copyright [2016] Hewlett Packard Enterprise Development LP
-
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
- documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
- rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
- persons to whom the Software is furnished to do so, subject to the following conditions:
-
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
- Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
- WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
- COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-package com.hpe.application.automation.tools.nv.common;
-
-import org.apache.commons.validator.routines.InetAddressValidator;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.regex.Pattern;
-
-public class NvValidatorUtils {
- private static final Pattern FQ_CLASS_NAME_PATTERN = Pattern.compile("" +
- "(\\p{javaJavaIdentifierStart}\\p{javaJavaIdentifierPart}*\\.)*\\p{javaJavaIdentifierStart}\\p{javaJavaIdentifierPart}*");
- private static final Pattern POSITIVE_FLOATING_POINT_PATTERN = Pattern.compile("^[+]?[0-9]*\\.?[0-9]+$");
- private static final String DEFAULT_THRESHOLD = "default";
-
- public static boolean isValidHostIp(String address) {
- return InetAddressValidator.getInstance().isValidInet4Address(address);
- }
-
- public static boolean validateClassName(String identifier) {
- return FQ_CLASS_NAME_PATTERN.matcher(identifier).matches();
- }
-
- public static boolean validateFloatingPoint(String number) {
- return POSITIVE_FLOATING_POINT_PATTERN.matcher(number).matches();
- }
-
- public static boolean validateFloatingPoint(String number, double maxValue) {
- boolean isValid = validateFloatingPoint(number);
- if(isValid) {
- Double dVal = Double.parseDouble(number);
- if(dVal < 0 || dVal > maxValue) {
- isValid = false;
- }
- }
- return isValid;
- }
-
- public static boolean validateFile(String fileName) {
- File thresholdFile = new File(fileName);
- Path filePath = thresholdFile.toPath();
-
- return Files.isReadable(filePath);
- }
-
- public static Map readThresholdsFile(String fileName) throws IOException {
- Map result = new HashMap<>();
- BufferedReader br = null;
- try {
- br = new BufferedReader(new FileReader(new File(fileName)));
- String line;
- String[] parts;
- while (null != (line = br.readLine())) {
- if (!isComment(line)) {
- parts = line.split(",");
- // default threshold
- if (line.startsWith(DEFAULT_THRESHOLD)) {
- if (parts.length != 2 || !NvValidatorUtils.validateFloatingPoint(parts[1])) {
- return null;
- }
- result.put(parts[0], Float.parseFloat(parts[1]));
- } else { // threshold per test
- if (parts.length != 3 || !NvValidatorUtils.validateClassName(parts[0]) || parts[1].isEmpty() || !NvValidatorUtils.validateFloatingPoint(parts[2])) {
- return null;
- }
- result.put(parts[0] + "." + parts[1], Float.parseFloat(parts[2]));
- }
- }
- }
- } finally {
- if (br != null) {
- br.close();
- }
- }
- return result;
- }
-
- private static boolean isComment(String line) {
- return line.startsWith("//") || line.startsWith("#");
- }
-}
diff --git a/src/main/java/com/hpe/application/automation/tools/nv/model/BandwidthEnum.java b/src/main/java/com/hpe/application/automation/tools/nv/model/BandwidthEnum.java
deleted file mode 100644
index 587ceb9e7f..0000000000
--- a/src/main/java/com/hpe/application/automation/tools/nv/model/BandwidthEnum.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- (c) Copyright [2016] Hewlett Packard Enterprise Development LP
-
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
- documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
- rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
- persons to whom the Software is furnished to do so, subject to the following conditions:
-
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
- Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
- WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
- COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-package com.hpe.application.automation.tools.nv.model;
-
-public enum BandwidthEnum {
- UNRESTRICTED(0, "Unrestricted"),
- KBPS14_4(14.4, "14.4"),
- KBPS28_8(28.8, "28.8"),
- KBPS33_6(33.6, "33.6"),
- KBPS56(56, "56"),
- KBPS64(64, "64"),
- KBPS128(128, "128"),
- KBPS256(256, "256"),
- KBPS512(512, "512"),
- KBPS768(768, "768"),
- KBPS1544(1544, "1544"),
- KBPS2048(2048, "2048"),
- KBPS4096(4096, "4096"),
- KBPS6144(6144, "6144"),
- KBPS8192(8192, "8192"),
- KBPS10240(10240, "10240"),
- KBPS34364(34364, "34364"),
- KBPS44736(44736, "44736"),
- KBPS54000(54000, "54000"),
- KBPS100000(100000, "100000");
-
- private double value;
- private String displayText;
-
- private BandwidthEnum(double value, String displayText) {
- this.value = value;
- this.displayText = displayText;
- }
-
- public double getValue() {
- return value;
- }
-
- public String getDisplayText() {
- return displayText;
- }
-}
diff --git a/src/main/java/com/hpe/application/automation/tools/nv/model/NvContext.java b/src/main/java/com/hpe/application/automation/tools/nv/model/NvContext.java
deleted file mode 100644
index 77ea10d9f7..0000000000
--- a/src/main/java/com/hpe/application/automation/tools/nv/model/NvContext.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- (c) Copyright [2016] Hewlett Packard Enterprise Development LP
-
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
- documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
- rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
- persons to whom the Software is furnished to do so, subject to the following conditions:
-
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
- Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
- WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
- COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-package com.hpe.application.automation.tools.nv.model;
-
-import com.hpe.nv.api.Test;
-import com.hpe.nv.api.Transaction;
-
-public class NvContext {
- private Test test;
- private Transaction transaction;
- private int run = 0;
-
- public Test getTest() {
- return test;
- }
-
- public void setTest(Test test) {
- this.test = test;
- }
-
- public Transaction getTransaction() {
- return transaction;
- }
-
- public void setTransaction(Transaction transaction) {
- this.transaction = transaction;
- }
-
- public int getRun() {
- return run;
- }
-
- public void increaseRun() {
- run = run + 1;
- }
-}
diff --git a/src/main/java/com/hpe/application/automation/tools/nv/model/NvDataHolder.java b/src/main/java/com/hpe/application/automation/tools/nv/model/NvDataHolder.java
deleted file mode 100644
index c235e9354d..0000000000
--- a/src/main/java/com/hpe/application/automation/tools/nv/model/NvDataHolder.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- (c) Copyright [2016] Hewlett Packard Enterprise Development LP
-
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
- documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
- rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
- persons to whom the Software is furnished to do so, subject to the following conditions:
-
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
- Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
- WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
- COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-package com.hpe.application.automation.tools.nv.model;
-
-import java.util.HashMap;
-import java.util.Map;
-
-public class NvDataHolder {
- private static NvDataHolder instance;
- private Map dataMap;
-
- private NvDataHolder() {
- dataMap = new HashMap<>();
- }
-
- public static synchronized NvDataHolder getInstance() {
- if(null == instance) {
- instance = new NvDataHolder();
- }
-
- return instance;
- }
-
- public NvContext get(String key) {
- return dataMap.get(key);
- }
-
- public void put(String key, NvContext context) {
- dataMap.put(key, context);
- }
-
- public void clear(String key) {
- dataMap.remove(key);
- }
-}
diff --git a/src/main/java/com/hpe/application/automation/tools/nv/model/NvModel.java b/src/main/java/com/hpe/application/automation/tools/nv/model/NvModel.java
deleted file mode 100644
index d60bc927e7..0000000000
--- a/src/main/java/com/hpe/application/automation/tools/nv/model/NvModel.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- (c) Copyright [2016] Hewlett Packard Enterprise Development LP
-
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
- documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
- rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
- persons to whom the Software is furnished to do so, subject to the following conditions:
-
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
- Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
- WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
- COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-package com.hpe.application.automation.tools.nv.model;
-
-import hudson.tasks.BuildStep;
-import org.kohsuke.stapler.DataBoundConstructor;
-
-import java.io.Serializable;
-import java.util.List;
-
-public class NvModel implements Serializable {
- private static final long serialVersionUID = 8642626061740581112L;
-
- private String serverName;
- private String includeClientIPs;
- private String excludeServerIPs;
- private String envVariable;
- private List steps;
- private String reportFiles;
- private String thresholdsFile;
- private boolean useProxy;
- private NvServer nvServer;
- private List profiles;
-
- @DataBoundConstructor
- public NvModel(String serverName, String includeClientIPs, String excludeServerIPs, String envVariable, String reportFiles, String thresholdsFile, List steps) {
- this.serverName = serverName;
- this.includeClientIPs = includeClientIPs;
- this.excludeServerIPs = excludeServerIPs;
- this.envVariable = envVariable;
- this.steps = steps;
- this.reportFiles = reportFiles;
- this.thresholdsFile = thresholdsFile;
-
- this.useProxy = envVariable != null && !envVariable.isEmpty();
- }
-
- public String getServerName() {
- return serverName;
- }
-
- public String getIncludeClientIPs() {
- return includeClientIPs;
- }
-
- public String getExcludeServerIPs() {
- return excludeServerIPs;
- }
-
- public String getEnvVariable() {
- return envVariable;
- }
-
- public List getSteps() {
- return steps;
- }
-
- public String getReportFiles() {
- return reportFiles;
- }
-
- public String getThresholdsFile() {
- return thresholdsFile;
- }
-
- public boolean isUseProxy() {
- return useProxy;
- }
-
- public NvServer getNvServer() {
- return nvServer;
- }
-
- public void setNvServer(NvServer nvServer) {
- this.nvServer = nvServer;
- }
-
- public List getProfiles() {
- return profiles;
- }
-
- public void setProfiles(List profiles) {
- this.profiles = profiles;
- }
-}
diff --git a/src/main/java/com/hpe/application/automation/tools/nv/model/NvNetworkProfile.java b/src/main/java/com/hpe/application/automation/tools/nv/model/NvNetworkProfile.java
deleted file mode 100644
index 7153a5a317..0000000000
--- a/src/main/java/com/hpe/application/automation/tools/nv/model/NvNetworkProfile.java
+++ /dev/null
@@ -1,200 +0,0 @@
-/*
- (c) Copyright [2016] Hewlett Packard Enterprise Development LP
-
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
- documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
- rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
- persons to whom the Software is furnished to do so, subject to the following conditions:
-
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
- Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
- WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
- COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-package com.hpe.application.automation.tools.nv.model;
-
-import com.fasterxml.jackson.annotation.JsonCreator;
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import hudson.Extension;
-import hudson.model.AbstractDescribableImpl;
-import hudson.model.Descriptor;
-import hudson.util.FormValidation;
-import hudson.util.ListBoxModel;
-import net.sf.json.JSONObject;
-import com.hpe.application.automation.tools.nv.common.NvValidatorUtils;
-import org.kohsuke.stapler.DataBoundConstructor;
-import org.kohsuke.stapler.DataBoundSetter;
-import org.kohsuke.stapler.QueryParameter;
-import org.kohsuke.stapler.StaplerRequest;
-
-import javax.servlet.ServletException;
-import java.io.IOException;
-import java.io.Serializable;
-
-@JsonIgnoreProperties({"serialVersionUID", "dto"})
-public class NvNetworkProfile extends AbstractDescribableImpl implements Serializable {
- private static final long serialVersionUID = 5600302656112810974L;
-
- private String profileName;
- private String latency = "0";
- private String packet = "0";
- private String bandwidthIn = BandwidthEnum.UNRESTRICTED.getDisplayText();
- private String bandwidthOut = BandwidthEnum.UNRESTRICTED.getDisplayText();
-
- private boolean custom = true;
- private NvProfileDTO dto;
-
- @JsonCreator
- @DataBoundConstructor
- public NvNetworkProfile(@JsonProperty("profileName") String profileName) {
- this.profileName = profileName;
- }
-
- public String getProfileName() {
- return profileName;
- }
-
- private void setProfileName(String profileName) {
- this.profileName = profileName;
- }
-
- public String getLatency() {
- return latency;
- }
-
- @DataBoundSetter
- public void setLatency(String latency) {
- this.latency = latency;
- }
-
- public String getPacket() {
- return packet;
- }
-
- @DataBoundSetter
- public void setPacket(String packet) {
- this.packet = packet;
- }
-
- public String getBandwidthIn() {
- return bandwidthIn;
- }
-
- @DataBoundSetter
- public void setBandwidthIn(String bandwidthIn) {
- this.bandwidthIn = bandwidthIn;
- }
-
- public String getBandwidthOut() {
- return bandwidthOut;
- }
-
- @DataBoundSetter
- public void setBandwidthOut(String bandwidthOut) {
- this.bandwidthOut = bandwidthOut;
- }
-
- public boolean isCustom() {
- return custom;
- }
-
- public void setCustom(boolean custom) {
- this.custom = custom;
- }
-
- @Override
- public String toString() {
- return "Network Profile{" +
- "profileName='" + profileName + '\'' +
- ", latency='" + latency + '\'' +
- ", packet='" + packet + '\'' +
- ", bandwidthIn='" + bandwidthIn + '\'' +
- ", bandwidthOut='" + bandwidthOut + '\'' +
- '}' + "\n";
- }
-
- public NvProfileDTO toDTO() {
- if (null == dto) {
- dto = new NvProfileDTO(profileName);
- dto.setLatency(Double.parseDouble(latency));
- dto.setPacket(Double.parseDouble(packet));
- dto.setBandwidthIn(BandwidthEnum.valueOf(bandwidthIn).getValue());
- dto.setBandwidthOut(BandwidthEnum.valueOf(bandwidthOut).getValue());
- }
-
- return dto;
- }
-
- @Extension
- public static class DescriptorImpl extends Descriptor