#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
#
from . import testutils
if __name__ == "__main__":
import pkg5unittest
import os
import unittest
import random
import re
import shutil
import signal
import time
# Default number iterations; tune with NASTY_ITERS in environ.
# Default nastiness; tune with NASTY_LEVEL in environ.
template_10 = """
open testpkg/__SUB__@1.0,5.11-0
add dir mode=0755 owner=root group=bin path=/stuff
close """
# in v1.1, file contents are shifted around
template_11 = """
open testpkg/__SUB__@1.1,5.11-0
add dir mode=0755 owner=root group=bin path=/stuff
close """
s = ""
while outlen > 0:
"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()")
outlen -= 1
return s
misc_files = {
}
for f in misc_files:
# Overwrite the number with file contents of size
# <that number>
misc_files[f] = \
self.NASTY_ITERS = \
self.NASTY_LEVEL = \
"PKG_CLIENT_MAX_CONSECUTIVE_ERRORS": "3",
"PKG_CLIENT_MAX_TIMEOUT": "2",
"PKG_CLIENT_LOWSPEED_TIMEOUT": \
}
pubname = "test"
# Note that we have chosen not to ignore errors here,
# since we're depending on knowing the internal layout
try:
except Exception:
"""Runs kallable ntries times; if after ntries the operation
has not returned 0, try again with the nastiness disabled in
the depot. The goal is to push through to get a real result
but also to prevent infinite looping."""
if tries > 1:
"--try: '{0}' try #{1:d}".format(
if ret == 0:
break
else:
# Turn nastiness off on the depot and try again;
# this helps prevent waiting around forever for
# something to eventually work.
"({1:d} times). Disabling nasty and retrying".format(
# Reset environment params and depot nastiness.
# We have to edit self.nasty_env in place (as opposed
# to just replacing it) because a reference to it is
# already bound up with kallable.
# Set these to "" to make them revert to defaults
# Restore Nastiness and environment parameters.
if ret != 0:
raise self.failureException(
"Failed '{0}' {1:d} times, then failed again "
"with nasty disabled. Test failed".format(
"""Loop running a nasty test. Iterations tunable by setting
NASTY_ITERS in the process environment, i.e. NASTY_ITERS=100."""
x, self.NASTY_ITERS))
try:
kallable()
except:
x, self.NASTY_ITERS))
raise
# Exists as a subclass only so we can run tests in parallel.
# Set up signature stuff.
# test contents -r
contentscmd = "contents -m -r testpkg/*A@1.0"
# clean up mfsts.
# Change a file in the image and then revert it.
print("I LIKE COCONUTS!", file=f)
f.close()
# Try some things which are supposed to fail; we can't really
# pick apart transport failures versus the actual semantic
# failure; oh well for now.
"""Test the pkg command against a nasty depot."""
# Exists as a subclass only so we can run tests in parallel.
# clean up pkgrecv "resume" turds
"""Test the pkgrecv command against a nasty depot."""
"""Test the pkgrepo command against a nasty depot."""
# Exists as a subclass only so we can run tests in parallel.
# Set up signature stuff.
# test list with temporary publisher
# test contents with temporary publisher
# clean out dl'd mfsts
# test info with temporary publisher
# clean out dl'd mfsts
# test install with temporary publisher
# test update with temporary publisher
foo10 = """
open foo@1.0,5.11-0
close """
"""Verify pkg client handles SIGTERM, SIGHUP, SIGINT gracefully
and writes a history entry if possible."""
# SIGHUP not supported on Windows.
else:
["-D", "simulate-plan-hang=true", "install", "foo"],
# Wait for hang file before sending signal.
# Verify that history records operation as canceled.
if __name__ == "__main__":