Stop violating image disk_format rules

Glance is going to start enforcing that if you upload something and
claim it is a different format than the content, the upload will fail.
Tempest currently just almost universally uses disk_formats[0],
despite not actually uploading content that matches that format. In
most cases it is using random data, which means the format it uses
should be "raw". This converts those cases to use raw, and does so
assuming raw is always available (as many other tests already do).

Change-Id: I06d66b969306b53cd177c2d95c23762db3bc72ea
Needed-By: https://review.opendev.org/c/openstack/glance/+/930492
diff --git a/tempest/api/compute/flavors/test_flavors_negative.py b/tempest/api/compute/flavors/test_flavors_negative.py
index 09f54b5..efd9cdd 100644
--- a/tempest/api/compute/flavors/test_flavors_negative.py
+++ b/tempest/api/compute/flavors/test_flavors_negative.py
@@ -47,7 +47,7 @@
             'name': data_utils.rand_name(
                 prefix=CONF.resource_name_prefix, name='image'),
             'container_format': CONF.image.container_formats[0],
-            'disk_format': CONF.image.disk_formats[0],
+            'disk_format': 'raw',
             'min_ram': min_img_ram,
             'visibility': 'private'
         }
diff --git a/tempest/api/image/v2/admin/test_images.py b/tempest/api/image/v2/admin/test_images.py
index 2b1c4fb..2c2e9a8 100644
--- a/tempest/api/image/v2/admin/test_images.py
+++ b/tempest/api/image/v2/admin/test_images.py
@@ -112,7 +112,7 @@
         image_name = data_utils.rand_name(
             prefix=CONF.resource_name_prefix, name='copy-image')
         container_format = CONF.image.container_formats[0]
-        disk_format = CONF.image.disk_formats[0]
+        disk_format = 'raw'
         image = self.create_image(name=image_name,
                                   container_format=container_format,
                                   disk_format=disk_format,
diff --git a/tempest/api/image/v2/test_images.py b/tempest/api/image/v2/test_images.py
index 5bb8eef..f6ca317 100644
--- a/tempest/api/image/v2/test_images.py
+++ b/tempest/api/image/v2/test_images.py
@@ -56,7 +56,14 @@
         image_name = data_utils.rand_name(
             prefix=CONF.resource_name_prefix, name='image')
         container_format = container_format or CONF.image.container_formats[0]
-        disk_format = disk_format or CONF.image.disk_formats[0]
+        disk_format = disk_format or 'raw'
+        if disk_format not in CONF.image.disk_formats:
+            # If the test asked for some disk format that is not available,
+            # consider that a programming error. Tests with specific
+            # requirements should be checking to see if it is available and
+            # skipping themselves instead of this helper doing it.
+            raise RuntimeError('Test requires unavailable disk_format %s, '
+                               'but did not skip' % disk_format)
         image = self.create_image(name=image_name,
                                   container_format=container_format,
                                   disk_format=disk_format,
@@ -390,7 +397,7 @@
         image_name = data_utils.rand_name(
             prefix=CONF.resource_name_prefix, name='image')
         container_format = CONF.image.container_formats[0]
-        disk_format = CONF.image.disk_formats[0]
+        disk_format = 'raw'
         image = self.create_image(name=image_name,
                                   container_format=container_format,
                                   disk_format=disk_format,
@@ -754,7 +761,7 @@
         # Create an image to be shared using default visibility
         image_file = io.BytesIO(data_utils.random_bytes(2048))
         container_format = CONF.image.container_formats[0]
-        disk_format = CONF.image.disk_formats[0]
+        disk_format = 'raw'
         image = self.create_image(container_format=container_format,
                                   disk_format=disk_format)
         self.client.store_image_file(image['id'], data=image_file)
diff --git a/tempest/api/volume/test_volumes_negative.py b/tempest/api/volume/test_volumes_negative.py
index d8480df..754b676 100644
--- a/tempest/api/volume/test_volumes_negative.py
+++ b/tempest/api/volume/test_volumes_negative.py
@@ -45,7 +45,7 @@
         image = self.images_client.create_image(
             name=image_name,
             container_format=CONF.image.container_formats[0],
-            disk_format=CONF.image.disk_formats[0],
+            disk_format='raw',
             visibility='private',
             min_disk=CONF.volume.volume_size + CONF.volume.volume_size_extend)
         self.addCleanup(test_utils.call_and_ignore_notfound_exc,