Skip to content
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

Use external GraphQL client for smoke tests #179

Merged
merged 9 commits into from
Aug 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .github/workflows/smoke-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,14 @@ jobs:
restore-keys: |
osm-${{ matrix.locations.name }}

- name: Run smoke tests
- name: Build graph
working-directory: smoke-tests
run: |
cd smoke-tests
make build-${{ matrix.locations.name }}

- name: Run smoke tests
working-directory: smoke-tests
run: |
make run-${{ matrix.locations.name }} &

# OTP needs a little while to start up so we sleep
Expand Down
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1008,6 +1008,12 @@
<version>1.23.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.opentripplanner</groupId>
<artifactId>otp-client</artifactId>
<version>0.0.10</version>
<scope>test</scope>
</dependency>
</dependencies>

<profiles>
Expand Down
31 changes: 15 additions & 16 deletions src/test/java/org/opentripplanner/smoketest/AtlantaSmokeTest.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
package org.opentripplanner.smoketest;

import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.opentripplanner.client.model.RequestMode.FLEX_EGRESS;
import static org.opentripplanner.client.model.RequestMode.TRANSIT;
import static org.opentripplanner.client.model.RequestMode.WALK;
import static org.opentripplanner.smoketest.SmokeTest.assertThatItineraryHasModes;
import static org.opentripplanner.smoketest.SmokeTest.basicRouteTest;

import java.util.List;
import java.util.Set;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.opentripplanner.framework.geometry.WgsCoordinate;
import org.opentripplanner.smoketest.util.RestClient;
import org.opentripplanner.client.model.Coordinate;
import org.opentripplanner.smoketest.util.SmokeTestRequest;

/**
Expand All @@ -25,15 +28,12 @@
@Tag("atlanta")
public class AtlantaSmokeTest {

WgsCoordinate nearGeorgiaStateStation = new WgsCoordinate(33.74139944890028, -84.38607215881348);
WgsCoordinate powderSpringsInsideFlexZone1 = new WgsCoordinate(
33.86916840022388,
-84.66315507888794
);
Coordinate nearGeorgiaStateStation = new Coordinate(33.74139944890028, -84.38607215881348);
Coordinate powderSpringsInsideFlexZone1 = new Coordinate(33.86916840022388, -84.66315507888794);

@Test
public void regularRouteFromCentralAtlantaToPowderSprings() {
Set<String> modes = Set.of("TRANSIT", "WALK");
var modes = Set.of(TRANSIT, WALK);
SmokeTest.basicRouteTest(
new SmokeTestRequest(nearGeorgiaStateStation, powderSpringsInsideFlexZone1, modes),
List.of("WALK", "SUBWAY", "WALK", "BUS", "WALK", "BUS", "WALK")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The expected modes could eventually be moved to use LegMode directly.

Expand All @@ -42,27 +42,26 @@ public void regularRouteFromCentralAtlantaToPowderSprings() {

@Test
public void flexRouteFromCentralAtlantaToPowderSprings() {
var params = new SmokeTestRequest(
var req = new SmokeTestRequest(
nearGeorgiaStateStation,
powderSpringsInsideFlexZone1,
Set.of("FLEX_EGRESS", "WALK", "TRANSIT")
Set.of(FLEX_EGRESS, WALK, TRANSIT)
);
var otpResponse = RestClient.sendPlanRequest(params);
var itineraries = otpResponse.getPlan().itineraries;

assertTrue(itineraries.size() > 0);

var expectedModes = List.of("WALK", "SUBWAY", "WALK", "BUS", "WALK", "BUS");
var plan = basicRouteTest(req, expectedModes);
var itineraries = plan.itineraries();

assertThatItineraryHasModes(itineraries, expectedModes);

var transitLegs = itineraries
.stream()
.flatMap(i -> i.legs.stream().filter(l -> l.transitLeg))
.flatMap(i -> i.legs().stream().filter(l -> l.route() != null))
.toList();

var usesZone1Route = transitLegs
.stream()
.map(l -> l.routeShortName)
.map(l -> l.route().shortName())
.anyMatch(name -> name.equals("Zone 1"));

assertTrue(usesZone1Route);
Expand Down
11 changes: 7 additions & 4 deletions src/test/java/org/opentripplanner/smoketest/DenverSmokeTest.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package org.opentripplanner.smoketest;

import static org.opentripplanner.client.model.RequestMode.TRANSIT;
import static org.opentripplanner.client.model.RequestMode.WALK;

import java.util.List;
import java.util.Set;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.opentripplanner.framework.geometry.WgsCoordinate;
import org.opentripplanner.client.model.Coordinate;
import org.opentripplanner.smoketest.util.SmokeTestRequest;

/**
Expand All @@ -16,12 +19,12 @@
@Tag("denver")
public class DenverSmokeTest {

WgsCoordinate southBroadway = new WgsCoordinate(39.7020, -104.9866);
WgsCoordinate twinLakes = new WgsCoordinate(39.8232, -105.0055);
Coordinate southBroadway = new Coordinate(39.7020, -104.9866);
Coordinate twinLakes = new Coordinate(39.8232, -105.0055);

@Test
public void routeFromSouthToNorth() {
Set<String> modes = Set.of("TRANSIT", "WALK");
var modes = Set.of(TRANSIT, WALK);
SmokeTest.basicRouteTest(
new SmokeTestRequest(southBroadway, twinLakes, modes),
List.of("WALK", "TRAM", "WALK", "BUS", "WALK")
Expand Down
17 changes: 11 additions & 6 deletions src/test/java/org/opentripplanner/smoketest/HoustonSmokeTest.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
package org.opentripplanner.smoketest;

import static org.opentripplanner.client.model.RequestMode.BICYCLE;
import static org.opentripplanner.client.model.RequestMode.BUS;
import static org.opentripplanner.client.model.RequestMode.TRANSIT;
import static org.opentripplanner.client.model.RequestMode.WALK;

import java.util.List;
import java.util.Set;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.opentripplanner.framework.geometry.WgsCoordinate;
import org.opentripplanner.client.model.Coordinate;
import org.opentripplanner.smoketest.util.SmokeTestRequest;

/**
Expand All @@ -16,12 +21,12 @@
@Tag("houston")
public class HoustonSmokeTest {

WgsCoordinate galvestonRoad = new WgsCoordinate(29.6598, -95.2342);
WgsCoordinate northLindale = new WgsCoordinate(29.8158, -95.3697);
Coordinate galvestonRoad = new Coordinate(29.6598, -95.2342);
Coordinate northLindale = new Coordinate(29.8158, -95.3697);

@Test
public void routeFromSouthToNorth() {
Set<String> modes = Set.of("TRANSIT", "WALK");
var modes = Set.of(TRANSIT, WALK);
SmokeTest.basicRouteTest(
new SmokeTestRequest(galvestonRoad, northLindale, modes),
List.of("WALK", "BUS", "BUS", "WALK", "TRAM", "WALK")
Expand All @@ -30,7 +35,7 @@ public void routeFromSouthToNorth() {

@Test
public void selectOnlyBusses() {
Set<String> modes = Set.of("BUS", "WALK");
var modes = Set.of(BUS, WALK);
SmokeTest.basicRouteTest(
new SmokeTestRequest(galvestonRoad, northLindale, modes),
List.of("WALK", "BUS", "BUS", "WALK", "BUS", "WALK")
Expand All @@ -40,7 +45,7 @@ public void selectOnlyBusses() {
@Test
public void bikeRoute() {
SmokeTest.basicRouteTest(
new SmokeTestRequest(galvestonRoad, northLindale, Set.of("BICYCLE")),
new SmokeTestRequest(galvestonRoad, northLindale, Set.of(BICYCLE)),
List.of("BICYCLE")
);
}
Expand Down
25 changes: 15 additions & 10 deletions src/test/java/org/opentripplanner/smoketest/PortlandSmokeTest.java
Original file line number Diff line number Diff line change
@@ -1,29 +1,34 @@
package org.opentripplanner.smoketest;

import static org.opentripplanner.client.model.RequestMode.SCOOTER_RENT;
import static org.opentripplanner.client.model.RequestMode.TRAM;
import static org.opentripplanner.client.model.RequestMode.WALK;

import java.util.List;
import java.util.Set;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import org.opentripplanner.framework.geometry.WgsCoordinate;
import org.opentripplanner.client.model.Coordinate;
import org.opentripplanner.smoketest.util.SmokeTestRequest;

@Tag("smoke-test")
@Tag("portland")
public class PortlandSmokeTest {

WgsCoordinate cennentenial = new WgsCoordinate(45.504602, -122.4968719);
WgsCoordinate hazelwood = new WgsCoordinate(45.52463, -122.5583);
WgsCoordinate piedmont = new WgsCoordinate(45.5746, -122.6697);
WgsCoordinate mountTaborPark = new WgsCoordinate(45.511399, -122.594203);
Coordinate cennentenial = new Coordinate(45.504602, -122.4968719);
Coordinate buckman = new Coordinate(45.51720, -122.652289867);
Coordinate hazelwood = new Coordinate(45.52463, -122.5583);
Coordinate piedmont = new Coordinate(45.5746, -122.6697);
Coordinate mountTaborPark = new Coordinate(45.511399, -122.594203);

@Test
public void railTrip() {
// this used to be across the city by since the train is interrupter in April '23 this is a
// this used to be across the city by since the train is interrupted in April '23 this is a
// much shorter trip
SmokeTest.basicRouteTest(
new SmokeTestRequest(cennentenial, hazelwood, Set.of("TRAM", "WALK")),
new SmokeTestRequest(cennentenial, hazelwood, Set.of(TRAM, WALK)),
List.of("WALK", "TRAM", "WALK")
);
}
Expand All @@ -32,11 +37,11 @@ public void railTrip() {
* Checks that a scooter rental finishes at the edge of the park area and is continued on
* foot rather than scootering all the way to the destination.
*/
@ParameterizedTest(name = "scooter rental with arriveBy={0}")
@ParameterizedTest(name = "scooter rental in a geofencing zone with arriveBy={0}")
@ValueSource(booleans = { true, false })
public void geofencingZone(boolean arriveBy) {
SmokeTest.basicRouteTest(
new SmokeTestRequest(cennentenial, mountTaborPark, Set.of("SCOOTER_RENT", "WALK"), arriveBy),
new SmokeTestRequest(buckman, mountTaborPark, Set.of(SCOOTER_RENT, WALK), arriveBy),
List.of("WALK", "SCOOTER", "WALK")
);
}
Expand All @@ -45,7 +50,7 @@ public void geofencingZone(boolean arriveBy) {
@ValueSource(booleans = { true, false })
void scooterRent(boolean arriveBy) {
SmokeTest.basicRouteTest(
new SmokeTestRequest(cennentenial, piedmont, Set.of("SCOOTER_RENT", "WALK"), arriveBy),
new SmokeTestRequest(cennentenial, piedmont, Set.of(SCOOTER_RENT, WALK), arriveBy),
List.of("WALK", "SCOOTER")
);
}
Expand Down
30 changes: 18 additions & 12 deletions src/test/java/org/opentripplanner/smoketest/SeattleSmokeTest.java
Original file line number Diff line number Diff line change
@@ -1,30 +1,37 @@
package org.opentripplanner.smoketest;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.opentripplanner.client.model.RequestMode.BUS;
import static org.opentripplanner.client.model.RequestMode.FLEX_ACCESS;
import static org.opentripplanner.client.model.RequestMode.FLEX_DIRECT;
import static org.opentripplanner.client.model.RequestMode.FLEX_EGRESS;
import static org.opentripplanner.client.model.RequestMode.TRANSIT;
import static org.opentripplanner.client.model.RequestMode.WALK;

import java.io.IOException;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.opentripplanner.framework.geometry.WgsCoordinate;
import org.opentripplanner.smoketest.util.GraphQLClient;
import org.opentripplanner.client.model.Coordinate;
import org.opentripplanner.client.model.Route;
import org.opentripplanner.smoketest.util.SmokeTestRequest;

@Tag("smoke-test")
@Tag("seattle")
public class SeattleSmokeTest {

WgsCoordinate sodo = new WgsCoordinate(47.5811, -122.3290);
WgsCoordinate clydeHill = new WgsCoordinate(47.6316, -122.2173);
Coordinate sodo = new Coordinate(47.5811, -122.3290);
Coordinate clydeHill = new Coordinate(47.6316, -122.2173);

WgsCoordinate boeingCreekPark = new WgsCoordinate(47.755872, -122.361645);
WgsCoordinate ronaldBogPark = new WgsCoordinate(47.75601664, -122.33141);
Coordinate boeingCreekPark = new Coordinate(47.755872, -122.361645);
Coordinate ronaldBogPark = new Coordinate(47.75601664, -122.33141);

@Test
public void acrossTheCity() {
Set<String> modes = Set.of("TRANSIT", "WALK");
var modes = Set.of(TRANSIT, WALK);
SmokeTest.basicRouteTest(
new SmokeTestRequest(sodo, clydeHill, modes),
List.of("WALK", "BUS", "WALK", "BUS", "WALK")
Expand All @@ -33,22 +40,21 @@ public void acrossTheCity() {

@Test
public void flexAndTransit() {
Set<String> modes = Set.of("WALK", "BUS", "FLEX", "FLEX_DIRECT", "FLEX_EGRESS", "FLEX_ACCESS");
var modes = Set.of(WALK, BUS, FLEX_DIRECT, FLEX_EGRESS, FLEX_ACCESS);
SmokeTest.basicRouteTest(
new SmokeTestRequest(boeingCreekPark, ronaldBogPark, modes),
List.of("BUS")
);
}

@Test
public void monorailRoute() {
var modes = GraphQLClient
public void monorailRoute() throws IOException, InterruptedException {
Set<Object> modes = SmokeTest.API_CLIENT
.routes()
.stream()
.map(GraphQLClient.Route::mode)
.map(Route::mode)
.map(Objects::toString)
.collect(Collectors.toSet());

assertEquals(Set.of("MONORAIL", "TRAM", "FERRY", "BUS"), modes);
}

Expand Down
19 changes: 12 additions & 7 deletions src/test/java/org/opentripplanner/smoketest/SeptaSmokeTest.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
package org.opentripplanner.smoketest;

import static org.opentripplanner.client.model.RequestMode.BICYCLE_RENT;
import static org.opentripplanner.client.model.RequestMode.TRANSIT;
import static org.opentripplanner.client.model.RequestMode.WALK;

import java.io.IOException;
import java.util.List;
import java.util.Set;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.opentripplanner.framework.geometry.WgsCoordinate;
import org.opentripplanner.client.model.Coordinate;
import org.opentripplanner.smoketest.util.SmokeTestRequest;

/**
Expand All @@ -14,15 +19,15 @@
@Tag("septa")
public class SeptaSmokeTest {

WgsCoordinate airport = new WgsCoordinate(39.876151, -75.245189);
WgsCoordinate stPetersCemetary = new WgsCoordinate(39.98974, -75.09515);
Coordinate airport = new Coordinate(39.876151, -75.245189);
Coordinate stPetersCemetary = new Coordinate(39.98974, -75.09515);

WgsCoordinate pierceStreet = new WgsCoordinate(39.93014, -75.18047);
WgsCoordinate templeUniversity = new WgsCoordinate(39.98069, -75.14886);
Coordinate pierceStreet = new Coordinate(39.93014, -75.18047);
Coordinate templeUniversity = new Coordinate(39.98069, -75.14886);

@Test
public void routeFromAirportToNorthPhiladelphia() {
Set<String> modes = Set.of("TRANSIT", "WALK");
var modes = Set.of(TRANSIT, WALK);
SmokeTest.basicRouteTest(
new SmokeTestRequest(airport, stPetersCemetary, modes),
List.of("WALK", "RAIL", "WALK", "SUBWAY", "WALK")
Expand All @@ -42,7 +47,7 @@ public void bikeRentalStations() {
@Test
public void routeWithBikeRental() {
SmokeTest.basicRouteTest(
new SmokeTestRequest(pierceStreet, templeUniversity, Set.of("BICYCLE_RENT")),
new SmokeTestRequest(pierceStreet, templeUniversity, Set.of(BICYCLE_RENT)),
List.of("WALK", "BICYCLE", "WALK")
);
}
Expand Down
Loading
Loading