abalakh / airgun

Airgun moved to https://github.com/SatelliteQE/airgun
https://github.com/SatelliteQE/airgun
1 stars 2 forks source link

nested sessions does not seem to work #21

Closed jhutar closed 6 years ago

jhutar commented 6 years ago

Having this test:

def test_unpriviledged_user_delete(session, test_name):
    name = gen_string('alpha')
    major = gen_string('numeric', 1)
    entities.OperatingSystem(name=name, major=major).create()
    login = gen_string('alpha')
    password = gen_string('alpha')
    roles = entities.Role().search(query={'search': 'name="Viewer"'})
    assert len(roles) == 1
    entities.User(login=login, password=password, role=roles).create()
    import time

    with session as admin_session:
        assert admin_session.operatingsystem.search(name) == '{} {}'.format(name, major)
    with Session(test_name, login, password) \
        as unpriviledged_session:
        unpriviledged_session.operatingsystem.search(name)
        with pytest.raises(NoSuchElementException):
            unpriviledged_session.operatingsystem.delete(name)
        unpriviledged_session.operatingsystem.search(name)
    with session as admin_session:
        assert admin_session.operatingsystem.search(name) == '{} {}'.format(name, major)

    current = entities.OperatingSystem(name=name).search()[0]
    entities.OperatingSystem(id=current.id).delete()

but same thing when the sessions are nested, it does not work:

    with session as admin_session:
        assert admin_session.operatingsystem.search(name) == '{} {}'.format(name, major)
        with Session(test_name, login, password) \
            as unpriviledged_session:
            unpriviledged_session.operatingsystem.search(name)
            with pytest.raises(NoSuchElementException):
                unpriviledged_session.operatingsystem.delete(name)
            unpriviledged_session.operatingsystem.search(name)
        assert admin_session.operatingsystem.search(name) == '{} {}'.format(name, major)
jhutar commented 6 years ago
`[Errno 32] Broken pipe` and `[Errno 111] Connection refused` in logs are root cause. is sat still accessible for you? if yes, then it's probably a bug in handling multiple sessions at the same time, i'll look at that later quick suggestion is to try the same scenario without nested sessions - unpriviledged_session, then admin session if that case will work - definitely a bug in nested sessions
jhutar commented 6 years ago

Log: nested-sessions.log