I’m a little confused on how self.server.status() works. I thought you did the following:
J = Job()
jid = self.server.submit(J)
js = self.server.status(JOB, id=jid)
js[‘exec_vnode’] would give you the exec_vnode of the job.
Looking around at different tests, I found the get_vnodes() member function of the Job() object. Looking at the PTL code, it picks up the exec_vnode from self.attributes[‘exec_vnode’]. Where is that set? Is it set via a self.server.status() call?
Usually, if I need multiple copies of the same job submitted, I’ll create a job object once and pass it through self.server.submit() multiple times. Is this incorrect practice? Does the job object get used again after submission? If so, I am incorrectly writing my tests.
I appear to be confused. I’d be greatful for any help.
This is quite confusing indeed. It seems that the expect() call is what sets the ‘exec_vnode’ attribute on a Job object. I’m not sure how it happens, my suspicion is that it happens via action functions, but I couldn’t figure out how it was being executed.
But coming to your question of whether you should be using the same Job object for multiple jobs or not, I’d strongly advice against it: the Server object maintains a list of jobs submitted inside ‘self.jobs’, which gets appended with a Job object each time you do a submit(). So, using the same Job object would mean that multiple entries inside ‘self.jobs’ will point to the same job object, which means that functions like expect will modify that object for any of the job ids that it is mapped to. So, the next time you call status() inside your test for any of the job ids which are mapped to the same object, you’ll see unexpected results. That’s probably the most harmless side-effect of this, there could be other, more serious effects as well.
Hey Ravi,
Thanks for your reply. I thought I was being efficient by using the same Job() object over again. I’ll make sure to not do this again. I suspect if I did status on one job at a time, I’d be OK. I definitely think I’d get in trouble if I statused all the jobs. PTL would probably overwrite the same job object multiple times.
I remember that Vincent once told me that expect() will do a status(). This is probably why the Job’s exec_vnode is filled in.
This still leaves the question on the best practice of using status() and J.get_vnodes(). Do you do a status() and then J.get_vnodes() by itself, or do you a s=self.server.status() and J.get_vnodes(s[0][‘exec_vnode’])? It seems confusing that there is two ways to get the same data. One from the Job() object itself, and the other from the return value of status().
I do agree with bhroam that it’s confusing that there are multiple ways of getting the same data. It’s also non-intuitive that PTL keeps track of job objects and modifies them internally. Do you know if there’s a reason why we save the Job object internally? Where all does it get used?
I see. If update_attributes() updates the attributes on the Job() object, then it is not a good idea to use one instance of a Job() object more than once? From the looks of it, the Job() object will updated with the last call to status().
I will keep this in mind for future test writing and code reviews for PTL tests.