mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge pull request #44285 from Ch3LL/all_spm
add spm integration tests for remove and build
This commit is contained in:
commit
e16707c403
3 changed files with 88 additions and 3 deletions
|
@ -8,12 +8,13 @@ import os
|
|||
import shutil
|
||||
|
||||
# Import Salt Testing libs
|
||||
from tests.support.case import SPMCase
|
||||
from tests.support.case import SPMCase, ModuleCase
|
||||
from tests.support.helpers import destructiveTest
|
||||
from tests.support.unit import skipIf
|
||||
|
||||
|
||||
@destructiveTest
|
||||
class SPMBuildTest(SPMCase):
|
||||
class SPMBuildTest(SPMCase, ModuleCase):
|
||||
'''
|
||||
Validate the spm build command
|
||||
'''
|
||||
|
@ -32,5 +33,44 @@ class SPMBuildTest(SPMCase):
|
|||
# Make sure formula path dir is created
|
||||
self.assertTrue(os.path.isdir(self.config['formula_path']))
|
||||
|
||||
@skipIf(salt.utils.which('fallocate') is None, 'fallocate not installed')
|
||||
def test_spm_build_big_file(self):
|
||||
'''
|
||||
test spm build
|
||||
'''
|
||||
big_file = self.run_function('cmd.run',
|
||||
['fallocate -l 1G {0}'.format(os.path.join(self.formula_sls_dir,
|
||||
'bigfile.txt'))])
|
||||
build_spm = self.run_spm('build', self.config, self.formula_dir)
|
||||
spm_file = os.path.join(self.config['spm_build_dir'], 'apache-201506-2.spm')
|
||||
install = self.run_spm('install', self.config, spm_file)
|
||||
|
||||
get_files = self.run_spm('files', self.config, 'apache')
|
||||
|
||||
files = ['apache.sls', 'bigfile.txt']
|
||||
for sls in files:
|
||||
self.assertIn(sls, ' '.join(get_files))
|
||||
|
||||
def test_spm_build_exclude(self):
|
||||
'''
|
||||
test spm build
|
||||
'''
|
||||
git_dir = os.path.join(self.formula_sls_dir, '.git')
|
||||
os.makedirs(git_dir)
|
||||
files = ['donotbuild1', 'donotbuild2', 'donotbuild3']
|
||||
|
||||
for git_file in files:
|
||||
with salt.utils.fopen(os.path.join(git_dir, git_file), 'w') as fp:
|
||||
fp.write('Please do not include me in build')
|
||||
|
||||
build_spm = self.run_spm('build', self.config, self.formula_dir)
|
||||
spm_file = os.path.join(self.config['spm_build_dir'], 'apache-201506-2.spm')
|
||||
install = self.run_spm('install', self.config, spm_file)
|
||||
|
||||
get_files = self.run_spm('files', self.config, 'apache')
|
||||
|
||||
for git_file in files:
|
||||
self.assertNotIn(git_file, ' '.join(get_files))
|
||||
|
||||
def tearDown(self):
|
||||
shutil.rmtree(self._tmp_spm)
|
||||
|
|
45
tests/integration/spm/test_remove.py
Normal file
45
tests/integration/spm/test_remove.py
Normal file
|
@ -0,0 +1,45 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
'''
|
||||
Tests for the spm remove utility
|
||||
'''
|
||||
# Import python libs
|
||||
from __future__ import absolute_import
|
||||
import os
|
||||
import shutil
|
||||
|
||||
# Import Salt Testing libs
|
||||
from tests.support.case import SPMCase
|
||||
from tests.support.helpers import destructiveTest
|
||||
|
||||
|
||||
@destructiveTest
|
||||
class SPMRemoveTest(SPMCase):
|
||||
'''
|
||||
Validate the spm remove command
|
||||
'''
|
||||
def setUp(self):
|
||||
self.config = self._spm_config()
|
||||
self._spm_build_files(self.config)
|
||||
|
||||
def test_spm_remove(self):
|
||||
'''
|
||||
test spm remove from an inital repo install
|
||||
'''
|
||||
# first install apache package
|
||||
self._spm_create_update_repo(self.config)
|
||||
install = self.run_spm('install', self.config, 'apache')
|
||||
|
||||
sls = os.path.join(self.config['formula_path'], 'apache', 'apache.sls')
|
||||
|
||||
self.assertTrue(os.path.exists(sls))
|
||||
|
||||
#now remove an make sure file is removed
|
||||
remove = self.run_spm('remove', self.config, 'apache')
|
||||
sls = os.path.join(self.config['formula_path'], 'apache', 'apache.sls')
|
||||
|
||||
self.assertFalse(os.path.exists(sls))
|
||||
|
||||
self.assertIn('... removing apache', remove)
|
||||
|
||||
def tearDown(self):
|
||||
shutil.rmtree(self._tmp_spm)
|
|
@ -626,7 +626,7 @@ class SPMCase(TestCase, AdaptedConfigurationTestCaseMixin):
|
|||
'spm_repos_config': os.path.join(self._tmp_spm, 'etc', 'spm.repos'),
|
||||
'spm_cache_dir': os.path.join(self._tmp_spm, 'cache'),
|
||||
'spm_build_dir': os.path.join(self._tmp_spm, 'build'),
|
||||
'spm_build_exclude': ['.git'],
|
||||
'spm_build_exclude': ['apache/.git'],
|
||||
'spm_db_provider': 'sqlite3',
|
||||
'spm_files_provider': 'local',
|
||||
'spm_db': os.path.join(self._tmp_spm, 'packages.db'),
|
||||
|
|
Loading…
Add table
Reference in a new issue