Github user gauravaradhye commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/117#discussion_r26301332 --- Diff: test/integration/testpaths/testpath_volume_snapshot.py --- @@ -0,0 +1,745 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +""" Test cases for VM/Volume snapshot Test Path +""" +from nose.plugins.attrib import attr +from marvin.cloudstackTestCase import cloudstackTestCase, unittest +from marvin.lib.utils import (cleanup_resources, + random_gen, + format_volume_to_ext3, + is_snapshot_on_nfs, + validateList) +from marvin.lib.base import (Account, + ServiceOffering, + DiskOffering, + Template, + VirtualMachine, + Snapshot + ) +from marvin.lib.common import (get_domain, + get_zone, + get_template, + list_volumes, + list_snapshots, + list_events, + ) + + +import hashlib +from marvin.sshClient import SshClient + +from marvin.codes import PASS + + +def createChecksum(self, virtual_machine, disk, disk_type): + """ Write data on the disk and return the md5 checksum""" + + random_data_0 = random_gen(size=100) + # creating checksum(MD5) + m = hashlib.md5() + m.update(random_data_0) + ckecksum_random_data_0 = m.hexdigest() + try: + ssh_client = SshClient( + virtual_machine.ssh_ip, + virtual_machine.ssh_port, + virtual_machine.username, + virtual_machine.password + ) + except Exception as e: + self.fail("SSH failed for VM: %s" % + e) + + self.debug("Formatting volume: %s to ext3" % disk.id) + # Format partition using ext3 + # Note that this is the second data disk partition of virtual machine + # as it was already containing data disk before attaching the new volume, + # Hence datadiskdevice_2 + + format_volume_to_ext3( + ssh_client, + self.testdata["volume_write_path"][ + virtual_machine.hypervisor][disk_type] + ) + cmds = ["fdisk -l", + "mkdir -p %s" % self.testdata["data_write_paths"]["mount_dir"], + "mount -t ext3 %s1 %s" % ( + self.testdata["volume_write_path"][ + virtual_machine.hypervisor][disk_type], + self.testdata["data_write_paths"]["mount_dir"] + ), + "mkdir -p %s/%s/%s " % ( + self.testdata["data_write_paths"]["mount_dir"], + self.testdata["data_write_paths"]["sub_dir"], + self.testdata["data_write_paths"]["sub_lvl_dir1"], + ), + "echo %s > %s/%s/%s/%s" % ( + random_data_0, + self.testdata["data_write_paths"]["mount_dir"], + self.testdata["data_write_paths"]["sub_dir"], + self.testdata["data_write_paths"]["sub_lvl_dir1"], + self.testdata["data_write_paths"]["random_data"] + ), + "cat %s/%s/%s/%s" % ( + self.testdata["data_write_paths"]["mount_dir"], + self.testdata["data_write_paths"]["sub_dir"], + self.testdata["data_write_paths"]["sub_lvl_dir1"], + self.testdata["data_write_paths"]["random_data"] + ) + ] + + for c in cmds: + self.debug("Command: %s" % c) + result = ssh_client.execute(c) + self.debug(result) + + # Unmount the storage + cmds = [ + "umount %s" % (self.testdata["data_write_paths"]["mount_dir"]), + ] + + for c in cmds: + self.debug("Command: %s" % c) + ssh_client.execute(c) + + return ckecksum_random_data_0 + + +def compareChecksum( --- End diff -- Same for this function
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---