|
22 | 22 |
|
23 | 23 | import os
|
24 | 24 | import sys
|
25 |
| -from framework.env import config_opts |
| 25 | +import time |
| 26 | +import logging |
| 27 | +import subprocess |
| 28 | +from framework.env import config_opts, BUILDTEST_ROOT, BUILDTEST_SHELLTYPES, BUILDTEST_JOB_EXTENSION |
| 29 | + |
| 30 | +def check_configuration(): |
| 31 | + """ |
| 32 | + Reports buildtest configuration and checks each BUILDTEST environment variable and check |
| 33 | + for module environment |
| 34 | + """ |
| 35 | + |
| 36 | + BUILDTEST_MODULE_ROOT = config_opts['BUILDTEST_MODULE_ROOT'] |
| 37 | + BUILDTEST_MODULE_NAMING_SCHEME = config_opts['BUILDTEST_MODULE_NAMING_SCHEME'] |
| 38 | + BUILDTEST_TESTDIR = config_opts['BUILDTEST_TESTDIR'] |
| 39 | + BUILDTEST_CONFIGS_REPO = config_opts['BUILDTEST_CONFIGS_REPO'] |
| 40 | + BUILDTEST_PYTHON_REPO = config_opts['BUILDTEST_PYTHON_REPO'] |
| 41 | + BUILDTEST_PERL_REPO = config_opts['BUILDTEST_PERL_REPO'] |
| 42 | + BUILDTEST_R_REPO = config_opts['BUILDTEST_R_REPO'] |
| 43 | + BUILDTEST_RUBY_REPO = config_opts['BUILDTEST_RUBY_REPO'] |
| 44 | + BUILDTEST_TCL_REPO = config_opts['BUILDTEST_TCL_REPO'] |
| 45 | + BUILDTEST_IGNORE_EASYBUILD = config_opts['BUILDTEST_IGNORE_EASYBUILD'] |
| 46 | + BUILDTEST_SHELL = config_opts['BUILDTEST_SHELL'] |
| 47 | + BUILDTEST_JOB_TEMPLATE = config_opts['BUILDTEST_JOB_TEMPLATE'] |
| 48 | + |
| 49 | + #print "Checking buildtest environment variables ..." |
| 50 | + |
| 51 | + ec = 0 |
| 52 | + |
| 53 | + time.sleep(0.1) |
| 54 | + if not os.path.exists(BUILDTEST_ROOT): |
| 55 | + ec = 1 |
| 56 | + print "ERROR: \t BUILDTEST_ROOT: ", BUILDTEST_ROOT, " does not exist" |
| 57 | + |
| 58 | + |
| 59 | + |
| 60 | + time.sleep(0.1) |
| 61 | + if not os.path.exists(BUILDTEST_CONFIGS_REPO): |
| 62 | + ec = 1 |
| 63 | + print "ERROR: \t BUILDTEST_CONFIGS_REPO: ", BUILDTEST_CONFIGS_REPO, " does not exist" |
| 64 | + |
| 65 | + |
| 66 | + time.sleep(0.1) |
| 67 | + for tree in BUILDTEST_MODULE_ROOT: |
| 68 | + if not os.path.exists(tree): |
| 69 | + ec = 1 |
| 70 | + print "ERROR: \t BUILDTEST_MODULE_ROOT:",tree, "does not exists " |
| 71 | + |
| 72 | + |
| 73 | + |
| 74 | + time.sleep(0.1) |
| 75 | + if BUILDTEST_MODULE_NAMING_SCHEME not in ["FNS", "HMNS"]: |
| 76 | + ec = 1 |
| 77 | + print "ERROR: \t BUILDTEST_MODULE_NAMING_SCHEME:", BUILDTEST_MODULE_NAMING_SCHEME, " valid values are {HMNS, FNS}" |
| 78 | + |
| 79 | + time.sleep(0.1) |
| 80 | + |
| 81 | + if BUILDTEST_IGNORE_EASYBUILD not in ["True", "False"]: |
| 82 | + ec = 1 |
| 83 | + print "ERROR: \t BUILDTEST_IGNORE_EASYBUILD:", BUILDTEST_IGNORE_EASYBUILD, " valid values are {True, False} " |
| 84 | + |
| 85 | + time.sleep(0.1) |
| 86 | + if not os.path.exists(BUILDTEST_R_REPO): |
| 87 | + ec = 1 |
| 88 | + print "ERROR: \t BUILDTEST_R_REPO: ", BUILDTEST_R_REPO, " does not exist" |
| 89 | + |
| 90 | + time.sleep(0.1) |
| 91 | + if not os.path.exists(BUILDTEST_PERL_REPO): |
| 92 | + ec = 1 |
| 93 | + print "ERROR: \t BUILDTEST_PERL_REPO: ", BUILDTEST_PERL_REPO, " does not exist" |
| 94 | + |
| 95 | + |
| 96 | + |
| 97 | + time.sleep(0.1) |
| 98 | + if not os.path.exists(BUILDTEST_PYTHON_REPO): |
| 99 | + ec = 1 |
| 100 | + print "ERROR: \t BUILDTEST_PYTHON_REPO: ", BUILDTEST_PYTHON_REPO, " does not exist" |
| 101 | + |
| 102 | + |
| 103 | + time.sleep(0.1) |
| 104 | + if not os.path.exists(BUILDTEST_RUBY_REPO): |
| 105 | + ec = 1 |
| 106 | + print "ERROR: \t BUILDTEST_RUBY_REPO: ", BUILDTEST_RUBY_REPO, " does not exist" |
| 107 | + |
| 108 | + |
| 109 | + |
| 110 | + time.sleep(0.1) |
| 111 | + if not os.path.exists(BUILDTEST_TCL_REPO): |
| 112 | + ec = 1 |
| 113 | + print "ERROR: \t BUILDTEST_TCL_REPO: ", BUILDTEST_TCL_REPO, " does not exist" |
| 114 | + |
| 115 | + |
| 116 | + time.sleep(0.1) |
| 117 | + if BUILDTEST_SHELL not in BUILDTEST_SHELLTYPES: |
| 118 | + ec = 1 |
| 119 | + print "ERROR: \t BUILDTEST_SHELL:", BUILDTEST_SHELL, " not a valid value, must be one of the following:", BUILDTEST_SHELLTYPES |
| 120 | + |
| 121 | + time.sleep(0.1) |
| 122 | + |
| 123 | + |
| 124 | + if not os.path.exists(BUILDTEST_JOB_TEMPLATE): |
| 125 | + ec = 1 |
| 126 | + print "ERROR:\t BUILDTEST_JOB_TEMPLATE: ", BUILDTEST_JOB_TEMPLATE, " does not exist" |
| 127 | + |
| 128 | + time.sleep(0.1) |
| 129 | + |
| 130 | + if os.path.splitext(BUILDTEST_JOB_TEMPLATE)[1] not in BUILDTEST_JOB_EXTENSION: |
| 131 | + print "Invalid file extension:", BUILDTEST_JOB_EXTENSION, ", must be one of the following extension", BUILDTEST_JOB_EXTENSION |
| 132 | + |
| 133 | + time.sleep(0.1) |
| 134 | + |
| 135 | + if ec != 0: |
| 136 | + print "Please fix your BUILDTEST configuration" |
| 137 | + sys.exit(1) |
| 138 | + |
| 139 | + cmd = "module --version" |
| 140 | + ret = subprocess.Popen(cmd,shell=True,stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.PIPE) |
| 141 | + (outputmsg,errormsg) = ret.communicate() |
| 142 | + ec = ret.returncode |
| 143 | + |
| 144 | + if ec != 0: |
| 145 | + print "module commmand not found in system" |
| 146 | + print outputmsg, errormsg |
| 147 | + sys.exit(1) |
26 | 148 |
|
27 | 149 | def show_configuration():
|
28 | 150 | """ show buildtest configuration """
|
|
0 commit comments