Skip to content

Commit

Permalink
Merge pull request #736 from TIBCOSoftware/2.10.0_master_merge
Browse files Browse the repository at this point in the history
2.10.0 to  master merge
  • Loading branch information
pramakan-tibco authored Dec 17, 2024
2 parents 91426da + fa01e48 commit ee4070d
Show file tree
Hide file tree
Showing 8 changed files with 177 additions and 34 deletions.
38 changes: 36 additions & 2 deletions Source/bw6-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.tibco.plugins</groupId>
<artifactId>bw6-maven-plugin</artifactId>
<version>2.9.9</version>
<version>2.10.0</version>
<packaging>maven-plugin</packaging>
<name>Plugin Code for Apache Maven and TIBCO BusinessWorks™</name>
<description>Plugin Code for Apache Maven and TIBCO BusinessWorks™.
Expand Down Expand Up @@ -193,6 +193,41 @@
<version>2.15.0</version>
</dependency>

<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.6.0</version>
</dependency>

<dependency>
<groupId>org.apache.maven.doxia</groupId>
<artifactId>doxia-sink-api</artifactId>
<version>2.0.0-M12</version>
</dependency>

<dependency>
<groupId>org.apache.maven.doxia</groupId>
<artifactId>doxia-site-model</artifactId>
<version>2.0.0-M19</version>
</dependency>

<dependency>
<groupId>org.apache.maven.doxia</groupId>
<artifactId>doxia-core</artifactId>
<version>2.0.0-M12</version>
</dependency>

<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
<version>4.0.1</version>
</dependency>

<dependency>
<groupId>org.apache.maven.doxia</groupId>
<artifactId>doxia-integration-tools</artifactId>
<version>2.0.0-M19</version>
</dependency>
</dependencies>
<distributionManagement>
<snapshotRepository>
Expand Down Expand Up @@ -265,7 +300,6 @@
</configuration>
</plugin>


<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,24 @@ public class BWEARInstallerMojo extends AbstractMojo {

@Parameter(property = "namespace")
private String namespace;

@Parameter(property="platformBuild", defaultValue ="false")
private boolean platformBuild;

@Parameter(property="platformDeploy", defaultValue ="false")
private boolean platformDeploy;

@Parameter(property="platformScale", defaultValue ="false")
private boolean platformScale;

@Parameter(property="platformUpgrade", defaultValue ="false")
private boolean platformUpgrade;

@Parameter(property = "appId")
private String appId;

@Parameter(property = "buildId")
private String buildId;

private String earLoc;
private String earName;
Expand Down Expand Up @@ -246,13 +264,28 @@ public void execute() throws MojoExecutionException {
deployer.close();
}else if(projectType != null && projectType.equalsIgnoreCase(Constants.Platform)) {
//Platform deployment
File [] files = BWFileUtils.getFilesForType(outputDirectory, ".ear");
if(files.length == 0) {
throw new Exception("EAR file not found for the Application");
}
String application = manifest.getMainAttributes().getValue(Constants.BUNDLE_SYMBOLIC_NAME);
PlatformDeployer deployer = new PlatformDeployer(connectTimeout, readTimeout, retryCount, getLog());
deployer.buildApp(application, files[0].getPath(), buildName, appName, profile, replicas, enableAutoScaling, enableServiceMesh, eula, platformConfigFile, dpUrl, authToken, baseVersion, baseImageTag, namespace);
PlatformDeployer deployer = new PlatformDeployer(connectTimeout, readTimeout, retryCount, getLog());
if(platformBuild || platformDeploy || platformScale || platformUpgrade) {
if(platformBuild) {
File [] files = BWFileUtils.getFilesForType(outputDirectory, ".ear");
if(files.length == 0) {
throw new Exception("EAR file not found for the Application");
}
deployer.buildApp(files[0].getPath(), buildName, appName, profile, replicas, enableAutoScaling, enableServiceMesh, eula, platformConfigFile, dpUrl, authToken, baseVersion, baseImageTag, namespace, false);
}else if(platformDeploy) {
deployer.deployApp(dpUrl, buildId, namespace, authToken, eula, appName, profile, platformConfigFile, enableAutoScaling, enableServiceMesh);
}else if(platformScale) {
deployer.scaleApp(dpUrl, appId, replicas, authToken);
}else if(platformUpgrade) {
deployer.upgradeApp(dpUrl, appId, buildId, namespace, authToken, eula, appName, profile, platformConfigFile, enableAutoScaling, enableServiceMesh);
}
}else {
File [] files = BWFileUtils.getFilesForType(outputDirectory, ".ear");
if(files.length == 0) {
throw new Exception("EAR file not found for the Application");
}
deployer.buildApp(files[0].getPath(), buildName, appName, profile, replicas, enableAutoScaling, enableServiceMesh, eula, platformConfigFile, dpUrl, authToken, baseVersion, baseImageTag, namespace, true);
}
}else {
//enterprise deployment
boolean configFileExists = deploymentConfigExists();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ public PlatformDeployer(int connectTimeout, int readTimeout, int retryCount, Log
this.log = log;
}

public void buildApp(String application, String earPath, String buildName, String appName, String profile, int replicas, boolean enableAutoScaling, boolean enableServiceMesh, boolean eula, String platformConfigFile, String dpUrl, String authToken, String baseVersion, String baseImageTag, String namespace) throws ClientException, IOException, InterruptedException {
public void buildApp(String earPath, String buildName, String appName, String profile, int replicas, boolean enableAutoScaling, boolean enableServiceMesh, boolean eula, String platformConfigFile, String dpUrl, String authToken, String baseVersion, String baseImageTag, String namespace, boolean deploy) throws ClientException, IOException, InterruptedException {
try {
this.log.info("Deployment to Platform started...");
this.log.info("Application build creation in Platform started...");
if(dpUrl == null) {
throw new ClientException("Unable to build the application. Please provide the data plane URL.");
}
Expand Down Expand Up @@ -143,13 +143,15 @@ public void buildApp(String application, String earPath, String buildName, Strin
.post(Entity.entity(multipart, MediaType.MULTIPART_FORM_DATA));
StatusType statusInfo = response.getStatusInfo();
if(statusInfo.getFamily().equals(Family.SUCCESSFUL)) {
String readEntity = response.readEntity(String.class);
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
Map<?, ?> responseMap;
responseMap = mapper.readValue(readEntity, Map.class);
String buildId = (String) responseMap.get("buildId");
deployApp(buildId, namespace, authToken, eula, replicas, appName, profile, platformConfigFile, enableAutoScaling, enableServiceMesh);
if(deploy) {
String readEntity = response.readEntity(String.class);
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
Map<?, ?> responseMap;
responseMap = mapper.readValue(readEntity, Map.class);
String buildId = (String) responseMap.get("buildId");
deployApp(null, buildId, namespace, authToken, eula, replicas, appName, profile, platformConfigFile, enableAutoScaling, enableServiceMesh, true);
}
}else {
processErrorResponse(response, statusInfo);
}
Expand All @@ -162,7 +164,7 @@ public void buildApp(String application, String earPath, String buildName, Strin
}
}

public void deployApp(String buildId, String namespace, String authToken, boolean eula, int replicas, String appName, String profile, String platformConfigFile, boolean enableAutoScaling, boolean enableServiceMesh) throws ClientException, IOException, InterruptedException {
public void deployApp(String appId, String buildId, String namespace, String authToken, boolean eula, int replicas, String appName, String profile, String platformConfigFile, boolean enableAutoScaling, boolean enableServiceMesh, boolean scale) throws ClientException, IOException, InterruptedException {
if(buildId == null || buildId.isEmpty()) {
throw new ClientException("Unable to deploy the application. Please provide a valid build ID.");
}
Expand Down Expand Up @@ -222,6 +224,9 @@ public void deployApp(String buildId, String namespace, String authToken, boolea
tagsArray = (JSONArray) tags.get("tags");
}
}
if(appId != null && !appId.isEmpty()) {
appJsonObject.put("appId", appId);
}
appJsonObject.put("buildId", buildId);
appJsonObject.put("enableAutoScaling", enableAutoScaling);
appJsonObject.put("enableServiceMesh", enableServiceMesh);
Expand Down Expand Up @@ -259,18 +264,35 @@ public void deployApp(String buildId, String namespace, String authToken, boolea
.post(Entity.entity(appJsonObject.toString(), MediaType.APPLICATION_JSON));
StatusType statusInfo = response.getStatusInfo();
if(statusInfo.getFamily().equals(Family.SUCCESSFUL)) {
String readEntity = response.readEntity(String.class);
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
Map<?, ?> responseMap;
responseMap = mapper.readValue(readEntity, Map.class);
String appId = (String) responseMap.get("appId");
scaleApp(appId, replicas, authToken);
if(scale) {
String readEntity = response.readEntity(String.class);
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
Map<?, ?> responseMap;
responseMap = mapper.readValue(readEntity, Map.class);
scaleApp((String) responseMap.get("appId"), replicas, authToken);
}
}else {
processErrorResponse(response, statusInfo);
}
}

public void deployApp(String dpUrl, String buildId, String namespace, String authToken, boolean eula, String appName, String profile, String platformConfigFile, boolean enableAutoScaling, boolean enableServiceMesh) throws ClientException, IOException, InterruptedException {
try {
this.log.info("Build deployment in Platform started...");
Client client = ClientBuilder.newClient();
webTarget = client.target(new URI(dpUrl));
webTarget.register(MultiPartFeature.class);
deployApp(null, buildId, namespace, authToken, eula, 0, appName, profile, platformConfigFile, enableAutoScaling, enableServiceMesh, false);
}catch (ProcessingException pe) {
pe.printStackTrace();
throw getConnectionException(pe);
}catch (Exception ex) {
ex.printStackTrace();
throw new ClientException(500, ex.getMessage(), ex);
}
}

public void scaleApp(String appId, int replicas, String authToken) throws ClientException, IOException, InterruptedException {
if(appId == null || appId.isEmpty()) {
throw new ClientException("Unable to scale the application. Please provide app ID.");
Expand All @@ -292,6 +314,38 @@ public void scaleApp(String appId, int replicas, String authToken) throws Client
}
}

public void scaleApp(String dpUrl, String appId, int replicas, String authToken) throws ClientException, IOException, InterruptedException {
try {
this.log.info("Applicatoin scaling in Platform started...");
Client client = ClientBuilder.newClient();
webTarget = client.target(new URI(dpUrl));
webTarget.register(MultiPartFeature.class);
scaleApp(appId, replicas, authToken);
}catch (ProcessingException pe) {
pe.printStackTrace();
throw getConnectionException(pe);
}catch (Exception ex) {
ex.printStackTrace();
throw new ClientException(500, ex.getMessage(), ex);
}
}

public void upgradeApp(String dpUrl, String appId, String buildId, String namespace, String authToken, boolean eula, String appName, String profile, String platformConfigFile, boolean enableAutoScaling, boolean enableServiceMesh) throws ClientException, IOException, InterruptedException {
try {
this.log.info("Application upgrade in Platform started...");
Client client = ClientBuilder.newClient();
webTarget = client.target(new URI(dpUrl));
webTarget.register(MultiPartFeature.class);
deployApp(appId, buildId, namespace, authToken, eula, 0, appName, profile, platformConfigFile, enableAutoScaling, enableServiceMesh, false);
}catch (ProcessingException pe) {
pe.printStackTrace();
throw getConnectionException(pe);
}catch (Exception ex) {
ex.printStackTrace();
throw new ClientException(500, ex.getMessage(), ex);
}
}

private void processErrorResponse(Response response, StatusType statusInfo) throws ClientException {
if (statusInfo.getStatusCode() == 401) {
throw new ClientException(response.getStatus(), statusInfo.getStatusCode() + ": " + statusInfo.getReasonPhrase(), null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ private void printFailureDetails(TestCaseResultDTO testcase,String testCaseFile,
if(!"passed".equals(assertion.getAssertionStatus())) {
String inputValue = assertion.getActivityOutput();
if(assertion.getAssertionMode().equals("Primitive") ){
if (inputValue.startsWith(assertion.getStartElementNameTag())) {
if (assertion.getStartElementNameTag() != null && inputValue.startsWith(assertion.getStartElementNameTag())) {
inputValue = StringUtils.substringBetween(inputValue, assertion.getStartElementNameTag(), assertion.getEndElementNameTag());
inputValue = inputValue!=null? inputValue:assertion.getActivityOutput();
if(inputValue!= null && inputValue.contains(assertion.getStartElementNameTag())){
Expand Down Expand Up @@ -570,9 +570,19 @@ private void printFailureDetails(TestCaseResultDTO testcase,String testCaseFile,
assertionFileBuilder.append("\n");
}
else {
assertionFileBuilder.append(" [Activity Output: "+inputValue+"]");
assertionFileBuilder.append(" [Gold Output: "+assertion.getGoldInput()+"]");
assertionFileBuilder.append("\n");
if (inputValue.equals(assertion.getGoldInput())) {
assertionFileBuilder.append(" [Activity Output does not match ");
if (assertion.getGoldInput() != null)
assertionFileBuilder.append(" [Gold Output: "+assertion.getGoldInput()+"]");
else
assertionFileBuilder.append(" [Gold Output");
assertionFileBuilder.append("\n");
}
else {
assertionFileBuilder.append(" [Activity Output: "+inputValue+"]");
assertionFileBuilder.append(" [Gold Output: "+assertion.getGoldInput()+"]");
assertionFileBuilder.append("\n");
}
}

BWTestConfig.INSTANCE.getLogger().error(assertionFileBuilder.toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ private void addPluginsFromDir( File target , StringBuilder builder )
File libFolder = new File(file.getAbsolutePath().concat("/lib"));
if(libFolder.exists()){
if (libFolder.getAbsolutePath() != null && !(libFolder.getAbsolutePath().indexOf("com.tibco.bw.jdbc.datasourcefactory.datadirect") >= 0)) {
if(libFolder.isDirectory() && libFolder.list().length==0){
if(libFolder.isDirectory() && !hasDBJar(libFolder)){
continue;
}
}
Expand Down Expand Up @@ -278,6 +278,18 @@ private void addPluginsFromDir( File target , StringBuilder builder )
}


private boolean hasDBJar(File libFolder) {
File[] files = libFolder.listFiles();
if (files != null) {
for (File file : files) {
if (file.isFile() && file.getName().endsWith(".jar")) {
return true;
}
}
}
return false;
}

private void addReference( StringBuilder builder , File file ,String key)
{

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
%%TIBCO_HOME%%/tibcojre64/11/Contents/Home/bin/java
%%TIBCO_HOME%%/tibcojre64/17/Contents/Home/bin/java
-Dbw.appnode=BWEclipseAppNode
-Xms256m
-Xmx2048m
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
%%TIBCO_HOME%%/tibcojre64/11/bin/java
%%TIBCO_HOME%%/tibcojre64/17/bin/java
-Dbw.appnode=BWEclipseAppNode
-Xms256m
-Xmx2048m
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
%%TIBCO_HOME%%/tibcojre64/11/bin/java.exe
%%TIBCO_HOME%%/tibcojre64/17/bin/java.exe
-Dbw.appnode=BWEclipseAppNode
-Xms256m
-Xmx2048m
Expand Down

0 comments on commit ee4070d

Please sign in to comment.