#!/usr/bin/env python3 # -*- encoding: UTF8 -*- # test_Upgrade.py # Tests SDP (Server Deployment Package) UPGRADES on Docker Compose images # See documentation and run_tests.sh in /sdp/main/test/README.md from __future__ import print_function import argparse import logging import os import re import sys import unittest import P4 import test_SDP from test_SDP import SDPTest_base LOGGER_NAME = 'UpgradeSDPTest' logger = logging.getLogger(LOGGER_NAME) options = None def init_logging(): global logger logger.setLevel(logging.DEBUG) formatter = logging.Formatter('%(asctime)s:%(name)s:%(levelname)s: %(message)s') fh = logging.FileHandler('/tmp/%s.log' % LOGGER_NAME, mode='w') fh.setLevel(logging.DEBUG) fh.setFormatter(formatter) logger.addHandler(fh) test_SDP.logger = logger class UpgradeSDPTest(SDPTest_base): "Tests for SDP upgrades" def setUp(self): self.setup_everything() self.p4 = None def install_binaries(self, ver): "Acquire Helix binaries from Perforce FTP server." output = self.run_cmd("./get_helix_binaries.sh -r %s" % ver, "/p4/sdp/helix_binaries", timeout=120) self.assertLinePresent("Downloading of Perforce Helix files completed OK", output) def p4run(self, *args): "Run the command logging" logger.debug('p4 cmd: %s' % ",".join([str(x) for x in args])) result = self.p4.run(args) logger.debug('result: %s' % str(result)) return result def dailyBackupTest(self, instance): "Test daily backup script" jnl_counter = self.p4run('counter', 'journal')[0]['value'] logger.debug("dailyBackupTest") self.run_cmd('/p4/common/bin/daily_checkpoint.sh %s' % instance) # Quick check on log file contents log_contents = self.readLog('checkpoint.log', instance) self.assertRegex(log_contents, "Dumping to /p4/%s/checkpoints/p4_%s.ckp" % (instance, instance)) self.assertRegex(log_contents, "journal") new_jnl_counter = self.p4run('counter', 'journal')[0]['value'] self.assertEqual(int(new_jnl_counter), int(jnl_counter) + 1) def testUpgrade(self): "Basic upgrade tests" self.run_cmd("cp -R /sdp /hxdepots/sdp") self.install_binaries("r%s" % options.from_version) self.sudo_cmd("rm -rf /tmp/p4") self.run_cmd("python3 /p4/test_SDP.py --instance 1 --setup", timeout=60) p4 = P4.P4() self.p4 = p4 p4.port = "1667" p4.user = "perforce" p4.connect() p4.disconnect() self.install_binaries("r%s" % options.to_version) output = self.run_cmd("/p4/common/bin/upgrade.sh 1 -y", timeout=60) self.assertLinePresent("Could not verify the p4broker server is online", output) self.assertLinePresent("Exiting because no upgrades are needed", output) p4.connect() # Validate expected server version is running info = p4.run_info()[0] self.assertLinePresent('P4D/LINUX26X86_64/20%s' % options.to_version, info['serverVersion']) self.dailyBackupTest("1") if __name__ == "__main__": init_logging() parser = argparse.ArgumentParser(add_help=False) parser.add_argument('--from-version', default="23.2") parser.add_argument('--to-version', default="24.1") options, args = parser.parse_known_args() testrunner = None unittest.main(testRunner=testrunner, argv=sys.argv[:1] + args)
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#20 | 30356 | C. Thomas Tyler |
Added Rocky 9 and Ubuntu 22 to test suite. Dropped CentOS 6. Changed default OS for tests from CentOS 7 to Rocky 9. Adapted to using podman for the test suite. Reduced minimum disk space requirement for testing from 1G to 10M. To be revisited: * Disabled OOM killer defenese feature and systemd due to compatibility issues with the test environment. * Disabled systemd by moving systemctl aside Enhanced build_docker_image.sh; added '-clean' option and added support for more platforms. Updated OS-specific packages as needed for all platforms, e.g. adding 'file' and 'rsync' utils as needed in Docker definitions. Added minimum performance recommendations for test containers in config. Updated env.sh utilities. This change test on: [X] centos7 [X] rocky8 [X] rocky9 [X] ubuntu20 [X] ubuntu22 #review-30357 @robert_cowham TO DO: * This builds using the official SDP test suite run manually on Tom's laptop. Next step: Get it working on our shiny new Jenkins Rocky 9 server machine. |
||
#19 | 30018 | C. Thomas Tyler | Upgrade tests changed to test upgrade from r23.1 -> r23.2. | ||
#18 | 29581 | C. Thomas Tyler | Adjusted Helix Core versions in test suite. | ||
#17 | 29229 | C. Thomas Tyler | Accounted for change to default Helix Server version. | ||
#16 | 28847 | C. Thomas Tyler | Test suite: Adjusted expected output for new version. | ||
#15 | 28379 | C. Thomas Tyler | Adjusted Helix Core versions to pull in test suite. | ||
#14 | 28237 | C. Thomas Tyler | Fixed broken test. | ||
#13 | 28226 | C. Thomas Tyler | chmod +x | ||
#12 | 28166 | C. Thomas Tyler | Added -y to upgrade.sh call in test suite. | ||
#11 | 27905 | C. Thomas Tyler | Adjusted to-version. | ||
#10 | 27903 | C. Thomas Tyler |
Adapted test suite for recent changes to get_helix_binaries.sh to get newer p4d versions. |
||
#9 | 27026 | C. Thomas Tyler |
Adapted to changed command line for get_helix_binaries.sh. Adapted to change in expectd output ("Perforce Helix" rather than "Helix"). |
||
#8 | 27022 | C. Thomas Tyler | Changed 'exes' to 'helix_binaries' in folder and script name, per review. | ||
#7 | 27003 | Robert Cowham | Work around timing issues for tests. | ||
#6 | 26996 | C. Thomas Tyler | Added check for expected output in get_latest_exes.sh script. | ||
#5 | 26991 | C. Thomas Tyler | Another upgrade test tweak. | ||
#4 | 26990 | C. Thomas Tyler | Tweaked upgrade test. | ||
#3 | 26982 | C. Thomas Tyler |
mkdirs.sh v4.1.0: * Accounted for directory structure change of Maintenance to Unsupported. * Added standard command line processing with '-h' and '-man' doc flags, and other flags (all documented). * Added in-code docs and updated AsciiDoc. * Enhanced '-test' mode to simulate /hx* mounts. * Enhanced preflight testing, and fixed '-test' mode installs. * Added support for installing to an alternate root directory. * Added '-s <ServerID>' option to override REPLICA_ID. * Added '-S <TargetServerID>' used for replicas of edge servers. * Added '-t <server_type>' option to override SERVER_TYPE. * Added '-M' option to override mount points. * Added '-f' fast option to skip big chown/chmod commands, and moved those commands near the end as well. verify_sdp.sh v5.9.0: * Added check for /p4/Version file, and checked that other legacy SDP methods of checking version * Added sanity check for crontab. * Added 'test skip' mechanism to skip certain tests: - crontab: Skip crontab check. Use this if you do not expect crontab to be configured, perhaps if a different scheduler is used. - license: Skip license related checks. - version: Skip version checks. - excess: Skip checks for excess copies of p4d/p4p/p4broker in PATH. * Added VERIFY_SDP_SKIP_TEST_LIST setting ton instance_vars.template, to define a standard way to have verify_sdp.sh always skip certain tests for a site. * Extended '-online' checks to check for bogus P4MASTERPORT, a common config error. Update test_SDP.py: * Adjusted test suite to account for various changes in mkdirs.sh. * Added 'dir' parameter to run_cmd() and sudo_cmd(), to run a command from a specified directory (as required to test new mkdirs.sh) * Added check_links() similar to existing check_dirs() function. === Upgrade Process Changes === Made /p4/common/bin/p4d/p4/p4broker/p4p shell script rather than binary. This changes the way SDP new binaries are staged for upgrade. For safety, exes are now staged to a director outside the PATH, the /p4/sdp/exes folder. A new 'get_latest_exes.sh' script simplifies the task of pulling executables from the Perforce FTP server. This can be used 'as is' for environments with outbound internet access, and is useful in any case to describe now to acquire binaries. This addresses an issue where a p4d binary staged for a future upgrade might be called before the actual upgrade is performed. upgrade.sh v4.0.0: * All preflight checks are now done first. Added '-p' to abort after preflight. * Added '-n' to show what would be done before anything is executed. * Minimalist logic to start/stop only servers that are upgrade, and apply upgrades only as needed. * Staging of exes for upgrade is now separate from /p4/common/bin * Improved in-code docs, added '-h' and '-man' options. * Retained pre/post P4D 2019.1 upgrade logic. |
||
#2 | 25555 | Robert Cowham | Handle new 19.1 upgrade.sh requirements | ||
#1 | 25554 | Robert Cowham | Automated tests for calling upgrade.sh |