Merge "Add a --no-stream option"

This commit is contained in:
Zuul 2020-12-15 20:31:18 +00:00 committed by Gerrit Code Review
commit 9f95cb8fa3
2 changed files with 46 additions and 5 deletions

View File

@ -170,10 +170,15 @@ def _parse_args():
parser.add_argument('--rdo-mirror',
default=DEFAULT_RDO_MIRROR,
help='Server from which to install RDO packages.')
parser.add_argument('--stream',
action='store_true',
default=False,
help='Enable stream support for CentOS repos')
stream_group = parser.add_mutually_exclusive_group()
stream_group.add_argument('--stream',
action='store_true',
default=False,
help='Enable stream support for CentOS repos')
stream_group.add_argument('--no-stream',
action='store_true',
default=False,
help='Disable stream support for CentOS repos')
args = parser.parse_args()
args.old_mirror = default_mirror
@ -417,7 +422,7 @@ def _install_repos(args, base_path):
# HA, Powertools are required for CentOS-8
if args.distro == 'centos8':
stream = '8'
if args.stream:
if args.stream and not args.no_stream:
stream = stream + '-stream'
content = HIGHAVAILABILITY_REPO_TEMPLATE % {'mirror': args.mirror,
'stream': stream}

View File

@ -425,6 +425,7 @@ enabled=1
args.output_path = 'test'
args.distro = 'centos8'
args.stream = True
args.no_stream = False
args.mirror = 'mirror'
mock_get.return_value = '[delorean]\nMr. Fusion'
main._install_repos(args, 'roads/')
@ -450,6 +451,41 @@ enabled=1
],
mock_write.mock_calls)
@mock.patch('tripleo_repos.main._get_repo')
@mock.patch('tripleo_repos.main._write_repo')
def test_install_repos_centos8_no_stream(self, mock_write, mock_get):
args = mock.Mock()
args.repos = ['current']
args.branch = 'master'
args.output_path = 'test'
args.distro = 'centos8'
args.stream = False
args.no_stream = True
args.mirror = 'mirror'
mock_get.return_value = '[delorean]\nMr. Fusion'
main._install_repos(args, 'roads/')
self.assertEqual([mock.call('roads/current/delorean.repo', args),
mock.call('roads/delorean-deps.repo', args),
],
mock_get.mock_calls)
self.assertEqual([mock.call('[delorean]\nMr. Fusion', 'test',
name='delorean'),
mock.call('[delorean]\nMr. Fusion', 'test'),
mock.call((
'\n[tripleo-centos-highavailability]\n'
'name=tripleo-centos-highavailability\n'
'baseurl=mirror/centos/8/HighAvailability'
'/$basearch/os/\ngpgcheck=0\nenabled=1\n'),
'test'),
mock.call((
'\n[tripleo-centos-powertools]\n'
'name=tripleo-centos-powertools\n'
'baseurl=mirror/centos/8/PowerTools'
'/$basearch/os/\ngpgcheck=0\nenabled=1\n'),
'test')
],
mock_write.mock_calls)
def test_write_repo(self):
m = mock.mock_open()
with mock.patch('tripleo_repos.main.open', m, create=True):