mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge branch '2019.2.1' into aix_docs
This commit is contained in:
commit
0ef9892149
17 changed files with 129 additions and 16 deletions
|
@ -12,6 +12,9 @@ properties([
|
|||
[
|
||||
$class: 'RebuildSettings', autoRebuild: false, rebuildDisabled: false
|
||||
],
|
||||
parameters([
|
||||
booleanParam(defaultValue: true, description: 'Run full test suite', name: 'runFull')
|
||||
])
|
||||
])
|
||||
timeout(time: global_timeout, unit: 'HOURS') {
|
||||
node('kitchen-slave') {
|
||||
|
@ -31,7 +34,7 @@ timeout(time: global_timeout, unit: 'HOURS') {
|
|||
'TEST_SUITE=py2',
|
||||
'TEST_PLATFORM=centos-6',
|
||||
'PY_COLORS=1',
|
||||
'FORCE_FULL=true',
|
||||
"FORCE_FULL=${params.runFull}",
|
||||
]) {
|
||||
// Set the GH status even before cloning the repo
|
||||
stage('github-pending') {
|
||||
|
|
|
@ -12,6 +12,9 @@ properties([
|
|||
[
|
||||
$class: 'RebuildSettings', autoRebuild: false, rebuildDisabled: false
|
||||
],
|
||||
parameters([
|
||||
booleanParam(defaultValue: true, description: 'Run full test suite', name: 'runFull')
|
||||
])
|
||||
])
|
||||
timeout(time: global_timeout, unit: 'HOURS') {
|
||||
node('kitchen-slave') {
|
||||
|
@ -31,7 +34,7 @@ timeout(time: global_timeout, unit: 'HOURS') {
|
|||
'TEST_SUITE=py2',
|
||||
'TEST_PLATFORM=centos-7',
|
||||
'PY_COLORS=1',
|
||||
'FORCE_FULL=true',
|
||||
"FORCE_FULL=${params.runFull}",
|
||||
]) {
|
||||
// Set the GH status even before cloning the repo
|
||||
stage('github-pending') {
|
||||
|
|
|
@ -12,6 +12,9 @@ properties([
|
|||
[
|
||||
$class: 'RebuildSettings', autoRebuild: false, rebuildDisabled: false
|
||||
],
|
||||
parameters([
|
||||
booleanParam(defaultValue: true, description: 'Run full test suite', name: 'runFull')
|
||||
])
|
||||
])
|
||||
timeout(time: global_timeout, unit: 'HOURS') {
|
||||
node('kitchen-slave') {
|
||||
|
@ -31,7 +34,7 @@ timeout(time: global_timeout, unit: 'HOURS') {
|
|||
'TEST_SUITE=py3',
|
||||
'TEST_PLATFORM=centos-7',
|
||||
'PY_COLORS=1',
|
||||
'FORCE_FULL=true',
|
||||
"FORCE_FULL=${params.runFull}",
|
||||
]) {
|
||||
// Set the GH status even before cloning the repo
|
||||
stage('github-pending') {
|
||||
|
|
|
@ -12,6 +12,9 @@ properties([
|
|||
[
|
||||
$class: 'RebuildSettings', autoRebuild: false, rebuildDisabled: false
|
||||
],
|
||||
parameters([
|
||||
booleanParam(defaultValue: true, description: 'Run full test suite', name: 'runFull')
|
||||
])
|
||||
])
|
||||
timeout(time: global_timeout, unit: 'HOURS') {
|
||||
node('kitchen-slave') {
|
||||
|
@ -31,7 +34,7 @@ timeout(time: global_timeout, unit: 'HOURS') {
|
|||
'TEST_SUITE=py2',
|
||||
'TEST_PLATFORM=debian-8',
|
||||
'PY_COLORS=1',
|
||||
'FORCE_FULL=true',
|
||||
"FORCE_FULL=${params.runFull}",
|
||||
]) {
|
||||
// Set the GH status even before cloning the repo
|
||||
stage('github-pending') {
|
||||
|
|
|
@ -12,6 +12,9 @@ properties([
|
|||
[
|
||||
$class: 'RebuildSettings', autoRebuild: false, rebuildDisabled: false
|
||||
],
|
||||
parameters([
|
||||
booleanParam(defaultValue: true, description: 'Run full test suite', name: 'runFull')
|
||||
])
|
||||
])
|
||||
timeout(time: global_timeout, unit: 'HOURS') {
|
||||
node('kitchen-slave') {
|
||||
|
@ -31,7 +34,7 @@ timeout(time: global_timeout, unit: 'HOURS') {
|
|||
'TEST_SUITE=py3',
|
||||
'TEST_PLATFORM=debian-8',
|
||||
'PY_COLORS=1',
|
||||
'FORCE_FULL=true',
|
||||
"FORCE_FULL=${params.runFull}",
|
||||
]) {
|
||||
// Set the GH status even before cloning the repo
|
||||
stage('github-pending') {
|
||||
|
|
|
@ -12,6 +12,9 @@ properties([
|
|||
[
|
||||
$class: 'RebuildSettings', autoRebuild: false, rebuildDisabled: false
|
||||
],
|
||||
parameters([
|
||||
booleanParam(defaultValue: true, description: 'Run full test suite', name: 'runFull')
|
||||
])
|
||||
])
|
||||
timeout(time: global_timeout, unit: 'HOURS') {
|
||||
node('kitchen-slave') {
|
||||
|
@ -31,7 +34,7 @@ timeout(time: global_timeout, unit: 'HOURS') {
|
|||
'TEST_SUITE=py2',
|
||||
'TEST_PLATFORM=debian-9',
|
||||
'PY_COLORS=1',
|
||||
'FORCE_FULL=true',
|
||||
"FORCE_FULL=${params.runFull}",
|
||||
]) {
|
||||
// Set the GH status even before cloning the repo
|
||||
stage('github-pending') {
|
||||
|
|
|
@ -12,6 +12,9 @@ properties([
|
|||
[
|
||||
$class: 'RebuildSettings', autoRebuild: false, rebuildDisabled: false
|
||||
],
|
||||
parameters([
|
||||
booleanParam(defaultValue: true, description: 'Run full test suite', name: 'runFull')
|
||||
])
|
||||
])
|
||||
timeout(time: global_timeout, unit: 'HOURS') {
|
||||
node('kitchen-slave') {
|
||||
|
@ -31,7 +34,7 @@ timeout(time: global_timeout, unit: 'HOURS') {
|
|||
'TEST_SUITE=py3',
|
||||
'TEST_PLATFORM=debian-9',
|
||||
'PY_COLORS=1',
|
||||
'FORCE_FULL=true',
|
||||
"FORCE_FULL=${params.runFull}",
|
||||
]) {
|
||||
// Set the GH status even before cloning the repo
|
||||
stage('github-pending') {
|
||||
|
|
|
@ -12,6 +12,9 @@ properties([
|
|||
[
|
||||
$class: 'RebuildSettings', autoRebuild: false, rebuildDisabled: false
|
||||
],
|
||||
parameters([
|
||||
booleanParam(defaultValue: true, description: 'Run full test suite', name: 'runFull')
|
||||
])
|
||||
])
|
||||
timeout(time: global_timeout, unit: 'HOURS') {
|
||||
node('kitchen-slave') {
|
||||
|
@ -31,7 +34,7 @@ timeout(time: global_timeout, unit: 'HOURS') {
|
|||
'TEST_SUITE=py2',
|
||||
'TEST_PLATFORM=ubuntu-1604',
|
||||
'PY_COLORS=1',
|
||||
'FORCE_FULL=true',
|
||||
"FORCE_FULL=${params.runFull}",
|
||||
]) {
|
||||
// Set the GH status even before cloning the repo
|
||||
stage('github-pending') {
|
||||
|
|
|
@ -12,6 +12,9 @@ properties([
|
|||
[
|
||||
$class: 'RebuildSettings', autoRebuild: false, rebuildDisabled: false
|
||||
],
|
||||
parameters([
|
||||
booleanParam(defaultValue: true, description: 'Run full test suite', name: 'runFull')
|
||||
])
|
||||
])
|
||||
timeout(time: global_timeout, unit: 'HOURS') {
|
||||
node('kitchen-slave') {
|
||||
|
@ -31,7 +34,7 @@ timeout(time: global_timeout, unit: 'HOURS') {
|
|||
'TEST_SUITE=py3',
|
||||
'TEST_PLATFORM=ubuntu-1604',
|
||||
'PY_COLORS=1',
|
||||
'FORCE_FULL=true',
|
||||
"FORCE_FULL=${params.runFull}",
|
||||
]) {
|
||||
// Set the GH status even before cloning the repo
|
||||
stage('github-pending') {
|
||||
|
|
|
@ -12,6 +12,9 @@ properties([
|
|||
[
|
||||
$class: 'RebuildSettings', autoRebuild: false, rebuildDisabled: false
|
||||
],
|
||||
parameters([
|
||||
booleanParam(defaultValue: true, description: 'Run full test suite', name: 'runFull')
|
||||
])
|
||||
])
|
||||
timeout(time: global_timeout, unit: 'HOURS') {
|
||||
node('kitchen-slave') {
|
||||
|
@ -31,7 +34,7 @@ timeout(time: global_timeout, unit: 'HOURS') {
|
|||
'TEST_SUITE=py2',
|
||||
'TEST_PLATFORM=ubuntu-1804',
|
||||
'PY_COLORS=1',
|
||||
'FORCE_FULL=true',
|
||||
"FORCE_FULL=${params.runFull}",
|
||||
]) {
|
||||
// Set the GH status even before cloning the repo
|
||||
stage('github-pending') {
|
||||
|
|
|
@ -12,6 +12,9 @@ properties([
|
|||
[
|
||||
$class: 'RebuildSettings', autoRebuild: false, rebuildDisabled: false
|
||||
],
|
||||
parameters([
|
||||
booleanParam(defaultValue: true, description: 'Run full test suite', name: 'runFull')
|
||||
])
|
||||
])
|
||||
timeout(time: global_timeout, unit: 'HOURS') {
|
||||
node('kitchen-slave') {
|
||||
|
@ -31,7 +34,7 @@ timeout(time: global_timeout, unit: 'HOURS') {
|
|||
'TEST_SUITE=py3',
|
||||
'TEST_PLATFORM=ubuntu-1804',
|
||||
'PY_COLORS=1',
|
||||
'FORCE_FULL=true',
|
||||
"FORCE_FULL=${params.runFull}",
|
||||
]) {
|
||||
// Set the GH status even before cloning the repo
|
||||
stage('github-pending') {
|
||||
|
|
|
@ -12,6 +12,9 @@ properties([
|
|||
[
|
||||
$class: 'RebuildSettings', autoRebuild: false, rebuildDisabled: false
|
||||
],
|
||||
parameters([
|
||||
booleanParam(defaultValue: true, description: 'Run full test suite', name: 'runFull')
|
||||
])
|
||||
])
|
||||
timeout(time: global_timeout, unit: 'HOURS') {
|
||||
node('kitchen-slave') {
|
||||
|
@ -30,7 +33,7 @@ timeout(time: global_timeout, unit: 'HOURS') {
|
|||
'TEST_SUITE=py2',
|
||||
'TEST_PLATFORM=windows-2016',
|
||||
'PY_COLORS=1',
|
||||
'FORCE_FULL=true',
|
||||
"FORCE_FULL=${params.runFull}",
|
||||
]) {
|
||||
// Set the GH status even before cloning the repo
|
||||
stage('github-pending') {
|
||||
|
|
|
@ -12,6 +12,9 @@ properties([
|
|||
[
|
||||
$class: 'RebuildSettings', autoRebuild: false, rebuildDisabled: false
|
||||
],
|
||||
parameters([
|
||||
booleanParam(defaultValue: true, description: 'Run full test suite', name: 'runFull')
|
||||
])
|
||||
])
|
||||
timeout(time: global_timeout, unit: 'HOURS') {
|
||||
node('kitchen-slave') {
|
||||
|
@ -30,7 +33,7 @@ timeout(time: global_timeout, unit: 'HOURS') {
|
|||
'TEST_SUITE=py3',
|
||||
'TEST_PLATFORM=windows-2016',
|
||||
'PY_COLORS=1',
|
||||
'FORCE_FULL=true',
|
||||
"FORCE_FULL=${params.runFull}",
|
||||
]) {
|
||||
// Set the GH status even before cloning the repo
|
||||
stage('github-pending') {
|
||||
|
|
|
@ -3670,7 +3670,7 @@ def stats(path, hash_type=None, follow_symlinks=True):
|
|||
ret['mtime'] = pstat.st_mtime
|
||||
ret['ctime'] = pstat.st_ctime
|
||||
ret['size'] = pstat.st_size
|
||||
ret['mode'] = six.text_type(oct(stat.S_IMODE(pstat.st_mode)))
|
||||
ret['mode'] = salt.utils.files.normalize_mode(oct(stat.S_IMODE(pstat.st_mode)))
|
||||
if hash_type:
|
||||
ret['sum'] = get_hash(path, hash_type)
|
||||
ret['type'] = 'file'
|
||||
|
|
|
@ -854,7 +854,7 @@ def stats(path, hash_type='sha256', follow_symlinks=True):
|
|||
ret['mtime'] = pstat.st_mtime
|
||||
ret['ctime'] = pstat.st_ctime
|
||||
ret['size'] = pstat.st_size
|
||||
ret['mode'] = six.text_type(oct(stat.S_IMODE(pstat.st_mode)))
|
||||
ret['mode'] = salt.utils.files.normalize_mode(oct(stat.S_IMODE(pstat.st_mode)))
|
||||
if hash_type:
|
||||
ret['sum'] = get_sum(path, hash_type)
|
||||
ret['type'] = 'file'
|
||||
|
|
|
@ -42,7 +42,16 @@ here
|
|||
|
||||
|
||||
class DummyStat(object):
|
||||
st_size = 123
|
||||
st_mode = 33188
|
||||
st_ino = 115331251
|
||||
st_dev = 44
|
||||
st_nlink = 1
|
||||
st_uid = 99200001
|
||||
st_gid = 99200001
|
||||
st_size = 41743
|
||||
st_atime = 1552661253
|
||||
st_mtime = 1552661253
|
||||
st_ctime = 1552661253
|
||||
|
||||
|
||||
class FileReplaceTestCase(TestCase, LoaderModuleMockMixin):
|
||||
|
@ -1109,6 +1118,14 @@ class FileModuleTestCase(TestCase, LoaderModuleMockMixin):
|
|||
ret = filemod.get_diff('binary1', 'text1')
|
||||
self.assertEqual(ret, 'Replace binary file with text file')
|
||||
|
||||
def test_stats(self):
|
||||
with patch('os.path.expanduser', MagicMock(side_effect=lambda path: path)), \
|
||||
patch('os.path.exists', MagicMock(return_value=True)), \
|
||||
patch('os.stat', MagicMock(return_value=DummyStat())):
|
||||
ret = filemod.stats('dummy', None, True)
|
||||
self.assertEqual(ret['mode'], '0644')
|
||||
self.assertEqual(ret['type'], 'file')
|
||||
|
||||
|
||||
@skipIf(pytest is None, 'PyTest required for this set of tests')
|
||||
class FilemodLineTests(TestCase, LoaderModuleMockMixin):
|
||||
|
|
|
@ -6,12 +6,15 @@
|
|||
from __future__ import absolute_import, unicode_literals, print_function
|
||||
import os
|
||||
import tempfile
|
||||
import sys
|
||||
from collections import namedtuple
|
||||
|
||||
# Import Salt Testing Libs
|
||||
from tests.support.helpers import destructiveTest
|
||||
from tests.support.mixins import LoaderModuleMockMixin
|
||||
from tests.support.mock import patch, NO_MOCK, NO_MOCK_REASON
|
||||
from tests.support.unit import TestCase, skipIf
|
||||
from tests.support.mock import MagicMock
|
||||
|
||||
# Import Salt Libs
|
||||
import salt.modules.win_file as win_file
|
||||
|
@ -21,6 +24,23 @@ import salt.utils.platform
|
|||
from salt.exceptions import CommandExecutionError
|
||||
|
||||
|
||||
class DummyStat(object):
|
||||
st_mode = 33188
|
||||
st_ino = 115331251
|
||||
st_dev = 44
|
||||
st_nlink = 1
|
||||
st_uid = 99200001
|
||||
st_gid = 99200001
|
||||
st_size = 41743
|
||||
st_atime = 1552661253
|
||||
st_mtime = 1552661253
|
||||
st_ctime = 1552661253
|
||||
|
||||
|
||||
WindowsVersion = namedtuple('WinowsVersion', 'major minor')
|
||||
winver = WindowsVersion(major=10, minor=0)
|
||||
|
||||
|
||||
@skipIf(NO_MOCK, NO_MOCK_REASON)
|
||||
class WinFileTestCase(TestCase, LoaderModuleMockMixin):
|
||||
'''
|
||||
|
@ -303,3 +323,40 @@ class WinFileCheckPermsTestCase(TestCase, LoaderModuleMockMixin):
|
|||
inheritance=False,
|
||||
reset=True)
|
||||
self.assertDictEqual(expected, ret)
|
||||
|
||||
def test_issue_52002_check_file_remove_symlink(self):
|
||||
'''
|
||||
Make sure that directories including symlinks or symlinks can be removed
|
||||
'''
|
||||
base = temp.dir(prefix='base-')
|
||||
target = os.path.join(base, 'child 1', 'target\\')
|
||||
symlink = os.path.join(base, 'child 2', 'link')
|
||||
try:
|
||||
# Create environment
|
||||
self.assertFalse(win_file.directory_exists(target))
|
||||
self.assertFalse(win_file.directory_exists(symlink))
|
||||
self.assertTrue(win_file.makedirs_(target))
|
||||
self.assertTrue(win_file.makedirs_(symlink))
|
||||
self.assertTrue(win_file.symlink(target, symlink))
|
||||
self.assertTrue(win_file.directory_exists(symlink))
|
||||
self.assertTrue(win_file.is_link(symlink))
|
||||
# Test removal of directory containing symlink
|
||||
self.assertTrue(win_file.remove(base))
|
||||
self.assertFalse(win_file.directory_exists(base))
|
||||
finally:
|
||||
if os.path.exists(base):
|
||||
win_file.remove(base)
|
||||
|
||||
def test_stat(self):
|
||||
sys.getwindowsversion = MagicMock(name='getwindowsversion')
|
||||
with patch('os.path.exists', MagicMock(return_value=True)), \
|
||||
patch('sys.getwindowsversion', MagicMock(return_value=winver)), \
|
||||
patch('salt.modules.win_file._resolve_symlink', MagicMock(side_effect=lambda path: path)), \
|
||||
patch('salt.modules.win_file.get_uid', MagicMock(return_value=1)), \
|
||||
patch('salt.modules.win_file.uid_to_user', MagicMock(return_value='dummy')), \
|
||||
patch('salt.modules.win_file.get_pgid', MagicMock(return_value=1)), \
|
||||
patch('salt.modules.win_file.gid_to_group', MagicMock(return_value='dummy')), \
|
||||
patch('os.stat', MagicMock(return_value=DummyStat())):
|
||||
ret = win_file.stats('dummy', None, True)
|
||||
self.assertEqual(ret['mode'], '0644')
|
||||
self.assertEqual(ret['type'], 'file')
|
||||
|
|
Loading…
Add table
Reference in a new issue