Merge branch '2019.2.1' into add_pygit2

This commit is contained in:
Megan Wilhite 2019-07-29 13:04:26 -04:00 committed by GitHub
commit 7dd97a62c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 59 additions and 21 deletions

View File

@ -5,7 +5,10 @@ Integration tests for DigitalOcean APIv2
# Import Python Libs # Import Python Libs
from __future__ import absolute_import, print_function, unicode_literals from __future__ import absolute_import, print_function, unicode_literals
import base64
import hashlib
import os import os
from Crypto.PublicKey import RSA
# Import Salt Testing Libs # Import Salt Testing Libs
from tests.support.case import ShellCase from tests.support.case import ShellCase
@ -14,6 +17,8 @@ from tests.support.helpers import expensiveTest, generate_random_name
# Import Salt Libs # Import Salt Libs
from salt.config import cloud_providers_config 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 # Create the cloud instance name to be used throughout the tests
@ -99,11 +104,16 @@ class DigitalOceanTest(ShellCase):
''' '''
Test key management Test key management
''' '''
pub = 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAQQDDHr/jh2Jy4yALcK4JyWbVkPRaWmhck3IgCoeOO3z1e2dBowLh64QAM+Qb72pxekALga2oi4GvT+TlWNhzPH4V example' do_key_name = INSTANCE_NAME + '-key'
finger_print = '3b:16:bf:e4:8b:00:8b:b8:59:8c:a9:d3:f0:19:45:fa'
# 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: 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 # Upload public key
self.assertIn( self.assertIn(
@ -120,8 +130,8 @@ class DigitalOceanTest(ShellCase):
) )
# List key # 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( self.assertIn(
finger_print, finger_print,
[i.strip() for i in show_keypair] [i.strip() for i in show_keypair]

View File

@ -7,6 +7,7 @@ import logging
import os import os
import signal import signal
import subprocess import subprocess
import time
import textwrap import textwrap
# Import Salt Testing libs # Import Salt Testing libs
@ -369,9 +370,15 @@ class WinSystemModuleTest(ModuleCase):
''' '''
Validate the date/time functions in the win_system module 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 @classmethod
def tearDownClass(cls): 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: if subprocess.call('w32tm /resync', shell=True) != 0:
log.error("Re-syncing time failed") log.error("Re-syncing time failed")
@ -402,13 +409,29 @@ class WinSystemModuleTest(ModuleCase):
finally: finally:
self.run_function('system.set_computer_desc', [current_desc]) self.run_function('system.set_computer_desc', [current_desc])
@skipIf(True, 'WAR ROOM 7/29/2019, unit test?')
def test_get_system_time(self): def test_get_system_time(self):
''' '''
Test getting the system time Test getting the system time
''' '''
ret = self.run_function('system.get_system_time') time_now = datetime.datetime.now()
now = datetime.datetime.now() # We have to do some datetime fu to account for the possibility that the
self.assertEqual(now.strftime("%I:%M"), ret.rsplit(':', 1)[0]) # 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?') @skipIf(True, 'WAR ROOM 7/18/2019, unit test?')
@destructiveTest @destructiveTest
@ -421,23 +444,22 @@ class WinSystemModuleTest(ModuleCase):
In order for this test to pass, time sync must be disabled for the In order for this test to pass, time sync must be disabled for the
VM in the hypervisor VM in the hypervisor
''' '''
self.run_function('service.stop', ['w32time'])
test_time = '10:55'
current_time = self.run_function('system.get_system_time')
try: try:
current_time = datetime.datetime.now().strftime('%H:%M:%S')
test_time = '10:55'
self.run_function('system.set_system_time', [test_time + ' AM']) self.run_function('system.set_system_time', [test_time + ' AM'])
get_time = self.run_function('system.get_system_time').rsplit(':', 1)[0] time.sleep(.25)
self.assertEqual(get_time, test_time) new_time = datetime.datetime.now().strftime('%H:%M')
self.assertEqual(new_time, test_time)
finally: finally:
self.run_function('system.set_system_time', [current_time]) self.run_function('system.set_system_time', [current_time])
self.run_function('service.start', ['w32time'])
def test_get_system_date(self): def test_get_system_date(self):
''' '''
Test getting system date Test getting system date
''' '''
ret = self.run_function('system.get_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) self.assertEqual(date, ret)
@skipIf(True, 'WAR ROOM 7/18/2019, unit test?') @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 In order for this test to pass, time sync must be disabled for the
VM in the hypervisor VM in the hypervisor
''' '''
self.run_function('service.stop', ['w32time'])
current_date = self.run_function('system.get_system_date')
try: 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']) self.run_function('system.set_system_date', ['03/25/2018'])
ret = self.run_function('system.get_system_date') new_date = datetime.datetime.now().strftime('%Y/%m/%d')
self.assertEqual(ret, '03/25/2018') self.assertEqual(new_date, '2018/03/25')
finally: finally:
self.run_function('system.set_system_date', [current_date]) self.run_function('system.set_system_date', [current_date])
self.run_function('service.start', ['w32time'])

View File

@ -151,6 +151,8 @@ class CallTest(ShellCase, testprogram.TestProgramCase, ShellCaseCommonTestsMixin
] ]
self.assertTrue(True in ['returnTOmaster' in a for a in master_out]) 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') @skipIf(sys.platform.startswith('win'), 'This test does not apply on Win')
@flaky @flaky
def test_issue_2731_masterless(self): def test_issue_2731_masterless(self):

View File

@ -1211,6 +1211,7 @@ class FileTest(ModuleCase, SaltReturnAssertsMixin):
self.assertTrue(os.path.exists(good_file)) self.assertTrue(os.path.exists(good_file))
self.assertFalse(os.path.exists(wrong_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() @with_tempdir()
def test_directory_clean_require_with_name(self, name): def test_directory_clean_require_with_name(self, name):
''' '''

View File

@ -653,7 +653,10 @@ class GitPillarHTTPTestBase(GitPillarTestBase, WebserverMixin):
for proc in (cls.case.nginx_proc, cls.case.uwsgi_proc): for proc in (cls.case.nginx_proc, cls.case.uwsgi_proc):
if proc is not None: if proc is not None:
try: 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: except psutil.NoSuchProcess:
pass pass
shutil.rmtree(cls.root_dir, ignore_errors=True) shutil.rmtree(cls.root_dir, ignore_errors=True)