#!/usr/bin/env python
#
# Tests for IO throttling
#
# Copyright (C) 2015 Red Hat, Inc.
# Copyright (C) 2015-2016 Igalia, S.L.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#

import iotests

nsec_per_sec = 1000000000

class ThrottleTestCase(iotests.QMPTestCase):
    test_driver = "null-aio"
    max_drives = 3

    def blockstats(self, device):
        result = self.vm.qmp("query-blockstats")
        for r in result['return']:
            if r['device'] == device:
                stat = r['stats']
                return stat['rd_bytes'], stat['rd_operations'], stat['wr_bytes'], stat['wr_operations']
        raise Exception("Device not found for blockstats: %s" % device)

    def required_drivers(self):
        return [self.test_driver]

    @iotests.skip_if_unsupported(required_drivers)
    def setUp(self):
        self.vm = iotests.VM()
        for i in range(0, self.max_drives):
            self.vm.add_drive(self.test_driver + "://", "file.read-zeroes=on")
        self.vm.launch()

    def tearDown(self):
        self.vm.shutdown()

    def configure_throttle(self, ndrives, params):
        params['group'] = 'test'

        # Set the I/O throttling parameters to all drives
        for i in range(0, ndrives):
            params['device'] = 'drive%d' % i
            result = self.vm.qmp("block_set_io_throttle", conv_keys=False, **params)
            self.assert_qmp(result, 'return', {})

    def do_test_throttle(self, ndrives, seconds, params, first_drive = 0):
        def check_limit(limit, num):
            # IO throttling algorithm is discrete, allow 10% error so the test
            # is more robust
            return limit == 0 or \
                   (num < seconds * limit * 1.1 / ndrives
                   and num > seconds * limit * 0.9 / ndrives)

        # Set vm clock to a known value
        ns = seconds * nsec_per_sec
        self.vm.qtest("clock_step %d" % ns)

        # Submit enough requests so the throttling mechanism kicks
        # in. The throttled requests won't be executed until we
        # advance the virtual clock.
        rq_size = 512
        rd_nr = max(params['bps'] // rq_size // 2,
                    params['bps_rd'] // rq_size,
                    params['iops'] // 2,
                    params['iops_rd'])
        rd_nr *= seconds * 2
        rd_nr //= ndrives
        wr_nr = max(params['bps'] // rq_size // 2,
                    params['bps_wr'] // rq_size,
                    params['iops'] // 2,
                    params['iops_wr'])
        wr_nr *= seconds * 2
        wr_nr //= ndrives

        # Send I/O requests to all drives
        for i in range(rd_nr):
            for drive in range(0, ndrives):
                idx = first_drive + drive
                self.vm.hmp_qemu_io("drive%d" % idx, "aio_read %d %d" %
                                    (i * rq_size, rq_size))

        for i in range(wr_nr):
            for drive in range(0, ndrives):
                idx = first_drive + drive
                self.vm.hmp_qemu_io("drive%d" % idx, "aio_write %d %d" %
                                    (i * rq_size, rq_size))

        # We'll store the I/O stats for each drive in these arrays
        start_rd_bytes = [0] * ndrives
        start_rd_iops  = [0] * ndrives
        start_wr_bytes = [0] * ndrives
        start_wr_iops  = [0] * ndrives
        end_rd_bytes   = [0] * ndrives
        end_rd_iops    = [0] * ndrives
        end_wr_bytes   = [0] * ndrives
        end_wr_iops    = [0] * ndrives

        # Read the stats before advancing the clock
        for i in range(0, ndrives):
            idx = first_drive + i
            start_rd_bytes[i], start_rd_iops[i], start_wr_bytes[i], \
                start_wr_iops[i] = self.blockstats('drive%d' % idx)

        self.vm.qtest("clock_step %d" % ns)

        # Read the stats after advancing the clock
        for i in range(0, ndrives):
            idx = first_drive + i
            end_rd_bytes[i], end_rd_iops[i], end_wr_bytes[i], \
                end_wr_iops[i] = self.blockstats('drive%d' % idx)

        # Check that the I/O is within the limits and evenly distributed
        for i in range(0, ndrives):
            rd_bytes = end_rd_bytes[i] - start_rd_bytes[i]
            rd_iops = end_rd_iops[i] - start_rd_iops[i]
            wr_bytes = end_wr_bytes[i] - start_wr_bytes[i]
            wr_iops = end_wr_iops[i] - start_wr_iops[i]

            self.assertTrue(check_limit(params['bps'], rd_bytes + wr_bytes))
            self.assertTrue(check_limit(params['bps_rd'], rd_bytes))
            self.assertTrue(check_limit(params['bps_wr'], wr_bytes))
            self.assertTrue(check_limit(params['iops'], rd_iops + wr_iops))
            self.assertTrue(check_limit(params['iops_rd'], rd_iops))
            self.assertTrue(check_limit(params['iops_wr'], wr_iops))

        # Allow remaining requests to finish.  We submitted twice as many to
        # ensure the throttle limit is reached.
        self.vm.qtest("clock_step %d" % ns)

    # Connect N drives to a VM and test I/O in all of them
    def test_all(self):
        params = {"bps": 4096,
                  "bps_rd": 4096,
                  "bps_wr": 4096,
                  "iops": 10,
                  "iops_rd": 10,
                  "iops_wr": 10,
                 }
        # Repeat the test with different numbers of drives
        for ndrives in range(1, self.max_drives + 1):
            # Pick each out of all possible params and test
            for tk in params:
                limits = dict([(k, 0) for k in params])
                limits[tk] = params[tk] * ndrives
                self.configure_throttle(ndrives, limits)
                self.do_test_throttle(ndrives, 5, limits)

    # Connect N drives to a VM and test I/O in just one of them a time
    def test_one(self):
        params = {"bps": 4096,
                  "bps_rd": 4096,
                  "bps_wr": 4096,
                  "iops": 10,
                  "iops_rd": 10,
                  "iops_wr": 10,
                 }
        # Repeat the test for each one of the drives
        for drive in range(0, self.max_drives):
            # Pick each out of all possible params and test
            for tk in params:
                limits = dict([(k, 0) for k in params])
                limits[tk] = params[tk] * self.max_drives
                self.configure_throttle(self.max_drives, limits)
                self.do_test_throttle(1, 5, limits, drive)

    def test_burst(self):
        params = {"bps": 4096,
                  "bps_rd": 4096,
                  "bps_wr": 4096,
                  "iops": 10,
                  "iops_rd": 10,
                  "iops_wr": 10,
                 }
        ndrives = 1
        # Pick each out of all possible params and test
        for tk in params:
            rate = params[tk] * ndrives
            burst_rate = rate * 7
            burst_length = 4

            # Configure the throttling settings
            settings = dict([(k, 0) for k in params])
            settings[tk] = rate
            settings['%s_max' % tk] = burst_rate
            settings['%s_max_length' % tk] = burst_length
            self.configure_throttle(ndrives, settings)

            # Wait for the bucket to empty so we can do bursts
            wait_ns = nsec_per_sec * burst_length * burst_rate // rate
            self.vm.qtest("clock_step %d" % wait_ns)

            # Test I/O at the max burst rate
            limits = dict([(k, 0) for k in params])
            limits[tk] = burst_rate
            self.do_test_throttle(ndrives, burst_length, limits)

            # Now test I/O at the normal rate
            limits[tk] = rate
            self.do_test_throttle(ndrives, 5, limits)

    # Test that removing a drive from a throttle group should not
    # affect the remaining members of the group.
    # https://bugzilla.redhat.com/show_bug.cgi?id=1535914
    def test_remove_group_member(self):
        # Create a throttle group with two drives
        # and set a 4 KB/s read limit.
        params = {"bps": 0,
                  "bps_rd": 4096,
                  "bps_wr": 0,
                  "iops": 0,
                  "iops_rd": 0,
                  "iops_wr": 0 }
        self.configure_throttle(2, params)

        # Read 4KB from drive0. This is performed immediately.
        self.vm.hmp_qemu_io("drive0", "aio_read 0 4096")

        # Read 2KB. The I/O limit has been exceeded so this
        # request is throttled and a timer is set to wake it up.
        self.vm.hmp_qemu_io("drive0", "aio_read 0 2048")

        # Read 2KB again. We're still over the I/O limit so this is
        # request is also throttled, but no new timer is set since
        # there's already one.
        self.vm.hmp_qemu_io("drive0", "aio_read 0 2048")

        # Read from drive1. This request is also throttled, and no
        # timer is set in drive1 because there's already one in
        # drive0.
        self.vm.hmp_qemu_io("drive1", "aio_read 0 4096")

        # At this point only the first 4KB have been read from drive0.
        # The other requests are throttled.
        self.assertEqual(self.blockstats('drive0')[0], 4096)
        self.assertEqual(self.blockstats('drive1')[0], 0)

        # Remove drive0 from the throttle group and disable its I/O limits.
        # drive1 remains in the group with a throttled request.
        params['bps_rd'] = 0
        params['device'] = 'drive0'
        result = self.vm.qmp("block_set_io_throttle", conv_keys=False, **params)
        self.assert_qmp(result, 'return', {})

        # Removing the I/O limits from drive0 drains its two pending requests.
        # The read request in drive1 is still throttled.
        self.assertEqual(self.blockstats('drive0')[0], 8192)
        self.assertEqual(self.blockstats('drive1')[0], 0)

        # Advance the clock 5 seconds. This completes the request in drive1
        self.vm.qtest("clock_step %d" % (5 * nsec_per_sec))

        # Now all requests have been processed.
        self.assertEqual(self.blockstats('drive0')[0], 8192)
        self.assertEqual(self.blockstats('drive1')[0], 4096)

class ThrottleTestCoroutine(ThrottleTestCase):
    test_driver = "null-co"

class ThrottleTestGroupNames(iotests.QMPTestCase):
    max_drives = 3

    def setUp(self):
        self.vm = iotests.VM()
        for i in range(0, self.max_drives):
            self.vm.add_drive("null-co://",
                              "throttling.iops-total=100,file.read-zeroes=on")
        self.vm.launch()

    def tearDown(self):
        self.vm.shutdown()

    def set_io_throttle(self, device, params):
        params["device"] = device
        result = self.vm.qmp("block_set_io_throttle", conv_keys=False, **params)
        self.assert_qmp(result, 'return', {})

    def verify_name(self, device, name):
        result = self.vm.qmp("query-block")
        for r in result["return"]:
            if r["device"] == device:
                info = r["inserted"]
                if name:
                    self.assertEqual(info["group"], name)
                else:
                    self.assertFalse('group' in info)
                return

        raise Exception("No group information found for '%s'" % device)

    def test_group_naming(self):
        params = {"bps": 0,
                  "bps_rd": 0,
                  "bps_wr": 0,
                  "iops": 0,
                  "iops_rd": 0,
                  "iops_wr": 0}

        # Check the drives added using the command line.
        # The default throttling group name is the device name.
        for i in range(self.max_drives):
            devname = "drive%d" % i
            self.verify_name(devname, devname)

        # Clear throttling settings => the group name is gone.
        for i in range(self.max_drives):
            devname = "drive%d" % i
            self.set_io_throttle(devname, params)
            self.verify_name(devname, None)

        # Set throttling settings using block_set_io_throttle and
        # check the default group names.
        params["iops"] = 10
        for i in range(self.max_drives):
            devname = "drive%d" % i
            self.set_io_throttle(devname, params)
            self.verify_name(devname, devname)

        # Set a custom group name for each device
        for i in range(3):
            devname = "drive%d" % i
            groupname = "group%d" % i
            params['group'] = groupname
            self.set_io_throttle(devname, params)
            self.verify_name(devname, groupname)

        # Put drive0 in group1 and check that all other devices remain
        # unchanged
        params['group'] = 'group1'
        self.set_io_throttle('drive0', params)
        self.verify_name('drive0', 'group1')
        for i in range(1, self.max_drives):
            devname = "drive%d" % i
            groupname = "group%d" % i
            self.verify_name(devname, groupname)

        # Put drive0 in group2 and check that all other devices remain
        # unchanged
        params['group'] = 'group2'
        self.set_io_throttle('drive0', params)
        self.verify_name('drive0', 'group2')
        for i in range(1, self.max_drives):
            devname = "drive%d" % i
            groupname = "group%d" % i
            self.verify_name(devname, groupname)

        # Clear throttling settings from drive0 check that all other
        # devices remain unchanged
        params["iops"] = 0
        self.set_io_throttle('drive0', params)
        self.verify_name('drive0', None)
        for i in range(1, self.max_drives):
            devname = "drive%d" % i
            groupname = "group%d" % i
            self.verify_name(devname, groupname)

class ThrottleTestRemovableMedia(iotests.QMPTestCase):
    def setUp(self):
        self.vm = iotests.VM()
        self.vm.add_device("{},id=virtio-scsi".format(
            iotests.get_virtio_scsi_device()))
        self.vm.launch()

    def tearDown(self):
        self.vm.shutdown()

    def test_removable_media(self):
        # Add a couple of dummy nodes named cd0 and cd1
        result = self.vm.qmp("blockdev-add", driver="null-co",
                             read_zeroes=True, node_name="cd0")
        self.assert_qmp(result, 'return', {})
        result = self.vm.qmp("blockdev-add", driver="null-co",
                             read_zeroes=True, node_name="cd1")
        self.assert_qmp(result, 'return', {})

        # Attach a CD drive with cd0 inserted
        result = self.vm.qmp("device_add", driver="scsi-cd",
                             id="dev0", drive="cd0")
        self.assert_qmp(result, 'return', {})

        # Set I/O limits
        args = { "id": "dev0", "iops": 100, "iops_rd": 0, "iops_wr": 0,
                                "bps":  50,  "bps_rd": 0,  "bps_wr": 0 }
        result = self.vm.qmp("block_set_io_throttle", conv_keys=False, **args)
        self.assert_qmp(result, 'return', {})

        # Check that the I/O limits have been set
        result = self.vm.qmp("query-block")
        self.assert_qmp(result, 'return[0]/inserted/iops', 100)
        self.assert_qmp(result, 'return[0]/inserted/bps',   50)

        # Now eject cd0 and insert cd1
        result = self.vm.qmp("blockdev-open-tray", id='dev0')
        self.assert_qmp(result, 'return', {})
        result = self.vm.qmp("blockdev-remove-medium", id='dev0')
        self.assert_qmp(result, 'return', {})
        result = self.vm.qmp("blockdev-insert-medium", id='dev0', node_name='cd1')
        self.assert_qmp(result, 'return', {})

        # Check that the I/O limits are still the same
        result = self.vm.qmp("query-block")
        self.assert_qmp(result, 'return[0]/inserted/iops', 100)
        self.assert_qmp(result, 'return[0]/inserted/bps',   50)

        # Eject cd1
        result = self.vm.qmp("blockdev-remove-medium", id='dev0')
        self.assert_qmp(result, 'return', {})

        # Check that we can't set limits if the device has no medium
        result = self.vm.qmp("block_set_io_throttle", conv_keys=False, **args)
        self.assert_qmp(result, 'error/class', 'GenericError')

        # Remove the CD drive
        result = self.vm.qmp("device_del", id='dev0')
        self.assert_qmp(result, 'return', {})


if __name__ == '__main__':
    if 'null-co' not in iotests.supported_formats():
        iotests.notrun('null-co driver support missing')
    iotests.main(supported_fmts=["raw"])
