From 638f09e82260ea3256c387cd55408e0411f36c23 Mon Sep 17 00:00:00 2001 From: Chad Smith Date: Sun, 7 Oct 2018 19:31:50 +0000 Subject: 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. --- .../cloud_tests/testcases/modules/apt_configure_primary.py | 14 +++++++++----- .../testcases/modules/apt_configure_primary.yaml | 7 ------- 2 files changed, 9 insertions(+), 12 deletions(-) (limited to 'tests') diff --git a/tests/cloud_tests/testcases/modules/apt_configure_primary.py b/tests/cloud_tests/testcases/modules/apt_configure_primary.py index c1c4bbc0..4950a2ef 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 41bcf2fd..cc067d4f 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 -- cgit v1.2.3