Skip to content
This repository was archived by the owner on Nov 24, 2025. It is now read-only.
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ RUN apk add --no-cache \
ENTRYPOINT cd traffic_router && \
export JAVA_HOME="$(command -v java | xargs realpath | xargs dirname)/.." && \
mvn "-Dmaven.repo.local=${GITHUB_WORKSPACE}/.m2/repository" \
test -Djava.library.path=/usr/share/java
"-Dskiprpms=true"\
clean verify -Djava.library.path=/usr/lib
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
under the License.
-->

# tr-unit-tests Docker action
This action runs the Traffic Router unit tests in an Alpine Docker container.
# tr-unit-and-integration-tests Docker action
This action runs the Traffic Router unit tests and integration tests in an Alpine Docker container.

## Inputs

Expand All @@ -42,13 +42,13 @@ jobs:
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Run unit tests
- name: Run unit tests and integration tests
uses: ./.github/actions/tr-unit-tests
```

To run the tests locally:
```shell
export GITHUB_WORKSPACE='/github/workspace';
docker build -f .github/actions/tr-unit-tests/Dockerfile -t tr-unit-tests .;
docker run --rm -te GITHUB_WORKSPACE -v "$(pwd):${GITHUB_WORKSPACE}" -w "$GITHUB_WORKSPACE" tr-unit-tests;
docker build -f .github/actions/tr-unit-and-integration-tests/Dockerfile -t tr-unit-and-integration-tests .;
docker run --rm -te GITHUB_WORKSPACE -v "$(pwd):${GITHUB_WORKSPACE}" -w "$GITHUB_WORKSPACE" tr-unit-and-integration-tests;
```
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
# specific language governing permissions and limitations
# under the License.

name: tr-unit-tests
description: Runs Traffic Ops unit tests
name: tr-unit-and-integration-tests
description: Runs Traffic Ops unit tests and integration tests
runs:
using: docker
image: Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# specific language governing permissions and limitations
# under the License.

name: Traffic Router Unit Tests
name: Traffic Router Unit Tests and Integration Tests

env:
# alpine:3.13
Expand All @@ -24,20 +24,20 @@ env:
on:
push:
paths:
- .github/actions/tr-unit-tests/**
- .github/workflows/tr.unit.tests.yaml
- .github/actions/tr-unit-and-integration-tests/**
- .github/workflows/tr.unit.tests.integration.tests.yaml
- traffic_router/**
create:
pull_request:
paths:
- .github/actions/tr-unit-tests/**
- .github/workflows/tr.unit.tests.yaml
- .github/actions/tr-unit-and-integration-tests/**
- .github/workflows/tr.unit.tests.integration.tests.yaml
- traffic_router/**
types: [ opened, reopened, ready_for_review, synchronize ]

jobs:
tests:
if: github.event.pull_request.draft == false
if: github.event.pull_request.draft == true
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -56,14 +56,20 @@ jobs:
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Run Traffic Router unit tests
uses: ./.github/actions/tr-unit-tests
- name: Run Traffic Router unit tests and integration tests
uses: ./.github/actions/tr-unit-and-integration-tests
- name: Upload Surefire Reports
uses: actions/upload-artifact@v2
if: ${{ failure() }}
with:
name: surefire-reports
path: ${{ github.workspace }}/traffic_router/core/target/surefire-reports/TEST-*.xml
- name: Upload Failsafe Reports
uses: actions/upload-artifact@v2
if: ${{ failure() }}
with:
name: failsafe-reports
path: ${{ github.workspace }}/traffic_router/core/target/failsafe-reports/TEST-*.xml
- name: Checkout junit-report-annotations action
uses: actions/checkout@v2
with:
Expand Down
4 changes: 4 additions & 0 deletions traffic_router/build/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@
<os>
<name>linux</name>
</os>
<property>
<name>skiprpms</name>
<value>false</value>
</property>
</activation>
<build>
<finalName>traffic_router</finalName>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public static void setupFakeServers() throws Exception {
e.printStackTrace();
}

ConsoleAppender consoleAppender = ConsoleAppender.newBuilder().setLayout(PatternLayout.newBuilder().withPattern("%d{ISO8601} [%-5p] %c{4}: %m%n").build()).build();
ConsoleAppender consoleAppender = ConsoleAppender.newBuilder().setName("stdout").setLayout(PatternLayout.newBuilder().withPattern("%d{ISO8601} [%-5p] %c{4}: %m%n").build()).build();
LoggerContext.getContext().getRootLogger().addAppender(consoleAppender);
LoggerContext.getContext().getRootLogger().setLevel(Level.INFO);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public static void main(String[] args) throws Exception {

LoggerContext.getContext().getLogger("org.springframework").setLevel(Level.WARN);

ConsoleAppender consoleAppender = ConsoleAppender.newBuilder().setLayout(PatternLayout.newBuilder().withPattern("%d{ISO8601} [%-5p] %c{4}: %m%n").build()).build();
ConsoleAppender consoleAppender = ConsoleAppender.newBuilder().setName("stdout").setLayout(PatternLayout.newBuilder().withPattern("%d{ISO8601} [%-5p] %c{4}: %m%n").build()).build();
LoggerContext.getContext().getRootLogger().addAppender(consoleAppender);
LoggerContext.getContext().getRootLogger().setLevel(Level.INFO);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public static void setUpBeforeClass() throws Exception {
public void setUp() throws Exception {
trafficRouterManager = (TrafficRouterManager) context.getBean("trafficRouterManager");
trafficRouterManager.getTrafficRouter().setApplicationContext(context);
final File file = new File("src/test/db/czmap.json");
final File file = new File("src/test/resources/czmap.json");
final ObjectMapper mapper = new ObjectMapper();
final JsonNode jsonNode = mapper.readTree(file);
final JsonNode coverageZones = jsonNode.get("coverageZones");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ public static void beforeClass() throws Exception {
LoggerContext.getContext().getLogger("org.eclipse.jetty").setLevel(Level.WARN);
LoggerContext.getContext().getLogger("org.springframework").setLevel(Level.WARN);

ConsoleAppender consoleAppender = ConsoleAppender.newBuilder().setLayout(PatternLayout.newBuilder().withPattern("%d{ISO8601} [%-5p] %c{4}: %m%n").build()).build();
System.out.println(LoggerContext.getContext().getLoggers());
ConsoleAppender consoleAppender = ConsoleAppender.newBuilder().setName("stdout").setLayout(PatternLayout.newBuilder().withPattern("%d{ISO8601} [%-5p] %c{4}: %m%n").build()).build();
LoggerContext.getContext().getRootLogger().addAppender(consoleAppender);
LoggerContext.getContext().getRootLogger().setLevel(Level.INFO);

Expand Down
Loading