#! /usr/bin/env perl
##**************************************************************
##
## Copyright (C) 1990-2007, Condor Team, Computer Sciences Department,
## University of Wisconsin-Madison, WI.
## 
## Licensed under the Apache License, Version 2.0 (the "License"); you
## may not use this file except in compliance with the License.  You may
## obtain a copy of the License at
## 
##    http://www.apache.org/licenses/LICENSE-2.0
## 
## Unless required by applicable law or agreed to in writing, software
## distributed under the License is distributed on an "AS IS" BASIS,
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
## See the License for the specific language governing permissions and
## limitations under the License.
##
##**************************************************************

use CondorTest;
use CondorUtils;
use Check::SimpleJob;

#testreq: personal
my $config = <<'CONDOR_TESTREQ_CONFIG';
  JOB_ROUTER_DEFAULTS = \
  [ \
    requirements=target.WantJobRouter is True; \
    delete_WantJobRouter = true; \
    set_requirements = true; \
  ]

  JOB_ROUTER_ENTRIES = \
   [ TargetUniverse = 12; \
     name = "Site 1"; \
   ]

  DAEMON_LIST = MASTER, SCHEDD, JOB_ROUTER, COLLECTOR, NEGOTIATOR
  SCHEDD_DEBUG = $(SCHEDD_DEBUG) D_FULLDEBUG D_COMMAND:1 D_CAT D_SUB_SECOND
  JOB_ROUTER_DEBUG = $(JOB_ROUTER_DEBUG) D_FULLDEBUG D_COMMAND:1 D_CAT D_SUB_SECOND

  JOB_ROUTER_POLLING_PERIOD = 10
CONDOR_TESTREQ_CONFIG
#endtestreq

# We submit a vanilla job with requirements=false and no startd,
# so we can be pretty sure that if it runs, it went through the job router
# and got transformed into a local universe job.
my $append_submit_commands = '
  +WantJobRouter = true
  requirements = false
';

if(is_windows()) {
	SimpleJob::RunCheck(
		runthis=>"sleep.exe",
		universe=>"local",
    	append_submit_commands=>$append_submit_commands,
);
} else {
	SimpleJob::RunCheck(
		universe=>"local",
    	append_submit_commands=>$append_submit_commands,
);
}

CondorTest::EndTest();
