Skip to content

Commit

Permalink
GH-4742 jstl (#4814)
Browse files Browse the repository at this point in the history
  • Loading branch information
hmottestad authored Nov 7, 2023
2 parents 8f754f4 + 592cb89 commit 66db3f2
Show file tree
Hide file tree
Showing 14 changed files with 947 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/pr-verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,37 @@ jobs:
repo: eclipse/rdf4j
workflow_id: ${{ github.run_id }}
access_token: ${{ github.token }}
e2e:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: 11
- name: Cache local Maven repository
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-jdk11-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-jdk11-maven-
- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y libxml2-utils
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 18
- name: Run end-to-end tests of RDF4J Server and Workbench
working-directory: ./e2e
run: ./run.sh
- name: Cancel workflow on failure
uses: vishnudxb/[email protected]
if: failure()
with:
repo: eclipse/rdf4j
workflow_id: ${{ github.run_id }}
access_token: ${{ github.token }}
copyright-check:
runs-on: ubuntu-latest
steps:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ compliance/*/overlays
docker/ignore
/core/queryparser/sparql/JavaCC/javacc/
/scripts/temp/
org.eclipse.dash.licenses-1.0.2.jar
e2e/node_modules
e2e/playwright-report
e2e/test-results
54 changes: 54 additions & 0 deletions docker/waitForDocker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/usr/bin/env bash
# Initial sleep to make sure docker has started
sleep 5


while : ; do
STARTING=`docker ps -f "health=starting" --format "{{.Names}}"`
if [ -z "$STARTING" ] #if STARTING is empty
then
break
fi
echo "Waiting for containers to finish starting"
sleep 1
done


while : ; do

# Get cpu % from docker stats, remove '%' and then sum all the values into one number
CPU=`docker stats --no-stream --format "{{.CPUPerc}}" | awk '{gsub ( "[%]","" ) ; print $0 }' | awk '{s+=$1} END {print s}'`
echo "CPU: $CPU%"

# Do floating point comparison, if $CPU is bigger than 15, WAIT will be 1
WAIT=`echo $CPU'>'15 | bc -l`
echo "WAIT (0/1): $WAIT"

sleep 1

# Get cpu % from docker stats, remove '%' and then sum all the values into one number
CPU2=`docker stats --no-stream --format "{{.CPUPerc}}" | awk '{gsub ( "[%]","" ) ; print $0 }' | awk '{s+=$1} END {print s}'`
echo "CPU2: $CPU2%"

# Do floating point comparison, if $CPU is bigger than 15, WAIT will be 1
WAIT2=`echo $CPU'>'15 | bc -l`
echo "WAIT2 (0/1): $WAIT2"

# Break from loop if WAIT is 0, which is when the sum of the cpu usage is smaller than 15%
[[ "$WAIT" -eq 0 ]] && [[ "$WAIT2" -eq 0 ]] && break

# Else sleep and loop
echo "Waiting for docker"
sleep 1

done

while : ; do
STARTING=`docker ps -f "health=starting" --format "{{.Names}}"`
if [ -z "$STARTING" ] #if STARTING is empty
then
break
fi
echo "Waiting for containers to finish starting"
sleep 1
done
27 changes: 27 additions & 0 deletions e2e/.github/workflows/playwright.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Playwright Tests
on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]
jobs:
test:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Install dependencies
run: npm ci
- name: Install Playwright Browsers
run: npx playwright install --with-deps
- name: Run Playwright tests
run: npx playwright test
- uses: actions/upload-artifact@v3
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30
4 changes: 4 additions & 0 deletions e2e/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules/
/test-results/
/playwright-report/
/playwright/.cache/
20 changes: 20 additions & 0 deletions e2e/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# End-to-end tests

This directory contains end-to-end tests for the project. These tests use docker to run the RDF4J server and workbench.

The tests are written using Microsoft Playwright and interact with the server and workbench using the browser.

## Running the tests

Requirements:
- docker
- java
- maven
- npm
- npx

The tests can be run using the `run.sh` script. This script will build the project, start the server and workbench and run the tests.

To run the tests interactively use `npx playwright test --ui`

The RDF4J server and workbench can be started independently using the `run.sh` script in the `docker` directory.
140 changes: 140 additions & 0 deletions e2e/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions e2e/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "e2e",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@playwright/test": "^1.39.0",
"@types/node": "^20.8.7"
}
}
78 changes: 78 additions & 0 deletions e2e/playwright.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
// @ts-check
const { defineConfig, devices } = require('@playwright/test');

/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
// require('dotenv').config();

/**
* @see https://playwright.dev/docs/test-configuration
*/
module.exports = defineConfig({
testDir: './tests',
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
workers: 1,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: 'html',
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Base URL to use in actions like `await page.goto('/')`. */
// baseURL: 'http://127.0.0.1:3000',

/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
},

/* Configure projects for major browsers */
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},

{
name: 'firefox',
use: { ...devices['Desktop Firefox'] },
},

{
name: 'webkit',
use: { ...devices['Desktop Safari'] },
},

/* Test against mobile viewports. */
// {
// name: 'Mobile Chrome',
// use: { ...devices['Pixel 5'] },
// },
// {
// name: 'Mobile Safari',
// use: { ...devices['iPhone 12'] },
// },

/* Test against branded browsers. */
// {
// name: 'Microsoft Edge',
// use: { ...devices['Desktop Edge'], channel: 'msedge' },
// },
// {
// name: 'Google Chrome',
// use: { ...devices['Desktop Chrome'], channel: 'chrome' },
// },
],

/* Run your local dev server before starting the tests */
// webServer: {
// command: 'npm run start',
// url: 'http://127.0.0.1:3000',
// reuseExistingServer: !process.env.CI,
// },
});

Loading

0 comments on commit 66db3f2

Please sign in to comment.