run-tests.sh now requires a minimal config.yml with database information.
Remove database.yml from run-tests.sh
Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <pamstutz@veritasgenetics.com>
setup_ruby_environment
if [[ -s "$CONFIGSRC/config.yml" ]] ; then
+ echo "Getting database configuration from $CONFIGSRC/config.yml"
cp "$CONFIGSRC/config.yml" "$temp/test-config.yml"
- export ARVADOS_CONFIG="$temp/test-config.yml"
else
if [[ -s /etc/arvados/config.yml ]] ; then
+ echo "Getting database configuration from /etc/arvados/config.yml"
python > "$temp/test-config.yml" <<EOF
import yaml
import json
v['Connection']['dbname'] = 'arvados_test'
print(json.dumps({"Clusters": { "zzzzz": {'PostgreSQL': v}}}))
EOF
- export ARVADOS_CONFIG="$temp/test-config.yml"
else
- if [[ ! -f "$WORKSPACE/services/api/config/database.yml" ]]; then
- fatal "Please provide a database.yml file for the test suite"
- fi
+ fatal "Please provide a config.yml file for the test suite in CONFIGSRC or /etc/arvados"
fi
fi
+ export ARVADOS_CONFIG="$temp/test-config.yml"
echo "PATH is $PATH"
}
rm -f config/environments/test.rb
cp config/environments/test.rb.example config/environments/test.rb
- if [ -n "$CONFIGSRC" ]
- then
- for f in database.yml
- do
- cp "$CONFIGSRC/$f" config/ || fatal "$f"
- done
- fi
-
# Clear out any lingering postgresql connections to the test
# database, so that we can drop it. This assumes the current user
# is a postgresql superuser.
cd "$WORKSPACE/services/api" \
- && test_database=$(python -c "import yaml; print yaml.safe_load(file('config/database.yml'))['test']['database']") \
+ && test_database=$(python -c "import yaml; print yaml.safe_load(file('$ARVADOS_CONFIG'))['Clusters']['zzzzz']['PostgreSQL']['Connection']['dbname']") \
&& psql "$test_database" -c "SELECT pg_terminate_backend (pg_stat_activity.pid::int) FROM pg_stat_activity WHERE pg_stat_activity.datname = '$test_database';" 2>/dev/null
mkdir -p "$WORKSPACE/services/api/tmp/pids"
}
// update config using values from an old-style keepstore config file.
-func (ldr *Loader) loadOldKeepstoreConfig(cfg *arvados.Config, required bool) error {
+func (ldr *Loader) loadOldKeepstoreConfig(cfg *arvados.Config) error {
var oc oldKeepstoreConfig
err := ldr.loadOldConfigHelper("keepstore", ldr.KeepstorePath, &oc)
- if os.IsNotExist(err) && !required {
+ if os.IsNotExist(err) && (ldr.KeepstorePath == defaultKeepstoreConfigPath) {
return nil
} else if err != nil {
return err
}
// update config using values from an crunch-dispatch-slurm config file.
-func (ldr *Loader) loadOldCrunchDispatchSlurmConfig(cfg *arvados.Config, required bool) error {
+func (ldr *Loader) loadOldCrunchDispatchSlurmConfig(cfg *arvados.Config) error {
var oc oldCrunchDispatchSlurmConfig
err := ldr.loadOldConfigHelper("crunch-dispatch-slurm", ldr.CrunchDispatchSlurmPath, &oc)
- if os.IsNotExist(err) && !required {
+ if os.IsNotExist(err) && (ldr.CrunchDispatchSlurmPath == defaultCrunchDispatchSlurmConfigPath) {
return nil
} else if err != nil {
return err
const defaultWebsocketConfigPath = "/etc/arvados/ws/ws.yml"
// update config using values from an crunch-dispatch-slurm config file.
-func (ldr *Loader) loadOldWebsocketConfig(cfg *arvados.Config, required bool) error {
+func (ldr *Loader) loadOldWebsocketConfig(cfg *arvados.Config) error {
var oc oldWsConfig
err := ldr.loadOldConfigHelper("arvados-ws", ldr.WebsocketPath, &oc)
- if os.IsNotExist(err) && !required {
+ if os.IsNotExist(err) && ldr.WebsocketPath == defaultWebsocketConfigPath {
return nil
} else if err != nil {
return err
CrunchDispatchSlurmPath string
WebsocketPath string
- // Legacy config file for the current component (will be the
- // same as one of the above files). If set, not being able to
- // load the 'main' config.yml will not be a fatal error, but
- // the the legacy file will be required instead.
- LegacyComponentConfig string
-
configdata []byte
}
if ldr.configdata == nil {
buf, err := ldr.loadBytes(ldr.Path)
if err != nil {
- if ldr.LegacyComponentConfig != "" && os.IsNotExist(err) && !ldr.SkipDeprecated {
- buf = []byte(`Clusters: {zzzzz: {}}`)
- } else {
- return nil, err
- }
+ return nil, err
}
ldr.configdata = buf
}
- noConfigLoaded := bytes.Compare(ldr.configdata, []byte(`Clusters: {zzzzz: {}}`)) == 0
// Load the config into a dummy map to get the cluster ID
// keys, discarding the values; then set up defaults for each
// * no primary config was loaded, and this is the
// legacy config file for the current component
for _, err := range []error{
- ldr.loadOldKeepstoreConfig(&cfg, (ldr.KeepstorePath != defaultKeepstoreConfigPath) ||
- (noConfigLoaded && ldr.LegacyComponentConfig == ldr.KeepstorePath)),
-
- ldr.loadOldCrunchDispatchSlurmConfig(&cfg, (ldr.CrunchDispatchSlurmPath != defaultCrunchDispatchSlurmConfigPath) ||
- (noConfigLoaded && ldr.LegacyComponentConfig == ldr.CrunchDispatchSlurmPath)),
-
- ldr.loadOldWebsocketConfig(&cfg, (ldr.WebsocketPath != defaultWebsocketConfigPath) ||
- (noConfigLoaded && ldr.LegacyComponentConfig == ldr.WebsocketPath)),
+ ldr.loadOldKeepstoreConfig(&cfg),
+ ldr.loadOldCrunchDispatchSlurmConfig(&cfg),
+ ldr.loadOldWebsocketConfig(&cfg),
} {
if err != nil {
return nil, err
disp.logger.Printf("crunch-dispatch-slurm %s started", version)
- loader.LegacyComponentConfig = loader.CrunchDispatchSlurmPath
cfg, err := loader.Load()
if err != nil {
return err
return nil
}
- loader.LegacyComponentConfig = loader.WebsocketPath
cfg, err := loader.Load()
if err != nil {
log.Fatal(err)
func (*serverSuite) testConfig() (*arvados.Cluster, error) {
ldr := config.NewLoader(nil, nil)
- ldr.LegacyComponentConfig = "ws-test"
cfg, err := ldr.Load()
if err != nil {
return nil, err