예제 #1
0
def test_submit_if_needed_notactive():
    _set_host_config("nohost")
    db = _set_database(0, 1, 0, 0)
    submitter = MockSubmitter(db)
    job = simcity.submit_if_needed("nohost", 2, submitter=submitter)
    assert_not_equal(job, None)
    assert_equal(job["batch_id"], MockSubmitter.BATCH_ID)
    assert_equal(job["hostname"], "nohost")
    assert_equal(job["method"], "local")
예제 #2
0
# 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.

'''
Start a new job on the infrastructure to process the tasks.
'''
from __future__ import print_function
import simcity
import argparse

if __name__ == '__main__':
    parser = argparse.ArgumentParser(description="Start a new job on the "
                                     "infrastructure to process the tasks.")
    parser.add_argument('host', help="host to run pilot job on")
    parser.add_argument('-m', '--max', default=2,
                        help="only run if there are less than MAX jobs "
                        "running")
    parser.add_argument('-c', '--config', default=None,
                        help="configuration file")
    args = parser.parse_args()

    simcity.init(config=args.config)

    job = simcity.submit_if_needed(args.host, args.max)
    if job is None:
        print("No tasks to process or already %d jobs running (increase "
              "maximum number of jobs with -m)" % args.max)
    else:
        print("Job %s (ID: %s) started" % (job['batch_id'], job.id))
예제 #3
0
def test_submit_if_needed_notreallyactive():
    _set_host_config("nohost")
    db = _set_database(0, 1, 5, 0)
    submitter = MockSubmitter(db)
    job = simcity.submit_if_needed("nohost", 2, submitter=submitter)
    assert_not_equal(job, None)
예제 #4
0
def test_submit_if_needed_maxed():
    _set_database(2, 5, 2, 0)
    assert_equal(simcity.submit_if_needed("nohost", 2), None)
예제 #5
0
def test_submit_if_needed_pending():
    _set_database(0, 1, 0, 1)
    assert_equal(simcity.submit_if_needed("nohost", 2), None)
예제 #6
0
def test_submit_if_needed_already_active():
    _set_database(1, 1, 1, 0)
    assert_equal(simcity.submit_if_needed("nohost", 2), None)