Skip to content

Commit

Permalink
Merge pull request #711 from emmartins/WFLY-18458
Browse files Browse the repository at this point in the history
[WFLY-18458] batch-processing quickstart enhancement CY2023Q3
  • Loading branch information
emmartins authored Oct 10, 2023
2 parents 7be3218 + 3dc7dda commit 602a46b
Show file tree
Hide file tree
Showing 7 changed files with 198 additions and 43 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/quickstart_batch-processing_ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: WildFly batch-processing Quickstart CI

on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
paths:
- 'batch-processing/**'
- '.github/workflows/quickstart_ci.yml'
jobs:
call-quickstart_ci:
uses: ./.github/workflows/quickstart_ci.yml
with:
QUICKSTART_PATH: batch-processing
MICROPROFILE: false
45 changes: 7 additions & 38 deletions batch-processing/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ The `batch-processing` quickstart shows how to use chunk oriented batch jobs to
:standalone-server-type: default
:archiveType: war
:uses-h2:
:uses-ds-xml:

== What is it?

Expand All @@ -31,8 +30,6 @@ The job contains two tasks:

The database schema defines that the column for name is unique. For that reason, any attempt to persist a duplicate value will throw an exception. On the second attempt to run the job, the `ChunkCheckpoint` provides information to skip the contacts that were already persisted.

ifndef::EAPCDRelease[]

// Considerations for Use in a Production Environment
include::../shared-doc/development-shortcuts.adoc[leveloffset=+1]
// System Requirements
Expand Down Expand Up @@ -133,41 +130,13 @@ INFO [org.jboss.as.quickstarts.batch.job.listener.JobListener] (Batch Thread -

. This time you will not fix the file. Just click on *Restart* button again. If you click on *Update jobs list* button, you will see that the job was marked as `ABANDONED` this time because it was restarted once. Notice that there is a new parameter: `restartedOnce=true`. This behavior was implemented in `JobListener` for demonstration purposes, to prevent a `FAILED` job from being restarted twice.

== Server Log: Expected Warnings and Errors

You will see the following warnings in the server log. You can ignore these warnings.

[source,options="nowrap"]
----
WFLYJCA0091: -ds.xml file deployments are deprecated. Support may be removed in a future version.
HHH000431: Unable to determine H2 database version, certain features may not work
----

// Server Distribution Testing
include::../shared-doc/run-integration-tests-with-server-distribution.adoc[leveloffset=+2]
// Undeploy the Quickstart
include::../shared-doc/undeploy-the-quickstart.adoc[leveloffset=+1]
// Run the Quickstart in Red Hat CodeReady Studio or Eclipse
include::../shared-doc/run-the-quickstart-in-jboss-developer-studio.adoc[leveloffset=+1]
// Debug the Application
include::../shared-doc/debug-the-application.adoc[leveloffset=+1]
include::../shared-doc/undeploy-the-quickstart.adoc[leveloffset=+2]

// Build and run sections for other environments/builds
ifndef::ProductRelease,EAPXPRelease[]
include::../shared-doc/build-and-run-the-quickstart-with-provisioned-server.adoc[leveloffset=+1]
endif::[]

//*************************************************
// Product Release content only
//*************************************************
ifdef::ProductRelease[]
// Getting Started with OpenShift
include::../shared-doc/openshift-getting-started.adoc[leveloffset=+1]
//Prepare OpenShift for Quickstart Deployment
include::../shared-doc/openshift-create-project.adoc[leveloffset=+1]
// Import the Latest {xpaasproduct-shortname} Image Streams and Templates
include::../shared-doc/openshift-import-imagestreams-templates.adoc[leveloffset=+1]
// Deploy the {ProductShortName} Source-to-Image (S2I) Quickstart to OpenShift
include::../shared-doc/openshift-deploy-project.adoc[leveloffset=+1]
// Openshift post deployment tasks
include::../shared-doc/openshift-post-deployment-tasks.adoc[leveloffset=+1]
endif::[]
include::../shared-doc/build-and-run-the-quickstart-with-openshift.adoc[leveloffset=+1]
6 changes: 6 additions & 0 deletions batch-processing/charts/helm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
build:
uri: https://github.com/wildfly/quickstart.git
ref: main
contextDir: batch-processing
deploy:
replicas: 1
113 changes: 110 additions & 3 deletions batch-processing/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,15 @@
</licenses>

<properties>
<!-- The versions for BOMs, Dependencies and Plugins -->
<version.server.bom>30.0.0.Beta1</version.server.bom>
<!-- the version for the Server -->
<version.server>30.0.0.Beta1</version.server>
<!-- the versions for BOMs, Packs and Plugins -->
<version.bom.ee>${version.server}</version.bom.ee>
<version.pack.cloud>5.0.0.Beta1</version.pack.cloud>
<version.plugin.wildfly>4.2.0.Final</version.plugin.wildfly>
</properties>


<repositories>
<repository>
<id>jboss-public-maven-repository</id>
Expand Down Expand Up @@ -109,7 +114,7 @@
<dependency>
<groupId>org.wildfly.bom</groupId>
<artifactId>wildfly-ee-with-tools</artifactId>
<version>${version.server.bom}</version>
<version>${version.bom.ee}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down Expand Up @@ -221,5 +226,107 @@
<scope>provided</scope>
</dependency>

<!-- Tests -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<profiles>
<profile>
<id>provisioned-server</id>
<build>
<plugins>
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<configuration>
<feature-packs>
<feature-pack>
<location>org.wildfly:wildfly-galleon-pack:${version.server}</location>
</feature-pack>
</feature-packs>
<layers>
<!-- layers may be used to customize the server to provision-->
<layer>batch-jberet</layer>
<layer>cloud-server</layer>
<layer>h2-default-datasource</layer>
<layer>jsf</layer>
</layers>
<!-- deploys the quickstart on root web context -->
<runtimeName>ROOT.war</runtimeName>
</configuration>
<executions>
<execution>
<goals>
<goal>package</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>openshift</id>
<build>
<plugins>
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<configuration>
<feature-packs>
<feature-pack>
<location>org.wildfly:wildfly-galleon-pack:${version.server}</location>
</feature-pack>
<feature-pack>
<location>org.wildfly.cloud:wildfly-cloud-galleon-pack:${version.pack.cloud}</location>
</feature-pack>
</feature-packs>
<layers>
<layer>batch-jberet</layer>
<layer>cloud-server</layer>
<layer>h2-default-datasource</layer>
<layer>jsf</layer>
</layers>
<filename>ROOT.war</filename>
</configuration>
<executions>
<execution>
<goals>
<goal>package</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>integration-testing</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<includes>
<include>**/BasicRuntimeIT</include>
</includes>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* Copyright 2023 JBoss by Red Hat.
*
* 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 org.wildfly.quickstarts.batch;

import org.junit.Test;

import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.time.Duration;

import static org.junit.Assert.assertEquals;

/**
* The very basic runtime integration testing.
* @author emartins
*/
public class BasicRuntimeIT {

private static final String DEFAULT_SERVER_HOST = "http://localhost:8080/batch-processing";

@Test
public void testHTTPEndpointIsAvailable() throws IOException, InterruptedException, URISyntaxException {
String serverHost = System.getenv("SERVER_HOST");
if (serverHost == null) {
serverHost = System.getProperty("server.host");
}
if (serverHost == null) {
serverHost = DEFAULT_SERVER_HOST;
}
final HttpRequest request = HttpRequest.newBuilder()
.uri(new URI(serverHost+"/"))
.GET()
.build();
final HttpClient client = HttpClient.newBuilder()
.followRedirects(HttpClient.Redirect.ALWAYS)
.connectTimeout(Duration.ofMinutes(1))
.build();
final HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
assertEquals(200, response.statusCode());
final String[] bodyLines = response.body().toString().split(System.lineSeparator());
assertEquals("<meta http-equiv=\"Refresh\" content=\"0; URL=batch.jsf\">", bodyLines[bodyLines.length -3]);
}
}
1 change: 0 additions & 1 deletion helloworld/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
<type>jar</type>
</dependency>
</dependencies>

Expand Down
2 changes: 1 addition & 1 deletion shared-doc/run-integration-tests-with-openshift.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ The integration tests expect a deployed application, so make sure you have deplo
Run the integration tests using the following command to run the `verify` goal with the `integration-testing` profile activated and the proper URL:
[source,options="nowrap",subs="+attributes"]
----
$ mvn clean verify -Pintegration-testing -Dserver.host=https://$(oc get route {artifactId} --template='{{ .spec.host }}')
$ mvn verify -Pintegration-testing -Dserver.host=https://$(oc get route {artifactId} --template='{{ .spec.host }}')
----

[NOTE]
Expand Down

0 comments on commit 602a46b

Please sign in to comment.