Skip to content
This repository has been archived by the owner on Aug 5, 2024. It is now read-only.

Commit

Permalink
Merge pull request #135 from itsthejb/test-container
Browse files Browse the repository at this point in the history
Add -test container suffix
  • Loading branch information
itsthejb authored Nov 13, 2019
2 parents a3a8a0b + 8b3a17c commit da045db
Show file tree
Hide file tree
Showing 16 changed files with 38 additions and 33 deletions.
2 changes: 1 addition & 1 deletion hooks/test
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function buildAndTest() {
fi

DOWN="docker-compose -f test/$YML down -v"
CMD="docker-compose -f test/$YML up --no-build --abort-on-container-exit sut"
CMD="docker-compose -f test/$YML up --no-build --abort-on-container-exit --force-recreate --remove-orphans sut"
if ! $CMD; then
echo "Failed: \"$CMD\""
$DOWN &> /dev/null || true
Expand Down
2 changes: 1 addition & 1 deletion test/bats/helpers.bash
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bats

export CONTAINER="ispconfig"
export CONTAINER="ispconfig-test"
export TIMEOUT=10

function waitForPort() {
Expand Down
6 changes: 3 additions & 3 deletions test/bats/no-ispconfig-ssl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ setup() {
}

@test "ISPConfig at expected HTTP URL" {
curl -sL "http://ispconfig:8080" | grep "<title>ISPConfig</title>"
curl -sL "http://$CONTAINER:8080" | grep "<title>ISPConfig</title>"
}

@test "phpMyAdmin at expected HTTP URL" {
curl -sL "http://ispconfig:8080/phpmyadmin" | grep "<title>phpMyAdmin</title>"
curl -sL "http://$CONTAINER:8080/phpmyadmin" | grep "<title>phpMyAdmin</title>"
}

@test "ISPConfig at expected HTTP URL" {
curl -sL "http://ispconfig:8080/webmail" | grep "<title>Roundcube Webmail :: Welcome to Roundcube Webmail</title>"
curl -sL "http://$CONTAINER:8080/webmail" | grep "<title>Roundcube Webmail :: Welcome to Roundcube Webmail</title>"
}
10 changes: 5 additions & 5 deletions test/bats/reconfigure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ setup() {
}

@test "services have been reconfigured to MYSQL_HOST" {
docker exec ispconfig grep "^\$conf\['db_host'\] = '0.0.0.0';$" /usr/local/ispconfig/interface/lib/config.inc.php
docker exec ispconfig grep "^\$dbserver='0.0.0.0';$" /etc/phpmyadmin/config-db.php
docker exec ispconfig grep "^\$config\['db_dsnw'\] = 'mysql://roundcube:[email protected]/roundcube';$" /opt/roundcube/config/config.inc.php
docker exec "$CONTAINER" grep "^\$conf\['db_host'\] = '0.0.0.0';$" /usr/local/ispconfig/interface/lib/config.inc.php
docker exec "$CONTAINER" grep "^\$dbserver='0.0.0.0';$" /etc/phpmyadmin/config-db.php
docker exec "$CONTAINER" grep "^\$config\['db_dsnw'\] = 'mysql://roundcube:[email protected]/roundcube';$" /opt/roundcube/config/config.inc.php
}

@test "ispconfig database connection" {
# The logo is stored in the database
curl -Lk "https://ispconfig:8080" | grep -E '<img src="data:image/png;base64,.*>'
curl -Lk "https://$CONTAINER:8080" | grep -E '<img src="data:image/png;base64,.*>'
}

@test "roundcube database connection" {
curl -Lk "https://ispconfig:8080/webmail/" | grep -v 'DATABASE ERROR: CONNECTION FAILED!'
curl -Lk "https://$CONTAINER:8080/webmail/" | grep -v 'DATABASE ERROR: CONNECTION FAILED!'
}

# How to test phpMyAdmin?
2 changes: 1 addition & 1 deletion test/bats/tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ setup() {
}

@test "stored roundcube password is correctly changed" {
run docker exec ispconfig grep "\$config\['db_dsnw'\] = 'mysql://roundcube:reconfigured@localhost/roundcube';" /opt/roundcube/config/config.inc.php
run docker exec "$CONTAINER" grep "\$config\['db_dsnw'\] = 'mysql://roundcube:reconfigured@localhost/roundcube';" /opt/roundcube/config/config.inc.php
}

@test "cron jobs are running" {
Expand Down
2 changes: 1 addition & 1 deletion test/default/ispconfig.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const puppeteer = require('puppeteer');
const host = "ispconfig:" + process.env.PORT;
const host = "ispconfig-test:" + process.env.PORT;

const timeout = 30 * 1000;
jasmine.DEFAULT_TIMEOUT_INTERVAL = timeout;
Expand Down
5 changes: 3 additions & 2 deletions test/docker-compose.bats.custom-ssl.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ services:
image: graze/bats
command: /app/bats/custom-ssl.sh
depends_on:
- ispconfig
- ispconfig-test
networks:
- test_shared
environment:
Expand All @@ -20,7 +20,8 @@ services:
- ./ssl:/etc/ssl/local:ro
- /var/run/docker.sock:/var/run/docker.sock

ispconfig:
ispconfig-test:
container_name: ispconfig-test
extends:
file: ../docker-compose.template.yml
service: ispconfig
Expand Down
5 changes: 3 additions & 2 deletions test/docker-compose.bats.no-ispconfig-ssl.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ services:
image: graze/bats
command: /app/bats/no-ispconfig-ssl.sh
depends_on:
- ispconfig
- ispconfig-test
networks:
- test_shared
environment:
Expand All @@ -18,7 +18,8 @@ services:
- ./ssl:/etc/ssl/local:ro
- /var/run/docker.sock:/var/run/docker.sock

ispconfig:
ispconfig-test:
container_name: ispconfig-test
build:
args:
BUILD_ISPCONFIG_USE_SSL: "no"
Expand Down
5 changes: 3 additions & 2 deletions test/docker-compose.bats.reconfigure.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ services:
image: graze/bats
command: /app/bats/reconfigure.sh
depends_on:
- ispconfig
- ispconfig-test
networks:
- test_shared
environment:
Expand All @@ -15,7 +15,8 @@ services:
- ./:/app:ro
- /var/run/docker.sock:/var/run/docker.sock

ispconfig:
ispconfig-test:
container_name: ispconfig-test
environment:
- MYSQL_HOST=0.0.0.0
- DISABLED_SERVICES=mailman
Expand Down
5 changes: 3 additions & 2 deletions test/docker-compose.bats.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ services:
image: graze/bats
command: /app/bats/tests.sh
depends_on:
- ispconfig
- ispconfig-test
networks:
- test_shared
volumes:
Expand All @@ -15,7 +15,8 @@ services:
environment:
- MYSQL_PW=pass

ispconfig:
ispconfig-test:
container_name: ispconfig-test
extends:
file: ../docker-compose.template.yml
service: ispconfig
Expand Down
5 changes: 3 additions & 2 deletions test/docker-compose.puppeteer.no-phpmyadmin.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@ services:
context: .
dockerfile: Dockerfile.puppeteer
depends_on:
- ispconfig
- ispconfig-test
networks:
- test_shared
cap_add:
- SYS_ADMIN
volumes:
- './no-phpmyadmin:/app/test:ro'

ispconfig:
ispconfig-test:
container_name: ispconfig-test
build:
args:
BUILD_PHPMYADMIN: "no"
Expand Down
6 changes: 3 additions & 3 deletions test/docker-compose.puppeteer.remote-db-seeded.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ services:
networks:
- test_shared
depends_on:
- ispconfig
- ispconfig-test
cap_add:
- SYS_ADMIN
volumes:
- './remote-db:/app/test:ro'

ispconfig:
ispconfig-test:
container_name: ispconfig-test
build:
context: ..
dockerfile: Dockerfile
Expand All @@ -25,7 +26,6 @@ services:
BUILD_PHPMYADMIN: "no"
extra_hosts:
database: 172.99.0.1
container_name: ispconfig
hostname: ispconfig
domainname: test.com
networks:
Expand Down
6 changes: 3 additions & 3 deletions test/docker-compose.puppeteer.remote-db.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ services:
networks:
- test_shared
depends_on:
- ispconfig
- ispconfig-test
cap_add:
- SYS_ADMIN
volumes:
- './remote-db:/app/test:ro'

ispconfig:
ispconfig-test:
container_name: ispconfig-test
build:
context: ..
dockerfile: Dockerfile
Expand All @@ -25,7 +26,6 @@ services:
BUILD_PHPMYADMIN: "no"
extra_hosts:
database: 172.99.0.1
container_name: ispconfig
hostname: ispconfig
domainname: test.com
networks:
Expand Down
4 changes: 2 additions & 2 deletions test/docker-compose.puppeteer.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ services:
context: .
dockerfile: Dockerfile.puppeteer
depends_on:
- ispconfig
- ispconfig-test
networks:
- test_shared
cap_add:
Expand All @@ -16,7 +16,7 @@ services:
volumes:
- './default:/app/test:ro'

ispconfig:
ispconfig-test:
build:
args:
BUILD_ISPCONFIG_PORT: "443"
Expand Down
4 changes: 2 additions & 2 deletions test/no-phpmyadmin/phpmyadmin.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const puppeteer = require('puppeteer');
const host = "ispconfig:8080";
const host = "ispconfig-test:8080";

const timeout = 30 * 1000;
jasmine.DEFAULT_TIMEOUT_INTERVAL = timeout;
Expand All @@ -8,7 +8,7 @@ page.setDefaultNavigationTimeout(timeout);
describe('phpMyAdmin Web Interface', () => {
it('should not be available', async () => {
try {
await page.goto('https://ispconfig:8080/phpmyadmin');
await page.goto('https://' + host + '/phpmyadmin');
throw new Error("phpMyAdmin interface loaded, but it should not be available");
} catch (error) {
// should fail
Expand Down
2 changes: 1 addition & 1 deletion test/remote-db/ispconfig.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const puppeteer = require('puppeteer');
const host = "ispconfig:8080";
const host = "ispconfig-test:8080";

const timeout = 30 * 1000;
jasmine.DEFAULT_TIMEOUT_INTERVAL = timeout;
Expand Down

0 comments on commit da045db

Please sign in to comment.