Skip to content

Commit 7912aaf

Browse files
torsavahhorak
authored andcommitted
Add NPM support and tests (sclorg#209)
* Rename virtualenv-uwsgi-test-app so npm tests can be added * Enable npm from the s2i-base-container and add tests for it
1 parent 1b8964a commit 7912aaf

18 files changed

Lines changed: 107 additions & 10 deletions

File tree

2.7/root/opt/app-root/etc/scl_enable

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
# doing. This file is sourced everytime the shell session is opened.
33
# This will make scl collection binaries work out of box.
44
unset BASH_ENV PROMPT_COMMAND ENV
5-
source scl_source enable httpd24 python27
5+
source scl_source enable httpd24 rh-nodejs6 python27
66
source /opt/app-root/bin/activate
File renamed without changes.

2.7/test/virtualenv-uwsgi-test-app/app.sh renamed to 2.7/test/npm-virtualenv-uwsgi-test-app/app.sh

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

3-
# First test virtualenv environment and pip upgrade
3+
# Test virtualenv environment and pip upgrade
44

55
# Get the latest stable version of the package released on PyPI
66
function get_latest_stable_version() {
@@ -37,6 +37,35 @@ done
3737

3838
# Now test the uwsgi server
3939

40+
# Test that npm works correctly
41+
42+
# Create a package.json file so npm doesn't throw off warnings
43+
echo "Initializing npm and testing the installation and use of a module ..."
44+
npm init -y
45+
46+
# mkdirp chosen because it's on the list of 'most depended-upon packages':
47+
# https://www.npmjs.com/browse/depended
48+
npm install mkdirp
49+
if [ $? -ne 0 ]; then
50+
echo "ERROR: Installation of npm module 'mkdirp' failed"
51+
exit 1
52+
fi
53+
54+
# Use the mkdirp module to create a directory and it's subdirectory
55+
node -e "var mkdirp = require('mkdirp'); mkdirp('dir1/dir2')"
56+
if [ $? -ne 0 ]; then
57+
echo "ERROR: Nodejs cannot use the freshly installed 'mkdirp' module."
58+
exit 1
59+
fi
60+
61+
if [ "$(ls dir1)" != "dir2" ]; then
62+
echo "ERROR: The 'mkdirp' module could not create subdirectories at the current path."
63+
exit 1
64+
fi
65+
66+
67+
# Test the uwsgi server
68+
4069
exec uwsgi \
4170
--http-socket :8080 \
4271
--die-on-term \
File renamed without changes.
File renamed without changes.

2.7/test/run

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#
99
IMAGE_NAME=${IMAGE_NAME:-centos/python-27-centos7-candidate}
1010

11-
declare -a WEB_APPS=({standalone,setup,setup-requirements,django,numpy,app-home,virtualenv-uwsgi,locale,mod-wsgi}-test-app)
11+
declare -a WEB_APPS=({standalone,setup,setup-requirements,django,numpy,app-home,npm-virtualenv-uwsgi,locale,mod-wsgi}-test-app)
1212

1313
# TODO: Make command compatible for Mac users
1414
test_dir="$(readlink -zf $(dirname "${BASH_SOURCE[0]}"))"
@@ -175,6 +175,10 @@ test_application() {
175175

176176
test_scl_usage "python --version" "Python 2.7." "${cid_file}"
177177
check_result $?
178+
test_scl_usage "node --version" "^v6." "${cid_file}"
179+
check_result $?
180+
test_scl_usage "npm --version" "^3." "${cid_file}"
181+
check_result $?
178182
test_connection
179183
check_result $?
180184
cleanup_app

3.4/root/opt/app-root/etc/scl_enable

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
# doing. This file is sourced everytime the shell session is opened.
33
# This will make scl collection binaries work out of box.
44
unset BASH_ENV PROMPT_COMMAND ENV
5-
source scl_source enable httpd24 rh-python34
5+
source scl_source enable httpd24 rh-nodejs6 rh-python34
66
source /opt/app-root/bin/activate
File renamed without changes.

3.4/test/virtualenv-uwsgi-test-app/app.sh renamed to 3.4/test/npm-virtualenv-uwsgi-test-app/app.sh

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

3-
# First test virtualenv environment and pip upgrade
3+
# Test virtualenv environment and pip upgrade
44

55
# Get the latest stable version of the package released on PyPI
66
function get_latest_stable_version() {
@@ -37,6 +37,35 @@ done
3737

3838
# Now test the uwsgi server
3939

40+
# Test that npm works correctly
41+
42+
# Create a package.json file so npm doesn't throw off warnings
43+
echo "Initializing npm and testing the installation and use of a module ..."
44+
npm init -y
45+
46+
# mkdirp chosen because it's on the list of 'most depended-upon packages':
47+
# https://www.npmjs.com/browse/depended
48+
npm install mkdirp
49+
if [ $? -ne 0 ]; then
50+
echo "ERROR: Installation of npm module 'mkdirp' failed"
51+
exit 1
52+
fi
53+
54+
# Use the mkdirp module to create a directory and it's subdirectory
55+
node -e "var mkdirp = require('mkdirp'); mkdirp('dir1/dir2')"
56+
if [ $? -ne 0 ]; then
57+
echo "ERROR: Nodejs cannot use the freshly installed 'mkdirp' module."
58+
exit 1
59+
fi
60+
61+
if [ "$(ls dir1)" != "dir2" ]; then
62+
echo "ERROR: The 'mkdirp' module could not create subdirectories at the current path."
63+
exit 1
64+
fi
65+
66+
67+
# Test the uwsgi server
68+
4069
exec uwsgi \
4170
--http-socket :8080 \
4271
--die-on-term \
File renamed without changes.

0 commit comments

Comments
 (0)