Exemplo n.º 1
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.
"""
Script to test creation of a stack of volumes 2 voumes deep.
"""
from nova_volume_testing.util.novaexerciser import Volume, Instance, Snapshot

if __name__ == "__main__":
    print "003 snapshot stack - create snapshots of volumes that were created "\
          "from snapshots, check all volumes can be changed without "\
          "corrupting other volumes"
    instance = Instance()
    volume = Volume(size=1)
    assert volume.attached() == False

    volume.attach(instance)
    assert volume.attached() == True
    assert volume.attached(instance) == True
    volume.write_test_pattern(key=1)
    assert volume.check_test_pattern(key=1) == True
    volume.detach()
    assert volume.attached() == False

    snapshot = Snapshot(volume)
    snapvol = Volume(snapshot=snapshot)
    snapvol.attach(instance)
    assert snapvol.check_test_pattern(key=1) == True
    snapvol.write_test_pattern(key=2)
#    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.

"""
Script to test basic snapshot creation mounting and deletion.
"""
from nova_volume_testing.util.novaexerciser import Volume, Instance, Snapshot

if __name__ == "__main__":
    print "002 basic snapshot - Create a volume, write to it, snapshot it, "\
          "create a volume from the snapshot, change original, check "\
          "snapshot, change snapshot, check original"
    instance = Instance()
    volume = Volume(size=1)

    assert volume.attached() == False

    volume.attach(instance)
    assert volume.attached() == True
    assert volume.attached(instance) == True

    volume.write_test_pattern(key=1)
    assert volume.check_test_pattern(key=1) == True

    volume.detach()
    assert volume.attached() == False

    snapshot = Snapshot(volume)
#    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.

"""
Script to test creation of a stack of volumes 2 voumes deep.
"""
from nova_volume_testing.util.novaexerciser import Volume, Instance, Snapshot

if __name__ == "__main__":
    print "003 snapshot stack - create snapshots of volumes that were created "\
          "from snapshots, check all volumes can be changed without "\
          "corrupting other volumes"
    instance = Instance()
    volume = Volume(size=1)
    assert volume.attached() == False

    volume.attach(instance)
    assert volume.attached() == True
    assert volume.attached(instance) == True
    volume.write_test_pattern(key=1)
    assert volume.check_test_pattern(key=1) == True
    volume.detach()
    assert volume.attached() == False

    snapshot = Snapshot(volume)
    snapvol = Volume(snapshot=snapshot)
    snapvol.attach(instance)
    assert snapvol.check_test_pattern(key=1) == True
    snapvol.write_test_pattern(key=2)
#    under the License.
"""
Script to test basic volume creation, mounting and deletion.
"""
import os
from nova_volume_testing.util.novaexerciser import Volume, Instance

if __name__ == "__main__":
    print "004 Test pre-existing volumes - Make sure volumes from before the "\
          "upgrade still work"
    if 'BOCK_TEST_VOLUMES' in os.environ:
        #
        # Make a list of volume id's, one from each line in the volumes file.
        # Then make a list of volume objects from each volume id.
        vol_list = [l.strip() for l in file(os.environ['BOCK_TEST_VOLUMES'])]
        volumes = [Volume(volume_id=v_id) for v_id in vol_list]

        if len(volumes) > 0:
            print 'Testing %s volumes' % len(volumes)

            instance = Instance()
            for volume in volumes:
                assert volume.attached() == False
                volume.attach(instance)
                assert volume.attached(instance) == True
                assert volume.check_mount_device() == True
                volume.detach()
                assert volume.attached() == False
            instance.delete()
        else:
            print "There are no volumes listed in %s" % \
#    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.
"""
Script to test basic volume creation, mounting and deletion.
"""
from nova_volume_testing.util.novaexerciser import Volume, Instance

if __name__ == "__main__":
    print "001 basic volume create attach - Create a volume, attach it to an "\
          "instance, write to it, dettach it and attach it to a different"\
          "instance, check the data"
    instance1 = Instance()
    instance2 = Instance()
    volume = Volume(size=1)

    assert volume.attached() == False

    volume.attach(instance1)
    assert volume.attached() == True
    assert volume.attached(instance1) == True

    volume.write_test_pattern()
    assert volume.check_test_pattern() == True
    assert volume.check_test_pattern(key=16) == False

    volume.detach()
    assert volume.attached() == False

    volume.attach(instance2)
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.

"""
Script to test basic volume creation, mounting and deletion.
"""
from nova_volume_testing.util.novaexerciser import Volume, Instance

if __name__ == "__main__":
    print "001 basic volume create attach - Create a volume, attach it to an "\
          "instance, write to it, dettach it and attach it to a different"\
          "instance, check the data"
    instance1 = Instance()
    instance2 = Instance()
    volume = Volume(size=1)

    assert volume.attached() == False

    volume.attach(instance1)
    assert volume.attached() == True
    assert volume.attached(instance1) == True

    volume.write_test_pattern()
    assert volume.check_test_pattern() == True
    assert volume.check_test_pattern(key=16) == False

    volume.detach()
    assert volume.attached() == False

    volume.attach(instance2)