Skip to content

stopRun method doesn’t work in separate sessions #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
patrickdaj opened this issue May 4, 2020 · 2 comments
Open

stopRun method doesn’t work in separate sessions #1

patrickdaj opened this issue May 4, 2020 · 2 comments

Comments

@patrickdaj
Copy link

testmodel.stopRun method hangs when run in a different bps_restpy session than the testmodel.run. The test does stop but the python API just hangs infinitely. This is pretty useful when you are automating long running tests to split the start and stop between multiple scripts.

from bps_restpy.bps import BPS

bps = BPS(host, user, password)

bps.login()

Successfully connected to x.x.x.x.

Login successful.

Welcome user.

Your session id is 5d180626-49ac-4cf3-b694-1b5b4b229fe2

bps.testmodel.run(modelname='test', group=10)

Out[6]: {'host': '127.0.0.1', 'name': 'test', 'iteration': 30, 'runid': 96}

bps.testmodel.stopRun(96)

Out[7]: b'canceled'

bps.testmodel.run(modelname='test', group=10)

Out[8]: {'host': '127.0.0.1', 'name': 'test', 'iteration': 31, 'runid': 97}

bps.logout()

Logout successful.

Bye user.

Successfully disconnected from x.x.x.x.

bps.login()

Successfully connected to x.x.x.x.

Login successful.

Welcome user.

Your session id is aee3511f-dbed-4de5-a4f1-c9f7179f920d

bps.testmodel.stopRun(97)

The last stopRun call just hangs infinitely. Above when the stopRun was done in the same session it completed with a response of b’canceled’.

@patrickdaj
Copy link
Author

Was this ever fixed?

@nutu
Copy link
Collaborator

nutu commented Sep 28, 2020

Was this ever fixed?
Hi Patrick,
We are working on fixing this in the next 9.10 Patch build that is targeted to be released in the next couple of weeks.
Thanks for bringing it to our attention.

Until then you can use this function as a workarround:

import json

def stopTest(testid, bps):
        testid = "TEST-%s" % testid
        service = 'https://' + bps.host + '/api/v1/bps/tests/operations/stop'
        jheaders = {'content-type': 'application/json'}
        jdata = json.dumps({'testid':testid})
        r = bps.session.post(service, data=jdata, headers=jheaders, verify=False)
        if(r.status_code == 200):
            print('Test: [' + testid + '] has been successfully stopped.')
        else:
            print('Some error occurred while cancelling the running test: [' + testid + ']')


# example ussage 
from bps_restpy.bps import BPS,pp

bps = BPS(bps_system, bpsuser, bpspass)
bps.login()

testid = 97

stopTest(testid, bps)

bps.logout()

Regards,
Constantin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants