Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/tests #78

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion test/tests/integration/bad-extensions.bats
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Integration test for a simple go app
# Integration test for a simple php app

# source environment helpers
. util/env.sh
Expand Down
2 changes: 1 addition & 1 deletion test/tests/integration/composer.bats
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Integration test for a simple go app
# Integration test for a simple php app

# source environment helpers
. util/env.sh
Expand Down
2 changes: 1 addition & 1 deletion test/tests/integration/extensions.bats
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Integration test for a simple go app
# Integration test for a simple php app

# source environment helpers
. util/env.sh
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Integration test for a simple go app
# Integration test for a simple php app

# source environment helpers
. util/env.sh
Expand All @@ -12,7 +12,7 @@ payload() {
"cache_dir": "/tmp/cache",
"etc_dir": "/data/etc",
"env_dir": "/data/etc/env.d",
"config": { "runtime": "php-5.3", "extensions": ["amqp", "dom", "timezonedb"] }
"config": { "runtime": "php-5.3", "extensions": ["amqp", "dom", "timezonedb"], "apache_version": "2.2" }
}
END
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Integration test for a simple go app
# Integration test for a simple php app

# source environment helpers
. util/env.sh
Expand All @@ -12,7 +12,7 @@ payload() {
"cache_dir": "/tmp/cache",
"etc_dir": "/data/etc",
"env_dir": "/data/etc/env.d",
"config": { "runtime": "php-5.4", "extensions": ["amqp", "dom", "timezonedb"] }
"config": { "runtime": "php-5.4", "extensions": ["amqp", "dom", "timezonedb"], "apache_version": "2.2" }
}
END
}
Expand Down Expand Up @@ -105,8 +105,6 @@ setup() {
# cd into the app code_dir
cd /tmp/code

export TEST_VARIABLE=testing

# start php-fpm
# /data/bin/start-php &

Expand Down Expand Up @@ -134,5 +132,4 @@ setup() {
[[ "$output" =~ amqp ]]
[[ "$output" =~ dom ]]
[[ "$output" =~ timezonedb ]]
[[ "$output" =~ TEST_VARIABLE ]]
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Integration test for a simple go app
# Integration test for a simple php app

# source environment helpers
. util/env.sh
Expand All @@ -12,7 +12,7 @@ payload() {
"cache_dir": "/tmp/cache",
"etc_dir": "/data/etc",
"env_dir": "/data/etc/env.d",
"config": { "runtime": "php-5.5", "extensions": ["amqp", "dom", "timezonedb"], "apache_php_interpreter": "mod_php" }
"config": { "runtime": "php-5.5", "extensions": ["amqp", "dom", "timezonedb"], "apache_version": "2.2" }
}
END
}
Expand Down Expand Up @@ -105,7 +105,8 @@ setup() {
# cd into the app code_dir
cd /tmp/code

export TEST_VARIABLE=testing
# start php-fpm
# /data/bin/start-php &

# start apache
# /data/bin/start-apache &
Expand All @@ -117,7 +118,10 @@ setup() {
# curl the index
run curl -s 127.0.0.1:8080 2>/dev/null

expected="Hello world!"

# kill the server
# pkill php-fpm
# pkill httpd
pkill php-server

Expand All @@ -128,5 +132,4 @@ setup() {
[[ "$output" =~ amqp ]]
[[ "$output" =~ dom ]]
[[ "$output" =~ timezonedb ]]
[[ "$output" =~ TEST_VARIABLE ]]
}
135 changes: 135 additions & 0 deletions test/tests/integration/phpinfo-apache2.2-fpm-php5.6.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
# Integration test for a simple php app

# source environment helpers
. util/env.sh

payload() {
cat <<-END
{
"code_dir": "/tmp/code",
"data_dir": "/data",
"app_dir": "/tmp/app",
"cache_dir": "/tmp/cache",
"etc_dir": "/data/etc",
"env_dir": "/data/etc/env.d",
"config": { "runtime": "php-5.6", "extensions": ["amqp", "dom", "timezonedb"], "apache_version": "2.2" }
}
END
}

setup() {
# cd into the engine bin dir
cd /engine/bin
}

@test "setup" {
# prepare environment (create directories etc)
prepare_environment

# prepare pkgsrc
run prepare_pkgsrc

# create the code_dir
mkdir -p /tmp/code

# copy the app into place
cp -ar /test/apps/phpinfo/* /tmp/code

run pwd

[ "$output" = "/engine/bin" ]
}

@test "boxfile" {
if [[ ! -f /engine/bin/boxfile ]]; then
skip "No boxfile script"
fi
run /engine/bin/boxfile "$(payload)"

echo "$output"

[ "$status" -eq 0 ]
}

@test "build" {
if [[ ! -f /engine/bin/build ]]; then
skip "No build script"
fi
run /engine/bin/build "$(payload)"

echo "$output"

[ "$status" -eq 0 ]
}

@test "compile" {
if [[ ! -f /engine/bin/compile ]]; then
skip "No compile script"
fi
run /engine/bin/compile "$(payload)"

echo "$output"

[ "$status" -eq 0 ]
}

@test "cleanup" {
if [[ ! -f /engine/bin/cleanup ]]; then
skip "No cleanup script"
fi
run /engine/bin/cleanup "$(payload)"

echo "$output"

[ "$status" -eq 0 ]
}

@test "release" {
if [[ ! -f /engine/bin/release ]]; then
skip "No release script"
fi
run /engine/bin/release "$(payload)"

echo "$output"

[ "$status" -eq 0 ]
}

@test "verify" {
# remove the code dir
rm -rf /tmp/code

# mv the app_dir to code_dir
mv /tmp/app /tmp/code

# cd into the app code_dir
cd /tmp/code

# start php-fpm
# /data/bin/start-php &

# start apache
# /data/bin/start-apache &
php-server &

# sleep a few seconds so the server can start
sleep 3

# curl the index
run curl -s 127.0.0.1:8080 2>/dev/null

expected="Hello world!"

# kill the server
# pkill php-fpm
# pkill httpd
pkill php-server

echo "$output"

[[ "$output" =~ "phpinfo()" ]]
[[ "$output" =~ PHP\ Version\ 5\.6\.[0-9]{1,2} ]]
[[ "$output" =~ amqp ]]
[[ "$output" =~ dom ]]
[[ "$output" =~ timezonedb ]]
}
135 changes: 135 additions & 0 deletions test/tests/integration/phpinfo-apache2.2-fpm-php7.0.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
# Integration test for a simple php app

# source environment helpers
. util/env.sh

payload() {
cat <<-END
{
"code_dir": "/tmp/code",
"data_dir": "/data",
"app_dir": "/tmp/app",
"cache_dir": "/tmp/cache",
"etc_dir": "/data/etc",
"env_dir": "/data/etc/env.d",
"config": { "runtime": "php-7.0", "extensions": ["amqp", "dom", "timezonedb"], "apache_version": "2.2" }
}
END
}

setup() {
# cd into the engine bin dir
cd /engine/bin
}

@test "setup" {
# prepare environment (create directories etc)
prepare_environment

# prepare pkgsrc
run prepare_pkgsrc

# create the code_dir
mkdir -p /tmp/code

# copy the app into place
cp -ar /test/apps/phpinfo/* /tmp/code

run pwd

[ "$output" = "/engine/bin" ]
}

@test "boxfile" {
if [[ ! -f /engine/bin/boxfile ]]; then
skip "No boxfile script"
fi
run /engine/bin/boxfile "$(payload)"

echo "$output"

[ "$status" -eq 0 ]
}

@test "build" {
if [[ ! -f /engine/bin/build ]]; then
skip "No build script"
fi
run /engine/bin/build "$(payload)"

echo "$output"

[ "$status" -eq 0 ]
}

@test "compile" {
if [[ ! -f /engine/bin/compile ]]; then
skip "No compile script"
fi
run /engine/bin/compile "$(payload)"

echo "$output"

[ "$status" -eq 0 ]
}

@test "cleanup" {
if [[ ! -f /engine/bin/cleanup ]]; then
skip "No cleanup script"
fi
run /engine/bin/cleanup "$(payload)"

echo "$output"

[ "$status" -eq 0 ]
}

@test "release" {
if [[ ! -f /engine/bin/release ]]; then
skip "No release script"
fi
run /engine/bin/release "$(payload)"

echo "$output"

[ "$status" -eq 0 ]
}

@test "verify" {
# remove the code dir
rm -rf /tmp/code

# mv the app_dir to code_dir
mv /tmp/app /tmp/code

# cd into the app code_dir
cd /tmp/code

# start php-fpm
# /data/bin/start-php &

# start apache
# /data/bin/start-apache &
php-server &

# sleep a few seconds so the server can start
sleep 3

# curl the index
run curl -s 127.0.0.1:8080 2>/dev/null

expected="Hello world!"

# kill the server
# pkill php-fpm
# pkill httpd
pkill php-server

echo "$output"

[[ "$output" =~ "phpinfo()" ]]
[[ "$output" =~ PHP\ Version\ 7\.0\.[0-9]{1,2} ]]
[[ "$output" =~ amqp ]]
[[ "$output" =~ dom ]]
[[ "$output" =~ timezonedb ]]
}
Loading