#!/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 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() def install_binaries(self, ver): for f in ["p4", "p4d", "p4broker"]: src = "/hxdepots/sdp/Server/Unix/p4/common/bin/%s-%s" % (f, ver) targ = "/hxdepots/sdp/Server/Unix/p4/common/bin/%s" % f self.run_cmd("cp %s %s" % (src,targ)) def testUpgrade(self): "Basic upgrade tests 18.1 -> 18.2" self.run_cmd("cp -R /sdp /hxdepots/sdp") self.install_binaries("18.1") self.sudo_cmd("rm -rf /tmp/p4") self.run_cmd("python3 /p4/test_SDP.py --instance 1 --setup") p4 = P4.P4() p4.port = "1667" p4.user = "perforce" p4.connect() p4.disconnect() for ver in ["18.2"]: self.install_binaries(ver) output = self.run_cmd("/p4/common/bin/upgrade.sh 1") self.assertLinePresent("/p4/common/bin/upgrade.sh: Finished p4_1 Upgrade", output) p4.connect() info = p4.run_info() self.assertLinePresent('P4D/LINUX26X86_64/20%s/' % ver, info['serverVersion']) if __name__ == "__main__": init_logging() testrunner = None unittest.main(testRunner=testrunner, argv=sys.argv[:1])
|#15||28379||tom_tyler||Adjusted Helix Core versions to pull in test suite.|
|#14||28237||tom_tyler||Fixed broken test.|
|#12||28166||tom_tyler||Added -y to upgrade.sh call in test suite.|
Adapted test suite for recent changes to get_helix_binaries.sh to
get newer p4d versions.
Adapted to changed command line for get_helix_binaries.sh.
Adapted to change in expectd output ("Perforce Helix" rather than
|#8||27022||tom_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||tom_tyler||Added check for expected output in get_latest_exes.sh script.|
|#5||26991||tom_tyler||Another upgrade test tweak.|
|#4||26990||tom_tyler||Tweaked upgrade test.|
* 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.
* 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
* 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
* 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.
* 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|