From c76f7eb028153194b688b83f27d5fee59bd482c4 Mon Sep 17 00:00:00 2001 From: Daniel Wallace Date: Thu, 15 Mar 2018 14:29:54 -0600 Subject: [PATCH 1/2] enable debug logging on the minionlog --- .kitchen.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.kitchen.yml b/.kitchen.yml index 1ebd0ee735..4381556910 100644 --- a/.kitchen.yml +++ b/.kitchen.yml @@ -31,7 +31,7 @@ provisioner: salt_version: latest salt_bootstrap_url: https://bootstrap.saltstack.com salt_bootstrap_options: -X -p rsync stable <%= version %> - log_level: info + log_level: debug sudo: true require_chef: false retry_on_exit_code: From 78cbf7b5cd49c54e5c7eb91afdfb935761c35277 Mon Sep 17 00:00:00 2001 From: Daniel Wallace Date: Fri, 16 Mar 2018 08:36:51 -0600 Subject: [PATCH 2/2] Fix npm issue Fixes saltstack/salt-jenkins#884 --- salt/modules/npm.py | 12 ++++++------ tests/integration/states/test_npm.py | 10 ++++++++-- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/salt/modules/npm.py b/salt/modules/npm.py index e794f8fdd5..b2c035f493 100644 --- a/salt/modules/npm.py +++ b/salt/modules/npm.py @@ -157,7 +157,7 @@ def install(pkg=None, if runas: uid = salt.utils.get_uid(runas) if uid: - env.update({'SUDO_UID': b'{0}'.format(uid), 'SUDO_USER': b''}) + env.update({'SUDO_UID': uid, 'SUDO_USER': ''}) cmd = ' '.join(cmd) result = __salt__['cmd.run_all'](cmd, python_shell=True, cwd=dir, runas=runas, env=env) @@ -236,7 +236,7 @@ def uninstall(pkg, dir=None, runas=None, env=None): if runas: uid = salt.utils.get_uid(runas) if uid: - env.update({'SUDO_UID': b'{0}'.format(uid), 'SUDO_USER': b''}) + env.update({'SUDO_UID': uid, 'SUDO_USER': ''}) cmd = ['npm', 'uninstall', '"{0}"'.format(pkg)] if not dir: @@ -295,7 +295,7 @@ def list_(pkg=None, dir=None, runas=None, env=None, depth=None): if runas: uid = salt.utils.get_uid(runas) if uid: - env.update({'SUDO_UID': b'{0}'.format(uid), 'SUDO_USER': b''}) + env.update({'SUDO_UID': uid, 'SUDO_USER': ''}) cmd = ['npm', 'list', '--json', '--silent'] @@ -358,7 +358,7 @@ def cache_clean(path=None, runas=None, env=None, force=False): if runas: uid = salt.utils.get_uid(runas) if uid: - env.update({'SUDO_UID': b'{0}'.format(uid), 'SUDO_USER': b''}) + env.update({'SUDO_UID': uid, 'SUDO_USER': ''}) cmd = ['npm', 'cache', 'clean'] if path: @@ -405,7 +405,7 @@ def cache_list(path=None, runas=None, env=None): if runas: uid = salt.utils.get_uid(runas) if uid: - env.update({'SUDO_UID': b'{0}'.format(uid), 'SUDO_USER': b''}) + env.update({'SUDO_UID': uid, 'SUDO_USER': ''}) cmd = ['npm', 'cache', 'ls'] if path: @@ -445,7 +445,7 @@ def cache_path(runas=None, env=None): if runas: uid = salt.utils.get_uid(runas) if uid: - env.update({'SUDO_UID': b'{0}'.format(uid), 'SUDO_USER': b''}) + env.update({'SUDO_UID': uid, 'SUDO_USER': ''}) cmd = 'npm config get cache' diff --git a/tests/integration/states/test_npm.py b/tests/integration/states/test_npm.py index 661b701a4d..e66a3aef37 100644 --- a/tests/integration/states/test_npm.py +++ b/tests/integration/states/test_npm.py @@ -6,12 +6,14 @@ ''' # Import Python libs from __future__ import absolute_import +import os # Import Salt Testing libs from tests.support.case import ModuleCase from tests.support.unit import skipIf from tests.support.helpers import destructiveTest, requires_network from tests.support.mixins import SaltReturnAssertsMixin +from tests.support.runtests import RUNTIME_VARS # Import salt libs import salt.utils @@ -42,10 +44,14 @@ class NpmStateTest(ModuleCase, SaltReturnAssertsMixin): ''' Determine if URL-referenced NPM module can be successfully installed. ''' - ret = self.run_state('npm.installed', name='request/request#v2.81.1') + user = os.environ.get('SUDO_USER', 'root') + npm_dir = os.path.join(RUNTIME_VARS.TMP, 'git-install-npm') + self.run_state('file.directory', name=npm_dir, user=user, dir_mode='755') + ret = self.run_state('npm.installed', name='request/request#v2.81.1', runas=user, dir=npm_dir) self.assertSaltTrueReturn(ret) - ret = self.run_state('npm.removed', name='git://github.com/request/request') + ret = self.run_state('npm.removed', name='git://github.com/request/request', runas=user, dir=npm_dir) self.assertSaltTrueReturn(ret) + self.run_state('file.absent', name=npm_dir) @requires_network() @destructiveTest