mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 00:55:19 +00:00
Merge branch '2019.2.1' into add_pygit2
This commit is contained in:
commit
7dd97a62c1
@ -5,7 +5,10 @@ Integration tests for DigitalOcean APIv2
|
||||
|
||||
# Import Python Libs
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import base64
|
||||
import hashlib
|
||||
import os
|
||||
from Crypto.PublicKey import RSA
|
||||
|
||||
# Import Salt Testing Libs
|
||||
from tests.support.case import ShellCase
|
||||
@ -14,6 +17,8 @@ from tests.support.helpers import expensiveTest, generate_random_name
|
||||
|
||||
# Import Salt Libs
|
||||
from salt.config import cloud_providers_config
|
||||
from salt.ext.six.moves import range
|
||||
import salt.utils.stringutils
|
||||
|
||||
|
||||
# Create the cloud instance name to be used throughout the tests
|
||||
@ -99,11 +104,16 @@ class DigitalOceanTest(ShellCase):
|
||||
'''
|
||||
Test key management
|
||||
'''
|
||||
pub = 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAQQDDHr/jh2Jy4yALcK4JyWbVkPRaWmhck3IgCoeOO3z1e2dBowLh64QAM+Qb72pxekALga2oi4GvT+TlWNhzPH4V example'
|
||||
finger_print = '3b:16:bf:e4:8b:00:8b:b8:59:8c:a9:d3:f0:19:45:fa'
|
||||
do_key_name = INSTANCE_NAME + '-key'
|
||||
|
||||
# generate key and fingerprint
|
||||
ssh_key = RSA.generate(4096)
|
||||
pub = salt.utils.stringutils.to_str(ssh_key.publickey().exportKey("OpenSSH"))
|
||||
key_hex = hashlib.md5(base64.b64decode(pub.strip().split()[1].encode())).hexdigest()
|
||||
finger_print = ':'.join([key_hex[x:x+2] for x in range(0, len(key_hex), 2)])
|
||||
|
||||
try:
|
||||
_key = self.run_cloud('-f create_key {0} name="MyPubKey" public_key="{1}"'.format(PROVIDER_NAME, pub))
|
||||
_key = self.run_cloud('-f create_key {0} name="{1}" public_key="{2}"'.format(PROVIDER_NAME, do_key_name, pub))
|
||||
|
||||
# Upload public key
|
||||
self.assertIn(
|
||||
@ -120,8 +130,8 @@ class DigitalOceanTest(ShellCase):
|
||||
)
|
||||
|
||||
# List key
|
||||
show_keypair = self.run_cloud('-f show_keypair {0} keyname={1}'.format(PROVIDER_NAME, 'MyPubKey'))
|
||||
|
||||
show_keypair = self.run_cloud('-f show_keypair {0} keyname={1}'.format(PROVIDER_NAME,
|
||||
do_key_name))
|
||||
self.assertIn(
|
||||
finger_print,
|
||||
[i.strip() for i in show_keypair]
|
||||
|
@ -7,6 +7,7 @@ import logging
|
||||
import os
|
||||
import signal
|
||||
import subprocess
|
||||
import time
|
||||
import textwrap
|
||||
|
||||
# Import Salt Testing libs
|
||||
@ -369,9 +370,15 @@ class WinSystemModuleTest(ModuleCase):
|
||||
'''
|
||||
Validate the date/time functions in the win_system module
|
||||
'''
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
if subprocess.call('net stop w32time', shell=True) != 0:
|
||||
log.error('Failed to stop w32time service')
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
if subprocess.call('net start w32time', shell=True) != 0:
|
||||
log.error('Failed to start w32time service')
|
||||
if subprocess.call('w32tm /resync', shell=True) != 0:
|
||||
log.error("Re-syncing time failed")
|
||||
|
||||
@ -402,13 +409,29 @@ class WinSystemModuleTest(ModuleCase):
|
||||
finally:
|
||||
self.run_function('system.set_computer_desc', [current_desc])
|
||||
|
||||
@skipIf(True, 'WAR ROOM 7/29/2019, unit test?')
|
||||
def test_get_system_time(self):
|
||||
'''
|
||||
Test getting the system time
|
||||
'''
|
||||
ret = self.run_function('system.get_system_time')
|
||||
now = datetime.datetime.now()
|
||||
self.assertEqual(now.strftime("%I:%M"), ret.rsplit(':', 1)[0])
|
||||
time_now = datetime.datetime.now()
|
||||
# We have to do some datetime fu to account for the possibility that the
|
||||
# system time will be obtained just before the minutes increment
|
||||
ret = self.run_function('system.get_system_time', timeout=300)
|
||||
# Split out time and AM/PM
|
||||
sys_time, meridian = ret.split(' ')
|
||||
h, m, s = sys_time.split(':')
|
||||
# Get the current time
|
||||
# Use the system time to generate a datetime object for the system time
|
||||
# with the same date
|
||||
time_sys = time_now.replace(hour=int(h), minute=int(m), second=int(s))
|
||||
# get_system_time returns a non 24 hour time
|
||||
# Lets make it 24 hour time
|
||||
if meridian == 'PM':
|
||||
time_sys = time_sys + datetime.timedelta(hours=12)
|
||||
diff = time_sys - time_now
|
||||
# Timeouts are set to 300 seconds. We're adding a 30 second buffer
|
||||
self.assertTrue(diff.seconds < 330)
|
||||
|
||||
@skipIf(True, 'WAR ROOM 7/18/2019, unit test?')
|
||||
@destructiveTest
|
||||
@ -421,23 +444,22 @@ class WinSystemModuleTest(ModuleCase):
|
||||
In order for this test to pass, time sync must be disabled for the
|
||||
VM in the hypervisor
|
||||
'''
|
||||
self.run_function('service.stop', ['w32time'])
|
||||
test_time = '10:55'
|
||||
current_time = self.run_function('system.get_system_time')
|
||||
try:
|
||||
current_time = datetime.datetime.now().strftime('%H:%M:%S')
|
||||
test_time = '10:55'
|
||||
self.run_function('system.set_system_time', [test_time + ' AM'])
|
||||
get_time = self.run_function('system.get_system_time').rsplit(':', 1)[0]
|
||||
self.assertEqual(get_time, test_time)
|
||||
time.sleep(.25)
|
||||
new_time = datetime.datetime.now().strftime('%H:%M')
|
||||
self.assertEqual(new_time, test_time)
|
||||
finally:
|
||||
self.run_function('system.set_system_time', [current_time])
|
||||
self.run_function('service.start', ['w32time'])
|
||||
|
||||
def test_get_system_date(self):
|
||||
'''
|
||||
Test getting system date
|
||||
'''
|
||||
ret = self.run_function('system.get_system_date')
|
||||
date = datetime.datetime.now().date().strftime("%m/%d/%Y")
|
||||
date = datetime.datetime.now().strftime("%m/%d/%Y")
|
||||
self.assertEqual(date, ret)
|
||||
|
||||
@skipIf(True, 'WAR ROOM 7/18/2019, unit test?')
|
||||
@ -451,12 +473,12 @@ class WinSystemModuleTest(ModuleCase):
|
||||
In order for this test to pass, time sync must be disabled for the
|
||||
VM in the hypervisor
|
||||
'''
|
||||
self.run_function('service.stop', ['w32time'])
|
||||
current_date = self.run_function('system.get_system_date')
|
||||
try:
|
||||
# If the test still fails, the hypervisor may be maintaining time
|
||||
# sync
|
||||
current_date = datetime.datetime.now().strftime('%Y/%m/%d')
|
||||
self.run_function('system.set_system_date', ['03/25/2018'])
|
||||
ret = self.run_function('system.get_system_date')
|
||||
self.assertEqual(ret, '03/25/2018')
|
||||
new_date = datetime.datetime.now().strftime('%Y/%m/%d')
|
||||
self.assertEqual(new_date, '2018/03/25')
|
||||
finally:
|
||||
self.run_function('system.set_system_date', [current_date])
|
||||
self.run_function('service.start', ['w32time'])
|
||||
|
@ -151,6 +151,8 @@ class CallTest(ShellCase, testprogram.TestProgramCase, ShellCaseCommonTestsMixin
|
||||
]
|
||||
self.assertTrue(True in ['returnTOmaster' in a for a in master_out])
|
||||
|
||||
# This test was skipped because it is consistantly failing on centos 7 tcp builds (2019.2.1)
|
||||
@skipIf(True, 'WAR ROOM TEMPORARY SKIP 7/24/2019')
|
||||
@skipIf(sys.platform.startswith('win'), 'This test does not apply on Win')
|
||||
@flaky
|
||||
def test_issue_2731_masterless(self):
|
||||
|
@ -1211,6 +1211,7 @@ class FileTest(ModuleCase, SaltReturnAssertsMixin):
|
||||
self.assertTrue(os.path.exists(good_file))
|
||||
self.assertFalse(os.path.exists(wrong_file))
|
||||
|
||||
@skipIf(salt.utils.platform.is_darwin(), 'WAR ROOM TEMPORARY SKIP, Test is flaky on macosx')
|
||||
@with_tempdir()
|
||||
def test_directory_clean_require_with_name(self, name):
|
||||
'''
|
||||
|
@ -653,7 +653,10 @@ class GitPillarHTTPTestBase(GitPillarTestBase, WebserverMixin):
|
||||
for proc in (cls.case.nginx_proc, cls.case.uwsgi_proc):
|
||||
if proc is not None:
|
||||
try:
|
||||
proc.send_signal(signal.SIGQUIT)
|
||||
proc.send_signal(signal.SIGTERM)
|
||||
time.sleep(1)
|
||||
if proc.is_running():
|
||||
proc.send_signal(signal.SIGKILL)
|
||||
except psutil.NoSuchProcess:
|
||||
pass
|
||||
shutil.rmtree(cls.root_dir, ignore_errors=True)
|
||||
|
Loading…
Reference in New Issue
Block a user