Skip to content

Commit

Permalink
Add config for e2e sql tests (#12762)
Browse files Browse the repository at this point in the history
  • Loading branch information
cedricongjh authored Feb 20, 2024
1 parent 2ae2446 commit d7666b7
Show file tree
Hide file tree
Showing 4 changed files with 119 additions and 0 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/e2e-sql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: E2E Tests

on:
push:
branches:
- master
- release
- v9-migration
pull_request:
branches:
- master
- release
- v9-migration
schedule:
- cron: "0 0 * * *" #end of every day
jobs:
E2E-testing:
runs-on: ubuntu-latest
strategy:
fail-fast: false #ensure both tests run even if one fails
matrix:
browser: [firefox]
tests: [stable, unstable]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '11'
- name: Cache Gradle packages
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Update Property File
run: mv src/e2e/resources/test.ci-${{ matrix.browser }}.properties src/e2e/resources/test.properties
- name: Run Solr search service + local Datastore emulator
run: docker-compose up -d
- name: Create Config Files
run: ./gradlew createConfigs testClasses generateTypes
- name: Install Frontend Dependencies
run: npm ci
- name: Build Frontend Bundle
run: npm run build
- name: Start Server
run: |
./gradlew serverRun &
./wait-for-server.sh
- name: Start Tests
run: xvfb-run --server-args="-screen 0 1024x768x24" ./gradlew -P${{ matrix.tests }} e2eTestsSql

37 changes: 37 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,43 @@ task e2eTests {
e2eTests.dependsOn "e2eTestTry${id}"
}

task e2eTestsSql {
description "Runs the E2E test suite and retries failed test up to ${numOfTestRetries} times."
group "Test"
}

(1..numOfTestRetries + 1).each { id ->
def isFirstTry = id == 1
def isLastRetry = id == numOfTestRetries + 1
def runUnstableTests = project.hasProperty('unstable')
def outputFileName = runUnstableTests ? "e2e-sql-unstable-test-try-" : "e2e-test-try-"

task "e2eSqlTestTry${id}"(type: Test) {
useTestNG()
options.suites isFirstTry
? (runUnstableTests ? "src/e2e/resources/testng-unstable-e2e-sql.xml" : "src/e2e/resources/testng-e2e-sql.xml")
: file("${buildDir}/reports/${outputFileName}${id - 1}/testng-failed.xml")
options.outputDirectory = file("${buildDir}/reports/${outputFileName}${id}")
options.useDefaultListeners = true
ignoreFailures = !isLastRetry
maxHeapSize = "1g"
reports.html.required = false
reports.junitXml.required = false
jvmArgs "-Xss2m", "-Dfile.encoding=UTF-8"
testLogging {
events "passed"
}
afterTest afterTestClosure
if (isFirstTry) {
afterSuite checkTestNgFailureClosure
}
onlyIf {
isFirstTry || file("${buildDir}/reports/${outputFileName}${id - 1}/testng-failed.xml").exists()
}
}
e2eTestsSql.dependsOn "e2eSqlTestTry${id}"
}

task axeTests {
description "Runs the full accessibility test suite and retries failed tests once."
group "Test"
Expand Down
12 changes: 12 additions & 0 deletions src/e2e/resources/testng-e2e-sql.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd">
<suite name="e2e-tests-sql" parallel="tests" thread-count="2">
<test name="e2e-tests-sql" parallel="classes">
<packages>
<package name="teammates.e2e.util" />
</packages>
<classes>
<class name="teammates.e2e.sql.StudentHomePageE2ETest" />
</classes>
</test>
</suite>
11 changes: 11 additions & 0 deletions src/e2e/resources/testng-unstable-e2e-sql.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd">
<suite name="e2e-unstable-tests-sql" parallel="tests" thread-count="2">
<test name="e2e-unstable-tests-sql" parallel="classes">
<packages>
<package name="teammates.e2e.util" />
</packages>
<classes>
</classes>
</test>
</suite>

0 comments on commit d7666b7

Please sign in to comment.