← Back to team overview

cloud-init-dev team mailing list archive

[Merge] ~chad.smith/cloud-init:tests/fix_apt_configure_primary into cloud-init:master

 

Chad Smith has proposed merging ~chad.smith/cloud-init:tests/fix_apt_configure_primary into cloud-init:master.

Commit message:
tests: fix apt_configure_primary to be more flexible

Commit d3e803ad316e6796e5d83e7e8f8f4f7224b92df9 added deb-src comments
to the cloud-init apt templates. This doubled the number of matching entries
seen in /etc/apt/sources.list in apt_configure_primary integration test.

This test was really asserting that GaTech urls were present in
/etc//apt/sources.list instead of archive.ubuntu.com. Fix the test to be
a bit more flexible in case cloud-init changes its bas apt template again.

Requested reviews:
  cloud-init commiters (cloud-init-dev)

For more details, see:
https://code.launchpad.net/~chad.smith/cloud-init/+git/cloud-init/+merge/356226
-- 
Your team cloud-init commiters is requested to review the proposed merge of ~chad.smith/cloud-init:tests/fix_apt_configure_primary into cloud-init:master.
diff --git a/tests/cloud_tests/testcases/modules/apt_configure_primary.py b/tests/cloud_tests/testcases/modules/apt_configure_primary.py
index c1c4bbc..4950a2e 100644
--- a/tests/cloud_tests/testcases/modules/apt_configure_primary.py
+++ b/tests/cloud_tests/testcases/modules/apt_configure_primary.py
@@ -9,12 +9,16 @@ class TestAptconfigurePrimary(base.CloudTestCase):
 
     def test_ubuntu_sources(self):
         """Test no default Ubuntu entries exist."""
-        out = self.get_data_file('ubuntu.sources.list')
-        self.assertEqual(0, int(out))
+        out = self.get_data_file('sources.list')
+        ubuntu_source_count = len(
+            [line for line in out.split('\n') if 'archive.ubuntu.com' in line])
+        self.assertEqual(0, ubuntu_source_count)
 
     def test_gatech_sources(self):
-        """Test GaTech entires exist."""
-        out = self.get_data_file('gatech.sources.list')
-        self.assertEqual(20, int(out))
+        """Test GaTech entries exist."""
+        out = self.get_data_file('sources.list')
+        gatech_source_count = len(
+            [line for line in out.split('\n') if 'gtlib.gatech.edu' in line])
+        self.assertGreater(gatech_source_count, 0)
 
 # vi: ts=4 expandtab
diff --git a/tests/cloud_tests/testcases/modules/apt_configure_primary.yaml b/tests/cloud_tests/testcases/modules/apt_configure_primary.yaml
index 41bcf2f..cc067d4 100644
--- a/tests/cloud_tests/testcases/modules/apt_configure_primary.yaml
+++ b/tests/cloud_tests/testcases/modules/apt_configure_primary.yaml
@@ -12,13 +12,6 @@ cloud_config: |
           - default
         uri: "http://www.gtlib.gatech.edu/pub/ubuntu-releases/";
 collect_scripts:
-  ubuntu.sources.list: |
-    #!/bin/bash
-    grep -v '^#' /etc/apt/sources.list | sed '/^\s*$/d' | grep -c archive.ubuntu.com
-  gatech.sources.list: |
-    #!/bin/bash
-    grep -v '^#' /etc/apt/sources.list | sed '/^\s*$/d' | grep -c gtlib.gatech.edu
-
   sources.list: |
       #!/bin/bash
       cat /etc/apt/sources.list

Follow ups