← Back to team overview

canonical-ubuntu-qa team mailing list archive

[Merge] ~andersson123/autopkgtest-cloud:fake_release_seed_new_release into autopkgtest-cloud:master

 

Tim Andersson has proposed merging ~andersson123/autopkgtest-cloud:fake_release_seed_new_release into autopkgtest-cloud:master.

Commit message:
add fake release flag for testing script

Requested reviews:
  Canonical's Ubuntu QA (canonical-ubuntu-qa)

For more details, see:
https://code.launchpad.net/~andersson123/autopkgtest-cloud/+git/autopkgtest-cloud/+merge/443973

add fake release flag for testing script
-- 
Your team Canonical's Ubuntu QA is requested to review the proposed merge of ~andersson123/autopkgtest-cloud:fake_release_seed_new_release into autopkgtest-cloud:master.
diff --git a/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/tools/create-test-instances b/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/tools/create-test-instances
old mode 100755
new mode 100644
diff --git a/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/tools/seed-new-release b/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/tools/seed-new-release
index 8fdd1a3..d04cb2d 100755
--- a/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/tools/seed-new-release
+++ b/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/tools/seed-new-release
@@ -57,6 +57,25 @@ def copy_result(rel_path, old_release, new_release):
                                    contents=contents,
                                    content_length=headers['content-length'],
                                    headers=headers_to_copy)
+            if args.fake_release:
+                            try:
+                                swiftclient.head_object(swift_con.url, token=swift_con.token,
+                                                        container='autopkgtest-' + new_release,
+                                                        name=to_path,
+                                                        headers=headers_to_copy)
+                                print("Confirmed existence of dummy object " + \
+                                            "%s from container %s... Deleting...",
+                                            to_path, 'autopkgtest-'+new_release)
+                                swiftclient.delete_object(swift_con.url, token=swift_con.token,
+                                                        container='autopkgtest-' + new_release,
+                                                        name=to_path,
+                                                        headers=headers_to_copy)
+                                print("Object %s deleted from container %s... Deleting...",
+                                            to_path, 'autopkgtest-'+new_release)
+                            except (IOError, AttributeError, swiftclient.exceptions.ClientException) as e:
+                                print("Couldn't get information for object %s from container %s...",
+                                            to_path, 'autopkgtest-'+new_release)
+
             break
         except (IOError, AttributeError, swiftclient.exceptions.ClientException) as e:
             print('Error connecting to swift, re-connecting in %is: %s' % (5 * retry, e))
@@ -71,6 +90,7 @@ ap = argparse.ArgumentParser()
 ap.add_argument('old_release')
 ap.add_argument('new_release')
 ap.add_argument('results_db', help='path to autopkgtest.db')
+ap.add_argument('-f', '--fake-release', action='store_true')
 args = ap.parse_args()
 
 # connect to Swift
@@ -121,3 +141,6 @@ for (package, arch, run_id) in db_con.execute(
             print('%s%s already exists, skipping' % (args.old_release, path))
             continue
         copy_result(path, args.old_release, args.new_release)
+if args.fake_release:
+    print("--fake-release selected, deleting container: %s", 'autopkgtest-' + args.new_release)
+    swift_con.delete_container('autopkgtest-' + args.new_release)