mirror of
https://github.com/dokku/dokku.git
synced 2025-12-29 00:25:08 +01:00
Merge pull request #3561 from dokku/3544-ps-can-scale
feat: disable scaling if app contains DOKKU_SCALE file
This commit is contained in:
5
tests/apps/dockerfile-dokku-scale/CHECKS
Normal file
5
tests/apps/dockerfile-dokku-scale/CHECKS
Normal file
@@ -0,0 +1,5 @@
|
||||
WAIT=2 # wait 2 seconds
|
||||
TIMEOUT=5 # set timeout to 5 seconds
|
||||
ATTEMPTS=2 # try 2 times
|
||||
|
||||
/ nodejs/express
|
||||
1
tests/apps/dockerfile-dokku-scale/DOKKU_SCALE
Normal file
1
tests/apps/dockerfile-dokku-scale/DOKKU_SCALE
Normal file
@@ -0,0 +1 @@
|
||||
web=1
|
||||
11
tests/apps/dockerfile-dokku-scale/Dockerfile
Normal file
11
tests/apps/dockerfile-dokku-scale/Dockerfile
Normal file
@@ -0,0 +1,11 @@
|
||||
FROM node:4
|
||||
|
||||
EXPOSE 3001/udp
|
||||
EXPOSE 3000/tcp
|
||||
EXPOSE 3003
|
||||
|
||||
COPY . /app
|
||||
WORKDIR /app
|
||||
RUN npm install
|
||||
|
||||
CMD npm start
|
||||
8
tests/apps/dockerfile-dokku-scale/Procfile
Normal file
8
tests/apps/dockerfile-dokku-scale/Procfile
Normal file
@@ -0,0 +1,8 @@
|
||||
###############################
|
||||
# DEVELOPMENT #
|
||||
###############################
|
||||
|
||||
# Procfile for development using the new threaded worker (scheduler, twitter stream and delayed job)
|
||||
cron: node worker.js
|
||||
web: node web.js
|
||||
worker: node worker.js
|
||||
5
tests/apps/dockerfile-dokku-scale/check_deploy
Executable file
5
tests/apps/dockerfile-dokku-scale/check_deploy
Executable file
@@ -0,0 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
output="$(curl -s -S "$1")"
|
||||
echo "$output"
|
||||
test "$output" == "nodejs/express"
|
||||
13
tests/apps/dockerfile-dokku-scale/package.json
Normal file
13
tests/apps/dockerfile-dokku-scale/package.json
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"name": "node-example",
|
||||
"version": "0.0.1",
|
||||
"dependencies": {
|
||||
"express": "2.5.x"
|
||||
},
|
||||
"engines": {
|
||||
"node": "4.2.x"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "false"
|
||||
}
|
||||
}
|
||||
12
tests/apps/dockerfile-dokku-scale/web.js
Normal file
12
tests/apps/dockerfile-dokku-scale/web.js
Normal file
@@ -0,0 +1,12 @@
|
||||
var express = require('express');
|
||||
|
||||
var app = express.createServer(express.logger());
|
||||
|
||||
app.get('/', function(request, response) {
|
||||
response.send('nodejs/express');
|
||||
});
|
||||
|
||||
var port = process.env.PORT || 5000;
|
||||
app.listen(port, function() {
|
||||
console.log("Listening on " + port);
|
||||
});
|
||||
6
tests/apps/dockerfile-dokku-scale/worker.js
Normal file
6
tests/apps/dockerfile-dokku-scale/worker.js
Normal file
@@ -0,0 +1,6 @@
|
||||
function worker() {
|
||||
console.log('sleeping for 60 seconds');
|
||||
setTimeout(worker, 60 * 1000);
|
||||
}
|
||||
|
||||
worker();
|
||||
@@ -134,6 +134,35 @@ teardown() {
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "(ps:scale) dockerfile dokku-scale" {
|
||||
run /bin/bash -c "dokku ps:scale $TEST_APP web=2"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
deploy_app dockerfile-dokku-scale
|
||||
CIDS=""
|
||||
for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.web.*; do
|
||||
CIDS+=$(< $CID_FILE)
|
||||
CIDS+=" "
|
||||
done
|
||||
CIDS_PATTERN=$(echo $CIDS | sed -e "s: :|:g")
|
||||
run /bin/bash -c "docker ps -q --no-trunc | egrep \"$CIDS_PATTERN\" | wc -l | grep 1"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run /bin/bash -c "dokku ps:scale $TEST_APP web=1"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_failure
|
||||
|
||||
run /bin/bash -c "dokku ps:report $TEST_APP --ps-can-scale"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_output "false"
|
||||
}
|
||||
|
||||
@test "(ps) dockerfile with procfile" {
|
||||
deploy_app dockerfile-procfile
|
||||
run /bin/bash -c "dokku ps:stop $TEST_APP"
|
||||
|
||||
Reference in New Issue
Block a user