Esempio n. 1
0
def test_worker_death_sets_status(redis):
    """Set worker status to IDLE."""

    yield from worker_birth(redis, 'foo', ['bar', 'baz'])
    yield from worker_death(redis, 'foo')
    status = yield from redis.hget(worker_key('foo'), 'status')
    assert status == WorkerStatus.IDLE.encode()
Esempio n. 2
0
def test_worker_death_sets_status(redis):
    """Set worker status to IDLE."""

    yield from worker_birth(redis, 'foo', ['bar', 'baz'])
    yield from worker_death(redis, 'foo')
    status = yield from redis.hget(worker_key('foo'), 'status')
    assert status == WorkerStatus.IDLE.encode()
Esempio n. 3
0
def test_worker_death_sets_death_date(redis):
    """Set worker death date."""

    yield from worker_birth(redis, 'foo', ['bar', 'baz'])
    yield from worker_death(redis, 'foo')
    death = utcformat(utcnow()).encode()
    assert (yield from redis.hget(worker_key('foo'), 'death')) == death
Esempio n. 4
0
def test_worker_death_sets_death_date(redis):
    """Set worker death date."""

    yield from worker_birth(redis, 'foo', ['bar', 'baz'])
    yield from worker_death(redis, 'foo')
    death = utcformat(utcnow()).encode()
    assert (yield from redis.hget(worker_key('foo'), 'death')) == death
Esempio n. 5
0
def test_worker_shutdown_requested(redis):
    """Set worker shutdown requested date."""

    yield from worker_birth(redis, 'foo', ['bar', 'baz'])
    yield from worker_shutdown_requested(redis, 'foo')
    shutdown = yield from redis.hget(
        worker_key('foo'), 'shutdown_requested_date')
    assert shutdown == utcformat(utcnow()).encode()
Esempio n. 6
0
def test_worker_shutdown_requested(redis):
    """Set worker shutdown requested date."""

    yield from worker_birth(redis, 'foo', ['bar', 'baz'])
    yield from worker_shutdown_requested(redis, 'foo')
    shutdown = yield from redis.hget(worker_key('foo'),
                                     'shutdown_requested_date')
    assert shutdown == utcformat(utcnow()).encode()
Esempio n. 7
0
def test_worker_death_sets_worker_ttl(redis):
    """Set worker hash ttl."""

    yield from worker_birth(redis, 'foo', ['bar', 'baz'])
    yield from worker_death(redis, 'foo')
    assert (yield from redis.ttl(worker_key('foo'))) == 60
Esempio n. 8
0
def test_worker_death_workers_set(redis):
    """Remove worker from workers set."""

    yield from worker_birth(redis, 'foo', ['bar', 'baz'])
    yield from worker_death(redis, 'foo')
    assert not (yield from redis.smembers(workers_key()))
Esempio n. 9
0
def test_worker_birth_removes_old_hash(redis):
    """Remove old hash stored from the previous run."""

    yield from redis.hmset(worker_key('foo'), 'bar', 'baz', 'death', 0)
    yield from worker_birth(redis, 'foo', ['bar', 'baz'])
    assert not (yield from redis.hget(worker_key('foo'), 'bar'))
Esempio n. 10
0
def test_worker_birth_worker_status(redis):
    """Register birth sets worker status to STARTED."""

    yield from worker_birth(redis, 'foo', ['bar', 'baz'])
    status = yield from redis.hget(worker_key('foo'), 'status')
    assert status == WorkerStatus.STARTED.encode()
Esempio n. 11
0
def test_worker_birth_current_job(redis):
    """Signify that aiorq doesn't support current_job worker attribute."""

    yield from worker_birth(redis, 'foo', ['bar', 'baz'])
    current_job = yield from redis.hget(worker_key('foo'), 'current_job')
    assert current_job == b'not supported'
Esempio n. 12
0
def test_worker_birth_sets_custom_worker_ttl(redis):
    """Set custom worker ttl."""

    yield from worker_birth(redis, 'foo', ['bar', 'baz'], 1000)
    assert (yield from redis.ttl(worker_key('foo'))) == 1000
Esempio n. 13
0
def test_worker_birth_fail_worker_exists(redis):
    """Register birth will fail with worker which already exists."""

    yield from redis.hset(worker_key('foo'), 'bar', 'baz')
    with pytest.raises(ValueError):
        yield from worker_birth(redis, 'foo', ['bar', 'baz'])
Esempio n. 14
0
def test_worker_birth_sets_queue_names(redis):
    """Set worker queue names."""

    yield from worker_birth(redis, 'foo', ['bar', 'baz'])
    assert (yield from redis.hget(worker_key('foo'), 'queues')) == b'bar,baz'
Esempio n. 15
0
def test_worker_birth_removes_old_hash(redis):
    """Remove old hash stored from the previous run."""

    yield from redis.hmset(worker_key('foo'), 'bar', 'baz', 'death', 0)
    yield from worker_birth(redis, 'foo', ['bar', 'baz'])
    assert not (yield from redis.hget(worker_key('foo'), 'bar'))
Esempio n. 16
0
def test_worker_birth_sets_custom_worker_ttl(redis):
    """Set custom worker ttl."""

    yield from worker_birth(redis, 'foo', ['bar', 'baz'], 1000)
    assert (yield from redis.ttl(worker_key('foo'))) == 1000
Esempio n. 17
0
def test_worker_birth_sets_queue_names(redis):
    """Set worker queue names."""

    yield from worker_birth(redis, 'foo', ['bar', 'baz'])
    assert (yield from redis.hget(worker_key('foo'), 'queues')) == b'bar,baz'
Esempio n. 18
0
def test_worker_birth_fail_worker_exists(redis):
    """Register birth will fail with worker which already exists."""

    yield from redis.hset(worker_key('foo'), 'bar', 'baz')
    with pytest.raises(ValueError):
        yield from worker_birth(redis, 'foo', ['bar', 'baz'])
Esempio n. 19
0
def test_worker_death_sets_worker_ttl(redis):
    """Set worker hash ttl."""

    yield from worker_birth(redis, 'foo', ['bar', 'baz'])
    yield from worker_death(redis, 'foo')
    assert (yield from redis.ttl(worker_key('foo'))) == 60
Esempio n. 20
0
def test_worker_birth_worker_status(redis):
    """Register birth sets worker status to STARTED."""

    yield from worker_birth(redis, 'foo', ['bar', 'baz'])
    status = yield from redis.hget(worker_key('foo'), 'status')
    assert status == WorkerStatus.STARTED.encode()
Esempio n. 21
0
def test_worker_death_workers_set(redis):
    """Remove worker from workers set."""

    yield from worker_birth(redis, 'foo', ['bar', 'baz'])
    yield from worker_death(redis, 'foo')
    assert not (yield from redis.smembers(workers_key()))
Esempio n. 22
0
def test_worker_birth_current_job(redis):
    """Signify that aiorq doesn't support current_job worker attribute."""

    yield from worker_birth(redis, 'foo', ['bar', 'baz'])
    current_job = yield from redis.hget(worker_key('foo'), 'current_job')
    assert current_job == b'not supported'
Esempio n. 23
0
def test_worker_birth_workers_set(redis):
    """Add worker to the workers set."""

    yield from worker_birth(redis, 'foo', ['bar', 'baz'])
    assert (yield from
            redis.smembers(workers_key())) == [worker_key('foo').encode()]
Esempio n. 24
0
def test_worker_birth_workers_set(redis):
    """Add worker to the workers set."""

    yield from worker_birth(redis, 'foo', ['bar', 'baz'])
    assert (yield from redis.smembers(workers_key())) == [worker_key('foo').encode()]