Exemplo n.º 1
0
 def test_30_check_options(self):
     cmd = ("sudo dumpe2fs -h %s 2> /dev/null | "
            "awk -F ':' '{ if($1 == \"Reserved block count\") "
            "{ rescnt=$2 } } { if($1 == \"Block count\") "
            "{ blkcnt=$2 } } END { print (rescnt/blkcnt)*100 }'")
     cmd = cmd % self.story.device_path
     out, err = process(cmd)
     self.assertEqual(float(5), round(float(out)), msg=out)
Exemplo n.º 2
0
 def test_30_check_options(self):
     cmd = ("sudo dumpe2fs -h %s 2> /dev/null | "
            "awk -F ':' '{ if($1 == \"Reserved block count\") "
            "{ rescnt=$2 } } { if($1 == \"Block count\") "
            "{ blkcnt=$2 } } END { print (rescnt/blkcnt)*100 }'")
     cmd = cmd % self.story.device_path
     out, err = process(cmd)
     self.assertEqual(float(5), round(float(out)), msg=out)
Exemplo n.º 3
0
def find_mysql_procid_on_instance(local_id):
    """Returns the process id of MySql on an instance if running, or None."""
    cmd = "sudo vzctl exec2 %d ps aux | grep /usr/sbin/mysqld " \
          "| awk '{print $2}'" % local_id
    stdout, stderr = process(cmd)
    try:
        return int(stdout)
    except ValueError:
        return None
Exemplo n.º 4
0
def find_mysql_procid_on_instance(local_id):
    """Returns the process id of MySql on an instance if running, or None."""
    cmd = "sudo vzctl exec2 %d ps aux | grep /usr/sbin/mysqld " \
          "| awk '{print $2}'" % local_id
    stdout, stderr = process(cmd)
    try:
        return int(stdout)
    except ValueError:
        return None
Exemplo n.º 5
0
def get_vz_ip_for_device(instance_id, device):
    """Get the IP of the device within openvz for the specified instance"""
    ip, err = process("""sudo vzctl exec %(instance_id)s ifconfig %(device)s"""
                      """ | awk '/inet addr/{gsub(/addr:/,"");print $2}'"""
                      % locals())
    if err:
        assert_false(True, err)
    else:
        return ip.strip()
Exemplo n.º 6
0
def get_vz_ip_for_device(instance_id, device):
    """Get the IP of the device within openvz for the specified instance"""
    ip, err = process("""sudo vzctl exec %(instance_id)s ifconfig %(device)s"""
                      """ | awk '/inet addr/{gsub(/addr:/,"");print $2}'""" %
                      locals())
    if err:
        assert_false(True, err)
    else:
        return ip.strip()
Exemplo n.º 7
0
def check_database(instance_id, dbname):
    """Checks if the name appears in an instance's list of databases."""
    default_db = re.compile("[\w\n]*%s[\w\n]*" % dbname)
    dblist, err = process("sudo vzctl exec %s \"mysql -e 'show databases';\""
                            % instance_id)
    if err:
        raise RuntimeError(err)
    if default_db.match(dblist):
        return True
    else:
        return False
Exemplo n.º 8
0
def check_database(instance_id, dbname):
    """Checks if the name appears in an instance's list of databases."""
    default_db = re.compile("[\w\n]*%s[\w\n]*" % dbname)
    dblist, err = process("sudo vzctl exec %s \"mysql -e 'show databases';\"" %
                          instance_id)
    if err:
        raise RuntimeError(err)
    if default_db.match(dblist):
        return True
    else:
        return False
Exemplo n.º 9
0
 def scp(self, src, dest, dest_is_remote=True, user=None):
     """SCP a file
      :param remote_is_dest: Whether the destination is the remote file
      """
     if dest_is_remote:
         dest = self.ip_address + ":" + dest
         if user:
             dest = user + '@' + dest
     else:
         src = self.ip_address + ":" + src
         if user:
             src = user + '@' + src
     exe_cmd = "%s %s %s" % (tests.SCP_CMD, src, dest)
     print("RUNNING COMMAND: %s" % exe_cmd)
     return util.process(exe_cmd)
Exemplo n.º 10
0
    def test_resizefs_rescan(self):
        self.story.client.resize_fs(self.story.context, self.story.volume_id)
        expected = "trove.tests.volume.driver.ISCSITestDriver"
        if FLAGS.volume_driver is expected:
            size = self.story.resize_volume_size * \
                   test_driver.TESTS_VOLUME_SIZE_MULTIPLIER * 1024 * 1024
        else:
            size = self.story.resize_volume_size * 1024 * 1024
        out, err = process('sudo blockdev --getsize64 %s' %
                           os.path.realpath(self.story.device_path))
        if int(out) < (size * 0.8):
            self.fail("Size %s is not more or less %s" % (out, size))

        # Reset the volume status to available
        self.story.api.update(self.story.context, self.story.volume_id,
                              {'status': 'available'})
Exemplo n.º 11
0
    def test_resizefs_rescan(self):
        self.story.client.resize_fs(self.story.context,
                                    self.story.volume_id)
        expected = "trove.tests.volume.driver.ISCSITestDriver"
        if FLAGS.volume_driver is expected:
            size = self.story.resize_volume_size * \
                   test_driver.TESTS_VOLUME_SIZE_MULTIPLIER * 1024 * 1024
        else:
            size = self.story.resize_volume_size * 1024 * 1024
        out, err = process('sudo blockdev --getsize64 %s' %
                           os.path.realpath(self.story.device_path))
        if int(out) < (size * 0.8):
            self.fail("Size %s is not more or less %s" % (out, size))

        # Reset the volume status to available
        self.story.api.update(self.story.context, self.story.volume_id,
                              {'status': 'available'})
Exemplo n.º 12
0
 def execute(self, cmd):
     exe_cmd = "sudo vzctl exec %s %s" % (self.instance_local_id, cmd)
     print("RUNNING COMMAND: %s" % exe_cmd)
     return util.process(exe_cmd)
Exemplo n.º 13
0
 def execute(self, cmd):
     exe_cmd = "%s %s %s" % (tests.SSH_CMD, self.ip_address, cmd)
     print("RUNNING COMMAND: %s" % exe_cmd)
     return util.process(exe_cmd)
 def execute(self, cmd):
     exe_cmd = "sudo vzctl exec %s '%s'" % (self.instance_local_id, cmd)
     print("RUNNING COMMAND: %s" % exe_cmd)
     return util.process(exe_cmd)
 def execute(self, cmd):
     exe_cmd = "%s %s '%s'" % (tests.SSH_CMD, self.ip_address, cmd)
     print("RUNNING COMMAND: %s" % exe_cmd)
     return util.process(exe_cmd)
Exemplo n.º 16
0
 def execute(self, cmd):
     exe_cmd = "%s %s %s" % (tests.SSH_CMD, self.ip_address, cmd)
     print("RUNNING COMMAND: %s" % exe_cmd)
     stdout, stderr = util.process(exe_cmd)
     return (stdout.decode(), stderr.decode())
Exemplo n.º 17
0
 def test_mount_options(self):
     cmd = "mount -l | awk '/%s.*noatime/ { print $1 }'"
     cmd %= LOCAL_MOUNT_PATH.replace('/', '')
     out, err = process(cmd)
     self.assertEqual(os.path.realpath(self.story.device_path), out.strip(),
                      msg=out)