On Wed, Apr 25, 2012 at 3:21 PM, Eric Blake <ebl...@redhat.com> wrote: > On 04/25/2012 07:17 AM, Stefan Hajnoczi wrote: >> Add tests to exercise the InvalidParameter 'speed' error code path, as >> well as the regular success case for setting the speed. The >> block-stream 'speed' parameter allows the speed limit of the job to be >> applied immediately when the job starts instead of issuing a separate >> block-job-set-speed command later. If the parameter has an invalid >> value we expect to get an error and the job is not created. >> >> It turns out that cancelling a block job is a common operation in these >> test cases, let's extract a cancel_and_wait() function instead of >> duplicating the QMP commands. >> >> Signed-off-by: Stefan Hajnoczi <stefa...@linux.vnet.ibm.com> >> Acked-by: Kevin Wolf <kw...@redhat.com> >> --- > >> + >> + def test_set_speed_invalid(self): >> self.assert_no_active_streams() >> >> + result = self.vm.qmp('block-stream', device='drive0', speed=2 * >> 1024 * 1024) >> + self.assert_qmp(result, {}) >> + >> + self.assert_no_active_streams() >> + >> + result = self.vm.qmp('block-stream', device='drive0') >> + self.assert_qmp(result, 'return', {}) >> + >> + result = self.vm.qmp('block-job-set-speed', device='drive0', >> speed=-1) >> + self.assert_qmp(result, 'error/class', 'InvalidParameter') >> + self.assert_qmp(result, 'error/data/name', 'speed') >> + >> + self.cancel_and_wait() >> + >> + def test_set_speed_invalid(self): > > Duplicate def test_set_speed_invalid. Bad copy-and-paste issue? The > first one looks bogus, the second one looks correct.
Hmm...not my finest patch series. I made a mess, it was indeed a copy paste error. Interestingly the tests still passed :). I'm sending a new revision that fixes this. There are three cases for set speed: 1. A throughput performance test which is not automatically run (because it takes several seconds to complete and is really only good for testing throttling). 2. A success case test that makes sure query-block-jobs reports the speed that we set. 3. A failure case for InvalidParameter. Stefan