Skip to content

Commit 2367e1f

Browse files
committed
Manually merged PR77 (part II); missing envhelp and Makefile changes
git-svn-id: svn+ssh://svn.code.sf.net/p/migrid/code/trunk@6098 b75ad72c-e7d7-11dd-a971-7dbc132099af
1 parent a093e66 commit 2367e1f

File tree

5 files changed

+195
-3
lines changed

5 files changed

+195
-3
lines changed

Makefile

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,23 @@ distclean: clean
4040
@rm -f ./tests/*.pyc
4141

4242
.PHONY: test
43-
test: dependencies
43+
test: dependencies testconfig
4444
@$(PYTHON_BIN) -m unittest discover -s tests/
4545

4646
.PHONY: dependencies
4747
dependencies: ./envhelp/venv/pyvenv.cfg ./envhelp/py3.depends
4848

49+
.PHONY: testconfig
50+
testconfig: ./envhelp/output/testconfs
51+
52+
./envhelp/output/testconfs:
53+
@echo "generating test configuration"
54+
@./envhelp/makeconfig test --python2
55+
@./envhelp/makeconfig test
56+
@mkdir -p ./envhelp/output/certs
57+
@mkdir -p ./envhelp/output/state
58+
@mkdir -p ./envhelp/output/state/log
59+
4960
ifeq ($(MIG_ENV),'local')
5061
./envhelp/py3.depends: $(REQS_PATH) local-requirements.txt
5162
else

envhelp/makeconfig

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/sh
2+
#
3+
# --- BEGIN_HEADER ---
4+
#
5+
# makeconfig - standalone wrapper for generating a test configuration.
6+
# Copyright (C) 2003-2024 The MiG Project by the Science HPC Center at UCPH
7+
#
8+
# This file is part of MiG.
9+
#
10+
# MiG is free software: you can redistribute it and/or modify
11+
# it under the terms of the GNU General Public License as published by
12+
# the Free Software Foundation; either version 2 of the License, or
13+
# (at your option) any later version.
14+
#
15+
# MiG is distributed in the hope that it will be useful,
16+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
17+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18+
# GNU General Public License for more details.
19+
#
20+
# You should have received a copy of the GNU General Public License
21+
# along with this program; if not, write to the Free Software
22+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
23+
# USA.
24+
#
25+
# --- END_HEADER ---
26+
#
27+
28+
set -e
29+
30+
SCRIPT_PATH=$(realpath "$0")
31+
SCRIPT_BASE=$(dirname -- "$SCRIPT_PATH")
32+
MIG_BASE=$(realpath "$SCRIPT_BASE/..")
33+
PYTHON_BIN=${PYTHON_BIN:-"$SCRIPT_BASE/venv/bin/python3"}
34+
PY=${PY:-'3'}
35+
36+
# default PYTHONPATH such that importing files in the repo "just works"
37+
PYTHONPATH=${PYTHONPATH:-"$MIG_BASE"}
38+
39+
# default any variables for local development
40+
MIG_ENV=${MIG_ENV:-'local'}
41+
42+
MIG_ENV="$MIG_ENV" PY="$PY" "$PYTHON_BIN" "$SCRIPT_BASE/makeconfig.py" "$@"

envhelp/makeconfig.py

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# -*- coding: utf-8 -*-
2+
#
3+
# --- BEGIN_HEADER ---
4+
#
5+
# makeconfig.py - standalone test configuration generation
6+
# Copyright (C) 2003-2024 The MiG Project by the Science HPC Center at UCPH
7+
#
8+
# This file is part of MiG.
9+
#
10+
# MiG is free software: you can redistribute it and/or modify
11+
# it under the terms of the GNU General Public License as published by
12+
# the Free Software Foundation; either version 2 of the License, or
13+
# (at your option) any later version.
14+
#
15+
# MiG is distributed in the hope that it will be useful,
16+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
17+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18+
# GNU General Public License for more details.
19+
#
20+
# You should have received a copy of the GNU General Public License
21+
# along with this program; if not, write to the Free Software
22+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
23+
# USA.
24+
#
25+
# --- END_HEADER ---
26+
#
27+
28+
"""Standalone test configuration generation."""
29+
30+
31+
from __future__ import print_function
32+
33+
import os
34+
import sys
35+
36+
sys.path.append(os.path.realpath(
37+
os.path.join(os.path.dirname(__file__), "..")))
38+
39+
from mig.shared.install import generate_confs
40+
41+
_ENVHELP_OUTPUT_DIR = os.path.realpath(
42+
os.path.join(os.path.dirname(__file__), "output"))
43+
_MAKECONFIG_ALLOWED = ["local", "test"]
44+
_PYTHON_MAJOR = os.environ.get('PY', '3')
45+
46+
47+
def _at(sequence, index=-1, default=None):
48+
assert index > -1
49+
try:
50+
return sequence[index]
51+
except IndexError:
52+
return default
53+
54+
55+
def write_testconfig(env_name, is_py2=False):
56+
confs_name = 'confs' if env_name == 'local' else '%sconfs' % (env_name,)
57+
overrides = {
58+
'destination': os.path.join(_ENVHELP_OUTPUT_DIR, confs_name),
59+
'destination_suffix': "-py%s" % ('2' if is_py2 else '3',),
60+
}
61+
if is_py2:
62+
overrides.update(**{
63+
'mig_code': '/usr/src/app/mig',
64+
'mig_certs': '/usr/src/app/envhelp/output/certs',
65+
'mig_state': '/usr/src/app/envhelp/output/state',
66+
})
67+
generate_confs(_ENVHELP_OUTPUT_DIR, **overrides)
68+
69+
70+
def main_(argv):
71+
env_name = _at(argv, index=1, default='')
72+
arg_is_py2 = '--python2' in argv
73+
74+
if env_name == '':
75+
raise RuntimeError(
76+
'expected the environment name as a single argument')
77+
if env_name not in _MAKECONFIG_ALLOWED:
78+
raise RuntimeError('environment must be one of %s' %
79+
(_MAKECONFIG_ALLOWED,))
80+
81+
write_testconfig(env_name, is_py2=arg_is_py2)
82+
83+
84+
def main(argv=sys.argv):
85+
try:
86+
main_(argv)
87+
except RuntimeError as e:
88+
print('makeconfig: %s' % (str(e),))
89+
exit(1)
90+
91+
92+
if __name__ == '__main__':
93+
main()

envhelp/python2

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,29 @@
11
#!/bin/sh
22
#
3-
# Wrap python2 docker container for testing
3+
# --- BEGIN_HEADER ---
4+
#
5+
# python2 - wrap python2 docker container for testing
6+
# Copyright (C) 2003-2024 The MiG Project by the Science HPC Center at UCPH
7+
#
8+
# This file is part of MiG.
9+
#
10+
# MiG is free software: you can redistribute it and/or modify
11+
# it under the terms of the GNU General Public License as published by
12+
# the Free Software Foundation; either version 2 of the License, or
13+
# (at your option) any later version.
14+
#
15+
# MiG is distributed in the hope that it will be useful,
16+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
17+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18+
# GNU General Public License for more details.
19+
#
20+
# You should have received a copy of the GNU General Public License
21+
# along with this program; if not, write to the Free Software
22+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
23+
# USA.
24+
#
25+
# --- END_HEADER ---
26+
#
427

528
set -e
629

envhelp/python3

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,29 @@
11
#!/bin/sh
22
#
3-
# Wrap python3 virtual environment for testing
3+
# --- BEGIN_HEADER ---
4+
#
5+
# python3 - wrap python3 virtual environment for testing
6+
# Copyright (C) 2003-2024 The MiG Project by the Science HPC Center at UCPH
7+
#
8+
# This file is part of MiG.
9+
#
10+
# MiG is free software: you can redistribute it and/or modify
11+
# it under the terms of the GNU General Public License as published by
12+
# the Free Software Foundation; either version 2 of the License, or
13+
# (at your option) any later version.
14+
#
15+
# MiG is distributed in the hope that it will be useful,
16+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
17+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18+
# GNU General Public License for more details.
19+
#
20+
# You should have received a copy of the GNU General Public License
21+
# along with this program; if not, write to the Free Software
22+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
23+
# USA.
24+
#
25+
# --- END_HEADER ---
26+
#
427

528
set -e
629

0 commit comments

Comments
 (0)