Skip to content

Commit

Permalink
Summarize guidelines
Browse files Browse the repository at this point in the history
  • Loading branch information
istraka authored and honza-kasik committed Jan 27, 2020
1 parent b57ea0b commit bcd353d
Show file tree
Hide file tree
Showing 7 changed files with 133 additions and 33 deletions.
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ jdk:
install:
- mvn -version; docker version
script:
- if [ $(git grep import | grep '\*' | grep -E -v '(.mvn/|.travis.yml:|README.md|CONTRIBUTING.md)' | wc -l) != 0 ]; then
echo "Wildcard found!";
git grep import | grep '\*' | grep -E -v '(.mvn/|.travis.yml:|README.md|CONTRIBUTING.md)';
exit 1;
fi
- mvn -B formatter:validate impsort:check
- mvn -B verify -DskipTests -Djboss.dist=foo
cache:
Expand Down
51 changes: 51 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
## Contributing
Standard PR workflow - [link](https://www.atlassian.com/git/tutorials/comparing-workflows/forking-workflow)

## Structure of the testsuite
Group all tests for given MP spec into single module
* for example to group all tests for MP Metric together
* in case that tests for integration of multiple MP specs are developed and it's not clear to which module they belong then new module can be created. Preferable a name of such module should reflect MP specs.

Tooling should be in separate module so it is isolated and easily used by other (test) modules.
Try to add tooling to existing module.
If there is no module that reflect tooling purpose you can create new module.
The name **must** include `tooling-` prefix.

Rather than add new dependency try to extend existing tooling or add new one yet still consider the trade-off.

Examples of available tooling:
* tooling-cpu-load
* tooling-docker
* tooling-server-configuration

**In order to configure and manage server you need to use tooling-server-configuration and Creaper core library, see [the module description](tooling-server-configuration/README.md)**

## Test documentation
For documentation and test plan purposes use following annotations for each test to properly document its purpose, passing criteria and version of EAP since a test is valid from:
```
/**
* @tpTestDetails __PUT TEST DETAILS__
* @tpPassCrit __PUT PASSING CRITERIA__
* @tpSince __VERSION OF WILDFLY/EAP WITH A FEATURE__
*/
```

## Coding conventions
To enforce common codestyle the testsuite uses formatter plugin which automatically formats a code. To run it manually run `mvn -B formatter:validate impsort:check`.

## Another best practices
To get arquillian properties such ach server address and so on, use:
```
ArquillianContainerProperties arqProps = new ArquillianContainerProperties(
ArquillianDescriptorWrapper.getArquillianDescriptor());
arqProps.getDefaultManagementAddress();
```

To validate server functionality via REST point use restassured library:
* if possible import statically `get()`, `given()`,... method
* use one `baseUri()` with fully-qualified URL instead of
```
.baseUri(...)
.port(...)
.basePath(...)
```
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,22 @@ mvn release:prepare release:clean -Darguments=-DskipTests
```

With commands you are able to define a release, a tag and a next development version name in interactive way.

## Issues found by the testsuite
Any issue found in WildFly/EAP release will be reported into the Red Hat issue tracker: https://issues.redhat.com/ . There are the following Jira projects:
* https://issues.redhat.com/projects/WFWIP - for issues in unreleased WildFly version (like WF dev branches)
* https://issues.redhat.com/projects/WFLY - for released WildFly versions
* https://issues.redhat.com/projects/JBEAP - for released EAP versions

Every reported issue must contain:
* Title (affected MP spec may be part of the title, proper Component must be set)
* Type: Bug
* Component: related Microprofile component (`mp-health`)
* Affected Version - WildFly/EAP version (for WFLY/JBEAP issues)
* Description of the issue
* provide high-level description of the issue
* information about tested WF/EAP build (or used commit/branch)
* impact on the user
* test scenario (actual and expected result)
* add logs/stacktraces
* automatic reproducer (if possible)
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@
import org.jboss.arquillian.container.test.api.RunAsClient;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.test.api.ArquillianResource;
import org.jboss.as.arquillian.api.ContainerResource;
import org.jboss.as.arquillian.container.ManagementClient;
import org.jboss.eap.qe.microprofile.metrics.hello.MetricsApp;
import org.jboss.eap.qe.microprofile.tooling.server.configuration.ConfigurationException;
import org.jboss.eap.qe.microprofile.tooling.server.configuration.arquillian.ArquillianContainerProperties;
import org.jboss.eap.qe.microprofile.tooling.server.configuration.arquillian.ArquillianDescriptorWrapper;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.EmptyAsset;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;

Expand All @@ -31,11 +32,9 @@
@RunWith(Arquillian.class)
public class ConnectionStressMetricsTest {

@ContainerResource
ManagementClient managementClient;
@ArquillianResource
private URL deploymentUrl;
private URL metricsURL;
private static URL metricsURL;

@Deployment
public static WebArchive createDeployment() {
Expand All @@ -44,9 +43,12 @@ public static WebArchive createDeployment() {
.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
}

@Before
public void composeHealthEndpointURL() throws MalformedURLException {
metricsURL = new URL("http://" + managementClient.getMgmtAddress() + ":" + managementClient.getMgmtPort() + "/metrics");
@BeforeClass
public static void composeMetricsEndpointURL() throws MalformedURLException, ConfigurationException {
ArquillianContainerProperties arqProps = new ArquillianContainerProperties(
ArquillianDescriptorWrapper.getArquillianDescriptor());
metricsURL = new URL("http://" + arqProps.getDefaultManagementAddress() + ":" + arqProps.getDefaultManagementPort()
+ "/metrics");
}

private HttpURLConnection getHTTPConn(URL url) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,18 @@
import static io.restassured.RestAssured.given;

import java.io.IOException;
import java.net.MalformedURLException;

import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.RunAsClient;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.as.arquillian.api.ContainerResource;
import org.jboss.as.arquillian.container.ManagementClient;
import org.jboss.eap.qe.microprofile.tooling.server.configuration.ConfigurationException;
import org.jboss.eap.qe.microprofile.tooling.server.configuration.arquillian.ArquillianContainerProperties;
import org.jboss.eap.qe.microprofile.tooling.server.configuration.arquillian.ArquillianDescriptorWrapper;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.EmptyAsset;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;

Expand All @@ -28,17 +30,15 @@ public static JavaArchive createDeployment() {
.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
}

@ContainerResource
ManagementClient managementClient;
private static RequestSpecification metricsRequest;

private RequestSpecification metricsRequest;

@Before
public void prepare() {
metricsRequest = given()
.baseUri("http://" + managementClient.getMgmtAddress())
.port(managementClient.getMgmtPort())
.basePath("metrics");
@BeforeClass
public static void composeMetricsEndpointURL() throws MalformedURLException, ConfigurationException {
ArquillianContainerProperties arqProps = new ArquillianContainerProperties(
ArquillianDescriptorWrapper.getArquillianDescriptor());
String metricsURL = "http://" + arqProps.getDefaultManagementAddress() + ":" + arqProps.getDefaultManagementPort()
+ "/metrics";
metricsRequest = given().baseUri(metricsURL);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@
import org.jboss.arquillian.container.test.api.RunAsClient;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.test.api.ArquillianResource;
import org.jboss.as.arquillian.api.ContainerResource;
import org.jboss.as.arquillian.container.ManagementClient;
import org.jboss.eap.qe.microprofile.metrics.hello.MetricsApp;
import org.jboss.eap.qe.microprofile.tooling.server.configuration.ConfigurationException;
import org.jboss.eap.qe.microprofile.tooling.server.configuration.arquillian.ArquillianContainerProperties;
import org.jboss.eap.qe.microprofile.tooling.server.configuration.arquillian.ArquillianDescriptorWrapper;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.EmptyAsset;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;

Expand All @@ -40,11 +41,8 @@ public class MetricsTest {
@ArquillianResource
URL deploymentUrl;

@ContainerResource
ManagementClient managementClient;

private RequestSpecification jsonMetricsRequest;
private RequestSpecification textMetricsRequest;
private static RequestSpecification jsonMetricsRequest;
private static RequestSpecification textMetricsRequest;

@Deployment
public static WebArchive createDeployment() {
Expand All @@ -53,9 +51,12 @@ public static WebArchive createDeployment() {
.addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
}

@Before
public void prepare() {
String metricsURL = "http://" + managementClient.getMgmtAddress() + ":" + managementClient.getMgmtPort() + "/metrics";
@BeforeClass
public static void composeMetricsEndpointURL() throws ConfigurationException {
ArquillianContainerProperties arqProps = new ArquillianContainerProperties(
ArquillianDescriptorWrapper.getArquillianDescriptor());
String metricsURL = "http://" + arqProps.getDefaultManagementAddress() + ":" + arqProps.getDefaultManagementPort()
+ "/metrics";
jsonMetricsRequest = given()
.baseUri(metricsURL)
.accept(ContentType.JSON);
Expand Down
22 changes: 22 additions & 0 deletions tooling-server-configuration/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Module description
Module contains classes for configuring and managing server.

## Creaper

Creaper core library [link](https://github.com/wildfly-extras/creaper) is meant to be used to configure and manage server.
To get `OnlineManagementClient` you can use `ManagementClientProvider` class.
The class reads Arquillian configuration autimatically.

## Configure server

To achieve desired configuration of server you can implement `MicroProfileServerSetupTask` that extends `ServerSetupTask` interface and annotate testclass with `@ServerSetup` annotation.
The setup task in invoked after Arquillian observers and before a deployment is deployed.
The interface provides two methods:
* setup(): implement desired changes
* teardown(): restore and rollback changes

If you need to configure a server see [Creaper section](#Creaper) to get a instance of `OnlineManagementClient`

## Logging

Module also contains tooling for checking server log files - `ModelNodeLogChecker`.

0 comments on commit bcd353d

Please sign in to comment.