-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Integration tests #6705
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev-2.x
Are you sure you want to change the base?
Integration tests #6705
Changes from all commits
1f507db
60c1b85
97689f4
9afdd6d
c319f53
f2c835e
d792072
728e3d5
b564538
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: Integration test | ||
|
||
on: | ||
pull_request: | ||
types: | ||
- labeled | ||
- synchronize | ||
env: | ||
MAVEN_ARGS: "--no-transfer-progress -Dstyle.color=always" | ||
|
||
jobs: | ||
run: | ||
runs-on: ubuntu-latest | ||
if: github.repository_owner == 'opentripplanner' && contains( github.event.pull_request.labels.*.name, 'Integration Test' ) | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up JDK 21 | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: 21 | ||
distribution: temurin | ||
cache: maven | ||
|
||
|
||
- name: Run integration tests | ||
run: mvn test-compile failsafe:integration-test -PprettierSkip |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.opentripplanner</groupId> | ||
<artifactId>otp-root</artifactId> | ||
<version>2.8.0-SNAPSHOT</version> | ||
<relativePath>../../pom.xml</relativePath> | ||
</parent> | ||
|
||
<artifactId>integration-test</artifactId> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>${project.groupId}</groupId> | ||
<artifactId>application</artifactId> | ||
<version>${project.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-api</artifactId> | ||
<version>${junit.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-params</artifactId> | ||
<version>${junit.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<configuration> | ||
<skipTests>true</skipTests> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-failsafe-plugin</artifactId> | ||
<version>3.5.3</version> | ||
<configuration> | ||
<includes> | ||
<include>**/*Test.java</include> | ||
</includes> | ||
<consoleOutputReporter> | ||
<disable>true</disable> | ||
</consoleOutputReporter> | ||
<reportFormat>plain</reportFormat> | ||
<statelessTestsetInfoReporter | ||
implementation="org.apache.maven.plugin.surefire.extensions.junit5.JUnit5StatelessTestsetInfoTreeReporter"> | ||
<printStacktraceOnError>true</printStacktraceOnError> | ||
<printStacktraceOnFailure>true</printStacktraceOnFailure> | ||
<printStdoutOnError>true</printStdoutOnError> | ||
<printStdoutOnFailure>true</printStdoutOnFailure> | ||
<printStdoutOnSuccess>false</printStdoutOnSuccess> | ||
<printStderrOnError>true</printStderrOnError> | ||
<printStderrOnFailure>true</printStderrOnFailure> | ||
<printStderrOnSuccess>false</printStderrOnSuccess> | ||
<theme>UNICODE</theme> | ||
</statelessTestsetInfoReporter> | ||
</configuration> | ||
<dependencies> | ||
<dependency> | ||
<groupId>me.fabriciorby</groupId> | ||
<artifactId>maven-surefire-junit5-tree-reporter</artifactId> | ||
<version>1.4.0</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package org.opentripplanner; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertNotEquals; | ||
|
||
import jakarta.ws.rs.core.UriBuilder; | ||
import java.io.IOException; | ||
import java.time.Duration; | ||
import java.util.Map; | ||
import org.apache.commons.io.IOUtils; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.ValueSource; | ||
import org.opentripplanner.framework.io.OtpHttpClient; | ||
import org.opentripplanner.framework.io.OtpHttpClientFactory; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* This integration test makes sure that Apache HTTP client still works with important hosts and | ||
* HTTP servers. | ||
*/ | ||
class OtpHttpClientTest { | ||
|
||
private static final Logger LOG = LoggerFactory.getLogger(OtpHttpClientTest.class); | ||
private static final OtpHttpClient OTP_HTTP_CLIENT = new OtpHttpClientFactory().create(LOG); | ||
|
||
@ParameterizedTest | ||
@ValueSource( | ||
strings = { | ||
// a few entur URLs | ||
"https://api.entur.io/mobility/v2/gbfs/", | ||
"https://storage.googleapis.com/marduk-production/outbound/gtfs/rb_sjn-aggregated-gtfs.zip", | ||
// Apache HTTP Client broke handling of S3 SSL certificates previously | ||
"https://s3.amazonaws.com/kcm-alerts-realtime-prod/tripupdates.pb", | ||
} | ||
) | ||
void httpGetRequest(String url) throws IOException { | ||
var uri = UriBuilder.fromUri(url).build(); | ||
|
||
var stream = OTP_HTTP_CLIENT.getAsInputStream(uri, Duration.ofSeconds(30), Map.of()); | ||
var bytes = IOUtils.toByteArray(stream); | ||
|
||
assertNotEquals(0, bytes.length, "Empty response body for %s".formatted(url)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the symptom of a HTTP client problem always an empty body? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the examples used in this test, yes. I'm mainly testing that general HTTP calls don't throw an exception, which they did for two previous version upgrades. |
||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think @t2gran suggested the postfix for integration tests could be IntegrationTest.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could use the (admittedly pretty dusty) integration test feature of maven (via the failsafe plugin) or use the tags to select just these tests, like we do with
@GeneratesDocumentation
. Do you have an opinion?