Skip to content

Commit

Permalink
Merge pull request #808 from rhusar/WFLY-18494
Browse files Browse the repository at this point in the history
WFLY-18494 microprofile-fault-tolerance Quickstart Common Enhancements CY2023Q3
  • Loading branch information
emmartins committed Dec 15, 2023
2 parents 4d60d68 + e6f5c77 commit 416b334
Show file tree
Hide file tree
Showing 13 changed files with 208 additions and 215 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/quickstart_microprofile-fault-tolerance_ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: WildFly microprofile-fault-tolerance Quickstart CI

on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
paths:
- 'microprofile-fault-tolerance/**'
- '.github/workflows/quickstart_ci.yml'
jobs:
call-quickstart_ci:
uses: ./.github/workflows/quickstart_ci.yml
with:
QUICKSTART_PATH: microprofile-fault-tolerance
TEST_BOOTABLE_JAR: true
27 changes: 7 additions & 20 deletions microprofile-fault-tolerance/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -619,31 +619,18 @@ further request processing for the duration of 5 seconds.
+
See details in the section <<adding_resiliency_circuit_breakers, Adding Resiliency: Circuit Breakers>>.

// 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=+2]

// Run the Arquillian Tests
include::../shared-doc/run-arquillian-tests.adoc[leveloffset=+2]

// Run the Quickstart in Red Hat CodeReady Studio or Eclipse
include::../shared-doc/run-the-quickstart-in-jboss-developer-studio.adoc[leveloffset=+2]

ifdef::EAPXPRelease[]
// Getting Started with OpenShift
include::../shared-doc/xp-openshift-getting-started.adoc[leveloffset=+1]
//Prepare OpenShift for Quickstart Deployment
include::../shared-doc/xp-create-project.adoc[leveloffset=+2]
// Import the Latest {xpaasproduct-shortname} Image Streams and Templates
include::../shared-doc/xp-import-imagestreams-templates.adoc[leveloffset=+2]
// Deploy the {ProductShortName} Source-to-Image (S2I) Quickstart to OpenShift
include::../shared-doc/xp-deploy-project.adoc[leveloffset=+2]
// Post deployment tasks
include::../shared-doc/xp-post-deployment-tasks.adoc[leveloffset=+2]
endif::[]

//Bootable JAR
// Bootable JAR
include::../shared-doc/build-and-run-the-quickstart-with-bootable-jar.adoc[leveloffset=+1]

// OpenShift
include::../shared-doc/build-and-run-the-quickstart-with-openshift.adoc[leveloffset=+1]

== Conclusion

MicroProfile Fault Tolerance allows improving resiliency of your application, without having an impact on the complexity
Expand Down
6 changes: 6 additions & 0 deletions microprofile-fault-tolerance/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: microprofile-fault-tolerance
deploy:
replicas: 1
165 changes: 61 additions & 104 deletions microprofile-fault-tolerance/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,16 @@
</licenses>

<properties>
<!-- The versions for BOMs, Dependencies and Plugins -->
<version.microprofile.bom>30.0.0.Final</version.microprofile.bom>
<version.server.bom>30.0.0.Final</version.server.bom>
<version.server.bootable-jar>30.0.0.Final</version.server.bootable-jar>
<version.wildfly-jar.maven.plugin>10.0.0.Final</version.wildfly-jar.maven.plugin>
<version.jkube.maven.plugin>1.0.1</version.jkube.maven.plugin>
<jkube.generator.from>registry.redhat.io/ubi8/openjdk-11:latest</jkube.generator.from>
<!-- the version for the Server -->
<version.server>30.0.0.Final</version.server>
<!-- The versions for the BOMs, Packs and Plugins -->
<version.bom.ee>${version.server}</version.bom.ee>
<version.bom.microprofile>${version.server}</version.bom.microprofile>
<version.pack.cloud>5.0.0.Final</version.pack.cloud>
<version.plugin.wildfly>4.2.0.Final</version.plugin.wildfly>
<version.plugin.wildfly-jar>10.0.0.Final</version.plugin.wildfly-jar>
<!-- The versions for other dependencies and plugin -->
<version.io.rest-assured>4.3.1</version.io.rest-assured>
</properties>

<repositories>
Expand Down Expand Up @@ -118,19 +121,19 @@

<dependencyManagement>
<dependencies>
<!-- importing the ee-with-tools BOM adds specs and other useful artifacts as managed dependencies -->
<!-- importing the microprofile BOM adds MicroProfile specs -->
<dependency>
<groupId>org.wildfly.bom</groupId>
<artifactId>wildfly-ee-with-tools</artifactId>
<version>${version.server.bom}</version>
<artifactId>wildfly-microprofile</artifactId>
<version>${version.bom.microprofile}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<!-- importing the microprofile BOM adds MicroProfile specs -->
<!-- importing the ee-with-tools BOM adds specs and other useful artifacts as managed dependencies -->
<dependency>
<groupId>org.wildfly.bom</groupId>
<artifactId>wildfly-microprofile</artifactId>
<version>${version.microprofile.bom}</version>
<artifactId>wildfly-ee-with-tools</artifactId>
<version>${version.bom.ee}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down Expand Up @@ -189,34 +192,43 @@
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<version>4.3.1</version>
<version>${version.io.rest-assured}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jackson2-provider</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<finalName>microprofile-fault-tolerance</finalName>
<finalName>${project.artifactId}</finalName>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<version>${version.plugin.wildfly}</version>
</plugin>
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-jar-maven-plugin</artifactId>
<version>${version.plugin.wildfly-jar}</version>
</plugin>
<plugin>
<groupId>org.asciidoctor</groupId>
<artifactId>asciidoctor-maven-plugin</artifactId>
<configuration>
<!-- adds versions properties as attributes for substitutions in README.adoc source blocks -->
<attributes>
<versionServerBom>${version.bom.ee}</versionServerBom>
<versionMicroprofileBom>${version.bom.microprofile}</versionMicroprofileBom>
</attributes>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.asciidoctor</groupId>
<artifactId>asciidoctor-maven-plugin</artifactId>
<configuration>
<!-- adds versions properties as attributes for substitutions in README.adoc source blocks -->
<attributes>
<versionServerBom>${version.server.bom}</versionServerBom>
<versionMicroprofileBom>${version.microprofile.bom}</versionMicroprofileBom>
</attributes>
</configuration>
</plugin>
</plugins>
</build>

<profiles>
Expand All @@ -227,12 +239,11 @@
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-jar-maven-plugin</artifactId>
<version>${version.wildfly-jar.maven.plugin}</version>
<configuration>
<feature-pack-location>wildfly@maven(org.jboss.universe:community-universe)#${version.server.bootable-jar}</feature-pack-location>
<feature-pack-location>wildfly@maven(org.jboss.universe:community-universe)#${version.server}</feature-pack-location>
<layers>
<layer>jaxrs-server</layer>
<layer>microprofile-platform</layer>
<layer>microprofile-fault-tolerance</layer>
</layers>
<plugin-options>
<jboss-fork-embedded>true</jboss-fork-embedded>
Expand All @@ -250,23 +261,26 @@
</build>
</profile>
<profile>
<id>bootable-jar-openshift</id>
<id>openshift</id>
<build>
<plugins>
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-jar-maven-plugin</artifactId>
<version>${version.wildfly-jar.maven.plugin}</version>
<artifactId>wildfly-maven-plugin</artifactId>
<configuration>
<feature-pack-location>wildfly@maven(org.jboss.universe:community-universe)#${version.server.bootable-jar}</feature-pack-location>
<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>jaxrs-server</layer>
<layer>microprofile-platform</layer>
<layer>cloud-server</layer>
<layer>microprofile-fault-tolerance</layer>
</layers>
<plugin-options>
<jboss-fork-embedded>true</jboss-fork-embedded>
</plugin-options>
<cloud/>
<filename>ROOT.war</filename>
</configuration>
<executions>
<execution>
Expand All @@ -276,78 +290,21 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.eclipse.jkube</groupId>
<artifactId>openshift-maven-plugin</artifactId>
<version>${version.jkube.maven.plugin}</version>
<executions>
<execution>
<goals>
<goal>resource</goal>
<goal>build</goal>
</goals>
</execution>
</executions>
<configuration>
<enricher>
<config>
<jkube-service>
<type>NodePort</type>
</jkube-service>
</config>
</enricher>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<!-- An optional Arquillian testing profile that executes tests in your JBoss EAP instance.
This profile will start a new JBoss EAP instance, and execute the test, shutting it down when done.
Run with: mvn clean verify -Parq-managed -->
<id>arq-managed</id>
<dependencies>
<dependency>
<groupId>org.wildfly.arquillian</groupId>
<artifactId>wildfly-arquillian-container-managed</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>${version.failsafe.plugin}</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<!-- An optional Arquillian testing profile that executes tests in a remote JBoss EAP instance.
Run with: mvn clean verify -Parq-remote -->
<id>arq-remote</id>
<dependencies>
<dependency>
<groupId>org.wildfly.arquillian</groupId>
<artifactId>wildfly-arquillian-container-remote</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<id>integration-testing</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>${version.failsafe.plugin}</version>
<configuration>
<includes>
<include>**/CoffeeResourceIT</include>
</includes>
</configuration>
<executions>
<execution>
<goals>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
package org.wildfly.quickstarts.microprofile.faulttolerance;

/**
* A simple entity class.
*
* @author Radoslav Husar
* A sample entity class.
*/
public class Coffee {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ public class CoffeeRepositoryService {

private static final Logger LOGGER = Logger.getLogger(CoffeeRepositoryService.class);

private Map<Integer, Coffee> coffeeList = new HashMap<>();
private final Map<Integer, Coffee> coffeeList = new HashMap<>();

private Map<Integer, Integer> availability = new HashMap<>();
private final Map<Integer, Integer> availability = new HashMap<>();

private AtomicLong counter = new AtomicLong(0);
private final AtomicLong counter = new AtomicLong(0);


public CoffeeRepositoryService() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import jakarta.inject.Inject;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
Expand All @@ -33,7 +34,6 @@
import org.eclipse.microprofile.faulttolerance.Retry;
import org.eclipse.microprofile.faulttolerance.Timeout;
import org.jboss.logging.Logger;
import jakarta.ws.rs.PathParam;

/**
* A JAX-RS resource that provides information about kinds of coffees we have on store and numbers of packages available.
Expand All @@ -51,7 +51,7 @@ public class CoffeeResource {
@Inject
CoffeeRepositoryService coffeeRepository;

private AtomicLong counter = new AtomicLong(0);
private final AtomicLong counter = new AtomicLong(0);

private Float failRatio = 0.5f;

Expand Down Expand Up @@ -171,15 +171,24 @@ private void randomDelay() throws InterruptedException {
Thread.sleep(new Random().nextInt(500));
}

void setFailRatio(Float failRatio) {
// The following methods are only used for automated integration testing

@GET
@Path("/setFailRatio/{failRatio}")
public void setFailRatio(@PathParam("failRatio") Float failRatio) {
this.failRatio = failRatio;
}

void resetCounter() {
this.counter.set(0);
@GET
@Path("/getCounter")
public Long getCounter() {
return counter.get();
}

Long getCounter() {
return counter.get();
@GET
@Path("/resetCounter")
public void resetCounter() {
this.counter.set(0);
}

}

0 comments on commit 416b334

Please sign in to comment.