mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 08:58:59 +00:00
Merge pull request #24606 from basepi/merge-forward-develop
Merge forward from 2015.5 to develop
This commit is contained in:
commit
21d9df2831
31
doc/_themes/saltstack2/layout.html
vendored
31
doc/_themes/saltstack2/layout.html
vendored
@ -21,13 +21,13 @@
|
||||
|
||||
|
||||
{% set script_files = [
|
||||
'_static/js/webhelp.min.js',
|
||||
'_static/js/webhelp.min_v1.1.js',
|
||||
'_static/js/bootstrap.min.js',
|
||||
] %}
|
||||
|
||||
{% set css_files = [
|
||||
'_static/css/core.min.css',
|
||||
'_static/css/webhelp.min.css',
|
||||
'_static/css/webhelp.min_v1.1.css',
|
||||
'_static/css/pygments.css',
|
||||
'_static/css/basic.css',
|
||||
'_static/css/main.css',
|
||||
@ -94,7 +94,7 @@
|
||||
{{ css() }}
|
||||
|
||||
<!--[if lt IE 9]>
|
||||
<script src="{{ pathto('_static/js/respond.min.js', 1) }}">
|
||||
<script src="{{ pathto('_static/js/respond.min.js', 1) }}"></script>
|
||||
<![endif]-->
|
||||
|
||||
{%- if not embedded %}
|
||||
@ -154,16 +154,11 @@
|
||||
<div id="wrapper">
|
||||
<div id="sidebar-wrapper">
|
||||
<div id="sidebar-static">
|
||||
<a class="ss-logo" href="http://saltstack.com"><img width="350px" class="nolightbox" src="{{ pathto('_static/images/saltstack_logo.png', 1) }}"></a>
|
||||
|
||||
{% if on_saltstack %}
|
||||
<div class="versions">
|
||||
|
||||
<a id="latest" data-container="body" data-toggle="tooltip" data-placement="bottom" title="Docs for the latest stable release" href="/en/latest/">{{ latest_release }} </a> {% if build_type == "latest" %}<i class="glyphicon glyphicon-ok"></i>{%- endif %} |
|
||||
<a id="previous" data-container="body" data-toggle="tooltip" data-placement="bottom" title="Docs for the previous stable release" href="/en/{{ previous_release_dir }}/">{{ previous_release }} </a> {% if build_type == "previous" %}<i class="glyphicon glyphicon-ok"></i>{%- endif %} |
|
||||
<a id="develop" data-container="body" data-toggle="tooltip" data-placement="bottom" title="Recent doc build from the develop branch" href="/en/develop/">Develop </a> {% if build_type == "develop" %}<i class="glyphicon glyphicon-ok"></i>{%- endif %}
|
||||
</div>
|
||||
|
||||
<a href="http://saltstack.com/saltstack-enterprise-4-0-now-with-gui/" target="_blank"><img class="nolightbox nav-banner center" width="275px" src="{{ pathto('_static/images/sse-4-gui.png', 1) }}"/></a>
|
||||
{% else %}
|
||||
<a class="ss-logo" href="http://saltstack.com"><img width="163px" class="nolightbox" src="{{ pathto('_static/images/saltstack_logo.svg', 1) }}"></a>
|
||||
{% endif %}
|
||||
<div class="text-nowrap">
|
||||
<!--social icons from http://vervex.deviantart.com/art/Somacro-45-300DPI-Social-Media-Icons-267955425-->
|
||||
<ul id="social-links" class="list-inline">
|
||||
@ -179,6 +174,14 @@
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
{% if on_saltstack %}
|
||||
<div class="versions {{ build_type }}">
|
||||
|
||||
<a id="previous"{% if build_type == "previous" %} class="selected-version" title="View release notes"{% else %} title="Switch to docs for the previous stable release"{% endif %} data-container="body" data-toggle="tooltip" data-placement="bottom" href="/en/{{ previous_release_dir }}/">{{ previous_release }} </a> {% if build_type == "previous" %}<i class="glyphicon glyphicon-ok"></i>{%- endif %} |
|
||||
<a id="latest"{% if build_type == "latest" %} class="selected-version" title="View release notes"{% else %} title="Switch to docs for the latest stable release"{% endif %} data-container="body" data-toggle="tooltip" data-placement="bottom" href="/en/latest/">{{ latest_release }} </a> {% if build_type == "latest" %}<i class="glyphicon glyphicon-ok"></i>{% endif %} |
|
||||
<a id="develop"{% if build_type == "develop" %} class="selected-version" title="View all release notes"{% endif %} title="Switch to docs built recently from the develop branch" data-container="body" data-toggle="tooltip" data-placement="bottom" href="/en/develop/">Develop </a> {% if build_type == "develop" %}<i class="glyphicon glyphicon-ok"></i>{% endif %}
|
||||
</div>
|
||||
|
||||
{% else %}
|
||||
<div class="versions">
|
||||
<p>Version {{ version }}</p>
|
||||
@ -222,7 +225,9 @@
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
|
||||
{% if on_saltstack %}
|
||||
<a class="ss-logo" href="http://saltstack.com"><img width="163px" class="nolightbox" src="{{ pathto('_static/images/saltstack_logo.svg', 1) }}"></a>
|
||||
{% endif %}
|
||||
<ul id="header-nav" class="nav navbar-nav">
|
||||
{%- block relbar_small %}{{ relbar() }}{% endblock %}
|
||||
|
||||
|
@ -247,3 +247,10 @@ dl.function {
|
||||
line-height: 1.3;
|
||||
font-weight: 300;
|
||||
}
|
||||
img.logo {
|
||||
margin-top: -10px;
|
||||
}
|
||||
img.nav-banner {
|
||||
margin-top: 5px;
|
||||
}
|
||||
|
27
doc/_themes/saltstack2/static/images/saltstack_logo.svg
vendored
Normal file
27
doc/_themes/saltstack2/static/images/saltstack_logo.svg
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 18.1.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
viewBox="0 0 257.5 65" enable-background="new 0 0 257.5 65" xml:space="preserve">
|
||||
<g>
|
||||
<path d="M162.6,29.3c-4.2-1-4.7-1.7-4.7-2.9c0-1.2,1.2-2,3-2c1.8,0,3.6,0.7,5.5,2.1l0.4,0.3l2.6-3.6l-0.4-0.3c-2.3-1.9-5-2.8-8-2.8
|
||||
c-4.6,0-7.8,2.8-7.8,6.8c0,4.2,2.7,5.7,7.5,6.9c4.1,1,4.4,1.7,4.4,2.8c0,1.3-1.3,2.2-3.3,2.2c-2.3,0-4.3-0.8-6.4-2.6l-0.4-0.3
|
||||
l-2.9,3.4l0.4,0.3c2.6,2.3,5.8,3.5,9.2,3.5c4.9,0,8.1-2.7,8.1-6.9C169.8,31.7,166.4,30.2,162.6,29.3z"/>
|
||||
<polygon points="189.6,20.3 171.3,20.3 171.3,24.8 178.1,24.8 178.1,42.7 182.8,42.7 182.8,24.8 189.6,24.8 "/>
|
||||
<path d="M197.6,20.2l-9.8,22.5h4.9l2.2-5.1h6l1.6-4.2l4,9.4h5.1l-9.8-22.5H197.6z M196.7,33.2l2.9-6.8l2.9,6.8H196.7z"/>
|
||||
<path d="M228.9,36c-1.7,1.6-3.3,2.6-5.8,2.6c-3.7,0-6.5-3-6.5-7.1c0-4,2.8-7,6.5-7c2,0,3.8,0.8,5.6,2.5l0.4,0.4l3.1-3.5l-0.3-0.3
|
||||
c-1.8-1.7-4.2-3.5-8.7-3.5c-6.6,0-11.5,5-11.5,11.6c0,6.4,5,11.5,11.4,11.5c3.7,0,6.4-1.2,9-3.9l0.3-0.4l-3.1-3.1L228.9,36z"/>
|
||||
<polygon points="245.9,30.1 255.3,20.3 249.3,20.3 239.8,30.3 239.8,20.3 235.1,20.3 235.1,42.7 239.8,42.7 239.8,36.2 242.6,33.3
|
||||
249.7,42.7 255.5,42.7 "/>
|
||||
<path d="M83.7,29.9c-5-1.1-5.4-2.2-5.4-3.7c0-1.7,1.7-2.9,4-2.9c2.1,0,4,0.7,5.8,2.2l0.4,0.3l2-2.7l-0.4-0.3
|
||||
c-2.4-1.9-4.7-2.7-7.8-2.7c-4.3,0-7.5,2.7-7.5,6.4c0,4.2,3,5.7,7.6,6.6c4.8,1,5.1,2.2,5.1,3.6c0,1.9-1.7,3.1-4.3,3.1
|
||||
c-2.7,0-4.7-0.8-7-2.9L76,36.6l-2.1,2.5l0.4,0.3c2.7,2.4,5.6,3.5,9.1,3.5c4.6,0,7.8-2.7,7.8-6.6C91,32.9,88.8,31,83.7,29.9z"/>
|
||||
<path d="M102.6,20.2L92.4,42.7H96l2.5-5.6h8.6l1.1-2.9l3.8,8.5h3.7l-10.2-22.5H102.6z M99.9,33.9l4.1-9.2l4.1,9.2H99.9z"/>
|
||||
<polygon points="122,20.3 118.6,20.3 118.6,42.7 134,42.7 134,39.4 122,39.4 "/>
|
||||
<polygon points="132.9,23.6 140,23.6 140,42.7 143.5,42.7 143.5,23.6 150.6,23.6 150.6,20.3 132.9,20.3 "/>
|
||||
</g>
|
||||
<path fill="#010101" d="M63.9,12.2L48.6,3.3L37.7,9.6l-8.9-5L3.9,19v28.9l25,14.4l25-14.4V35.7l10-5.8V12.2z M59.6,13l-11,6.4
|
||||
l-11-6.4l11-6.4L59.6,13z M31.5,19.8l1.8-1l0,2l-0.7-0.4l0,0L31.5,19.8z M36.1,15.5l11,6.4v12.7L42,31.5v-5.7l-5.9-3.4L36.1,15.5z
|
||||
M42,34.8l4,2.4l-4,2.3V34.8z M28.9,7.5l6.3,3.5l-1.9,1.1l0,3.6l-6.9,3.9l3.4,2l8.4,4.9L28.9,32L7.7,19.8L28.9,7.5z M6.5,22
|
||||
l21.2,12.2v24.4L6.5,46.4V22z M51.3,46.4L30.2,58.6V34.2l9.3-5.4V44l9.1-5.2l0,0l2.8-1.6V46.4z M50,34.6V21.9l11-6.4v12.8L50,34.6z"
|
||||
/>
|
||||
</svg>
|
After Width: | Height: | Size: 2.5 KiB |
BIN
doc/_themes/saltstack2/static/images/sse-4-gui.png
vendored
Normal file
BIN
doc/_themes/saltstack2/static/images/sse-4-gui.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 20 KiB |
@ -158,6 +158,20 @@ $( document ).ready(function() {
|
||||
$( '#wrapper' ).toggleClass( 'toggled' );
|
||||
});
|
||||
|
||||
$( 'div.versions' ).on('click', 'a', function (e) {
|
||||
e.preventDefault();
|
||||
var clickedVer = $(this).attr("href");
|
||||
var $currentVer = $( 'a.selected-version' );
|
||||
if (window.location.href.indexOf(clickedVer) == -1) {
|
||||
window.location.href = window.location.href.replace($currentVer.attr("href"), clickedVer);
|
||||
}
|
||||
else {
|
||||
if ($currentVer.text().indexOf("develop") == -1) {
|
||||
window.location.href = clickedVer + "topics/releases/" + $currentVer.text().trim() + ".html";
|
||||
}
|
||||
else window.location.href = clickedVer + "topics/releases/";
|
||||
}
|
||||
});
|
||||
}); // $.document.ready
|
||||
|
||||
//refresh on window resize
|
@ -162,7 +162,7 @@ project = 'Salt'
|
||||
copyright = '2015 SaltStack, Inc.'
|
||||
|
||||
version = salt.version.__version__
|
||||
latest_release = '2015.5.1' # latest release
|
||||
latest_release = '2015.5.2' # latest release
|
||||
previous_release = '2014.7.6' # latest release from previous branch
|
||||
previous_release_dir = '2014.7' # path on web server for previous branch
|
||||
build_type = 'develop' # latest, previous, develop
|
||||
@ -224,7 +224,7 @@ rst_prolog = """\
|
||||
.. _`salt-users`: https://groups.google.com/forum/#!forum/salt-users
|
||||
.. _`salt-announce`: https://groups.google.com/forum/#!forum/salt-announce
|
||||
.. _`salt-packagers`: https://groups.google.com/forum/#!forum/salt-packagers
|
||||
""".format(release=latest_release)
|
||||
""".format(release=release)
|
||||
|
||||
# A shortcut for linking to tickets on the GitHub issue tracker
|
||||
extlinks = {
|
||||
|
@ -147,7 +147,7 @@ to add them to the pool of load balanced servers.
|
||||
|
||||
<...file contents snipped...>
|
||||
|
||||
{% for server, addrs in salt['mine.get']('roles:web', 'network.ip_addrs', expr_form='grain').items() %}
|
||||
{% for server, addrs in salt['mine.get']('roles:web', 'network.ip_addrs', expr_form='pillar').items() %}
|
||||
server {{ server }} {{ addrs[0] }}:80 check
|
||||
{% endfor %}
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
Salt 2015.5.2 Release Notes
|
||||
===========================
|
||||
|
||||
:release: TBA
|
||||
:release: 2015-06-10
|
||||
|
||||
Version 2015.5.2 is a bugfix release for :doc:`2015.5.0
|
||||
</topics/releases/2015.5.0>`.
|
||||
|
@ -142,19 +142,6 @@ Function updateMinionConfig
|
||||
|
||||
FunctionEnd
|
||||
|
||||
Function MsiQueryProductState
|
||||
|
||||
!define INSTALLSTATE_DEFAULT "5"
|
||||
Var /GLOBAL NeedVcRedist ; used as a return value
|
||||
|
||||
Pop $R0
|
||||
StrCpy $NeedVcRedist "False"
|
||||
System::Call "msi::MsiQueryProductStateA(t '$R0') i.r0"
|
||||
StrCmp $0 ${INSTALLSTATE_DEFAULT} +2 0
|
||||
StrCpy $NeedVcRedist "True"
|
||||
|
||||
FunctionEnd
|
||||
|
||||
Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
|
||||
OutFile "Salt-Minion-${PRODUCT_VERSION}-${CPUARCH}-Setup.exe"
|
||||
InstallDir "c:\salt"
|
||||
@ -162,37 +149,6 @@ InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" ""
|
||||
ShowInstDetails show
|
||||
ShowUnInstDetails show
|
||||
|
||||
; Check and install Visual C++ 2008 SP1 MFC Security Update redist packages
|
||||
; See http://blogs.msdn.com/b/astebner/archive/2009/01/29/9384143.aspx for more info
|
||||
Section -Prerequisites
|
||||
|
||||
; !define VC_REDIST_X64_GUID "{5FCE6D76-F5DC-37AB-B2B8-22AB8CEDB1D4}"
|
||||
; !define VC_REDIST_X86_GUID "{9BE518E6-ECC6-35A9-88E4-87755C07200F}"
|
||||
; !define VC_REDIST_X64_URI "http://download.microsoft.com/download/5/D/8/5D8C65CB-C849-4025-8E95-C3966CAFD8AE/vcredist_x64.exe"
|
||||
; !define VC_REDIST_X86_URI "http://download.microsoft.com/download/5/D/8/5D8C65CB-C849-4025-8E95-C3966CAFD8AE/vcredist_x86.exe"
|
||||
|
||||
; Var /GLOBAL VcRedistGuid
|
||||
; Var /GLOBAL VcRedistUri
|
||||
; ${If} ${RunningX64}
|
||||
; StrCpy $VcRedistGuid ${VC_REDIST_X64_GUID}
|
||||
; StrCpy $VcRedistUri ${VC_REDIST_X64_URI}
|
||||
; ${Else}
|
||||
; StrCpy $VcRedistGuid ${VC_REDIST_X86_GUID}
|
||||
; StrCpy $VcRedistUri ${VC_REDIST_X86_URI}
|
||||
; ${EndIf}
|
||||
|
||||
; Push $VcRedistGuid
|
||||
Call MsiQueryProductState
|
||||
; ${If} $NeedVcRedist == "True"
|
||||
; NSISdl::download /TIMEOUT=30000 $VcRedistUri $TEMP\vcredist.exe
|
||||
; Pop $R0
|
||||
; StrCmp $R0 "success" +2
|
||||
; MessageBox MB_OK "VC redist package download failed: $R0" /SD IDOK ; just report, do not break installation
|
||||
; Execwait '"$TEMP\vcredist.exe" /q'
|
||||
; ${EndIf}
|
||||
|
||||
SectionEnd
|
||||
|
||||
Section "MainSection" SEC01
|
||||
|
||||
; Remove previous version of salt, but don't remove conf and key
|
||||
@ -255,6 +211,12 @@ Section -Post
|
||||
Call updateMinionConfig
|
||||
SectionEnd
|
||||
|
||||
Function .onInstSuccess
|
||||
; If the installer is running Silently, start the service
|
||||
IfSilent 0 +2
|
||||
Exec 'net start salt-minion'
|
||||
FunctionEnd
|
||||
|
||||
Function un.onUninstSuccess
|
||||
HideWindow
|
||||
MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) was successfully removed from your computer." /SD IDOK
|
||||
@ -367,8 +329,6 @@ Section Uninstall
|
||||
Delete "$INSTDIR\salt*"
|
||||
Delete "$INSTDIR\bin"
|
||||
|
||||
#Delete "$SMPROGRAMS\Salt Minion\Uninstall.lnk"
|
||||
#RMDir /r "$SMPROGRAMS\Salt Minion"
|
||||
${If} $INSTDIR != 'Program Files'
|
||||
${AndIf} $INSTDIR != 'Program Files (x86)'
|
||||
RMDir /r "$INSTDIR"
|
||||
|
@ -946,14 +946,15 @@ ARGS = {9}\n'''.format(self.minion_config,
|
||||
def cmd_block(self, is_retry=False):
|
||||
'''
|
||||
Prepare the pre-check command to send to the subsystem
|
||||
'''
|
||||
# 1. execute SHIM + command
|
||||
# 2. check if SHIM returns a master request or if it completed
|
||||
# 3. handle any master request
|
||||
# 4. re-execute SHIM + command
|
||||
# 5. split SHIM results from command results
|
||||
# 6. return command results
|
||||
|
||||
1. execute SHIM + command
|
||||
2. check if SHIM returns a master request or if it completed
|
||||
3. handle any master request
|
||||
4. re-execute SHIM + command
|
||||
5. split SHIM results from command results
|
||||
6. return command results
|
||||
'''
|
||||
self.argv = _convert_args(self.argv)
|
||||
log.debug('Performing shimmed, blocking command as follows:\n{0}'.format(' '.join(self.argv)))
|
||||
cmd_str = self._cmd_str()
|
||||
stdout, stderr, retcode = self.shim_cmd(cmd_str)
|
||||
@ -1218,3 +1219,18 @@ def ssh_version():
|
||||
return ret[1].split(b',')[0].split(b'_')[1]
|
||||
except IndexError:
|
||||
return '2.0'
|
||||
|
||||
|
||||
def _convert_args(args):
|
||||
'''
|
||||
Take a list of args, and convert any dicts inside the list to keyword
|
||||
args in the form of `key=value`, ready to be passed to salt-ssh
|
||||
'''
|
||||
converted = []
|
||||
for arg in args:
|
||||
if isinstance(arg, dict):
|
||||
for key in list(arg.keys()):
|
||||
converted.append('{0}={1}'.format(key, arg[key]))
|
||||
else:
|
||||
converted.append(arg)
|
||||
return converted
|
||||
|
@ -6,7 +6,8 @@ State Caching
|
||||
-------------
|
||||
|
||||
When a highstate is called, the minion automatically caches a copy of the last high data.
|
||||
If you then run a highstate with cache=True it will use that cached highdata and won't hit the fileserver.
|
||||
If you then run a highstate with cache=True it will use that cached highdata and won't hit the fileserver
|
||||
except for ``salt://`` links in the states themselves.
|
||||
'''
|
||||
|
||||
# Import python libs
|
||||
|
@ -404,6 +404,8 @@ def function(
|
||||
if mdata.get('failed', False):
|
||||
m_func = False
|
||||
else:
|
||||
if 'return' in mdata and 'ret' not in mdata:
|
||||
mdata['ret'] = mdata.pop('return')
|
||||
m_ret = mdata['ret']
|
||||
m_func = (not fail_function and True) or __salt__[fail_function](m_ret)
|
||||
|
||||
|
@ -126,6 +126,7 @@ class SREQTestCase(TestCase):
|
||||
sreq = self.get_sreq()
|
||||
assert sreq.send('clear', 'foo') == {'enc': 'clear', 'load': 'foo'}
|
||||
|
||||
@skipIf(True, 'Disabled until we can figure out how to make this more reliable.')
|
||||
def test_timeout(self):
|
||||
'''
|
||||
Test SREQ Timeouts
|
||||
|
102
tests/unit/states/rdp_test.py
Normal file
102
tests/unit/states/rdp_test.py
Normal file
@ -0,0 +1,102 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
'''
|
||||
:codeauthor: :email:`Jayesh Kariya <jayeshk@saltstack.com>`
|
||||
'''
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import
|
||||
|
||||
# Import Salt Testing Libs
|
||||
from salttesting import skipIf, TestCase
|
||||
from salttesting.mock import (
|
||||
NO_MOCK,
|
||||
NO_MOCK_REASON,
|
||||
MagicMock,
|
||||
patch
|
||||
)
|
||||
|
||||
from salttesting.helpers import ensure_in_syspath
|
||||
|
||||
ensure_in_syspath('../../')
|
||||
|
||||
# Import Salt Libs
|
||||
from salt.states import rdp
|
||||
|
||||
rdp.__opts__ = {}
|
||||
rdp.__salt__ = {}
|
||||
|
||||
|
||||
@skipIf(NO_MOCK, NO_MOCK_REASON)
|
||||
class RdpTestCase(TestCase):
|
||||
'''
|
||||
Test cases for salt.states.rdp
|
||||
'''
|
||||
# 'enabled' function tests: 1
|
||||
|
||||
def test_enabled(self):
|
||||
'''
|
||||
Test to enable the RDP service and make sure access
|
||||
to the RDP port is allowed in the firewall configuration.
|
||||
'''
|
||||
name = 'my_service'
|
||||
|
||||
ret = {'name': name,
|
||||
'changes': {},
|
||||
'result': True,
|
||||
'comment': ''}
|
||||
|
||||
mock_t = MagicMock(side_effect=[False, False, True])
|
||||
mock_f = MagicMock(return_value=False)
|
||||
with patch.dict(rdp.__salt__,
|
||||
{'rdp.status': mock_t,
|
||||
'rdp.enable': mock_f}):
|
||||
with patch.dict(rdp.__opts__, {'test': True}):
|
||||
comt = ('RDP will be enabled')
|
||||
ret.update({'comment': comt, 'result': None})
|
||||
self.assertDictEqual(rdp.enabled(name), ret)
|
||||
|
||||
with patch.dict(rdp.__opts__, {'test': False}):
|
||||
ret.update({'comment': '', 'result': False,
|
||||
'changes': {'RDP was enabled': True}})
|
||||
self.assertDictEqual(rdp.enabled(name), ret)
|
||||
|
||||
comt = ('RDP is enabled')
|
||||
ret.update({'comment': comt, 'result': True,
|
||||
'changes': {}})
|
||||
self.assertDictEqual(rdp.enabled(name), ret)
|
||||
|
||||
# 'disabled' function tests: 1
|
||||
|
||||
def test_disabled(self):
|
||||
'''
|
||||
Test to disable the RDP service.
|
||||
'''
|
||||
name = 'my_service'
|
||||
|
||||
ret = {'name': name,
|
||||
'changes': {},
|
||||
'result': True,
|
||||
'comment': ''}
|
||||
|
||||
mock = MagicMock(side_effect=[True, True, False])
|
||||
mock_t = MagicMock(return_value=True)
|
||||
with patch.dict(rdp.__salt__,
|
||||
{'rdp.status': mock,
|
||||
'rdp.disable': mock_t}):
|
||||
with patch.dict(rdp.__opts__, {'test': True}):
|
||||
comt = ('RDP will be disabled')
|
||||
ret.update({'comment': comt, 'result': None})
|
||||
self.assertDictEqual(rdp.disabled(name), ret)
|
||||
|
||||
with patch.dict(rdp.__opts__, {'test': False}):
|
||||
ret.update({'comment': '', 'result': True,
|
||||
'changes': {'RDP was disabled': True}})
|
||||
self.assertDictEqual(rdp.disabled(name), ret)
|
||||
|
||||
comt = ('RDP is disabled')
|
||||
ret.update({'comment': comt, 'result': True, 'changes': {}})
|
||||
self.assertDictEqual(rdp.disabled(name), ret)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
from integration import run_tests
|
||||
run_tests(RdpTestCase, needs_daemon=False)
|
88
tests/unit/states/redismod_test.py
Normal file
88
tests/unit/states/redismod_test.py
Normal file
@ -0,0 +1,88 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
'''
|
||||
:codeauthor: :email:`Jayesh Kariya <jayeshk@saltstack.com>`
|
||||
'''
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import
|
||||
|
||||
# Import Salt Testing Libs
|
||||
from salttesting import skipIf, TestCase
|
||||
from salttesting.mock import (
|
||||
NO_MOCK,
|
||||
NO_MOCK_REASON,
|
||||
MagicMock,
|
||||
patch
|
||||
)
|
||||
|
||||
from salttesting.helpers import ensure_in_syspath
|
||||
|
||||
ensure_in_syspath('../../')
|
||||
|
||||
# Import Salt Libs
|
||||
from salt.states import redismod
|
||||
|
||||
redismod.__salt__ = {}
|
||||
|
||||
|
||||
@skipIf(NO_MOCK, NO_MOCK_REASON)
|
||||
class RedismodTestCase(TestCase):
|
||||
'''
|
||||
Test cases for salt.states.redismod
|
||||
'''
|
||||
# 'string' function tests: 1
|
||||
|
||||
def test_string(self):
|
||||
'''
|
||||
Test to ensure that the key exists in redis with the value specified.
|
||||
'''
|
||||
name = 'key_in_redis'
|
||||
value = 'string data'
|
||||
|
||||
ret = {'name': name,
|
||||
'changes': {},
|
||||
'result': True,
|
||||
'comment': 'Key already set to defined value'}
|
||||
|
||||
mock = MagicMock(return_value=value)
|
||||
with patch.dict(redismod.__salt__, {'redis.get_key': mock}):
|
||||
self.assertDictEqual(redismod.string(name, value), ret)
|
||||
|
||||
# 'absent' function tests: 1
|
||||
|
||||
def test_absent(self):
|
||||
'''
|
||||
Test to ensure key absent from redis.
|
||||
'''
|
||||
name = 'key_in_redis'
|
||||
|
||||
ret = {'name': name,
|
||||
'changes': {},
|
||||
'result': True,
|
||||
'comment': ''}
|
||||
|
||||
mock = MagicMock(side_effect=[False, True, True])
|
||||
mock_t = MagicMock(return_value=False)
|
||||
with patch.dict(redismod.__salt__,
|
||||
{'redis.exists': mock,
|
||||
'redis.delete': mock_t}):
|
||||
comt = ('`keys` not formed as a list type')
|
||||
ret.update({'comment': comt, 'result': False})
|
||||
self.assertDictEqual(redismod.absent(name, 'key'), ret)
|
||||
|
||||
comt = ('Key(s) specified already absent')
|
||||
ret.update({'comment': comt, 'result': True})
|
||||
self.assertDictEqual(redismod.absent(name, ['key']), ret)
|
||||
|
||||
comt = ('Keys deleted')
|
||||
ret.update({'comment': comt, 'changes': {'deleted': ['key']}})
|
||||
self.assertDictEqual(redismod.absent(name, ['key']), ret)
|
||||
|
||||
comt = ('Key deleted')
|
||||
ret.update({'comment': comt,
|
||||
'changes': {'deleted': ['key_in_redis']}})
|
||||
self.assertDictEqual(redismod.absent(name), ret)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
from integration import run_tests
|
||||
run_tests(RedismodTestCase, needs_daemon=False)
|
@ -122,6 +122,7 @@ class VTTestCase(TestCase):
|
||||
# We're pushing the system resources, let's keep going
|
||||
continue
|
||||
|
||||
@skipIf(True, 'Disabled until we can figure out how to make this more reliable.')
|
||||
def test_isalive_while_theres_data_to_read(self):
|
||||
expected_data = 'Alive!\n'
|
||||
term = vt.Terminal('echo "Alive!"', shell=True, stream_stdout=False, stream_stderr=False)
|
||||
|
Loading…
Reference in New Issue
Block a user