Skip to content
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: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,11 @@ release: tag_major_minor release_grid_scaler
docker push $(NAME)/standalone-all-browsers:$(MAJOR_MINOR_PATCH)
docker push $(NAME)/video:$(FFMPEG_TAG_VERSION)-$(BUILD_DATE)

start_test_site:
@docker rm -f the-internet 2>/dev/null || true
@docker run --rm --name the-internet -d -p 5001:5000 ndviet/the-internet:latest
@echo "Test site started at http://localhost:5001"

test: test_chrome \
test_chrome_standalone \
test_chrome_standalone_java \
Expand Down Expand Up @@ -839,7 +844,7 @@ test_parallel: hub chrome firefox edge chromium video
echo CHART_CERT_PATH=$$(readlink -f ./videos/certs/tls.crt) >> .env ; \
export $$(cat .env | xargs) ; \
DOCKER_DEFAULT_PLATFORM=$(PLATFORMS) docker compose --profile $(PLATFORMS) -f docker-compose-v3-test-parallel.yml up -d --remove-orphans --no-log-prefix ; \
RUN_IN_DOCKER_COMPOSE=true bash ./bootstrap.sh $$node ; \
RUN_IN_DOCKER_COMPOSE=true TEST_SITE=the-internet:5000 bash ./bootstrap.sh $$node ; \
docker compose -f docker-compose-v3-test-parallel.yml down ; \
done
make test_video_integrity
Expand Down
13 changes: 8 additions & 5 deletions tests/CDPTests/tests/Tests.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,29 @@
const {test, expect} = require('@playwright/test');
const path = require('path');

// Get test site URL from environment variable or use default
const TEST_SITE = process.env.TEST_SITE || 'the-internet.herokuapp.com';

function sleep(ms: number) {
return new Promise(resolve => setTimeout(resolve, ms));
}

test.describe.parallel('Parallel tests connect to autoscaling Grid', () => {
test('test_title', async ({page}) => {
await page.goto('https://the-internet.herokuapp.com');
await page.goto(`http://${TEST_SITE}`);
await expect(page).toHaveTitle('The Internet');
await sleep(2);
});

test('test_with_frames', async ({page}) => {
await page.goto('http://the-internet.herokuapp.com/nested_frames');
await page.goto(`http://${TEST_SITE}/nested_frames`);
const frame = page.frameLocator('frame[name="frame-top"]').frameLocator('frame[name="frame-middle"]');
await expect(frame.locator('#content')).toHaveText('MIDDLE');
await sleep(2);
});

test('test_select_from_a_dropdown', async ({page}) => {
await page.goto('http://the-internet.herokuapp.com/dropdown');
await page.goto(`http://${TEST_SITE}/dropdown`);
const dropdown = await page.locator('#dropdown');
await dropdown.selectOption({label: 'Option 1'});
const selectedOption = await dropdown.inputValue();
Expand All @@ -29,14 +32,14 @@ test.describe.parallel('Parallel tests connect to autoscaling Grid', () => {
});

test('test_visit_basic_auth_secured_page', async ({page}) => {
await page.goto('http://admin:admin@the-internet.herokuapp.com/basic_auth');
await page.goto(`http://admin:admin@${TEST_SITE}/basic_auth`);
const pageMessage = await page.locator('.example p').textContent();
expect(pageMessage.trim()).toBe('Congratulations! You must have the proper credentials.');
await sleep(2);
});

test('test_download_file', async ({page}) => {
await page.goto('https://the-internet.herokuapp.com/download');
await page.goto(`http://${TEST_SITE}/download`);
const fileLink = page.locator('a', {hasText: 'some-file.txt'});
await fileLink.scrollIntoViewIfNeeded();
const [download] = await Promise.all([
Expand Down
7 changes: 6 additions & 1 deletion tests/SeleniumJavaTests/bootstrap_java.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ VERSION="${VERSION:-"latest"}"
function cleanup {
echo "Stopping the Selenium Grid container..."
docker rm -f standalone || true
docker rm -f the-internet || true
docker network rm standalone || true
exit $exit_code
}

Expand All @@ -18,7 +20,9 @@ trap cleanup EXIT
# Change to the test directory relative to the project root
cd "$(dirname "$0")"

docker run --rm --name standalone -d -p 4444:4444 "${NAMESPACE}/${IMAGE_NAME}:${VERSION}"
docker network create standalone
docker run --rm --name the-internet -d --network standalone "ndviet/the-internet:latest"
docker run --rm --name standalone -d --network standalone -p 4444:4444 "${NAMESPACE}/${IMAGE_NAME}:${VERSION}"

until curl -s "${GRID_URL}/status" | grep -q 'Selenium Grid ready'; do
echo "Waiting for Selenium Grid to be ready..."
Expand All @@ -30,5 +34,6 @@ echo "Running tests with Selenium Grid at ${GRID_URL}"

export GRID_URL="${GRID_URL}"
export BROWSER="${BROWSER}"
export TEST_SITE="the-internet:5000"
./gradlew clean test
exit_code=$?
7 changes: 4 additions & 3 deletions tests/SeleniumJavaTests/src/test/java/SeleniumTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

class SeleniumTests {
private WebDriver driver;
private String TEST_SITE = System.getenv().getOrDefault("TEST_SITE", "the-internet.herokuapp.com");

@BeforeEach
void setUp() {
Expand Down Expand Up @@ -59,15 +60,15 @@ void setUp() {

@Test
void abTestingLinkOpensCorrectPage() {
driver.get("https://the-internet.herokuapp.com/");
driver.get(String.format("http://%s", TEST_SITE));
driver.findElement(By.linkText("A/B Testing")).click();
String header = driver.findElement(By.tagName("h3")).getText();
assert header.contains("A/B Test");
}

@Test
void checkboxesCanBeToggled() {
driver.get("https://the-internet.herokuapp.com/checkboxes");
driver.get(String.format("http://%s/checkboxes", TEST_SITE));
WebElement checkbox1 = driver.findElements(By.cssSelector("input[type='checkbox']")).get(0);
boolean initialState = checkbox1.isSelected();
checkbox1.click();
Expand All @@ -76,7 +77,7 @@ void checkboxesCanBeToggled() {

@Test
void dropdownSelectionWorks() {
driver.get("https://the-internet.herokuapp.com/dropdown");
driver.get(String.format("http://%s/dropdown", TEST_SITE));
WebElement dropdown = driver.findElement(By.id("dropdown"));
Select select = new Select(dropdown);
select.selectByVisibleText("Option 2");
Expand Down
13 changes: 7 additions & 6 deletions tests/SeleniumTests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
LIST_CHROMIUM_VERSIONS = ['140.0', '139.0', '138.0', '137.0', '136.0', '135.0', '134.0']
LIST_FIREFOX_VERSIONS = ['142.0', '141.0', '140.0', '139.0', '138.0', '137.0', '136.0']
LIST_PLATFORMS = ['Linux', None, 'Windows 11']
TEST_SITE = os.environ.get('TEST_SITE', 'the-internet.herokuapp.com')

if not TEST_MULTIPLE_VERSIONS_EXPLICIT:
LIST_CHROMIUM_VERSIONS.append(None)
Expand All @@ -65,15 +66,15 @@
class SeleniumGenericTests(unittest.TestCase):

def test_title(self):
self.driver.get('https://the-internet.herokuapp.com')
self.driver.get(f'http://{TEST_SITE}')
wait = WebDriverWait(self.driver, WEB_DRIVER_WAIT_TIMEOUT)
wait.until(EC.title_is('The Internet'))
self.assertTrue(self.driver.title == 'The Internet')

# https://github.com/tourdedave/elemental-selenium-tips/blob/master/03-work-with-frames/python/frames.py
def test_with_frames(self):
driver = self.driver
driver.get('http://the-internet.herokuapp.com/nested_frames')
driver.get(f'http://{TEST_SITE}/nested_frames')
wait = WebDriverWait(driver, WEB_DRIVER_WAIT_TIMEOUT)
frame_top = wait.until(EC.frame_to_be_available_and_switch_to_it('frame-top'))
frame_middle = wait.until(EC.frame_to_be_available_and_switch_to_it('frame-middle'))
Expand All @@ -82,7 +83,7 @@ def test_with_frames(self):
# https://github.com/tourdedave/elemental-selenium-tips/blob/master/05-select-from-a-dropdown/python/dropdown.py
def test_select_from_a_dropdown(self):
driver = self.driver
driver.get('http://the-internet.herokuapp.com/dropdown')
driver.get(f'http://{TEST_SITE}/dropdown')
dropdown_list = driver.find_element(By.ID, 'dropdown')
options = dropdown_list.find_elements(By.TAG_NAME, 'option')
for opt in options:
Expand All @@ -98,7 +99,7 @@ def test_select_from_a_dropdown(self):
# https://github.com/tourdedave/elemental-selenium-tips/blob/master/13-work-with-basic-auth/python/basic_auth_1.py
def test_visit_basic_auth_secured_page(self):
driver = self.driver
driver.get('http://admin:admin@the-internet.herokuapp.com/basic_auth')
driver.get(f'http://admin:admin@{TEST_SITE}/basic_auth')
page_message = driver.find_element(By.CSS_SELECTOR, '.example p').text
self.assertTrue(page_message == 'Congratulations! You must have the proper credentials.')

Expand All @@ -116,7 +117,7 @@ def test_play_video(self):

def test_download_file(self):
driver = self.driver
driver.get('https://the-internet.herokuapp.com/download')
driver.get(f'http://{TEST_SITE}/download')
file_name = 'some-file.txt'
wait = WebDriverWait(driver, 30)
file_link = wait.until(EC.element_to_be_clickable((By.LINK_TEXT, file_name)))
Expand Down Expand Up @@ -305,7 +306,7 @@ def setUp(self):
raise e

def test_title_and_maximize_window(self):
self.driver.get('https://the-internet.herokuapp.com')
self.driver.get(f'http://{TEST_SITE}')
self.driver.maximize_window()
self.assertTrue(self.driver.title == 'The Internet')

Expand Down
1 change: 1 addition & 0 deletions tests/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ elif [ "$1" = "AutoScalingTestsScaleChaos" ]; then
python3 -m unittest AutoscalingTests.test_scale_chaos
ret_code=$?
else
export TEST_SITE="the-internet:5000"
python3 test.py $1
ret_code=$?
fi
Expand Down
24 changes: 24 additions & 0 deletions tests/charts/ci/local-pvc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,30 @@ spec:
containers:
- name: ftp-server
image: delfer/alpine-ftp-server:latest
ports:
- name: ftp
containerPort: 21
livenessProbe:
tcpSocket:
port: ftp
initialDelaySeconds: 10
periodSeconds: 5
failureThreshold: 3
timeoutSeconds: 2
readinessProbe:
tcpSocket:
port: ftp
initialDelaySeconds: 5
periodSeconds: 5
failureThreshold: 3
timeoutSeconds: 2
resources:
limits:
cpu: "200m"
memory: "256Mi"
requests:
cpu: "100m"
memory: "128Mi"
env:
- name: USERS
value: "seluser|selenium.dev"
Expand Down
58 changes: 58 additions & 0 deletions tests/charts/ci/the-internet-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: the-internet
labels:
app: the-internet
spec:
replicas: 1
selector:
matchLabels:
app: the-internet
template:
metadata:
labels:
app: the-internet
spec:
containers:
- name: the-internet
image: ndviet/the-internet:latest
imagePullPolicy: IfNotPresent
ports:
- containerPort: 5000
resources:
limits:
cpu: "200m"
memory: "256Mi"
requests:
cpu: "100m"
memory: "64Mi"
livenessProbe:
httpGet:
path: /
port: 5000
initialDelaySeconds: 10
periodSeconds: 10
failureThreshold: 3
readinessProbe:
httpGet:
path: /
port: 5000
initialDelaySeconds: 5
periodSeconds: 5
---
apiVersion: v1
kind: Service
metadata:
name: the-internet
labels:
app: the-internet
spec:
type: ClusterIP
ports:
- port: 5000
targetPort: 5000
protocol: TCP
name: http
selector:
app: the-internet
5 changes: 4 additions & 1 deletion tests/charts/make/chart_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ TEST_MULTIPLE_PLATFORMS=${TEST_MULTIPLE_PLATFORMS:-"false"}
TEST_MULTIPLE_PLATFORMS_RELAY=${TEST_MULTIPLE_PLATFORMS_RELAY:-"false"}
TEST_CUSTOM_SPECIFIC_NAME=${TEST_CUSTOM_SPECIFIC_NAME:-"false"}
TEST_VIDEO_RECORDER_SIDECAR=${TEST_VIDEO_RECORDER_SIDECAR:-"false"}
TEST_SITE=${TEST_SITE:-"the-internet:5000"}

wait_for_terminated() {
# Wait until no pods are in "Terminating" state
Expand Down Expand Up @@ -164,8 +165,9 @@ if [ "${TEST_UPGRADE_CHART}" != "true" ] && [ "${RENDER_HELM_TEMPLATE_ONLY}" !=
sudo chmod -R 777 ${HOST_PATH}
kubectl create ns ${SELENIUM_NAMESPACE} || true
kubectl apply -n ${SELENIUM_NAMESPACE} -f ${LOCAL_PVC_YAML}
kubectl apply -n ${SELENIUM_NAMESPACE} -f "${TEST_VALUES_PATH}/the-internet-deployment.yaml"
kubectl describe pod,svc,pv,pvc -n ${SELENIUM_NAMESPACE} -l app=ftp-server
kubectl delete pod -n ${SELENIUM_NAMESPACE} -l app=ftp-server --force --grace-period=0
kubectl describe pod,svc,pv,pvc -n ${SELENIUM_NAMESPACE} -l app=the-internet
fi

if [ "${TEST_NAME_OVERRIDE}" = "true" ]; then
Expand Down Expand Up @@ -546,6 +548,7 @@ export TEST_MULTIPLE_VERSIONS_EXPLICIT=${TEST_MULTIPLE_VERSIONS_EXPLICIT}
export TEST_MULTIPLE_PLATFORMS=${TEST_MULTIPLE_PLATFORMS}
export TEST_MULTIPLE_PLATFORMS_RELAY=${TEST_MULTIPLE_PLATFORMS_RELAY}
export TEST_CUSTOM_SPECIFIC_NAME=${TEST_CUSTOM_SPECIFIC_NAME}
export TEST_SITE="${TEST_SITE}"
if [ "${MATRIX_BROWSER}" = "NoAutoscaling" ]; then
./tests/bootstrap.sh NodeFirefox
if [ "${TEST_PLATFORMS}" = "linux/amd64" ]; then
Expand Down
6 changes: 6 additions & 0 deletions tests/docker-compose-v3-test-node-docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,20 @@ services:
- ./videos/upload:/ftp/seluser
stop_grace_period: 30s

the-internet:
image: ndviet/the-internet:latest
container_name: the-internet

tests:
image: docker-selenium-tests:latest
build:
context: ./
dockerfile: ./Dockerfile
depends_on:
- selenium-hub
- the-internet
environment:
- TEST_SITE=the-internet:5000
- RUN_IN_DOCKER_COMPOSE=true
- SELENIUM_GRID_HOST=selenium-hub
- BINDING_VERSION=${BINDING_VERSION}
Expand Down
6 changes: 6 additions & 0 deletions tests/docker-compose-v3-test-node-relay.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,20 @@ services:
- "4443:4443"
- "4444:4444"

the-internet:
image: ndviet/the-internet:latest
container_name: the-internet

tests:
image: docker-selenium-tests:${TAG}
build:
context: ./
dockerfile: ./Dockerfile
depends_on:
- selenium-hub
- the-internet
environment:
- TEST_SITE=the-internet:5000
- RUN_IN_DOCKER_COMPOSE=true
- SELENIUM_GRID_HOST=selenium-hub
- BINDING_VERSION=${BINDING_VERSION}
Expand Down
4 changes: 4 additions & 0 deletions tests/docker-compose-v3-test-parallel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ services:
timeout: 30s
retries: 5

the-internet:
image: ndviet/the-internet:latest
container_name: the-internet

# tests:
# image: docker-selenium-tests:latest
# build:
Expand Down
6 changes: 6 additions & 0 deletions tests/docker-compose-v3-test-standalone-docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,20 @@ services:
- ./videos/upload:/ftp/seluser
stop_grace_period: 30s

the-internet:
image: ndviet/the-internet:latest
container_name: the-internet

tests:
image: docker-selenium-tests:latest
build:
context: ./
dockerfile: ./Dockerfile
depends_on:
- standalone-docker
- the-internet
environment:
- TEST_SITE=the-internet:5000
- RUN_IN_DOCKER_COMPOSE=true
- SELENIUM_GRID_HOST=selenium-hub
- BINDING_VERSION=${BINDING_VERSION}
Expand Down
Loading
Loading