Exemplo 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()
Exemplo 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()
Exemplo 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
Exemplo 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
Exemplo 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()
Exemplo 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()
Exemplo 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
Exemplo 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()))
Exemplo 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'))
Exemplo 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()
Exemplo 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'
Exemplo 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
Exemplo 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'])
Exemplo 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'
Exemplo 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'))
Exemplo 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
Exemplo 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'
Exemplo 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'])
Exemplo 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
Exemplo 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()
Exemplo 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()))
Exemplo 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'
Exemplo 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()]
Exemplo 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()]