src/tests/pkg5unittest.py
author saurabh.vyas@oracle.com
Wed, 16 Jul 2014 06:51:23 -0700
branchs11u2-sru
changeset 3240 3661c0b9accd
parent 3192 13377dbd6773
permissions -rw-r--r--
19218185 TTY display tests fail in >b50
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
430
3fb945d3bff3 2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff changeset
     1
# CDDL HEADER START
3fb945d3bff3 2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff changeset
     2
#
3fb945d3bff3 2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff changeset
     3
# The contents of this file are subject to the terms of the
3fb945d3bff3 2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff changeset
     4
# Common Development and Distribution License (the "License").
3fb945d3bff3 2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff changeset
     5
# You may not use this file except in compliance with the License.
3fb945d3bff3 2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff changeset
     6
#
3fb945d3bff3 2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff changeset
     7
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
3fb945d3bff3 2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff changeset
     8
# or http://www.opensolaris.org/os/licensing.
3fb945d3bff3 2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff changeset
     9
# See the License for the specific language governing permissions
3fb945d3bff3 2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff changeset
    10
# and limitations under the License.
3fb945d3bff3 2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff changeset
    11
#
3fb945d3bff3 2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff changeset
    12
# When distributing Covered Code, include this CDDL HEADER in each
3fb945d3bff3 2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff changeset
    13
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
3fb945d3bff3 2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff changeset
    14
# If applicable, add the following below this CDDL HEADER, with the
3fb945d3bff3 2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff changeset
    15
# fields enclosed by brackets "[]" replaced with your own identifying
3fb945d3bff3 2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff changeset
    16
# information: Portions Copyright [yyyy] [name of copyright owner]
3fb945d3bff3 2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff changeset
    17
#
3fb945d3bff3 2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff changeset
    18
# CDDL HEADER END
3fb945d3bff3 2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff changeset
    19
#
3fb945d3bff3 2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff changeset
    20
3190
ebc9455aaf57 18779149 pkg uninstall should support automatic downgrades from pkg metadata
saurabh.vyas@oracle.com
parents: 3144
diff changeset
    21
# Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
430
3fb945d3bff3 2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff changeset
    22
2339
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
    23
#
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
    24
# Define the basic classes that all test cases are inherited from.
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
    25
# The currently defined test case classes are:
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
    26
#
2852
5650587d9468 15807357 need an Apache-based pkg.depotd
Tim Foster <tim.s.foster@oracle.com>
parents: 2843
diff changeset
    27
# ApacheDepotTestCase
2339
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
    28
# CliTestCase
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
    29
# ManyDepotTestCase
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
    30
# Pkg5TestCase
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
    31
# SingleDepotTestCase
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
    32
# SingleDepotTestCaseCorruptImage
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
    33
#
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
    34
430
3fb945d3bff3 2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff changeset
    35
import baseline
2085
10a27146ebc2 16802 pkglint should check the value of info.classification in manifests
Tim Foster <tim.s.foster@oracle.com>
parents: 2081
diff changeset
    36
import ConfigParser
502
3f98e94acc4a 2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents: 448
diff changeset
    37
import copy
1730
c12580e62699 14347 Add tests to exercise the new -F tsv option for pkg publisher
Gary Pennington <gary.pennington@sun.com>
parents: 1715
diff changeset
    38
import difflib
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
    39
import errno
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
    40
import gettext
2026
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 1970
diff changeset
    41
import hashlib
2310
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
    42
import httplib
2028
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
    43
import logging
2499
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
    44
import multiprocessing
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
    45
import os
1859
6e6e866921e7 529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents: 1839
diff changeset
    46
import pprint
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
    47
import shutil
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
    48
import signal
2500
a63fead21404 18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2499
diff changeset
    49
import simplejson as json
1832
df15686547e4 6795 pkg fix should fix file modes for some preserved files
Shawn Walker <shawn.walker@oracle.com>
parents: 1795
diff changeset
    50
import stat
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
    51
import subprocess
430
3fb945d3bff3 2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff changeset
    52
import sys
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
    53
import tempfile
448
bcfa99ac18b0 2664 test suite baseline enhancements
Brad Hall <bhall@eng.sun.com>
parents: 436
diff changeset
    54
import time
2852
5650587d9468 15807357 need an Apache-based pkg.depotd
Tim Foster <tim.s.foster@oracle.com>
parents: 2843
diff changeset
    55
import traceback
430
3fb945d3bff3 2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff changeset
    56
import unittest
2310
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
    57
import urllib2
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
    58
import urlparse
2843
4e1d09017f2c 15722190 pkgrepo verify subcommand needed
Tim Foster <tim.s.foster@oracle.com>
parents: 2830
diff changeset
    59
import operator
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
    60
import platform
2755
9de4d0300695 7187397 pkg commands fail when TERM empty or non-standard
Dan Price <daniel.price@oracle.com>
parents: 2753
diff changeset
    61
import pty
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
    62
import pwd
1730
c12580e62699 14347 Add tests to exercise the new -F tsv option for pkg publisher
Gary Pennington <gary.pennington@sun.com>
parents: 1715
diff changeset
    63
import re
2310
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
    64
import ssl
2499
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
    65
import StringIO
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
    66
import textwrap
2755
9de4d0300695 7187397 pkg commands fail when TERM empty or non-standard
Dan Price <daniel.price@oracle.com>
parents: 2753
diff changeset
    67
import threading
9de4d0300695 7187397 pkg commands fail when TERM empty or non-standard
Dan Price <daniel.price@oracle.com>
parents: 2753
diff changeset
    68
import traceback
9de4d0300695 7187397 pkg commands fail when TERM empty or non-standard
Dan Price <daniel.price@oracle.com>
parents: 2753
diff changeset
    69
import types
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
    70
2339
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
    71
import pkg.client.api_errors as apx
2756
04d926cf9f51 7140807 sysrepo should not cache catalog responses
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2755
diff changeset
    72
import pkg.misc as misc
2339
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
    73
import pkg.client.publisher as publisher
2499
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
    74
import pkg.portable as portable
2339
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
    75
import pkg.server.repository as sr
2414
ce704b29a50c 18464 revoka-ca-cert needs a rethink
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2401
diff changeset
    76
import M2Crypto as m2
2339
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
    77
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
    78
from pkg.client.debugvalues import DebugValues
2756
04d926cf9f51 7140807 sysrepo should not cache catalog responses
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2755
diff changeset
    79
from socket import error as socketerror
2339
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
    80
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
    81
EmptyI = tuple()
1859
6e6e866921e7 529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents: 1839
diff changeset
    82
EmptyDict = dict()
616
6d307b088d92 4056 make_uninstall_plan misreports trying to uninstall a known, but uninstalled package
Brock Pytlik <bpytlik@sun.com>
parents: 571
diff changeset
    83
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
    84
#
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
    85
# These are initialized by pkg5testenv.setup_environment.
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
    86
#
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
    87
g_proto_area = "TOXIC"
3048
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
    88
g_proto_readable = False
2758
ff2b3e357cac 7187141 usr/src/cmd/installadm/test/test_image.py fails in s11u1_21
Dan Price <daniel.price@oracle.com>
parents: 2756
diff changeset
    89
# Location of root of test suite.
ff2b3e357cac 7187141 usr/src/cmd/installadm/test/test_image.py fails in s11u1_21
Dan Price <daniel.price@oracle.com>
parents: 2756
diff changeset
    90
g_test_dir = "TOXIC"
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
    91
# User's value for TEMPDIR
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
    92
g_tempdir = "/tmp"
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
    93
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
    94
g_debug_output = False
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
    95
if "DEBUG" in os.environ:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
    96
        g_debug_output = True
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
    97
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
    98
#
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
    99
# XXX?
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   100
#
1946
8ef3acf32d54 16132 various bits of pkg specify non-existent domains to gettext.install
Richard Lowe <richlowe@richlowe.net>
parents: 1908
diff changeset
   101
gettext.install("pkg", "/usr/share/locale")
430
3fb945d3bff3 2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff changeset
   102
2073
9fcacc9e5eaa 16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents: 2047
diff changeset
   103
OUTPUT_DOTS = 0         # Dots ...
9fcacc9e5eaa 16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents: 2047
diff changeset
   104
OUTPUT_VERBOSE = 1      # Verbose
9fcacc9e5eaa 16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents: 2047
diff changeset
   105
OUTPUT_PARSEABLE = 2    # Machine readable
430
3fb945d3bff3 2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff changeset
   106
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   107
class TestStopException(Exception):
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   108
        """An exception used to signal that all testing should cease.
2073
9fcacc9e5eaa 16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents: 2047
diff changeset
   109
        This is a framework-internal exception that tests should not
9fcacc9e5eaa 16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents: 2047
diff changeset
   110
        raise"""
435
461b1c739de9 1753 An exception thrown during the teardown phase of the test program leaves pkg.depot running.
Brock Pytlik <bpytlik@sun.com>
parents: 430
diff changeset
   111
        pass
461b1c739de9 1753 An exception thrown during the teardown phase of the test program leaves pkg.depot running.
Brock Pytlik <bpytlik@sun.com>
parents: 430
diff changeset
   112
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   113
class TestSkippedException(Exception):
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   114
        """An exception used to signal that a test was skipped.
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   115
        Should be initialized with a string giving a more detailed
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   116
        reason.  Test cases can raise this to the framework
2073
9fcacc9e5eaa 16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents: 2047
diff changeset
   117
        that some prerequisite of the test is unsatisfied.  A string
9fcacc9e5eaa 16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents: 2047
diff changeset
   118
        explaining the error should be passed at construction.  """
9fcacc9e5eaa 16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents: 2047
diff changeset
   119
        def __str__(self):
9fcacc9e5eaa 16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents: 2047
diff changeset
   120
                return "Test Skipped: " + " ".join(self.args)
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   121
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   122
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   123
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   124
#
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   125
# Errors for which the traceback is likely not useful.
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   126
#
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   127
import pkg.depotcontroller as depotcontroller
1832
df15686547e4 6795 pkg fix should fix file modes for some preserved files
Shawn Walker <shawn.walker@oracle.com>
parents: 1795
diff changeset
   128
import pkg.portable as portable
1859
6e6e866921e7 529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents: 1839
diff changeset
   129
import pkg.client.api
6e6e866921e7 529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents: 1839
diff changeset
   130
import pkg.client.progress
6e6e866921e7 529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents: 1839
diff changeset
   131
2310
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
   132
from pkg.client.debugvalues import DebugValues
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
   133
1859
6e6e866921e7 529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents: 1839
diff changeset
   134
# Version test suite is known to work with.
6e6e866921e7 529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents: 1839
diff changeset
   135
PKG_CLIENT_NAME = "pkg"
3190
ebc9455aaf57 18779149 pkg uninstall should support automatic downgrades from pkg metadata
saurabh.vyas@oracle.com
parents: 3144
diff changeset
   136
CLIENT_API_VERSION = 80
1859
6e6e866921e7 529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents: 1839
diff changeset
   137
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   138
ELIDABLE_ERRORS = [ TestSkippedException, depotcontroller.DepotStateException ]
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   139
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   140
class Pkg5CommonException(AssertionError):
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   141
        def __init__(self, com = ""):
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   142
                Pkg5TestCase.failureException.__init__(self, com)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   143
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   144
        topdivider = \
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   145
        ",---------------------------------------------------------------------\n"
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   146
        botdivider = \
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   147
        "`---------------------------------------------------------------------\n"
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   148
        def format_comment(self, comment):
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   149
                if comment is not None:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   150
                        comment = comment.expandtabs()
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   151
                        comm = ""
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   152
                        for line in comment.splitlines():
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   153
                                line = line.strip()
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   154
                                if line == "":
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   155
                                        continue
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   156
                                comm += "  " + line + "\n"
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   157
                        return comm + "\n"
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   158
                else:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   159
                        return "<no comment>\n\n"
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   160
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   161
        def format_output(self, command, output):
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   162
                str = "  Output Follows:\n"
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   163
                str += self.topdivider
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   164
                if command is not None:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   165
                        str += "| $ " + command + "\n"
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   166
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   167
                if output is None or output == "":
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   168
                        str += "| <no output>\n"
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   169
                else:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   170
                        for line in output.split("\n"):
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   171
                                str += "| " + line.rstrip() + "\n"
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   172
                str += self.botdivider
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   173
                return str
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   174
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   175
        def format_debug(self, output):
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   176
                str = "  Debug Buffer Follows:\n"
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   177
                str += self.topdivider
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   178
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   179
                if output is None or output == "":
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   180
                        str += "| <no debug buffer>\n"
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   181
                else:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   182
                        for line in output.split("\n"):
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   183
                                str += "| " + line.rstrip() + "\n"
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   184
                str += self.botdivider
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   185
                return str
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   186
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   187
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   188
class AssFailException(Pkg5CommonException):
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   189
        def __init__(self, comment = None, debug=None):
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   190
                Pkg5CommonException.__init__(self, comment)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   191
                self.__comment = comment
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   192
                self.__debug = debug
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   193
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   194
        def __str__(self):
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   195
                str = ""
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   196
                if self.__comment is None:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   197
                        str += Exception.__str__(self)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   198
                else:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   199
                        str += self.format_comment(self.__comment)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   200
                if self.__debug is not None and self.__debug != "":
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   201
                        str += self.format_debug(self.__debug)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   202
                return str
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   203
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   204
2028
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
   205
class DebugLogHandler(logging.Handler):
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
   206
        """This class is a special log handler to redirect logger output to
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
   207
        the test case class' debug() method.
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
   208
        """
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
   209
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
   210
        def __init__(self, test_case):
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
   211
                self.test_case = test_case
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
   212
                logging.Handler.__init__(self)
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
   213
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
   214
        def emit(self, record):
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
   215
                self.test_case.debug(record)
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
   216
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
   217
def setup_logging(test_case):
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
   218
        # Ensure logger messages output by unit tests are redirected
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
   219
        # to debug output so they are not shown by default.
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
   220
        from pkg.client import global_settings
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
   221
        log_handler = DebugLogHandler(test_case)
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
   222
        global_settings.info_log_handler = log_handler
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
   223
        global_settings.error_log_handler = log_handler
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
   224
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
   225
430
3fb945d3bff3 2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff changeset
   226
class Pkg5TestCase(unittest.TestCase):
502
3f98e94acc4a 2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents: 448
diff changeset
   227
2339
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
   228
        # Needed for compatibility
502
3f98e94acc4a 2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents: 448
diff changeset
   229
        failureException = AssertionError
3f98e94acc4a 2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents: 448
diff changeset
   230
2339
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
   231
        #
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
   232
        # Some dns servers return results for unknown dns names to redirect
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
   233
        # callers to a common landing page.  To avoid getting tripped up by
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
   234
        # these stupid servers make sure that bogus_url actually contains an
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
   235
        # syntactically invalid dns name so we'll never succeed at the lookup.
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
   236
        #
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
   237
        bogus_url = "test.0.invalid"
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   238
        __debug_buf = ""
683
5e5d509f00e3 4422 t_pkg_authority pinging extant node accidentally
Brock Pytlik <bpytlik@sun.com>
parents: 616
diff changeset
   239
2310
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
   240
        smf_cmds = { \
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
   241
            "usr/bin/svcprop" : """\
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
   242
#!/usr/bin/python
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
   243
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
   244
import sys
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
   245
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
   246
if __name__ == "__main__":
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
   247
        sys.exit(1)
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
   248
"""}
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
   249
430
3fb945d3bff3 2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff changeset
   250
        def __init__(self, methodName='runTest'):
3fb945d3bff3 2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff changeset
   251
                super(Pkg5TestCase, self).__init__(methodName)
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   252
                self.__test_root = None
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   253
                self.__pid = os.getpid()
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   254
                self.__pwd = os.getcwd()
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   255
                self.__didteardown = False
2499
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
   256
                self.__base_port = None
3048
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   257
                self.coverage_cmd = ""
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   258
                self.coverage_env = {}
2499
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
   259
                self.next_free_port = None
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
   260
                self.ident = None
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
   261
                self.pkg_cmdpath = "TOXIC"
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
   262
                self.debug_output = g_debug_output
2028
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
   263
                setup_logging(self)
3048
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   264
                global g_proto_readable
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   265
                if not g_proto_readable:
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   266
                        self.assertProtoReadable()
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   267
                        g_proto_readable = True
430
3fb945d3bff3 2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff changeset
   268
2499
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
   269
        @property
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
   270
        def methodName(self):
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
   271
                return self._testMethodName
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
   272
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
   273
        @property
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
   274
        def suite_name(self):
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
   275
                return self.__suite_name
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
   276
430
3fb945d3bff3 2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff changeset
   277
        def __str__(self):
3fb945d3bff3 2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff changeset
   278
                return "%s.py %s.%s" % (self.__class__.__module__,
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   279
                    self.__class__.__name__, self._testMethodName)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   280
2499
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
   281
        def __set_base_port(self, port):
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
   282
                if self.__base_port is not None or \
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
   283
                    self.next_free_port is not None:
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
   284
                        raise RuntimeError("Setting the base port twice isn't "
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
   285
                            "allowed")
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
   286
                self.__base_port = port
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
   287
                self.next_free_port = port
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
   288
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
   289
        base_port = property(lambda self: self.__base_port, __set_base_port)
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
   290
3048
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   291
        def assertProtoReadable(self):
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   292
                """Ensure proto area is readable by unprivileged user."""
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   293
                try:
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   294
                        self.cmdline_run("dir {0}".format(g_proto_area),
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   295
                            su_wrap=True)
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   296
                except:
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   297
                        raise TestStopException("proto area '{0} is not "
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   298
                            "readable by unprivileged user {1}".format(
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   299
                                g_proto_area, get_su_wrap_user()))
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   300
2690
11a8cae074e0 7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2681
diff changeset
   301
        def assertRegexp(self, text, regexp):
11a8cae074e0 7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2681
diff changeset
   302
                """Test that a regexp search matches text."""
11a8cae074e0 7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2681
diff changeset
   303
11a8cae074e0 7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2681
diff changeset
   304
                if re.search(regexp, text):
11a8cae074e0 7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2681
diff changeset
   305
                        return
11a8cae074e0 7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2681
diff changeset
   306
                raise self.failureException, \
11a8cae074e0 7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2681
diff changeset
   307
                    "\"%s\" does not match \"%s\"" % (regexp, text)
11a8cae074e0 7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2681
diff changeset
   308
11a8cae074e0 7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2681
diff changeset
   309
        def assertRaisesRegexp(self, excClass, regexp,
11a8cae074e0 7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2681
diff changeset
   310
            callableObj, *args, **kwargs):
11a8cae074e0 7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2681
diff changeset
   311
                """Perform the same logic as assertRaises, but then verify
11a8cae074e0 7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2681
diff changeset
   312
                that the stringified version of the exception contains the
11a8cae074e0 7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2681
diff changeset
   313
                regexp pattern.
11a8cae074e0 7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2681
diff changeset
   314
11a8cae074e0 7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2681
diff changeset
   315
                Introduced in in python 2.7"""
11a8cae074e0 7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2681
diff changeset
   316
11a8cae074e0 7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2681
diff changeset
   317
                try:
11a8cae074e0 7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2681
diff changeset
   318
                        callableObj(*args, **kwargs)
11a8cae074e0 7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2681
diff changeset
   319
11a8cae074e0 7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2681
diff changeset
   320
                except excClass, e:
11a8cae074e0 7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2681
diff changeset
   321
                        if re.search(regexp, str(e)):
11a8cae074e0 7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2681
diff changeset
   322
                                return
11a8cae074e0 7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2681
diff changeset
   323
                        raise self.failureException, \
11a8cae074e0 7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2681
diff changeset
   324
                            "\"%s\" does not match \"%s\"" % (regexp, str(e))
11a8cae074e0 7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2681
diff changeset
   325
11a8cae074e0 7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2681
diff changeset
   326
                raise self.failureException, \
11a8cae074e0 7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2681
diff changeset
   327
                    "%s not raised" % excClass
11a8cae074e0 7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2681
diff changeset
   328
2219
60ad60f7592c 2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents: 2218
diff changeset
   329
        def assertRaisesStringify(self, excClass, callableObj, *args, **kwargs):
60ad60f7592c 2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents: 2218
diff changeset
   330
                """Perform the same logic as assertRaises, but then verify that
60ad60f7592c 2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents: 2218
diff changeset
   331
                the exception raised can be stringified."""
60ad60f7592c 2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents: 2218
diff changeset
   332
60ad60f7592c 2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents: 2218
diff changeset
   333
                try:
60ad60f7592c 2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents: 2218
diff changeset
   334
                        callableObj(*args, **kwargs)
60ad60f7592c 2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents: 2218
diff changeset
   335
                except excClass, e:
60ad60f7592c 2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents: 2218
diff changeset
   336
                        str(e)
60ad60f7592c 2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents: 2218
diff changeset
   337
                        return
60ad60f7592c 2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents: 2218
diff changeset
   338
                else:
60ad60f7592c 2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents: 2218
diff changeset
   339
                        raise self.failureException, "%s not raised" % excClass
60ad60f7592c 2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents: 2218
diff changeset
   340
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   341
        #
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   342
        # Uses property() to implements test_root as a read-only attribute.
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   343
        #
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   344
        test_root = property(fget=lambda self: self.__test_root)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   345
2026
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 1970
diff changeset
   346
        def __get_ro_data_root(self):
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 1970
diff changeset
   347
                if not self.__test_root:
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 1970
diff changeset
   348
                        return None
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 1970
diff changeset
   349
                return os.path.join(self.__test_root, "ro_data")
2183
21ae45e8dfcf 17581 There should be a way of removing a package as part of upgrade
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents: 2158
diff changeset
   350
2026
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 1970
diff changeset
   351
        ro_data_root = property(fget=__get_ro_data_root)
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 1970
diff changeset
   352
2339
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
   353
        def persistent_setup_copy(self, orig):
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
   354
                pass
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
   355
2755
9de4d0300695 7187397 pkg commands fail when TERM empty or non-standard
Dan Price <daniel.price@oracle.com>
parents: 2753
diff changeset
   356
        @staticmethod
9de4d0300695 7187397 pkg commands fail when TERM empty or non-standard
Dan Price <daniel.price@oracle.com>
parents: 2753
diff changeset
   357
        def ptyPopen(args, executable=None, env=None, shell=False):
9de4d0300695 7187397 pkg commands fail when TERM empty or non-standard
Dan Price <daniel.price@oracle.com>
parents: 2753
diff changeset
   358
                """Less featureful but inspired by subprocess.Popen.
9de4d0300695 7187397 pkg commands fail when TERM empty or non-standard
Dan Price <daniel.price@oracle.com>
parents: 2753
diff changeset
   359
                Runs subprocess in a pty"""
9de4d0300695 7187397 pkg commands fail when TERM empty or non-standard
Dan Price <daniel.price@oracle.com>
parents: 2753
diff changeset
   360
                #
9de4d0300695 7187397 pkg commands fail when TERM empty or non-standard
Dan Price <daniel.price@oracle.com>
parents: 2753
diff changeset
   361
                # Note: In theory the right answer here is to subclass Popen,
9de4d0300695 7187397 pkg commands fail when TERM empty or non-standard
Dan Price <daniel.price@oracle.com>
parents: 2753
diff changeset
   362
                # but we found that in practice we'd have to reimplement most
9de4d0300695 7187397 pkg commands fail when TERM empty or non-standard
Dan Price <daniel.price@oracle.com>
parents: 2753
diff changeset
   363
                # of that class, because its handling of file descriptors is
9de4d0300695 7187397 pkg commands fail when TERM empty or non-standard
Dan Price <daniel.price@oracle.com>
parents: 2753
diff changeset
   364
                # too brittle in its _execute_child() code.
9de4d0300695 7187397 pkg commands fail when TERM empty or non-standard
Dan Price <daniel.price@oracle.com>
parents: 2753
diff changeset
   365
                #
9de4d0300695 7187397 pkg commands fail when TERM empty or non-standard
Dan Price <daniel.price@oracle.com>
parents: 2753
diff changeset
   366
                def __drain(masterf, outlist):
9de4d0300695 7187397 pkg commands fail when TERM empty or non-standard
Dan Price <daniel.price@oracle.com>
parents: 2753
diff changeset
   367
                        # Use a list as a way to pass by reference
9de4d0300695 7187397 pkg commands fail when TERM empty or non-standard
Dan Price <daniel.price@oracle.com>
parents: 2753
diff changeset
   368
                        while True:
3240
3661c0b9accd 19218185 TTY display tests fail in >b50
saurabh.vyas@oracle.com
parents: 3192
diff changeset
   369
                                chunksz = 1024
3661c0b9accd 19218185 TTY display tests fail in >b50
saurabh.vyas@oracle.com
parents: 3192
diff changeset
   370
                                termdata = masterf.read(chunksz)
3661c0b9accd 19218185 TTY display tests fail in >b50
saurabh.vyas@oracle.com
parents: 3192
diff changeset
   371
                                outlist.append(termdata)
3661c0b9accd 19218185 TTY display tests fail in >b50
saurabh.vyas@oracle.com
parents: 3192
diff changeset
   372
                                if len(termdata) < chunksz:
3661c0b9accd 19218185 TTY display tests fail in >b50
saurabh.vyas@oracle.com
parents: 3192
diff changeset
   373
                                        # assume we hit EOF
2755
9de4d0300695 7187397 pkg commands fail when TERM empty or non-standard
Dan Price <daniel.price@oracle.com>
parents: 2753
diff changeset
   374
                                        break
9de4d0300695 7187397 pkg commands fail when TERM empty or non-standard
Dan Price <daniel.price@oracle.com>
parents: 2753
diff changeset
   375
9de4d0300695 7187397 pkg commands fail when TERM empty or non-standard
Dan Price <daniel.price@oracle.com>
parents: 2753
diff changeset
   376
                # This is the arg handling protocol from Popen
9de4d0300695 7187397 pkg commands fail when TERM empty or non-standard
Dan Price <daniel.price@oracle.com>
parents: 2753
diff changeset
   377
                if isinstance(args, types.StringTypes):
9de4d0300695 7187397 pkg commands fail when TERM empty or non-standard
Dan Price <daniel.price@oracle.com>
parents: 2753
diff changeset
   378
                        args = [args]
9de4d0300695 7187397 pkg commands fail when TERM empty or non-standard
Dan Price <daniel.price@oracle.com>
parents: 2753
diff changeset
   379
                else:
9de4d0300695 7187397 pkg commands fail when TERM empty or non-standard
Dan Price <daniel.price@oracle.com>
parents: 2753
diff changeset
   380
                        args = list(args)
9de4d0300695 7187397 pkg commands fail when TERM empty or non-standard
Dan Price <daniel.price@oracle.com>
parents: 2753
diff changeset
   381
9de4d0300695 7187397 pkg commands fail when TERM empty or non-standard
Dan Price <daniel.price@oracle.com>
parents: 2753
diff changeset
   382
                if shell:
9de4d0300695 7187397 pkg commands fail when TERM empty or non-standard
Dan Price <daniel.price@oracle.com>
parents: 2753
diff changeset
   383
                        args = ["/bin/sh", "-c"] + args
9de4d0300695 7187397 pkg commands fail when TERM empty or non-standard
Dan Price <daniel.price@oracle.com>
parents: 2753
diff changeset
   384
                        if executable:
9de4d0300695 7187397 pkg commands fail when TERM empty or non-standard
Dan Price <daniel.price@oracle.com>
parents: 2753
diff changeset
   385
                                args[0] = executable
9de4d0300695 7187397 pkg commands fail when TERM empty or non-standard
Dan Price <daniel.price@oracle.com>
parents: 2753
diff changeset
   386
9de4d0300695 7187397 pkg commands fail when TERM empty or non-standard
Dan Price <daniel.price@oracle.com>
parents: 2753
diff changeset
   387
                if executable is None:
9de4d0300695 7187397 pkg commands fail when TERM empty or non-standard
Dan Price <daniel.price@oracle.com>
parents: 2753
diff changeset
   388
                        executable = args[0]
9de4d0300695 7187397 pkg commands fail when TERM empty or non-standard
Dan Price <daniel.price@oracle.com>
parents: 2753
diff changeset
   389
9de4d0300695 7187397 pkg commands fail when TERM empty or non-standard
Dan Price <daniel.price@oracle.com>
parents: 2753
diff changeset
   390
                pid,fd = pty.fork()
9de4d0300695 7187397 pkg commands fail when TERM empty or non-standard
Dan Price <daniel.price@oracle.com>
parents: 2753
diff changeset
   391
                if pid == 0:
9de4d0300695 7187397 pkg commands fail when TERM empty or non-standard
Dan Price <daniel.price@oracle.com>
parents: 2753
diff changeset
   392
                        try:
9de4d0300695 7187397 pkg commands fail when TERM empty or non-standard
Dan Price <daniel.price@oracle.com>
parents: 2753
diff changeset
   393
                                # Child
9de4d0300695 7187397 pkg commands fail when TERM empty or non-standard
Dan Price <daniel.price@oracle.com>
parents: 2753
diff changeset
   394
                                if env is None:
9de4d0300695 7187397 pkg commands fail when TERM empty or non-standard
Dan Price <daniel.price@oracle.com>
parents: 2753
diff changeset
   395
                                        os.execvp(executable, args)
9de4d0300695 7187397 pkg commands fail when TERM empty or non-standard
Dan Price <daniel.price@oracle.com>
parents: 2753
diff changeset
   396
                                else:
9de4d0300695 7187397 pkg commands fail when TERM empty or non-standard
Dan Price <daniel.price@oracle.com>
parents: 2753
diff changeset
   397
                                        os.execvpe(executable, args, env)
9de4d0300695 7187397 pkg commands fail when TERM empty or non-standard
Dan Price <daniel.price@oracle.com>
parents: 2753
diff changeset
   398
                        except:
9de4d0300695 7187397 pkg commands fail when TERM empty or non-standard
Dan Price <daniel.price@oracle.com>
parents: 2753
diff changeset
   399
                                traceback.print_exc()
9de4d0300695 7187397 pkg commands fail when TERM empty or non-standard
Dan Price <daniel.price@oracle.com>
parents: 2753
diff changeset
   400
                                os._exit(99)
9de4d0300695 7187397 pkg commands fail when TERM empty or non-standard
Dan Price <daniel.price@oracle.com>
parents: 2753
diff changeset
   401
                else:
9de4d0300695 7187397 pkg commands fail when TERM empty or non-standard
Dan Price <daniel.price@oracle.com>
parents: 2753
diff changeset
   402
                        masterf = os.fdopen(fd)
9de4d0300695 7187397 pkg commands fail when TERM empty or non-standard
Dan Price <daniel.price@oracle.com>
parents: 2753
diff changeset
   403
                        outlist = []
9de4d0300695 7187397 pkg commands fail when TERM empty or non-standard
Dan Price <daniel.price@oracle.com>
parents: 2753
diff changeset
   404
                        t = threading.Thread(target=__drain,
9de4d0300695 7187397 pkg commands fail when TERM empty or non-standard
Dan Price <daniel.price@oracle.com>
parents: 2753
diff changeset
   405
                            args=(masterf, outlist))
9de4d0300695 7187397 pkg commands fail when TERM empty or non-standard
Dan Price <daniel.price@oracle.com>
parents: 2753
diff changeset
   406
                        t.start()
9de4d0300695 7187397 pkg commands fail when TERM empty or non-standard
Dan Price <daniel.price@oracle.com>
parents: 2753
diff changeset
   407
                        waitedpid, retcode = os.waitpid(pid, 0)
9de4d0300695 7187397 pkg commands fail when TERM empty or non-standard
Dan Price <daniel.price@oracle.com>
parents: 2753
diff changeset
   408
                        retcode = retcode >> 8
9de4d0300695 7187397 pkg commands fail when TERM empty or non-standard
Dan Price <daniel.price@oracle.com>
parents: 2753
diff changeset
   409
                        t.join()
9de4d0300695 7187397 pkg commands fail when TERM empty or non-standard
Dan Price <daniel.price@oracle.com>
parents: 2753
diff changeset
   410
                return retcode, "".join(outlist)
9de4d0300695 7187397 pkg commands fail when TERM empty or non-standard
Dan Price <daniel.price@oracle.com>
parents: 2753
diff changeset
   411
1968
c0540b1e4f7e 8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents: 1949
diff changeset
   412
        def cmdline_run(self, cmdline, comment="", coverage=True, exit=0,
2046
2522cde7adc2 13536 We need a way to audit one or more packages
Tim Foster <tim.s.foster@oracle.com>
parents: 2034
diff changeset
   413
            handle=False, out=False, prefix="", raise_error=True, su_wrap=None,
2755
9de4d0300695 7187397 pkg commands fail when TERM empty or non-standard
Dan Price <daniel.price@oracle.com>
parents: 2753
diff changeset
   414
            stderr=False, env_arg=None, usepty=False):
3048
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   415
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   416
                # If caller provides arguments as a string, the shell must
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   417
                # process them.
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   418
                shell = not isinstance(cmdline, list)
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   419
1968
c0540b1e4f7e 8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents: 1949
diff changeset
   420
                wrapper = ""
c0540b1e4f7e 8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents: 1949
diff changeset
   421
                if coverage:
c0540b1e4f7e 8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents: 1949
diff changeset
   422
                        wrapper = self.coverage_cmd
3048
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   423
                su_wrap, su_end = self.get_su_wrapper(su_wrap=su_wrap,
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   424
                    shell=shell)
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   425
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   426
                if isinstance(cmdline, list):
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   427
                        if wrapper:
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   428
                                # Coverage command must be split into arguments.
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   429
                                wrapper = wrapper.split()
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   430
                                while wrapper:
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   431
                                        cmdline.insert(0, wrapper.pop())
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   432
                        if su_wrap:
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   433
                                # This ensures that all parts of the command
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   434
                                # line to be passed to 'su -c' are passed as a
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   435
                                # single argument.
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   436
                                while su_wrap[-1] != "-c":
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   437
                                        cmdline.insert(0, su_wrap.pop())
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   438
                                cmdline = [" ".join(cmdline)]
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   439
                                while su_wrap:
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   440
                                        cmdline.insert(0, su_wrap.pop())
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   441
                        if prefix:
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   442
                                cmdline.insert(0, prefix)
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   443
                else:
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   444
                        # Space needed between su_wrap and wrapper.
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   445
                        cmdline = "%s%s %s %s%s" % (prefix, su_wrap, wrapper,
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   446
                            cmdline, su_end)
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   447
1968
c0540b1e4f7e 8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents: 1949
diff changeset
   448
                self.debugcmd(cmdline)
c0540b1e4f7e 8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents: 1949
diff changeset
   449
c0540b1e4f7e 8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents: 1949
diff changeset
   450
                newenv = os.environ.copy()
c0540b1e4f7e 8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents: 1949
diff changeset
   451
                if coverage:
c0540b1e4f7e 8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents: 1949
diff changeset
   452
                        newenv.update(self.coverage_env)
2310
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
   453
                if env_arg:
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
   454
                        newenv.update(env_arg)
1968
c0540b1e4f7e 8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents: 1949
diff changeset
   455
2755
9de4d0300695 7187397 pkg commands fail when TERM empty or non-standard
Dan Price <daniel.price@oracle.com>
parents: 2753
diff changeset
   456
                if not usepty:
9de4d0300695 7187397 pkg commands fail when TERM empty or non-standard
Dan Price <daniel.price@oracle.com>
parents: 2753
diff changeset
   457
                        p = subprocess.Popen(cmdline,
9de4d0300695 7187397 pkg commands fail when TERM empty or non-standard
Dan Price <daniel.price@oracle.com>
parents: 2753
diff changeset
   458
                            env=newenv,
3048
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   459
                            shell=shell,
2755
9de4d0300695 7187397 pkg commands fail when TERM empty or non-standard
Dan Price <daniel.price@oracle.com>
parents: 2753
diff changeset
   460
                            stdout=subprocess.PIPE,
9de4d0300695 7187397 pkg commands fail when TERM empty or non-standard
Dan Price <daniel.price@oracle.com>
parents: 2753
diff changeset
   461
                            stderr=subprocess.PIPE)
9de4d0300695 7187397 pkg commands fail when TERM empty or non-standard
Dan Price <daniel.price@oracle.com>
parents: 2753
diff changeset
   462
9de4d0300695 7187397 pkg commands fail when TERM empty or non-standard
Dan Price <daniel.price@oracle.com>
parents: 2753
diff changeset
   463
                        if handle:
9de4d0300695 7187397 pkg commands fail when TERM empty or non-standard
Dan Price <daniel.price@oracle.com>
parents: 2753
diff changeset
   464
                                # Do nothing more.
9de4d0300695 7187397 pkg commands fail when TERM empty or non-standard
Dan Price <daniel.price@oracle.com>
parents: 2753
diff changeset
   465
                                return p
3048
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   466
2755
9de4d0300695 7187397 pkg commands fail when TERM empty or non-standard
Dan Price <daniel.price@oracle.com>
parents: 2753
diff changeset
   467
                        self.output, self.errout = p.communicate()
9de4d0300695 7187397 pkg commands fail when TERM empty or non-standard
Dan Price <daniel.price@oracle.com>
parents: 2753
diff changeset
   468
                        retcode = p.returncode
9de4d0300695 7187397 pkg commands fail when TERM empty or non-standard
Dan Price <daniel.price@oracle.com>
parents: 2753
diff changeset
   469
                else:
9de4d0300695 7187397 pkg commands fail when TERM empty or non-standard
Dan Price <daniel.price@oracle.com>
parents: 2753
diff changeset
   470
                        retcode, self.output = self.ptyPopen(cmdline,
9de4d0300695 7187397 pkg commands fail when TERM empty or non-standard
Dan Price <daniel.price@oracle.com>
parents: 2753
diff changeset
   471
                            env=newenv, shell=True)
9de4d0300695 7187397 pkg commands fail when TERM empty or non-standard
Dan Price <daniel.price@oracle.com>
parents: 2753
diff changeset
   472
                        self.errout = ""
9de4d0300695 7187397 pkg commands fail when TERM empty or non-standard
Dan Price <daniel.price@oracle.com>
parents: 2753
diff changeset
   473
2693
cfee571ea6d5 7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents: 2690
diff changeset
   474
                self.debugresult(retcode, exit, self.output + self.errout)
1968
c0540b1e4f7e 8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents: 1949
diff changeset
   475
c0540b1e4f7e 8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents: 1949
diff changeset
   476
                if raise_error and retcode == 99:
c0540b1e4f7e 8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents: 1949
diff changeset
   477
                        raise TracebackException(cmdline, self.output +
c0540b1e4f7e 8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents: 1949
diff changeset
   478
                            self.errout, comment)
c0540b1e4f7e 8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents: 1949
diff changeset
   479
c0540b1e4f7e 8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents: 1949
diff changeset
   480
                if not isinstance(exit, list):
c0540b1e4f7e 8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents: 1949
diff changeset
   481
                        exit = [exit]
c0540b1e4f7e 8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents: 1949
diff changeset
   482
c0540b1e4f7e 8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents: 1949
diff changeset
   483
                if raise_error and retcode not in exit:
c0540b1e4f7e 8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents: 1949
diff changeset
   484
                        raise UnexpectedExitCodeException(cmdline,
c0540b1e4f7e 8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents: 1949
diff changeset
   485
                            exit, retcode, self.output + self.errout,
c0540b1e4f7e 8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents: 1949
diff changeset
   486
                            comment)
c0540b1e4f7e 8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents: 1949
diff changeset
   487
c0540b1e4f7e 8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents: 1949
diff changeset
   488
                if out:
2046
2522cde7adc2 13536 We need a way to audit one or more packages
Tim Foster <tim.s.foster@oracle.com>
parents: 2034
diff changeset
   489
                        if stderr:
2522cde7adc2 13536 We need a way to audit one or more packages
Tim Foster <tim.s.foster@oracle.com>
parents: 2034
diff changeset
   490
                                return retcode, self.output, self.errout
1968
c0540b1e4f7e 8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents: 1949
diff changeset
   491
                        return retcode, self.output
c0540b1e4f7e 8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents: 1949
diff changeset
   492
                return retcode
c0540b1e4f7e 8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents: 1949
diff changeset
   493
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   494
        def debug(self, s):
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   495
                s = str(s)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   496
                for x in s.splitlines():
2499
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
   497
                        if self.debug_output:
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   498
                                print >> sys.stderr, "# %s" % x
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   499
                        self.__debug_buf += x + "\n"
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   500
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   501
        def debugcmd(self, cmdline):
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   502
                wrapper = textwrap.TextWrapper(initial_indent="$ ",
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   503
                    subsequent_indent="\t",
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   504
                    break_long_words=False,
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   505
                    break_on_hyphens=False)
3048
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   506
                if isinstance(cmdline, list):
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   507
                        res = wrapper.wrap(" ".join(cmdline).strip())
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   508
                else:
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   509
                        res = wrapper.wrap(cmdline.strip())
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   510
                self.debug(" \\\n".join(res))
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   511
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   512
        def debugfilecreate(self, content, path):
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   513
                lines = content.splitlines()
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   514
                if lines == []:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   515
                        lines = [""]
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   516
                if len(lines) > 1:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   517
                        ins = " [+%d lines...]" % (len(lines) - 1)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   518
                else:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   519
                        ins = ""
2708
4dac3e277ccf 7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents: 2701
diff changeset
   520
                if isinstance(lines[0], unicode):
4dac3e277ccf 7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents: 2701
diff changeset
   521
                        lines[0] = lines[0].encode("utf-8")
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   522
                self.debugcmd(
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   523
                    "echo '%s%s' > %s" % (lines[0], ins, path))
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   524
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   525
        def debugresult(self, retcode, expected, output):
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   526
                if output.strip() != "":
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   527
                        self.debug(output.strip())
1968
c0540b1e4f7e 8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents: 1949
diff changeset
   528
                if not isinstance(expected, list):
c0540b1e4f7e 8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents: 1949
diff changeset
   529
                        expected = [expected]
c0540b1e4f7e 8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents: 1949
diff changeset
   530
                if retcode is None or retcode != 0 or \
c0540b1e4f7e 8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents: 1949
diff changeset
   531
                    retcode not in expected:
c0540b1e4f7e 8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents: 1949
diff changeset
   532
                        self.debug("[exited %s, expected %s]" %
c0540b1e4f7e 8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents: 1949
diff changeset
   533
                            (retcode, ", ".join(str(e) for e in expected)))
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   534
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   535
        def get_debugbuf(self):
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   536
                return self.__debug_buf
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   537
2499
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
   538
        def set_debugbuf(self, s):
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
   539
                self.__debug_buf = s
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
   540
3048
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   541
        def get_su_wrapper(self, su_wrap=None, shell=True):
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   542
                """If 'shell' is True, the wrapper will be returned as a tuple of
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   543
                strings of the form (su_wrap, su_end).  If 'shell' is False, the
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   544
                wrapper willbe returned as a tuple of (args, ignore) where
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   545
                'args' is a list of the commands and their arguments that should
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   546
                come before the command being executed."""
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   547
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   548
                if not su_wrap:
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   549
                        return "", ""
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   550
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   551
                if su_wrap == True:
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   552
                        su_user = get_su_wrap_user()
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   553
                else:
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   554
                        su_user = ""
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   555
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   556
                cov_env = [
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   557
                    "%s=%s" % e
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   558
                    for e in self.coverage_env.items()
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   559
                ]
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   560
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   561
                su_wrap = ["su"]
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   562
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   563
                if su_user:
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   564
                        su_wrap.append(su_user)
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   565
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   566
                if shell:
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   567
                        su_wrap.append("-c 'env LD_LIBRARY_PATH=%s" %
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   568
                            os.getenv("LD_LIBRARY_PATH", ""))
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   569
                else:
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   570
                        # If this ever changes, cmdline_run must be updated.
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   571
                        su_wrap.append("-c")
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   572
                        su_wrap.append("env")
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   573
                        su_wrap.append("LD_LIBRARY_PATH=%s" %
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   574
                            os.getenv("LD_LIBRARY_PATH", ""))
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   575
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   576
                su_wrap.extend(cov_env)
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   577
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   578
                if shell:
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   579
                        su_wrap = " ".join(su_wrap)
1968
c0540b1e4f7e 8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents: 1949
diff changeset
   580
                        su_end = "'"
c0540b1e4f7e 8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents: 1949
diff changeset
   581
                else:
c0540b1e4f7e 8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents: 1949
diff changeset
   582
                        su_end = ""
3048
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
   583
1968
c0540b1e4f7e 8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents: 1949
diff changeset
   584
                return su_wrap, su_end
c0540b1e4f7e 8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents: 1949
diff changeset
   585
502
3f98e94acc4a 2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents: 448
diff changeset
   586
        def getTeardownFunc(self):
3f98e94acc4a 2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents: 448
diff changeset
   587
                return (self, self.tearDown)
3f98e94acc4a 2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents: 448
diff changeset
   588
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   589
        def getSetupFunc(self):
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   590
                return (self, self.setUp)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   591
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   592
        def setUp(self):
2499
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
   593
                assert self.ident is not None
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   594
                self.__test_root = os.path.join(g_tempdir,
2499
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
   595
                    "ips.test.%d" % self.__pid, "%d" % self.ident)
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   596
                self.__didtearDown = False
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   597
                try:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   598
                        os.makedirs(self.__test_root, 0755)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   599
                except OSError, e:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   600
                        if e.errno != errno.EEXIST:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   601
                                raise e
2046
2522cde7adc2 13536 We need a way to audit one or more packages
Tim Foster <tim.s.foster@oracle.com>
parents: 2034
diff changeset
   602
                test_relative = os.path.sep.join(["..", "..", "src", "tests"])
2522cde7adc2 13536 We need a way to audit one or more packages
Tim Foster <tim.s.foster@oracle.com>
parents: 2034
diff changeset
   603
                test_src = os.path.join(g_proto_area, test_relative)
2272
d81ea073d050 3617 Testsuite should allow choice for base port to use
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2240
diff changeset
   604
                if getattr(self, "need_ro_data", False):
d81ea073d050 3617 Testsuite should allow choice for base port to use
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2240
diff changeset
   605
                        shutil.copytree(os.path.join(test_src, "ro_data"),
d81ea073d050 3617 Testsuite should allow choice for base port to use
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2240
diff changeset
   606
                            self.ro_data_root)
2433
7af4ccfa1c06 5060 cert and key files should be validated when adding or updating publishers
Shawn Walker <shawn.walker@oracle.com>
parents: 2414
diff changeset
   607
                        self.path_to_certs = os.path.join(self.ro_data_root,
7af4ccfa1c06 5060 cert and key files should be validated when adding or updating publishers
Shawn Walker <shawn.walker@oracle.com>
parents: 2414
diff changeset
   608
                            "signing_certs", "produced")
7af4ccfa1c06 5060 cert and key files should be validated when adding or updating publishers
Shawn Walker <shawn.walker@oracle.com>
parents: 2414
diff changeset
   609
                        self.keys_dir = os.path.join(self.path_to_certs, "keys")
7af4ccfa1c06 5060 cert and key files should be validated when adding or updating publishers
Shawn Walker <shawn.walker@oracle.com>
parents: 2414
diff changeset
   610
                        self.cs_dir = os.path.join(self.path_to_certs,
7af4ccfa1c06 5060 cert and key files should be validated when adding or updating publishers
Shawn Walker <shawn.walker@oracle.com>
parents: 2414
diff changeset
   611
                            "code_signing_certs")
2753
4d4b2324d1c0 7139940 cached manifests persist for packages not currently installed even when copy in repository changes
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2731
diff changeset
   612
                        self.chain_certs_dir = os.path.join(self.path_to_certs,
4d4b2324d1c0 7139940 cached manifests persist for packages not currently installed even when copy in repository changes
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2731
diff changeset
   613
                            "chain_certs")
4d4b2324d1c0 7139940 cached manifests persist for packages not currently installed even when copy in repository changes
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2731
diff changeset
   614
                        self.raw_trust_anchor_dir = os.path.join(
4d4b2324d1c0 7139940 cached manifests persist for packages not currently installed even when copy in repository changes
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2731
diff changeset
   615
                            self.path_to_certs, "trust_anchors")
4d4b2324d1c0 7139940 cached manifests persist for packages not currently installed even when copy in repository changes
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2731
diff changeset
   616
                        self.crl_dir = os.path.join(self.path_to_certs, "crl")
2433
7af4ccfa1c06 5060 cert and key files should be validated when adding or updating publishers
Shawn Walker <shawn.walker@oracle.com>
parents: 2414
diff changeset
   617
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   618
                #
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   619
                # TMPDIR affects the behavior of mkdtemp and mkstemp.
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   620
                # Setting this here should ensure that tests will make temp
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   621
                # files and dirs inside the test directory rather than
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   622
                # polluting /tmp.
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   623
                #
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   624
                os.environ["TMPDIR"] = self.__test_root
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   625
                tempfile.tempdir = self.__test_root
2028
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
   626
                setup_logging(self)
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   627
2731
4ef27f88d3ce 7139394 pkglint should check that path parents are directories
Tim Foster <tim.s.foster@oracle.com>
parents: 2720
diff changeset
   628
                # Create a pkglintrc file that points to our info.classification
4ef27f88d3ce 7139394 pkglint should check that path parents are directories
Tim Foster <tim.s.foster@oracle.com>
parents: 2720
diff changeset
   629
                # data, and doesn't exclude any shipped plugins.
2085
10a27146ebc2 16802 pkglint should check the value of info.classification in manifests
Tim Foster <tim.s.foster@oracle.com>
parents: 2081
diff changeset
   630
                self.configure_rcfile( "%s/usr/share/lib/pkg/pkglintrc" %
10a27146ebc2 16802 pkglint should check the value of info.classification in manifests
Tim Foster <tim.s.foster@oracle.com>
parents: 2081
diff changeset
   631
                    g_proto_area,
10a27146ebc2 16802 pkglint should check the value of info.classification in manifests
Tim Foster <tim.s.foster@oracle.com>
parents: 2081
diff changeset
   632
                    {"info_classification_path":
2223
2da8c49e53dc 17735 build should use custom pkglintrc to locate proto version of opensolaris.org.sections
Tim Foster <tim.s.foster@oracle.com>
parents: 2219
diff changeset
   633
                    "%s/usr/share/lib/pkg/opensolaris.org.sections" %
2731
4ef27f88d3ce 7139394 pkglint should check that path parents are directories
Tim Foster <tim.s.foster@oracle.com>
parents: 2720
diff changeset
   634
                    g_proto_area,
4ef27f88d3ce 7139394 pkglint should check that path parents are directories
Tim Foster <tim.s.foster@oracle.com>
parents: 2720
diff changeset
   635
                    "pkglint.exclude": ""}, self.test_root, section="pkglint")
2085
10a27146ebc2 16802 pkglint should check the value of info.classification in manifests
Tim Foster <tim.s.foster@oracle.com>
parents: 2081
diff changeset
   636
2852
5650587d9468 15807357 need an Apache-based pkg.depotd
Tim Foster <tim.s.foster@oracle.com>
parents: 2843
diff changeset
   637
                self.sysrepo_template_dir = "%s/etc/pkg/sysrepo" % g_proto_area
5650587d9468 15807357 need an Apache-based pkg.depotd
Tim Foster <tim.s.foster@oracle.com>
parents: 2843
diff changeset
   638
                self.depot_template_dir = "%s/etc/pkg/depot" % g_proto_area
2310
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
   639
                self.make_misc_files(self.smf_cmds, prefix="smf_cmds",
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
   640
                    mode=0755)
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
   641
                DebugValues["smf_cmds_dir"] = \
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
   642
                    os.path.join(self.test_root, "smf_cmds")
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
   643
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   644
        def impl_tearDown(self):
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   645
                # impl_tearDown exists so that we can ensure that this class's
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   646
                # teardown is actually called.  Sometimes, subclasses will
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   647
                # implement teardown but forget to call the superclass teardown.
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   648
                if self.__didteardown:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   649
                        return
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   650
                self.__didteardown = True
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   651
                try:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   652
                        os.chdir(self.__pwd)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   653
                except OSError:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   654
                        # working directory of last resort.
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   655
                        os.chdir(g_tempdir)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   656
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   657
                #
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   658
                # Kill depots before blowing away test dir-- otherwise
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   659
                # the depot can race with the shutil.rmtree()
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   660
                #
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   661
                if hasattr(self, "killalldepots"):
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   662
                        try:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   663
                                self.killalldepots()
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   664
                        except Exception, e:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   665
                                print >> sys.stderr, str(e)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   666
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   667
                #
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   668
                # We have some sloppy subclasses which don't call the superclass
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   669
                # setUp-- in which case the dir might not exist.  Tolerate it.
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   670
                #
2339
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
   671
                # Also, avoid deleting our fakeroot since then we'd have to
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
   672
                # keep re-creating it.
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
   673
                #
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   674
                if self.__test_root is not None and \
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   675
                    os.path.exists(self.__test_root):
2339
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
   676
                        for d in os.listdir(self.__test_root):
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
   677
                                path = os.path.join(self.__test_root, d)
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
   678
                                self.debug("removing: %s" % path)
3192
13377dbd6773 18876698 Plan serialization for linked images does not support unicode in license actions
saurabh.vyas@oracle.com
parents: 3190
diff changeset
   679
                                try:
2339
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
   680
                                        os.remove(path)
3192
13377dbd6773 18876698 Plan serialization for linked images does not support unicode in license actions
saurabh.vyas@oracle.com
parents: 3190
diff changeset
   681
                                except OSError as e:
13377dbd6773 18876698 Plan serialization for linked images does not support unicode in license actions
saurabh.vyas@oracle.com
parents: 3190
diff changeset
   682
                                        if e.errno == errno.EPERM:
13377dbd6773 18876698 Plan serialization for linked images does not support unicode in license actions
saurabh.vyas@oracle.com
parents: 3190
diff changeset
   683
                                                shutil.rmtree(path)
13377dbd6773 18876698 Plan serialization for linked images does not support unicode in license actions
saurabh.vyas@oracle.com
parents: 3190
diff changeset
   684
                                        else:
13377dbd6773 18876698 Plan serialization for linked images does not support unicode in license actions
saurabh.vyas@oracle.com
parents: 3190
diff changeset
   685
                                                raise
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   686
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   687
        def tearDown(self):
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   688
                # In reality this call does nothing.
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   689
                unittest.TestCase.tearDown(self)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   690
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   691
                self.impl_tearDown()
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   692
435
461b1c739de9 1753 An exception thrown during the teardown phase of the test program leaves pkg.depot running.
Brock Pytlik <bpytlik@sun.com>
parents: 430
diff changeset
   693
        def run(self, result=None):
2499
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
   694
                assert self.base_port is not None
436
5f150abbfba7 Shawn's feedback
Brock Pytlik <bpytlik@sun.com>
parents: 435
diff changeset
   695
                if result is None:
5f150abbfba7 Shawn's feedback
Brock Pytlik <bpytlik@sun.com>
parents: 435
diff changeset
   696
                        result = self.defaultTestResult()
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   697
                pwd = os.getcwd()
435
461b1c739de9 1753 An exception thrown during the teardown phase of the test program leaves pkg.depot running.
Brock Pytlik <bpytlik@sun.com>
parents: 430
diff changeset
   698
                result.startTest(self)
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   699
                testMethod = getattr(self, self._testMethodName)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   700
                if getattr(result, "coverage", None) is not None:
1513
3ece69a26155 5032 make coverage should only report on the files in our gate
Danek Duvall <danek.duvall@sun.com>
parents: 1505
diff changeset
   701
                        self.coverage_cmd, self.coverage_env = result.coverage
435
461b1c739de9 1753 An exception thrown during the teardown phase of the test program leaves pkg.depot running.
Brock Pytlik <bpytlik@sun.com>
parents: 430
diff changeset
   702
                try:
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   703
                        needtodie = False
571
1a2452c33cb9 3476 Most cli test cases can't be run standalone anymore
Brad Hall <bhall@eng.sun.com>
parents: 516
diff changeset
   704
                        try:
1a2452c33cb9 3476 Most cli test cases can't be run standalone anymore
Brad Hall <bhall@eng.sun.com>
parents: 516
diff changeset
   705
                                self.setUp()
1a2452c33cb9 3476 Most cli test cases can't be run standalone anymore
Brad Hall <bhall@eng.sun.com>
parents: 516
diff changeset
   706
                        except KeyboardInterrupt:
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   707
                                # Try hard to make sure we've done a teardown.
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   708
                                try:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   709
                                        self.tearDown()
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   710
                                except:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   711
                                        pass
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   712
                                self.impl_tearDown()
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   713
                                raise TestStopException
571
1a2452c33cb9 3476 Most cli test cases can't be run standalone anymore
Brad Hall <bhall@eng.sun.com>
parents: 516
diff changeset
   714
                        except:
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   715
                                # teardown could fail too, esp. if setup failed...
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   716
                                try:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   717
                                        self.tearDown()
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   718
                                except:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   719
                                        pass
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   720
                                # Try hard to make sure we've done a teardown.
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   721
                                self.impl_tearDown()
571
1a2452c33cb9 3476 Most cli test cases can't be run standalone anymore
Brad Hall <bhall@eng.sun.com>
parents: 516
diff changeset
   722
                                result.addError(self, sys.exc_info())
1a2452c33cb9 3476 Most cli test cases can't be run standalone anymore
Brad Hall <bhall@eng.sun.com>
parents: 516
diff changeset
   723
                                return
435
461b1c739de9 1753 An exception thrown during the teardown phase of the test program leaves pkg.depot running.
Brock Pytlik <bpytlik@sun.com>
parents: 430
diff changeset
   724
461b1c739de9 1753 An exception thrown during the teardown phase of the test program leaves pkg.depot running.
Brock Pytlik <bpytlik@sun.com>
parents: 430
diff changeset
   725
                        ok = False
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   726
                        error_added = False
435
461b1c739de9 1753 An exception thrown during the teardown phase of the test program leaves pkg.depot running.
Brock Pytlik <bpytlik@sun.com>
parents: 430
diff changeset
   727
                        try:
461b1c739de9 1753 An exception thrown during the teardown phase of the test program leaves pkg.depot running.
Brock Pytlik <bpytlik@sun.com>
parents: 430
diff changeset
   728
                                testMethod()
461b1c739de9 1753 An exception thrown during the teardown phase of the test program leaves pkg.depot running.
Brock Pytlik <bpytlik@sun.com>
parents: 430
diff changeset
   729
                                ok = True
461b1c739de9 1753 An exception thrown during the teardown phase of the test program leaves pkg.depot running.
Brock Pytlik <bpytlik@sun.com>
parents: 430
diff changeset
   730
                        except self.failureException:
502
3f98e94acc4a 2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents: 448
diff changeset
   731
                                result.addFailure(self, sys.exc_info())
435
461b1c739de9 1753 An exception thrown during the teardown phase of the test program leaves pkg.depot running.
Brock Pytlik <bpytlik@sun.com>
parents: 430
diff changeset
   732
                        except KeyboardInterrupt:
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   733
                                # Try hard to make sure we've done a teardown.
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   734
                                needtodie = True
2306
dfc3f8634dcc 17158 importer.py could use some basic unit tests
Tim Foster <tim.s.foster@oracle.com>
parents: 2293
diff changeset
   735
                        except TestSkippedException, err:
dfc3f8634dcc 17158 importer.py could use some basic unit tests
Tim Foster <tim.s.foster@oracle.com>
parents: 2293
diff changeset
   736
                                result.addSkip(self, err)
435
461b1c739de9 1753 An exception thrown during the teardown phase of the test program leaves pkg.depot running.
Brock Pytlik <bpytlik@sun.com>
parents: 430
diff changeset
   737
                        except:
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   738
                                error_added = True
502
3f98e94acc4a 2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents: 448
diff changeset
   739
                                result.addError(self, sys.exc_info())
435
461b1c739de9 1753 An exception thrown during the teardown phase of the test program leaves pkg.depot running.
Brock Pytlik <bpytlik@sun.com>
parents: 430
diff changeset
   740
571
1a2452c33cb9 3476 Most cli test cases can't be run standalone anymore
Brad Hall <bhall@eng.sun.com>
parents: 516
diff changeset
   741
                        try:
1a2452c33cb9 3476 Most cli test cases can't be run standalone anymore
Brad Hall <bhall@eng.sun.com>
parents: 516
diff changeset
   742
                                self.tearDown()
1a2452c33cb9 3476 Most cli test cases can't be run standalone anymore
Brad Hall <bhall@eng.sun.com>
parents: 516
diff changeset
   743
                        except KeyboardInterrupt:
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   744
                                needtodie = True
571
1a2452c33cb9 3476 Most cli test cases can't be run standalone anymore
Brad Hall <bhall@eng.sun.com>
parents: 516
diff changeset
   745
                        except:
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   746
                                # Try hard to make sure we've done a teardown.
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   747
                                self.impl_tearDown()
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   748
                                # Make sure we don't mark this error'd twice.
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   749
                                if not error_added:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   750
                                        result.addError(self, sys.exc_info())
571
1a2452c33cb9 3476 Most cli test cases can't be run standalone anymore
Brad Hall <bhall@eng.sun.com>
parents: 516
diff changeset
   751
                                ok = False
502
3f98e94acc4a 2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents: 448
diff changeset
   752
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   753
                        if needtodie:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   754
                                try:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   755
                                        self.impl_tearDown()
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   756
                                except:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   757
                                        pass
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   758
                                raise TestStopException
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   759
436
5f150abbfba7 Shawn's feedback
Brock Pytlik <bpytlik@sun.com>
parents: 435
diff changeset
   760
                        if ok:
5f150abbfba7 Shawn's feedback
Brock Pytlik <bpytlik@sun.com>
parents: 435
diff changeset
   761
                                result.addSuccess(self)
435
461b1c739de9 1753 An exception thrown during the teardown phase of the test program leaves pkg.depot running.
Brock Pytlik <bpytlik@sun.com>
parents: 430
diff changeset
   762
                finally:
461b1c739de9 1753 An exception thrown during the teardown phase of the test program leaves pkg.depot running.
Brock Pytlik <bpytlik@sun.com>
parents: 430
diff changeset
   763
                        result.stopTest(self)
2073
9fcacc9e5eaa 16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents: 2047
diff changeset
   764
                        # make sure we restore our directory if it still exists.
9fcacc9e5eaa 16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents: 2047
diff changeset
   765
                        try:
9fcacc9e5eaa 16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents: 2047
diff changeset
   766
                                os.chdir(pwd)
9fcacc9e5eaa 16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents: 2047
diff changeset
   767
                        except OSError, e:
9fcacc9e5eaa 16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents: 2047
diff changeset
   768
                                # If directory doesn't exist anymore it doesn't
9fcacc9e5eaa 16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents: 2047
diff changeset
   769
                                # matter.
9fcacc9e5eaa 16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents: 2047
diff changeset
   770
                                if e.errno != errno.ENOENT:
9fcacc9e5eaa 16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents: 2047
diff changeset
   771
                                        raise
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   772
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   773
        #
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   774
        # The following are utility functions for use by testcases.
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   775
        #
2595
0bb36cea68dc 18990 generate should know about SUNW_FILTER, FILTER and POSFLAG_1 elf tags
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2580
diff changeset
   776
        def c_compile(self, prog_text, opts, outputfile, obj_files=None):
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   777
                """Given a C program (as a string), compile it into the
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   778
                executable given by outputfile.  Outputfile should be
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   779
                given as a relative path, and will be located below the
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   780
                test prefix path.  Additional compiler options should be
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   781
                passed in 'opts'.  Suitable for compiling small test
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   782
                programs."""
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   783
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   784
                #
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   785
                # We use a series of likely compilers.  At present we support
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   786
                # this testing with SunStudio.
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   787
                #
2595
0bb36cea68dc 18990 generate should know about SUNW_FILTER, FILTER and POSFLAG_1 elf tags
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2580
diff changeset
   788
                assert obj_files is not None or prog_text is not None
0bb36cea68dc 18990 generate should know about SUNW_FILTER, FILTER and POSFLAG_1 elf tags
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2580
diff changeset
   789
                assert obj_files is None or prog_text is None
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   790
                if os.path.dirname(outputfile) != "":
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   791
                        try:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   792
                                os.makedirs(os.path.dirname(outputfile))
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   793
                        except OSError, e:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   794
                                if e.errno != errno.EEXIST:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   795
                                        raise
2595
0bb36cea68dc 18990 generate should know about SUNW_FILTER, FILTER and POSFLAG_1 elf tags
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2580
diff changeset
   796
                if prog_text:
0bb36cea68dc 18990 generate should know about SUNW_FILTER, FILTER and POSFLAG_1 elf tags
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2580
diff changeset
   797
                        c_fd, c_path = tempfile.mkstemp(suffix=".c",
0bb36cea68dc 18990 generate should know about SUNW_FILTER, FILTER and POSFLAG_1 elf tags
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2580
diff changeset
   798
                            dir=self.test_root)
0bb36cea68dc 18990 generate should know about SUNW_FILTER, FILTER and POSFLAG_1 elf tags
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2580
diff changeset
   799
                        c_fh = os.fdopen(c_fd, "w")
0bb36cea68dc 18990 generate should know about SUNW_FILTER, FILTER and POSFLAG_1 elf tags
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2580
diff changeset
   800
                        c_fh.write(prog_text)
0bb36cea68dc 18990 generate should know about SUNW_FILTER, FILTER and POSFLAG_1 elf tags
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2580
diff changeset
   801
                        c_fh.close()
0bb36cea68dc 18990 generate should know about SUNW_FILTER, FILTER and POSFLAG_1 elf tags
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2580
diff changeset
   802
                else:
0bb36cea68dc 18990 generate should know about SUNW_FILTER, FILTER and POSFLAG_1 elf tags
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2580
diff changeset
   803
                        c_path = " ".join(obj_files)
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   804
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   805
                found = False
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   806
                outpath = os.path.join(self.test_root, outputfile)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   807
                compilers = ["/usr/bin/cc", "cc", "$CC"]
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   808
                for compiler in compilers:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   809
                        cmd = [compiler, "-o", outpath]
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   810
                        cmd.extend(opts)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   811
                        cmd.append(c_path)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   812
                        try:
2028
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
   813
                                # Make sure to use shell=True so that env.
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   814
                                # vars and $PATH are evaluated.
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   815
                                self.debugcmd(" ".join(cmd))
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   816
                                s = subprocess.Popen(" ".join(cmd),
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   817
                                    shell=True,
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   818
                                    stdout=subprocess.PIPE,
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   819
                                    stderr=subprocess.STDOUT)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   820
                                sout, serr = s.communicate()
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   821
                                rc = s.returncode
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   822
                                if rc != 0 and rc != 127:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   823
                                        try: os.remove(outpath)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   824
                                        except OSError: pass
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   825
                                        try: os.remove(c_path)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   826
                                        except OSError: pass
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   827
                                        raise RuntimeError(
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   828
                                            "Compile failed: %s --> %d\n%s" % \
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   829
                                            (cmd, rc, sout))
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   830
                                if rc == 127:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   831
                                        self.debug("[%s not found]" % compiler)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   832
                                        continue
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   833
                                # so rc == 0
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   834
                                found = True
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   835
                                break
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   836
                        except OSError:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   837
                                continue
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   838
                try:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   839
                        os.remove(c_path)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   840
                except OSError:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   841
                        pass
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   842
                if not found:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   843
                        raise TestSkippedException(
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   844
                            "No suitable Sun Studio compiler found. "
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   845
                            "Tried: %s.  Try setting $CC to a valid"
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   846
                            "compiler." % compilers)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   847
2339
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
   848
        def make_file(self, path, content, mode=0644):
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
   849
                if not os.path.exists(os.path.dirname(path)):
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
   850
                        os.makedirs(os.path.dirname(path), 0777)
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
   851
                self.debugfilecreate(content, path)
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
   852
                fh = open(path, 'wb')
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
   853
                if isinstance(content, unicode):
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
   854
                        content = content.encode("utf-8")
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
   855
                fh.write(content)
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
   856
                fh.close()
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
   857
                os.chmod(path, mode)
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   858
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   859
        def make_misc_files(self, files, prefix=None, mode=0644):
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   860
                """ Make miscellaneous text files.  Files can be a
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   861
                single relative pathname, a list of relative pathnames,
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   862
                or a hash mapping relative pathnames to specific contents.
1839
53bdcdd547cb 11023 DirectoryBundle emits bad paths if basedir has trailing /
Shawn Walker <shawn.walker@oracle.com>
parents: 1832
diff changeset
   863
                If file contents are not specified, the pathname of the
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   864
                file is placed into the file as default content. """
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   865
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   866
                outpaths = []
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   867
                #
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   868
                # If files is a string, make it a list.  Then, if it is
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   869
                # a list, simply turn it into a dict where each file's
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   870
                # contents is its own name, so that we get some uniqueness.
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   871
                #
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   872
                if isinstance(files, basestring):
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   873
                        files = [files]
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   874
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   875
                if isinstance(files, list):
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   876
                        nfiles = {}
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   877
                        for f in files:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   878
                                nfiles[f] = f
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   879
                        files = nfiles
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   880
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   881
                if prefix is None:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   882
                        prefix = self.test_root
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   883
                else:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   884
                        assert(not prefix.startswith(os.pathsep))
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   885
                        prefix = os.path.join(self.test_root, prefix)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   886
2794
75f1771bec69 7196957 pkg.depotd fails to read passphrase-protected ssl key when using smf or exec authentication
Shawn Walker <shawn.walker@oracle.com>
parents: 2758
diff changeset
   887
                # Ensure output paths are returned in consistent order.
75f1771bec69 7196957 pkg.depotd fails to read passphrase-protected ssl key when using smf or exec authentication
Shawn Walker <shawn.walker@oracle.com>
parents: 2758
diff changeset
   888
                for f in sorted(files):
75f1771bec69 7196957 pkg.depotd fails to read passphrase-protected ssl key when using smf or exec authentication
Shawn Walker <shawn.walker@oracle.com>
parents: 2758
diff changeset
   889
                        content = files[f]
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   890
                        assert not f.startswith("/"), \
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   891
                            ("%s: misc file paths must be relative!" % f)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   892
                        path = os.path.join(prefix, f)
2339
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
   893
                        self.make_file(path, content, mode)
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   894
                        outpaths.append(path)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   895
                return outpaths
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   896
2456
063737b8ee9b 9809 pkgsend publish should take bundle files as sources for files
Shawn Walker <shawn.walker@oracle.com>
parents: 2453
diff changeset
   897
        def make_manifest(self, content, manifest_dir="manifests", pfmri=None):
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   898
                # Trim to ensure nice looking output.
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   899
                content = content.strip()
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   900
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   901
                # Place inside of test prefix.
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   902
                manifest_dir = os.path.join(self.test_root,
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   903
                    manifest_dir)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   904
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   905
                if not os.path.exists(manifest_dir):
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   906
                        os.makedirs(manifest_dir)
2456
063737b8ee9b 9809 pkgsend publish should take bundle files as sources for files
Shawn Walker <shawn.walker@oracle.com>
parents: 2453
diff changeset
   907
                t_fd, t_path = tempfile.mkstemp(prefix="mfst.",
063737b8ee9b 9809 pkgsend publish should take bundle files as sources for files
Shawn Walker <shawn.walker@oracle.com>
parents: 2453
diff changeset
   908
                    dir=manifest_dir)
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   909
                t_fh = os.fdopen(t_fd, "w")
2456
063737b8ee9b 9809 pkgsend publish should take bundle files as sources for files
Shawn Walker <shawn.walker@oracle.com>
parents: 2453
diff changeset
   910
                if pfmri:
063737b8ee9b 9809 pkgsend publish should take bundle files as sources for files
Shawn Walker <shawn.walker@oracle.com>
parents: 2453
diff changeset
   911
                        t_fh.write("set name=pkg.fmri value=%s\n" % pfmri)
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   912
                t_fh.write(content)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   913
                t_fh.close()
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   914
                self.debugfilecreate(content, t_path)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
   915
                return t_path
435
461b1c739de9 1753 An exception thrown during the teardown phase of the test program leaves pkg.depot running.
Brock Pytlik <bpytlik@sun.com>
parents: 430
diff changeset
   916
2026
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 1970
diff changeset
   917
        @staticmethod
2414
ce704b29a50c 18464 revoka-ca-cert needs a rethink
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2401
diff changeset
   918
        def calc_pem_hash(pth):
ce704b29a50c 18464 revoka-ca-cert needs a rethink
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2401
diff changeset
   919
                # Find the hash of pem representation the file.
ce704b29a50c 18464 revoka-ca-cert needs a rethink
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2401
diff changeset
   920
                cert = m2.X509.load_cert(pth)
ce704b29a50c 18464 revoka-ca-cert needs a rethink
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2401
diff changeset
   921
                return hashlib.sha1(cert.as_pem()).hexdigest()
2026
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 1970
diff changeset
   922
1730
c12580e62699 14347 Add tests to exercise the new -F tsv option for pkg publisher
Gary Pennington <gary.pennington@sun.com>
parents: 1715
diff changeset
   923
        def reduceSpaces(self, string):
c12580e62699 14347 Add tests to exercise the new -F tsv option for pkg publisher
Gary Pennington <gary.pennington@sun.com>
parents: 1715
diff changeset
   924
                """Reduce runs of spaces down to a single space."""
c12580e62699 14347 Add tests to exercise the new -F tsv option for pkg publisher
Gary Pennington <gary.pennington@sun.com>
parents: 1715
diff changeset
   925
                return re.sub(" +", " ", string)
1946
8ef3acf32d54 16132 various bits of pkg specify non-existent domains to gettext.install
Richard Lowe <richlowe@richlowe.net>
parents: 1908
diff changeset
   926
3192
13377dbd6773 18876698 Plan serialization for linked images does not support unicode in license actions
saurabh.vyas@oracle.com
parents: 3190
diff changeset
   927
        def assertEqualJSON(self, expected, actual, msg=""):
13377dbd6773 18876698 Plan serialization for linked images does not support unicode in license actions
saurabh.vyas@oracle.com
parents: 3190
diff changeset
   928
                """Compare two JSON-encoded strings."""
13377dbd6773 18876698 Plan serialization for linked images does not support unicode in license actions
saurabh.vyas@oracle.com
parents: 3190
diff changeset
   929
                je = json.loads(expected)
13377dbd6773 18876698 Plan serialization for linked images does not support unicode in license actions
saurabh.vyas@oracle.com
parents: 3190
diff changeset
   930
                ja = json.loads(actual)
13377dbd6773 18876698 Plan serialization for linked images does not support unicode in license actions
saurabh.vyas@oracle.com
parents: 3190
diff changeset
   931
                try:
13377dbd6773 18876698 Plan serialization for linked images does not support unicode in license actions
saurabh.vyas@oracle.com
parents: 3190
diff changeset
   932
                        misc.json_diff("test", je, ja, je, ja)
13377dbd6773 18876698 Plan serialization for linked images does not support unicode in license actions
saurabh.vyas@oracle.com
parents: 3190
diff changeset
   933
                except AssertionError as e:
13377dbd6773 18876698 Plan serialization for linked images does not support unicode in license actions
saurabh.vyas@oracle.com
parents: 3190
diff changeset
   934
                        if msg:
13377dbd6773 18876698 Plan serialization for linked images does not support unicode in license actions
saurabh.vyas@oracle.com
parents: 3190
diff changeset
   935
                                msg += "\n"
13377dbd6773 18876698 Plan serialization for linked images does not support unicode in license actions
saurabh.vyas@oracle.com
parents: 3190
diff changeset
   936
                        self.fail(msg + str(e))
13377dbd6773 18876698 Plan serialization for linked images does not support unicode in license actions
saurabh.vyas@oracle.com
parents: 3190
diff changeset
   937
2546
a9487a95b5cc 18911 pkgfmt v2 should only force indent on dir action type and not words
Shawn Walker <shawn.walker@oracle.com>
parents: 2524
diff changeset
   938
        def assertEqualDiff(self, expected, actual, bound_white_space=False,
a9487a95b5cc 18911 pkgfmt v2 should only force indent on dir action type and not words
Shawn Walker <shawn.walker@oracle.com>
parents: 2524
diff changeset
   939
            msg=""):
1730
c12580e62699 14347 Add tests to exercise the new -F tsv option for pkg publisher
Gary Pennington <gary.pennington@sun.com>
parents: 1715
diff changeset
   940
                """Compare two strings."""
1859
6e6e866921e7 529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents: 1839
diff changeset
   941
6e6e866921e7 529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents: 1839
diff changeset
   942
                if not isinstance(expected, basestring):
6e6e866921e7 529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents: 1839
diff changeset
   943
                        expected = pprint.pformat(expected)
6e6e866921e7 529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents: 1839
diff changeset
   944
                if not isinstance(actual, basestring):
6e6e866921e7 529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents: 1839
diff changeset
   945
                        actual = pprint.pformat(actual)
6e6e866921e7 529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents: 1839
diff changeset
   946
2310
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
   947
                expected_lines = expected.splitlines()
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
   948
                actual_lines = actual.splitlines()
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
   949
                if bound_white_space:
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
   950
                        expected_lines = ["'%s'" % l for l in expected_lines]
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
   951
                        actual_lines = ["'%s'" % l for l in actual_lines]
2546
a9487a95b5cc 18911 pkgfmt v2 should only force indent on dir action type and not words
Shawn Walker <shawn.walker@oracle.com>
parents: 2524
diff changeset
   952
                if msg:
a9487a95b5cc 18911 pkgfmt v2 should only force indent on dir action type and not words
Shawn Walker <shawn.walker@oracle.com>
parents: 2524
diff changeset
   953
                        msg += "\n"
a9487a95b5cc 18911 pkgfmt v2 should only force indent on dir action type and not words
Shawn Walker <shawn.walker@oracle.com>
parents: 2524
diff changeset
   954
                self.assertEqual(expected, actual, msg +
a9487a95b5cc 18911 pkgfmt v2 should only force indent on dir action type and not words
Shawn Walker <shawn.walker@oracle.com>
parents: 2524
diff changeset
   955
                    "Actual output differed from expected output\n" + msg +
2310
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
   956
                    "\n".join(difflib.unified_diff(expected_lines, actual_lines,
1730
c12580e62699 14347 Add tests to exercise the new -F tsv option for pkg publisher
Gary Pennington <gary.pennington@sun.com>
parents: 1715
diff changeset
   957
                        "Expected output", "Actual output", lineterm="")))
1946
8ef3acf32d54 16132 various bits of pkg specify non-existent domains to gettext.install
Richard Lowe <richlowe@richlowe.net>
parents: 1908
diff changeset
   958
2500
a63fead21404 18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2499
diff changeset
   959
        def __compare_child_images(self, ev, ov):
a63fead21404 18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2499
diff changeset
   960
                """A helper function used to match child images with their
a63fead21404 18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2499
diff changeset
   961
                expected values so that they can be checked."""
a63fead21404 18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2499
diff changeset
   962
a63fead21404 18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2499
diff changeset
   963
                enames = [d["image_name"] for d in ev]
a63fead21404 18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2499
diff changeset
   964
                onames = [d["image-name"] for d in ov]
a63fead21404 18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2499
diff changeset
   965
                if sorted(enames) != sorted(onames):
a63fead21404 18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2499
diff changeset
   966
                        raise RuntimeError("Got a different set of image names "
a63fead21404 18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2499
diff changeset
   967
                            "than was expected.\nExpected:\n%s\nSeen:\n%s" %
a63fead21404 18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2499
diff changeset
   968
                            (" ".join(enames), " ".join(onames)))
a63fead21404 18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2499
diff changeset
   969
                for ed in ev:
a63fead21404 18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2499
diff changeset
   970
                        for od in ov:
a63fead21404 18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2499
diff changeset
   971
                                if ed["image_name"] == od["image-name"]:
a63fead21404 18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2499
diff changeset
   972
                                        self.assertEqualParsable(od, **ed)
a63fead21404 18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2499
diff changeset
   973
                                        break
a63fead21404 18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2499
diff changeset
   974
a63fead21404 18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2499
diff changeset
   975
        def assertEqualParsable(self, output, activate_be=True,
a63fead21404 18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2499
diff changeset
   976
            add_packages=EmptyI, affect_packages=EmptyI, affect_services=EmptyI,
2517
8f26a1d7100c 18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents: 2500
diff changeset
   977
            backup_be_name=None, be_name=None, boot_archive_rebuild=False,
3063
bbaaf1579de3 15744850 no actuators are run when pkg manipulates a booted NGZ image from the GZ
thejaswini.k@oracle.com
parents: 3048
diff changeset
   978
            change_editables=EmptyI, change_facets=EmptyI,
bbaaf1579de3 15744850 no actuators are run when pkg manipulates a booted NGZ image from the GZ
thejaswini.k@oracle.com
parents: 3048
diff changeset
   979
            change_packages=EmptyI, change_mediators=EmptyI,
bbaaf1579de3 15744850 no actuators are run when pkg manipulates a booted NGZ image from the GZ
thejaswini.k@oracle.com
parents: 3048
diff changeset
   980
            change_variants=EmptyI, child_images=EmptyI, create_backup_be=False,
bbaaf1579de3 15744850 no actuators are run when pkg manipulates a booted NGZ image from the GZ
thejaswini.k@oracle.com
parents: 3048
diff changeset
   981
            create_new_be=False, image_name=None, licenses=EmptyI,
bbaaf1579de3 15744850 no actuators are run when pkg manipulates a booted NGZ image from the GZ
thejaswini.k@oracle.com
parents: 3048
diff changeset
   982
            remove_packages=EmptyI, release_notes=EmptyI, include=EmptyI,
2500
a63fead21404 18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2499
diff changeset
   983
            version=0):
a63fead21404 18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2499
diff changeset
   984
                """Check that the parsable output in 'output' is what is
a63fead21404 18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2499
diff changeset
   985
                expected."""
a63fead21404 18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2499
diff changeset
   986
a63fead21404 18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2499
diff changeset
   987
                if isinstance(output, basestring):
a63fead21404 18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2499
diff changeset
   988
                        try:
a63fead21404 18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2499
diff changeset
   989
                                outd = json.loads(output)
a63fead21404 18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2499
diff changeset
   990
                        except Exception, e:
a63fead21404 18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2499
diff changeset
   991
                                raise RuntimeError("JSON couldn't parse the "
a63fead21404 18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2499
diff changeset
   992
                                    "output.\nError was: %s\nOutput was:\n%s" %
a63fead21404 18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2499
diff changeset
   993
                                    (e, output))
a63fead21404 18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2499
diff changeset
   994
                else:
a63fead21404 18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2499
diff changeset
   995
                        self.assert_(isinstance(output, dict))
a63fead21404 18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2499
diff changeset
   996
                        outd = output
a63fead21404 18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2499
diff changeset
   997
                expected = locals()
a63fead21404 18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2499
diff changeset
   998
                # It's difficult to check that space-available is correct in the
a63fead21404 18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2499
diff changeset
   999
                # test suite.
a63fead21404 18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2499
diff changeset
  1000
                self.assert_("space-available" in outd)
a63fead21404 18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2499
diff changeset
  1001
                del outd["space-available"]
a63fead21404 18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2499
diff changeset
  1002
                # While we could check for space-required, it just means lots of
a63fead21404 18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2499
diff changeset
  1003
                # tests would need to be changed if we ever changed our size
a63fead21404 18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2499
diff changeset
  1004
                # measurement and other tests should be ensuring that the number
a63fead21404 18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2499
diff changeset
  1005
                # is correct.
a63fead21404 18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2499
diff changeset
  1006
                self.assert_("space-required" in outd)
a63fead21404 18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2499
diff changeset
  1007
                del outd["space-required"]
3063
bbaaf1579de3 15744850 no actuators are run when pkg manipulates a booted NGZ image from the GZ
thejaswini.k@oracle.com
parents: 3048
diff changeset
  1008
                # Add 4 to account for self, output, include, and outd.
bbaaf1579de3 15744850 no actuators are run when pkg manipulates a booted NGZ image from the GZ
thejaswini.k@oracle.com
parents: 3048
diff changeset
  1009
                self.assertEqual(len(expected), len(outd) + 4, "Got a "
2500
a63fead21404 18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2499
diff changeset
  1010
                    "different set of keys for expected and outd.  Those in "
a63fead21404 18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2499
diff changeset
  1011
                    "expected but not in outd:\n%s\nThose in outd but not in "
a63fead21404 18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2499
diff changeset
  1012
                    "expected:\n%s" % (
a63fead21404 18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2499
diff changeset
  1013
                        sorted(set([k.replace("_", "-") for k in expected]) -
a63fead21404 18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2499
diff changeset
  1014
                        set(outd)),
a63fead21404 18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2499
diff changeset
  1015
                        sorted(set(outd) -
a63fead21404 18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2499
diff changeset
  1016
                        set([k.replace("_", "-") for k in expected]))))
3063
bbaaf1579de3 15744850 no actuators are run when pkg manipulates a booted NGZ image from the GZ
thejaswini.k@oracle.com
parents: 3048
diff changeset
  1017
bbaaf1579de3 15744850 no actuators are run when pkg manipulates a booted NGZ image from the GZ
thejaswini.k@oracle.com
parents: 3048
diff changeset
  1018
                seen = set()
2500
a63fead21404 18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2499
diff changeset
  1019
                for k in sorted(outd):
3063
bbaaf1579de3 15744850 no actuators are run when pkg manipulates a booted NGZ image from the GZ
thejaswini.k@oracle.com
parents: 3048
diff changeset
  1020
                        seen.add(k)
bbaaf1579de3 15744850 no actuators are run when pkg manipulates a booted NGZ image from the GZ
thejaswini.k@oracle.com
parents: 3048
diff changeset
  1021
                        if include and k not in include:
bbaaf1579de3 15744850 no actuators are run when pkg manipulates a booted NGZ image from the GZ
thejaswini.k@oracle.com
parents: 3048
diff changeset
  1022
                                continue
bbaaf1579de3 15744850 no actuators are run when pkg manipulates a booted NGZ image from the GZ
thejaswini.k@oracle.com
parents: 3048
diff changeset
  1023
2500
a63fead21404 18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2499
diff changeset
  1024
                        ek = k.replace("-", "_")
a63fead21404 18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2499
diff changeset
  1025
                        ev = expected[ek]
a63fead21404 18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2499
diff changeset
  1026
                        if ev == EmptyI:
a63fead21404 18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2499
diff changeset
  1027
                                ev = []
a63fead21404 18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2499
diff changeset
  1028
                        if ek == "child_images" and ev != []:
a63fead21404 18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2499
diff changeset
  1029
                                self.__compare_child_images(ev, outd[k])
a63fead21404 18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2499
diff changeset
  1030
                                continue
a63fead21404 18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2499
diff changeset
  1031
                        self.assertEqual(ev, outd[k], "In image %s, the value "
a63fead21404 18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2499
diff changeset
  1032
                            "of %s was expected to be\n%s but was\n%s" %
a63fead21404 18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2499
diff changeset
  1033
                            (image_name, k, ev, outd[k]))
a63fead21404 18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2499
diff changeset
  1034
3063
bbaaf1579de3 15744850 no actuators are run when pkg manipulates a booted NGZ image from the GZ
thejaswini.k@oracle.com
parents: 3048
diff changeset
  1035
                if include:
bbaaf1579de3 15744850 no actuators are run when pkg manipulates a booted NGZ image from the GZ
thejaswini.k@oracle.com
parents: 3048
diff changeset
  1036
                        # Assert all sections expicitly requested were matched.
bbaaf1579de3 15744850 no actuators are run when pkg manipulates a booted NGZ image from the GZ
thejaswini.k@oracle.com
parents: 3048
diff changeset
  1037
                        self.assertEqualDiff(include, list(x for x in (seen &
bbaaf1579de3 15744850 no actuators are run when pkg manipulates a booted NGZ image from the GZ
thejaswini.k@oracle.com
parents: 3048
diff changeset
  1038
                            set(include))))
bbaaf1579de3 15744850 no actuators are run when pkg manipulates a booted NGZ image from the GZ
thejaswini.k@oracle.com
parents: 3048
diff changeset
  1039
2085
10a27146ebc2 16802 pkglint should check the value of info.classification in manifests
Tim Foster <tim.s.foster@oracle.com>
parents: 2081
diff changeset
  1040
        def configure_rcfile(self, rcfile, config, test_root, section="DEFAULT",
10a27146ebc2 16802 pkglint should check the value of info.classification in manifests
Tim Foster <tim.s.foster@oracle.com>
parents: 2081
diff changeset
  1041
            suffix=""):
10a27146ebc2 16802 pkglint should check the value of info.classification in manifests
Tim Foster <tim.s.foster@oracle.com>
parents: 2081
diff changeset
  1042
                """Reads the provided rcfile file, setting key/value
10a27146ebc2 16802 pkglint should check the value of info.classification in manifests
Tim Foster <tim.s.foster@oracle.com>
parents: 2081
diff changeset
  1043
                pairs in the provided section those from the 'config'
10a27146ebc2 16802 pkglint should check the value of info.classification in manifests
Tim Foster <tim.s.foster@oracle.com>
parents: 2081
diff changeset
  1044
                dictionary. The new config file is written to the supplied
10a27146ebc2 16802 pkglint should check the value of info.classification in manifests
Tim Foster <tim.s.foster@oracle.com>
parents: 2081
diff changeset
  1045
                test_root, returning the name of that new file.
10a27146ebc2 16802 pkglint should check the value of info.classification in manifests
Tim Foster <tim.s.foster@oracle.com>
parents: 2081
diff changeset
  1046
10a27146ebc2 16802 pkglint should check the value of info.classification in manifests
Tim Foster <tim.s.foster@oracle.com>
parents: 2081
diff changeset
  1047
                Used to set keys to point to paths beneath our test_root,
10a27146ebc2 16802 pkglint should check the value of info.classification in manifests
Tim Foster <tim.s.foster@oracle.com>
parents: 2081
diff changeset
  1048
                which would otherwise be shipped as hard-coded paths, relative
10a27146ebc2 16802 pkglint should check the value of info.classification in manifests
Tim Foster <tim.s.foster@oracle.com>
parents: 2081
diff changeset
  1049
                to /.
10a27146ebc2 16802 pkglint should check the value of info.classification in manifests
Tim Foster <tim.s.foster@oracle.com>
parents: 2081
diff changeset
  1050
                """
10a27146ebc2 16802 pkglint should check the value of info.classification in manifests
Tim Foster <tim.s.foster@oracle.com>
parents: 2081
diff changeset
  1051
10a27146ebc2 16802 pkglint should check the value of info.classification in manifests
Tim Foster <tim.s.foster@oracle.com>
parents: 2081
diff changeset
  1052
                new_rcfile = file("%s/%s%s" % (test_root, os.path.basename(rcfile),
10a27146ebc2 16802 pkglint should check the value of info.classification in manifests
Tim Foster <tim.s.foster@oracle.com>
parents: 2081
diff changeset
  1053
                    suffix), "w")
10a27146ebc2 16802 pkglint should check the value of info.classification in manifests
Tim Foster <tim.s.foster@oracle.com>
parents: 2081
diff changeset
  1054
3048
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
  1055
                conf = ConfigParser.RawConfigParser()
2085
10a27146ebc2 16802 pkglint should check the value of info.classification in manifests
Tim Foster <tim.s.foster@oracle.com>
parents: 2081
diff changeset
  1056
                conf.readfp(open(rcfile))
10a27146ebc2 16802 pkglint should check the value of info.classification in manifests
Tim Foster <tim.s.foster@oracle.com>
parents: 2081
diff changeset
  1057
10a27146ebc2 16802 pkglint should check the value of info.classification in manifests
Tim Foster <tim.s.foster@oracle.com>
parents: 2081
diff changeset
  1058
                for key in config:
10a27146ebc2 16802 pkglint should check the value of info.classification in manifests
Tim Foster <tim.s.foster@oracle.com>
parents: 2081
diff changeset
  1059
                        conf.set(section, key, config[key])
10a27146ebc2 16802 pkglint should check the value of info.classification in manifests
Tim Foster <tim.s.foster@oracle.com>
parents: 2081
diff changeset
  1060
10a27146ebc2 16802 pkglint should check the value of info.classification in manifests
Tim Foster <tim.s.foster@oracle.com>
parents: 2081
diff changeset
  1061
                conf.write(new_rcfile)
10a27146ebc2 16802 pkglint should check the value of info.classification in manifests
Tim Foster <tim.s.foster@oracle.com>
parents: 2081
diff changeset
  1062
                return new_rcfile.name
10a27146ebc2 16802 pkglint should check the value of info.classification in manifests
Tim Foster <tim.s.foster@oracle.com>
parents: 2081
diff changeset
  1063
1730
c12580e62699 14347 Add tests to exercise the new -F tsv option for pkg publisher
Gary Pennington <gary.pennington@sun.com>
parents: 1715
diff changeset
  1064
2499
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1065
class _OverTheWireResults(object):
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1066
        """Class for passing test results between processes."""
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1067
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1068
        separator1 = '=' * 70
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1069
        separator2 = '-' * 70
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1070
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1071
        list_attrs = ["baseline_failures", "errors", "failures", "skips",
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1072
            "timing"]
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1073
        num_attrs = ["mismatches", "num_successes", "testsRun"]
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1074
        
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1075
        def __init__(self, res):
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1076
                self.errors = [(str(test), err) for  test, err in res.errors]
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1077
                self.failures = [(str(test), err) for test, err in res.failures]
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1078
                self.mismatches = len(res.mismatches)
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1079
                self.num_successes = len(res.success)
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1080
                self.skips = res.skips
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1081
                self.testsRun = res.testsRun
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1082
                self.timing = []
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1083
                self.text = ""
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1084
                self.baseline_failures = []
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1085
                self.debug_buf = ""
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1086
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1087
        def wasSuccessful(self):
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1088
                return self.mismatches == 0
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1089
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1090
        def wasSkipped(self):
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1091
                return len(self.skips) != 0
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1092
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1093
        def printErrors(self):
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1094
                self.stream.write("\n")
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1095
                self.printErrorList('ERROR', self.errors)
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1096
                self.printErrorList('FAIL', self.failures)
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1097
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1098
        def printErrorList(self, flavour, errors):
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1099
                for test, err in errors:
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1100
                        self.stream.write(self.separator1 + "\n")
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1101
                        self.stream.write("%s: %s\n" %
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1102
                            (flavour, test))
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1103
                        self.stream.write(self.separator2 + "\n")
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1104
                        self.stream.write("%s\n" % err)
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1105
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1106
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1107
class _CombinedResult(_OverTheWireResults):
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1108
        """Class for combining test results from different test cases."""
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1109
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1110
        def __init__(self):
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1111
                for l in self.list_attrs:
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1112
                        setattr(self, l, [])
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1113
                for n in self.num_attrs:
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1114
                        setattr(self, n, 0)
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1115
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1116
        def combine(self, o):
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1117
                for l in self.list_attrs:
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1118
                        v = getattr(self, l)
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1119
                        v.extend(getattr(o, l))
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1120
                        setattr(self, l, v)
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1121
                for n in self.num_attrs:
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1122
                        v = getattr(self, n)
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1123
                        v += getattr(o, n)
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1124
                        setattr(self, n, v)
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1125
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1126
        
430
3fb945d3bff3 2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff changeset
  1127
class _Pkg5TestResult(unittest._TextTestResult):
3fb945d3bff3 2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff changeset
  1128
        baseline = None
3fb945d3bff3 2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff changeset
  1129
        machsep = "|"
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1130
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1131
        def __init__(self, stream, output, baseline, bailonfail=False,
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1132
            show_on_expected_fail=False, archive_dir=None):
430
3fb945d3bff3 2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff changeset
  1133
                unittest.TestResult.__init__(self)
3fb945d3bff3 2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff changeset
  1134
                self.stream = stream
3fb945d3bff3 2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff changeset
  1135
                self.output = output
3fb945d3bff3 2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff changeset
  1136
                self.baseline = baseline
448
bcfa99ac18b0 2664 test suite baseline enhancements
Brad Hall <bhall@eng.sun.com>
parents: 436
diff changeset
  1137
                self.success = []
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1138
                self.mismatches = []
1421
d6733f41c267 3961 Test suite should have a flag that makes it stop after encountering a failure
John Sonnenschein <John.Sonnenschein@Sun.COM>
parents: 1101
diff changeset
  1139
                self.bailonfail = bailonfail
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1140
                self.show_on_expected_fail = show_on_expected_fail
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1141
                self.archive_dir = archive_dir
2306
dfc3f8634dcc 17158 importer.py could use some basic unit tests
Tim Foster <tim.s.foster@oracle.com>
parents: 2293
diff changeset
  1142
                self.skips = []
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1143
2499
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1144
        def collapse(self):
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1145
                return _OverTheWireResults(self)
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1146
2073
9fcacc9e5eaa 16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents: 2047
diff changeset
  1147
        def getDescription(self, test):
9fcacc9e5eaa 16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents: 2047
diff changeset
  1148
                return str(test)
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1149
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1150
        # Override the unittest version of this so that success is
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1151
        # considered "matching the baseline"
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1152
        def wasSuccessful(self):
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1153
                return len(self.mismatches) == 0
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1154
2306
dfc3f8634dcc 17158 importer.py could use some basic unit tests
Tim Foster <tim.s.foster@oracle.com>
parents: 2293
diff changeset
  1155
        def wasSkipped(self):
dfc3f8634dcc 17158 importer.py could use some basic unit tests
Tim Foster <tim.s.foster@oracle.com>
parents: 2293
diff changeset
  1156
                return len(self.skips) != 0
dfc3f8634dcc 17158 importer.py could use some basic unit tests
Tim Foster <tim.s.foster@oracle.com>
parents: 2293
diff changeset
  1157
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1158
        def dobailout(self, test):
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1159
                """ Pull the ejection lever.  Stop execution, doing as
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1160
                much forcible cleanup as possible. """
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1161
                inst, tdf = test.getTeardownFunc()
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1162
                try:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1163
                        tdf()
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1164
                except Exception, e:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1165
                        print >> sys.stderr, str(e)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1166
                        pass
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1167
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1168
                if getattr(test, "persistent_setup", None):
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1169
                        try:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1170
                                test.reallytearDown()
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1171
                        except Exception, e:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1172
                                print >> sys.stderr, str(e)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1173
                                pass
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1174
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1175
                if hasattr(inst, "killalldepots"):
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1176
                        try:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1177
                                inst.killalldepots()
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1178
                        except Exception, e:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1179
                                print >> sys.stderr, str(e)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1180
                                pass
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1181
                raise TestStopException()
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1182
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1183
        def fmt_parseable(self, match, actual, expected):
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1184
                if match == baseline.BASELINE_MATCH:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1185
                        mstr = "MATCH"
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1186
                else:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1187
                        mstr = "MISMATCH"
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1188
                return "%s|%s|%s" % (mstr, actual, expected)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1189
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1190
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1191
        @staticmethod
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1192
        def fmt_prefix_with(instr, prefix):
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1193
                res = ""
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1194
                for s in instr.splitlines():
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1195
                        res += "%s%s\n" % (prefix, s)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1196
                return res
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1197
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1198
        @staticmethod
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1199
        def fmt_box(instr, title, prefix=""):
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1200
                trailingdashes = (50 - len(title)) * "-"
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1201
                res = "\n.---" + title + trailingdashes + "\n"
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1202
                for s in instr.splitlines():
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1203
                        if s.strip() == "":
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1204
                                continue
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1205
                        res += "| %s\n" % s
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1206
                res += "`---" + len(title) * "-" + trailingdashes
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1207
                return _Pkg5TestResult.fmt_prefix_with(res, prefix)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1208
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1209
        def do_archive(self, test, info):
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1210
                assert self.archive_dir
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1211
                if not os.path.exists(self.archive_dir):
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1212
                        os.makedirs(self.archive_dir, mode=0755)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1213
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1214
                archive_path = os.path.join(self.archive_dir,
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1215
                    "%d" % os.getpid())
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1216
                if not os.path.exists(archive_path):
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1217
                        os.makedirs(archive_path, mode=0755)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1218
                archive_path = os.path.join(archive_path, test.id())
2499
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1219
                if test.debug_output:
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1220
                        self.stream.write("# Archiving to %s\n" % archive_path)
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1221
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1222
                if os.path.exists(test.test_root):
2756
04d926cf9f51 7140807 sysrepo should not cache catalog responses
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2755
diff changeset
  1223
                        try:
04d926cf9f51 7140807 sysrepo should not cache catalog responses
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2755
diff changeset
  1224
                                misc.copytree(test.test_root, archive_path)
04d926cf9f51 7140807 sysrepo should not cache catalog responses
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2755
diff changeset
  1225
                        except socketerror, e:
04d926cf9f51 7140807 sysrepo should not cache catalog responses
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2755
diff changeset
  1226
                                pass
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1227
                else:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1228
                        # If the test has failed without creating its directory,
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1229
                        # make it manually, so that we have a place to write out
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1230
                        # ERROR_INFO.
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1231
                        os.makedirs(archive_path, mode=0755)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1232
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1233
                f = open(os.path.join(archive_path, "ERROR_INFO"), "w")
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1234
                f.write("------------------DEBUG LOG---------------\n")
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1235
                f.write(test.get_debugbuf())
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1236
                if info is not None:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1237
                        f.write("\n\n------------------EXCEPTION---------------\n")
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1238
                        f.write(info)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1239
                f.close()
448
bcfa99ac18b0 2664 test suite baseline enhancements
Brad Hall <bhall@eng.sun.com>
parents: 436
diff changeset
  1240
430
3fb945d3bff3 2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff changeset
  1241
        def addSuccess(self, test):
3fb945d3bff3 2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff changeset
  1242
                unittest.TestResult.addSuccess(self, test)
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1243
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1244
                # If we're debugging, we'll have had output since we
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1245
                # announced the name of the test, so restate it.
2499
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1246
                if test.debug_output:
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1247
                        self.statename(test)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1248
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1249
                errinfo = self.format_output_and_exc(test, None)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1250
430
3fb945d3bff3 2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff changeset
  1251
                bresult = self.baseline.handleresult(str(test), "pass")
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1252
                expected = self.baseline.expectedresult(str(test))
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1253
                if self.output == OUTPUT_PARSEABLE:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1254
                        res = self.fmt_parseable(bresult, "pass", expected)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1255
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1256
                elif self.output == OUTPUT_VERBOSE:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1257
                        if bresult == baseline.BASELINE_MATCH:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1258
                                res = "match pass"
430
3fb945d3bff3 2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff changeset
  1259
                        else:
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1260
                                res = "MISMATCH pass (expected: %s)" % \
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1261
                                    expected
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1262
                                res = self.fmt_box(errinfo,
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1263
                                    "Successful Test", "# ")
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1264
                else:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1265
                        assert self.output == OUTPUT_DOTS
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1266
                        res = "."
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1267
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1268
                if self.output != OUTPUT_DOTS:
2499
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1269
                        self.stream.write(res + "\n")
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1270
                else:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1271
                        self.stream.write(res)
448
bcfa99ac18b0 2664 test suite baseline enhancements
Brad Hall <bhall@eng.sun.com>
parents: 436
diff changeset
  1272
                self.success.append(test)
430
3fb945d3bff3 2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff changeset
  1273
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1274
                if bresult == baseline.BASELINE_MISMATCH:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1275
                        self.mismatches.append(test)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1276
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1277
                if bresult == baseline.BASELINE_MISMATCH and self.archive_dir:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1278
                        self.do_archive(test, None)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1279
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1280
                # Bail out completely if the 'bail on fail' flag is set
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1281
                # but iff the result disagrees with the baseline.
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1282
                if self.bailonfail and bresult == baseline.BASELINE_MISMATCH:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1283
                        self.dobailout(test)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1284
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1285
430
3fb945d3bff3 2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff changeset
  1286
        def addError(self, test, err):
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1287
                errtype, errval = err[:2]
2073
9fcacc9e5eaa 16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents: 2047
diff changeset
  1288
                # for a few special exceptions, we delete the traceback so
9fcacc9e5eaa 16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents: 2047
diff changeset
  1289
                # as to elide it.  use only when the traceback itself
9fcacc9e5eaa 16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents: 2047
diff changeset
  1290
                # is not likely to be useful.
9fcacc9e5eaa 16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents: 2047
diff changeset
  1291
                if errtype in ELIDABLE_ERRORS:
9fcacc9e5eaa 16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents: 2047
diff changeset
  1292
                        unittest.TestResult.addError(self, test,
9fcacc9e5eaa 16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents: 2047
diff changeset
  1293
                            (err[0], err[1], None))
9fcacc9e5eaa 16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents: 2047
diff changeset
  1294
                else:
9fcacc9e5eaa 16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents: 2047
diff changeset
  1295
                        unittest.TestResult.addError(self, test, err)
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1296
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1297
                # If we're debugging, we'll have had output since we
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1298
                # announced the name of the test, so restate it.
2499
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1299
                if test.debug_output:
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1300
                        self.statename(test)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1301
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1302
                errinfo = self.format_output_and_exc(test, err)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1303
1002
56ab3be9a8b7 3488 Test suite should supress expected failures (or notate them more clearly)
Danek Duvall <danek.duvall@sun.com>
parents: 683
diff changeset
  1304
                bresult = self.baseline.handleresult(str(test), "error")
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1305
                expected = self.baseline.expectedresult(str(test))
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1306
                if self.output == OUTPUT_PARSEABLE:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1307
                        if errtype in ELIDABLE_ERRORS:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1308
                                res = self.fmt_parseable(bresult, "ERROR", expected)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1309
                                res += "\n# %s\n" % str(errval).strip()
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1310
                        else:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1311
                                res = self.fmt_parseable(bresult, "ERROR", expected)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1312
                                res += "\n"
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1313
                                if bresult == baseline.BASELINE_MISMATCH \
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1314
                                   or self.show_on_expected_fail:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1315
                                        res += self.fmt_prefix_with(errinfo, "# ")
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1316
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1317
                elif self.output == OUTPUT_VERBOSE:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1318
                        if bresult == baseline.BASELINE_MATCH:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1319
                                b = "match"
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1320
                        else:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1321
                                b = "MISMATCH"
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1322
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1323
                        if errtype in ELIDABLE_ERRORS:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1324
                                res = "%s ERROR\n" % b
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1325
                                res += "#\t%s" % str(errval)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1326
                        else:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1327
                                res = "%s ERROR\n" % b
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1328
                                if bresult == baseline.BASELINE_MISMATCH \
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1329
                                   or self.show_on_expected_fail:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1330
                                        res += self.fmt_box(errinfo,
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1331
                                            "Error Information", "# ")
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1332
430
3fb945d3bff3 2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff changeset
  1333
                elif self.output == OUTPUT_DOTS:
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1334
                        if bresult == baseline.BASELINE_MATCH:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1335
                                res = "e"
1002
56ab3be9a8b7 3488 Test suite should supress expected failures (or notate them more clearly)
Danek Duvall <danek.duvall@sun.com>
parents: 683
diff changeset
  1336
                        else:
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1337
                                res = "E"
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1338
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1339
                if self.output == OUTPUT_DOTS:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1340
                        self.stream.write(res)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1341
                else:
2499
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1342
                        self.stream.write(res + "\n")
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1343
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1344
                if bresult == baseline.BASELINE_MISMATCH:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1345
                        self.mismatches.append(test)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1346
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1347
                # Check to see if we should archive this baseline mismatch.
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1348
                if bresult == baseline.BASELINE_MISMATCH and self.archive_dir:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1349
                        self.do_archive(test, self._exc_info_to_string(err, test))
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1350
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1351
                # Bail out completely if the 'bail on fail' flag is set
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1352
                # but iff the result disagrees with the baseline.
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1353
                if self.bailonfail and bresult == baseline.BASELINE_MISMATCH:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1354
                        self.dobailout(test)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1355
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1356
        def format_output_and_exc(self, test, error):
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1357
                res = ""
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1358
                dbgbuf = test.get_debugbuf()
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1359
                if dbgbuf != "":
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1360
                        res += dbgbuf
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1361
                if error is not None:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1362
                        res += self._exc_info_to_string(error, test)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1363
                return res
430
3fb945d3bff3 2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff changeset
  1364
3fb945d3bff3 2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff changeset
  1365
        def addFailure(self, test, err):
2073
9fcacc9e5eaa 16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents: 2047
diff changeset
  1366
                unittest.TestResult.addFailure(self, test, err)
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1367
430
3fb945d3bff3 2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff changeset
  1368
                bresult = self.baseline.handleresult(str(test), "fail")
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1369
                expected = self.baseline.expectedresult(str(test))
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1370
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1371
                # If we're debugging, we'll have had output since we
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1372
                # announced the name of the test, so restate it.
2499
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1373
                if test.debug_output:
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1374
                        self.statename(test)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1375
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1376
                errinfo = self.format_output_and_exc(test, err)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1377
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1378
                if self.output == OUTPUT_PARSEABLE:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1379
                        res = self.fmt_parseable(bresult, "FAIL", expected)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1380
                        res += "\n"
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1381
                        if bresult == baseline.BASELINE_MISMATCH \
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1382
                           or self.show_on_expected_fail:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1383
                                res += self.fmt_prefix_with(errinfo, "# ")
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1384
                elif self.output == OUTPUT_VERBOSE:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1385
                        if bresult == baseline.BASELINE_MISMATCH:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1386
                                res = "MISMATCH FAIL (expected: %s)" % expected
430
3fb945d3bff3 2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff changeset
  1387
                        else:
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1388
                                res = "match FAIL (expected: FAIL)"
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1389
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1390
                        if bresult == baseline.BASELINE_MISMATCH \
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1391
                           or self.show_on_expected_fail:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1392
                                res += self.fmt_box(errinfo,
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1393
                                    "Failure Information", "# ")
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1394
430
3fb945d3bff3 2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff changeset
  1395
                elif self.output == OUTPUT_DOTS:
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1396
                        if bresult == baseline.BASELINE_MATCH:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1397
                                res = "f"
1002
56ab3be9a8b7 3488 Test suite should supress expected failures (or notate them more clearly)
Danek Duvall <danek.duvall@sun.com>
parents: 683
diff changeset
  1398
                        else:
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1399
                                res = "F"
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1400
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1401
                if self.output == OUTPUT_DOTS:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1402
                        self.stream.write(res)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1403
                else:
2499
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1404
                        self.stream.write(res + "\n")
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1405
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1406
                if bresult == baseline.BASELINE_MISMATCH:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1407
                        self.mismatches.append(test)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1408
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1409
                # Check to see if we should archive this baseline mismatch.
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1410
                if bresult == baseline.BASELINE_MISMATCH and self.archive_dir:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1411
                        self.do_archive(test, self._exc_info_to_string(err, test))
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1412
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1413
                # Bail out completely if the 'bail on fail' flag is set
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1414
                # but iff the result disagrees with the baseline.
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1415
                if self.bailonfail and bresult == baseline.BASELINE_MISMATCH:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1416
                        self.dobailout(test)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1417
2306
dfc3f8634dcc 17158 importer.py could use some basic unit tests
Tim Foster <tim.s.foster@oracle.com>
parents: 2293
diff changeset
  1418
        def addSkip(self, test, err):
dfc3f8634dcc 17158 importer.py could use some basic unit tests
Tim Foster <tim.s.foster@oracle.com>
parents: 2293
diff changeset
  1419
                """Python 2.7 adds formal support for skipped tests in unittest
dfc3f8634dcc 17158 importer.py could use some basic unit tests
Tim Foster <tim.s.foster@oracle.com>
parents: 2293
diff changeset
  1420
                For now, we'll record this as a success, but also save the
dfc3f8634dcc 17158 importer.py could use some basic unit tests
Tim Foster <tim.s.foster@oracle.com>
parents: 2293
diff changeset
  1421
                reason why we wanted to skip this test"""
dfc3f8634dcc 17158 importer.py could use some basic unit tests
Tim Foster <tim.s.foster@oracle.com>
parents: 2293
diff changeset
  1422
                self.addSuccess(test)
2644
434fe01f111b 7120902 var/cache/pkg/sysrepo recreated with broken perms
abhinandan.ekande@oracle.com
parents: 2629
diff changeset
  1423
                self.skips.append((str(test), err))
2306
dfc3f8634dcc 17158 importer.py could use some basic unit tests
Tim Foster <tim.s.foster@oracle.com>
parents: 2293
diff changeset
  1424
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1425
        def addPersistentSetupError(self, test, err):
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1426
                errtype, errval = err[:2]
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1427
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1428
                errinfo = self.format_output_and_exc(test, err)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1429
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1430
                res = "# ERROR during persistent setup for %s\n" % test.id()
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1431
                res += "# As a result, all test cases in this class will " \
2656
c51505c00dab 7161073 depotcontroller could return more useful exception when depot fails to start
Dan Price <daniel.price@oracle.com>
parents: 2644
diff changeset
  1432
                    "result in errors!\n#\n"
430
3fb945d3bff3 2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff changeset
  1433
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1434
                if errtype in ELIDABLE_ERRORS:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1435
                        res += "#   " + str(errval)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1436
                else:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1437
                        res += self.fmt_box(errinfo, \
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1438
                            "Persistent Setup Error Information", "# ")
2499
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1439
                self.stream.write(res + "\n")
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1440
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1441
        def addPersistentTeardownError(self, test, err):
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1442
                errtype, errval = err[:2]
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1443
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1444
                errinfo = self.format_output_and_exc(test, err)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1445
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1446
                res = "# ERROR during persistent teardown for %s\n" % test.id()
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1447
                if errtype in ELIDABLE_ERRORS:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1448
                        res += "#   " + str(errval)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1449
                else:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1450
                        res += self.fmt_box(errinfo, \
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1451
                            "Persistent Teardown Error Information", "# ")
2499
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1452
                self.stream.write(res + "\n")
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1453
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1454
        def statename(self, test, prefix=""):
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1455
                name = self.getDescription(test)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1456
                if self.output == OUTPUT_VERBOSE:
2073
9fcacc9e5eaa 16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents: 2047
diff changeset
  1457
                        name = name.ljust(65) + "  "
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1458
                elif self.output == OUTPUT_PARSEABLE:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1459
                        name += "|"
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1460
                elif self.output == OUTPUT_DOTS:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1461
                        return
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1462
                self.stream.write(name)
430
3fb945d3bff3 2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff changeset
  1463
3fb945d3bff3 2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff changeset
  1464
        def startTest(self, test):
3fb945d3bff3 2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff changeset
  1465
                unittest.TestResult.startTest(self, test)
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1466
                test.debug("_" * 75)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1467
                test.debug("Start:   %s" % \
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1468
                    self.getDescription(test))
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1469
                if test._testMethodDoc is not None:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1470
                        docs = ["  " + x.strip() \
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1471
                            for x in test._testMethodDoc.splitlines()]
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1472
                        while len(docs) > 0 and docs[-1] == "":
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1473
                                del docs[-1]
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1474
                        for x in docs:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1475
                                test.debug(x)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1476
                test.debug("_" * 75)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1477
                test.debug("")
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1478
2499
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1479
                if not test.debug_output:
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1480
                        self.statename(test)
430
3fb945d3bff3 2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff changeset
  1481
3fb945d3bff3 2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff changeset
  1482
        def printErrors(self):
2499
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1483
                self.stream.write("\n")
430
3fb945d3bff3 2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff changeset
  1484
                self.printErrorList('ERROR', self.errors)
3fb945d3bff3 2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff changeset
  1485
                self.printErrorList('FAIL', self.failures)
3fb945d3bff3 2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff changeset
  1486
3fb945d3bff3 2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff changeset
  1487
        def printErrorList(self, flavour, errors):
3fb945d3bff3 2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff changeset
  1488
                for test, err in errors:
2499
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1489
                        self.stream.write(self.separator1 + "\n")
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1490
                        self.stream.write("%s: %s\n" %
430
3fb945d3bff3 2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff changeset
  1491
                            (flavour, self.getDescription(test)))
2499
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1492
                        self.stream.write(self.separator2 + "\n")
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1493
                        self.stream.write("%s\n" % err)
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1494
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1495
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1496
def find_names(s):
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1497
        """Find the module and class names for the given test suite."""
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1498
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1499
        l = str(s).split()
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1500
        mod = l[0]
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1501
        c = l[1].split(".")[0]
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1502
        return mod, c
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1503
                
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1504
def q_makeResult(s, o, b, bail_on_fail, show_on_expected_fail, a, cov):
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1505
        """Construct a test result for use in the parallel test suite."""
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1506
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1507
        res = _Pkg5TestResult(s, o, b, bailonfail=bail_on_fail,
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1508
            show_on_expected_fail=show_on_expected_fail, archive_dir=a)
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1509
        res.coverage = cov
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1510
        return res
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1511
                        
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1512
def q_run(inq, outq, i, o, baseline_filepath, bail_on_fail,
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1513
    show_on_expected_fail, a, cov, port, suite_name):
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1514
        """Function used to run the test suite in parallel.
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1515
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1516
        The 'inq' parameter is the queue to pull from to get test suites.
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1517
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1518
        The 'outq' parameter is the queue on which to post results."""
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1519
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1520
        # Set up the coverage environment if it's needed.
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1521
        cov_cmd, cov_env = cov
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1522
        cov_inst = None
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1523
        if cov_env:
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1524
                cov_env["COVERAGE_FILE"] += ".%s.%s" % (suite_name, i)
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1525
                import coverage
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1526
                cov_inst = coverage.coverage(
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1527
                    data_file=cov_env["COVERAGE_FILE"], data_suffix=True)
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1528
                cov_inst.start()
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1529
        cov = (cov_cmd, cov_env)
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1530
        try:
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1531
                while True:
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1532
                        # Get the next test suite to run.
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1533
                        test_suite = inq.get()
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1534
                        if test_suite == "STOP":
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1535
                                break
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1536
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1537
                        # Set up the test so that it plays nicely with tests
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1538
                        # running in other processes.
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1539
                        test_suite.parallel_init(port + i * 20, i, cov)
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1540
                        # Let the master process know that we have this test
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1541
                        # suite and we're about to start running it.
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1542
                        outq.put(("START", find_names(test_suite.tests[0]), i),
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1543
                            block=True)
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1544
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1545
                        buf = StringIO.StringIO()
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1546
                        b = baseline.ReadOnlyBaseLine(
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1547
                            filename=baseline_filepath)
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1548
                        b.load()
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1549
                        # Build a _Pkg5TestResult object to use for this test.
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1550
                        result = q_makeResult(buf, o, b, bail_on_fail,
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1551
                            show_on_expected_fail, a, cov)
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1552
                        try:
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1553
                                test_suite.run(result)
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1554
                        except TestStopException:
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1555
                                pass
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1556
                        otw = result.collapse()
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1557
                        # Pull in the information stored in places other than
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1558
                        # the _Pkg5TestResult that we need to send back to the
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1559
                        # master process.
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1560
                        otw.timing = test_suite.timing.items()
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1561
                        otw.text = buf.getvalue()
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1562
                        otw.baseline_failures = b.getfailures()
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1563
                        if g_debug_output:
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1564
                                otw.debug_buf = test_suite.get_debug_bufs()
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1565
                        outq.put(
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1566
                            ("RESULT", find_names(test_suite.tests[0]), i, otw),
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1567
                            block=True)
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1568
        finally:
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1569
                if cov_inst:
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1570
                        cov_inst.stop()
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1571
                        cov_inst.save()
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1572
430
3fb945d3bff3 2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff changeset
  1573
3fb945d3bff3 2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff changeset
  1574
class Pkg5TestRunner(unittest.TextTestRunner):
3fb945d3bff3 2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff changeset
  1575
        """TestRunner for test suites that we want to be able to compare
3fb945d3bff3 2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff changeset
  1576
        against a result baseline."""
3fb945d3bff3 2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff changeset
  1577
        baseline = None
3fb945d3bff3 2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff changeset
  1578
1101
35f360e2ee19 5247 Test suite should provide timing info
Brock Pytlik <bpytlik@sun.com>
parents: 1002
diff changeset
  1579
        def __init__(self, baseline, stream=sys.stderr, output=OUTPUT_DOTS,
2499
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1580
            timing_file=None, timing_history=None, bailonfail=False,
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1581
            coverage=None,
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1582
            show_on_expected_fail=False, archive_dir=None):
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1583
                """Set up the test runner"""
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1584
                # output is one of OUTPUT_DOTS, OUTPUT_VERBOSE, OUTPUT_PARSEABLE
430
3fb945d3bff3 2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff changeset
  1585
                super(Pkg5TestRunner, self).__init__(stream)
448
bcfa99ac18b0 2664 test suite baseline enhancements
Brad Hall <bhall@eng.sun.com>
parents: 436
diff changeset
  1586
                self.baseline = baseline
430
3fb945d3bff3 2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff changeset
  1587
                self.output = output
1101
35f360e2ee19 5247 Test suite should provide timing info
Brock Pytlik <bpytlik@sun.com>
parents: 1002
diff changeset
  1588
                self.timing_file = timing_file
2499
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1589
                self.timing_history = timing_history
1421
d6733f41c267 3961 Test suite should have a flag that makes it stop after encountering a failure
John Sonnenschein <John.Sonnenschein@Sun.COM>
parents: 1101
diff changeset
  1590
                self.bailonfail = bailonfail
1513
3ece69a26155 5032 make coverage should only report on the files in our gate
Danek Duvall <danek.duvall@sun.com>
parents: 1505
diff changeset
  1591
                self.coverage = coverage
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1592
                self.show_on_expected_fail = show_on_expected_fail
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1593
                self.archive_dir = archive_dir
430
3fb945d3bff3 2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff changeset
  1594
3fb945d3bff3 2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff changeset
  1595
        def _makeResult(self):
1421
d6733f41c267 3961 Test suite should have a flag that makes it stop after encountering a failure
John Sonnenschein <John.Sonnenschein@Sun.COM>
parents: 1101
diff changeset
  1596
                return _Pkg5TestResult(self.stream, self.output, self.baseline,
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1597
                    bailonfail=self.bailonfail,
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1598
                    show_on_expected_fail=self.show_on_expected_fail,
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1599
                    archive_dir=self.archive_dir)
430
3fb945d3bff3 2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff changeset
  1600
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1601
        @staticmethod
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1602
        def __write_timing_info(stream, suite_name, class_list, method_list):
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1603
                if not class_list and not method_list:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1604
                        return
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1605
                tot = 0
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1606
                print >> stream, "Tests run for '%s' Suite, " \
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1607
                    "broken down by class:\n" % suite_name
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1608
                for secs, cname in class_list:
2499
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1609
                        print >> stream, "%6.2f %s.%s" % \
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1610
                            (secs, suite_name, cname)
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1611
                        tot += secs
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1612
                        for secs, mcname, mname in method_list:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1613
                                if mcname != cname:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1614
                                        continue
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1615
                                print >> stream, \
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1616
                                    "    %6.2f %s" % (secs, mname)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1617
                        print >> stream
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1618
                print >> stream, "%6.2f Total time\n" % tot
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1619
                print >> stream, "=" * 60
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1620
                print >> stream, "\nTests run for '%s' Suite, " \
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1621
                    "sorted by time taken:\n" % suite_name
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1622
                for secs, cname, mname in method_list:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1623
                        print >> stream, "%6.2f %s %s" % (secs, cname, mname)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1624
                print >> stream, "%6.2f Total time\n" % tot
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1625
                print >> stream, "=" * 60
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1626
                print >> stream, ""
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1627
2499
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1628
        @staticmethod
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1629
        def __write_timing_history(stream, suite_name, method_list,
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1630
            time_estimates):
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1631
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1632
                assert suite_name
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1633
                total = 0
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1634
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1635
                time_estimates.setdefault(suite_name, {})
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1636
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1637
                # Calculate the new time estimates for each test suite method
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1638
                # run in the last run.
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1639
                for secs, cname, mname in method_list:
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1640
                        time_estimates[suite_name].setdefault(cname,
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1641
                            {}).setdefault(mname, secs)
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1642
                        time_estimates[suite_name][cname][mname] = \
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1643
                            (time_estimates[suite_name][cname][mname] + secs) \
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1644
                            / 2
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1645
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1646
                # For each test class, find the average time each test in the
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1647
                # class takes to run.
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1648
                total = 0
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1649
                m_cnt = 0
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1650
                for cname in time_estimates[suite_name]:
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1651
                # for c in class_tot:
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1652
                        if cname == "TOTAL":
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1653
                                continue
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1654
                        c_tot = 0
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1655
                        c_cnt = 0
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1656
                        for mname in time_estimates[suite_name][cname]:
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1657
                                if mname == "CLASS":
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1658
                                        continue
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1659
                                c_tot += \
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1660
                                    time_estimates[suite_name][cname][mname]
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1661
                                c_cnt += 1
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1662
                        total += c_tot
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1663
                        m_cnt += c_cnt
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1664
                        c_avg = c_tot / max(c_cnt, 1)
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1665
                        time_estimates[suite_name][cname].setdefault(
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1666
                            "CLASS", c_avg)
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1667
                        time_estimates[suite_name][cname]["CLASS"] = \
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1668
                            (time_estimates[suite_name][cname]["CLASS"] +
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1669
                            c_avg) / 2
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1670
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1671
                # Calculate the average per test, regardless of which test class
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1672
                # or method is being run.
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1673
                tot_avg = total / max(m_cnt, 1)
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1674
                time_estimates[suite_name].setdefault("TOTAL", tot_avg)
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1675
                time_estimates[suite_name]["TOTAL"] = \
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1676
                    (time_estimates[suite_name]["TOTAL"] + tot_avg) / 2
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1677
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1678
                # Save the estimates to disk.
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1679
                json.dump(("1", time_estimates), stream)
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1680
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1681
        def _do_timings(self, result, time_estimates):
1101
35f360e2ee19 5247 Test suite should provide timing info
Brock Pytlik <bpytlik@sun.com>
parents: 1002
diff changeset
  1682
                timing = {}
35f360e2ee19 5247 Test suite should provide timing info
Brock Pytlik <bpytlik@sun.com>
parents: 1002
diff changeset
  1683
                lst = []
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1684
                suite_name = None
2499
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1685
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1686
                for (sname, cname, mname), secs in result.timing:
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1687
                        lst.append((secs, cname, mname))
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1688
                        if cname not in timing:
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1689
                                timing[cname] = 0
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1690
                        timing[cname] += secs
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1691
                        suite_name = sname
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1692
                if not lst:
2306
dfc3f8634dcc 17158 importer.py could use some basic unit tests
Tim Foster <tim.s.foster@oracle.com>
parents: 2293
diff changeset
  1693
                        return
1101
35f360e2ee19 5247 Test suite should provide timing info
Brock Pytlik <bpytlik@sun.com>
parents: 1002
diff changeset
  1694
                lst.sort()
35f360e2ee19 5247 Test suite should provide timing info
Brock Pytlik <bpytlik@sun.com>
parents: 1002
diff changeset
  1695
                clst = sorted((secs, cname) for cname, secs in timing.items())
35f360e2ee19 5247 Test suite should provide timing info
Brock Pytlik <bpytlik@sun.com>
parents: 1002
diff changeset
  1696
2499
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1697
                if self.timing_history:
1101
35f360e2ee19 5247 Test suite should provide timing info
Brock Pytlik <bpytlik@sun.com>
parents: 1002
diff changeset
  1698
                        try:
2499
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1699
                                with open(self.timing_history + ".tmp",
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1700
                                    "wb+") as fh:
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1701
                                        self.__write_timing_history(fh,
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1702
                                            suite_name, lst, time_estimates)
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1703
                                portable.rename(self.timing_history + ".tmp",
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1704
                                    self.timing_history)
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1705
                                os.chmod(self.timing_history, stat.S_IRUSR |
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1706
                                    stat.S_IWUSR | stat.S_IRGRP | stat.S_IWGRP |
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1707
                                    stat.S_IROTH | stat.S_IWOTH)
1101
35f360e2ee19 5247 Test suite should provide timing info
Brock Pytlik <bpytlik@sun.com>
parents: 1002
diff changeset
  1708
                        except KeyboardInterrupt:
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1709
                                raise TestStopException()
2499
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1710
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1711
                if not self.timing_file:
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1712
                        return
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1713
                try:
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1714
                        fh = open(self.timing_file, "ab+")
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1715
                        opened = True
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1716
                except KeyboardInterrupt:
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1717
                        raise TestStopException()
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1718
                except Exception:
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1719
                        fh = sys.stderr
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1720
                        opened = False
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1721
                self.__write_timing_info(fh, suite_name, clst, lst)
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1722
                if opened:
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1723
                        fh.close()
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1724
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1725
        @staticmethod
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1726
        def estimate_method_time(time_estimates, suite_name, c, method_name):
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1727
                # If there's an estimate for the method, use it.  If no method
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1728
                # estimate is available, fall back to the average time each test
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1729
                # in this class takes, if it's available.  If not class estimate
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1730
                # is available, fall back to the average time for each test in
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1731
                # the test suite.
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1732
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1733
                if c in time_estimates[suite_name]:
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1734
                        return time_estimates[suite_name][c].get(
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1735
                            method_name,
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1736
                            time_estimates[suite_name][c]["CLASS"])
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1737
                return time_estimates[suite_name]["TOTAL"]
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1738
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1739
        @staticmethod
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1740
        def __calc_remaining_time(test_classes, test_map, time_estimates,
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1741
            procs, start_times):
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1742
                """Given the running and unfinished tests, estimate the amount
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1743
                of time remaining before the remaining tests finish."""
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1744
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1745
                secs = 0
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1746
                long_pole = 0
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1747
                for mod, c in test_classes:
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1748
                        suite_name = mod.split(".")[0]
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1749
                        if suite_name not in time_estimates:
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1750
                                return None
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1751
                        class_tot = 0
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1752
                        for test in test_map[(mod, c)]:
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1753
                                class_tot += \
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1754
                                    Pkg5TestRunner.estimate_method_time(
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1755
                                    time_estimates, suite_name, c,
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1756
                                    test.methodName)
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1757
                        # Some tests have been running for a while, adjust the
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1758
                        # remaining time using this info.
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1759
                        if (mod, c) in start_times:
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1760
                                class_tot -= time.time() - start_times[(mod, c)]
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1761
                        class_tot = max(class_tot, 0)
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1762
                        secs += class_tot
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1763
                        if class_tot > long_pole:
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1764
                                long_pole = class_tot
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1765
                est = secs/max(min(procs, len(test_classes)), 1)
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1766
                return max(est, long_pole)
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1767
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1768
        def test_start_display(self, started_tests, remaining_time, p_dict,
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1769
            quiet):
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1770
                if quiet:
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1771
                        return
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1772
                print >> self.stream, "\n\n"
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1773
                print >> self.stream, "Tests in " \
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1774
                    "progress:"
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1775
                for p in sorted(started_tests.keys()):
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1776
                        print >> self.stream, "\t%s\t%s\t%s %s" % \
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1777
                            (p, p_dict[p].pid, started_tests[p][0],
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1778
                            started_tests[p][1])
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1779
                if remaining_time is not None:
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1780
                        print >> self.stream, "Estimated time remaining %d " \
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1781
                            "seconds" % round(remaining_time)
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1782
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1783
        def test_done_display(self, result, all_tests, finished_tests,
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1784
            started_tests, total_tests, quiet, remaining_time, output_text,
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1785
            comm):
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1786
                if quiet:
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1787
                        self.stream.write(output_text)
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1788
                        return
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1789
                if g_debug_output:
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1790
                        print >> sys.stderr, "\n%s" % comm[3].debug_buf
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1791
                print >> self.stream, "\n\n"
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1792
                print >> self.stream, "Finished %s %s in process %s" % \
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1793
                    (comm[1][0], comm[1][1], comm[2])
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1794
                print >> self.stream, "Total test classes:%s Finished test " \
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1795
                    "classes:%s Running tests:%s" % \
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1796
                    (len(all_tests), len(finished_tests), len(started_tests))
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1797
                print >> self.stream, "Total tests:%s Tests run:%s " \
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1798
                    "Errors:%s Failures:%s Skips:%s" % \
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1799
                    (total_tests, result.testsRun, len(result.errors),
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1800
                    len(result.failures), len(result.skips))
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1801
                if remaining_time and all_tests - finished_tests:
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1802
                        print >> self.stream, "Estimated time remaining %d " \
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1803
                            "seconds" % round(remaining_time)
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1804
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1805
        @staticmethod
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1806
        def __terminate_processes(jobs):
2693
cfee571ea6d5 7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents: 2690
diff changeset
  1807
                """Terminate all processes in this process's task.  This
cfee571ea6d5 7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents: 2690
diff changeset
  1808
                assumes that test suite is running in its own task which
2499
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1809
                run.py should ensure."""
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1810
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1811
                signal.signal(signal.SIGTERM, signal.SIG_IGN)
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1812
                cmd = ["pkill", "-T", "0"]
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1813
                subprocess.call(cmd)
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1814
                print >> sys.stderr, "All spawned processes should be " \
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1815
                    "terminated, now cleaning up directories."
2580
92480b147363 2707 directory salvage doesn't deal with special files well
Danek Duvall <danek.duvall@oracle.com>
parents: 2550
diff changeset
  1816
92480b147363 2707 directory salvage doesn't deal with special files well
Danek Duvall <danek.duvall@oracle.com>
parents: 2550
diff changeset
  1817
                # Terminated test jobs may have mounted filesystems under their
92480b147363 2707 directory salvage doesn't deal with special files well
Danek Duvall <danek.duvall@oracle.com>
parents: 2550
diff changeset
  1818
                # images and not told us about them, so we catch EBUSY, unmount,
92480b147363 2707 directory salvage doesn't deal with special files well
Danek Duvall <danek.duvall@oracle.com>
parents: 2550
diff changeset
  1819
                # and keep trying.
92480b147363 2707 directory salvage doesn't deal with special files well
Danek Duvall <danek.duvall@oracle.com>
parents: 2550
diff changeset
  1820
                finished = False
2693
cfee571ea6d5 7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents: 2690
diff changeset
  1821
                retry = 0
cfee571ea6d5 7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents: 2690
diff changeset
  1822
cfee571ea6d5 7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents: 2690
diff changeset
  1823
                while not finished and retry < 10:
2580
92480b147363 2707 directory salvage doesn't deal with special files well
Danek Duvall <danek.duvall@oracle.com>
parents: 2550
diff changeset
  1824
                        try:
2595
0bb36cea68dc 18990 generate should know about SUNW_FILTER, FILTER and POSFLAG_1 elf tags
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2580
diff changeset
  1825
                                shutil.rmtree(os.path.join(g_tempdir,
0bb36cea68dc 18990 generate should know about SUNW_FILTER, FILTER and POSFLAG_1 elf tags
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2580
diff changeset
  1826
                                    "ips.test.%s" % os.getpid()))
2580
92480b147363 2707 directory salvage doesn't deal with special files well
Danek Duvall <danek.duvall@oracle.com>
parents: 2550
diff changeset
  1827
                        except OSError, e:
2693
cfee571ea6d5 7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents: 2690
diff changeset
  1828
                                if e.errno == errno.ENOENT:
cfee571ea6d5 7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents: 2690
diff changeset
  1829
                                        #
cfee571ea6d5 7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents: 2690
diff changeset
  1830
                                        # seems to sporadically happen if we
cfee571ea6d5 7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents: 2690
diff changeset
  1831
                                        # race with e.g. something shutting
cfee571ea6d5 7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents: 2690
diff changeset
  1832
                                        # down which has a pid file; retry.
cfee571ea6d5 7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents: 2690
diff changeset
  1833
                                        #
cfee571ea6d5 7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents: 2690
diff changeset
  1834
                                        retry += 1
cfee571ea6d5 7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents: 2690
diff changeset
  1835
                                        continue
cfee571ea6d5 7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents: 2690
diff changeset
  1836
                                elif e.errno == errno.EBUSY:
cfee571ea6d5 7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents: 2690
diff changeset
  1837
                                        ret = subprocess.call(
cfee571ea6d5 7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents: 2690
diff changeset
  1838
                                            ["/usr/sbin/umount",
cfee571ea6d5 7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents: 2690
diff changeset
  1839
                                            e.filename])
cfee571ea6d5 7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents: 2690
diff changeset
  1840
                                        # if the umount failed, bump retry so
cfee571ea6d5 7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents: 2690
diff changeset
  1841
                                        # we won't be stuck doing this forever.
cfee571ea6d5 7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents: 2690
diff changeset
  1842
                                        if ret != 0:
cfee571ea6d5 7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents: 2690
diff changeset
  1843
                                                retry += 1
cfee571ea6d5 7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents: 2690
diff changeset
  1844
                                        continue
cfee571ea6d5 7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents: 2690
diff changeset
  1845
                                else:
2580
92480b147363 2707 directory salvage doesn't deal with special files well
Danek Duvall <danek.duvall@oracle.com>
parents: 2550
diff changeset
  1846
                                        raise
92480b147363 2707 directory salvage doesn't deal with special files well
Danek Duvall <danek.duvall@oracle.com>
parents: 2550
diff changeset
  1847
                        else:
92480b147363 2707 directory salvage doesn't deal with special files well
Danek Duvall <danek.duvall@oracle.com>
parents: 2550
diff changeset
  1848
                                finished = True
92480b147363 2707 directory salvage doesn't deal with special files well
Danek Duvall <danek.duvall@oracle.com>
parents: 2550
diff changeset
  1849
2693
cfee571ea6d5 7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents: 2690
diff changeset
  1850
                if not finished:
cfee571ea6d5 7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents: 2690
diff changeset
  1851
                        print >> sys.stderr, "Not all directories removed!"
cfee571ea6d5 7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents: 2690
diff changeset
  1852
                else:
cfee571ea6d5 7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents: 2690
diff changeset
  1853
                        print >> sys.stderr, "Directories successfully removed."
2499
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1854
                sys.exit(1)
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1855
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1856
        def run(self, suite_list, jobs, port, time_estimates, quiet,
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1857
            baseline_filepath):
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1858
                "Run the given test case or test suite."
2499
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1859
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1860
                terminate = False
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1861
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1862
                all_tests = set()
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1863
                started_tests = {}
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1864
                finished_tests = set()
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1865
                total_tests = 0
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1866
                test_map = {}
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1867
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1868
                start_times = {}
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1869
                suite_name = None
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1870
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1871
                # test case setUp() may require running pkg commands
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1872
                # so setup a fakeroot to run them from.
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1873
                fakeroot, fakeroot_cmdpath = fakeroot_create()
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1874
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1875
                inq = multiprocessing.Queue(len(suite_list) + jobs)
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1876
                for t in suite_list:
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1877
                        if not t.tests:
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1878
                                continue
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1879
                        mod, c = find_names(t.tests[0])
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1880
                        for test in t.tests:
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1881
                                tmp = find_names(test)
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1882
                                if suite_name is None:
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1883
                                        suite_name = test.suite_name
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1884
                                else:
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1885
                                        assert suite_name == test.suite_name
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1886
                                if tmp[0] != mod or tmp[1] != c:
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1887
                                        raise RuntimeError("tmp:%s mod:%s "
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1888
                                            "c:%s" % (tmp, mod, c))
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1889
                        all_tests.add((mod, c))
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1890
                        t.pkg_cmdpath = fakeroot_cmdpath
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1891
                        if jobs > 1:
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1892
                                t.debug_output = False
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1893
                        inq.put(t, block=True)
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1894
                        total_tests += len(t.tests)
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1895
                        test_map[(mod, c)] = t.tests
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1896
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1897
                result = _CombinedResult()
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1898
                if not all_tests:
2595
0bb36cea68dc 18990 generate should know about SUNW_FILTER, FILTER and POSFLAG_1 elf tags
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2580
diff changeset
  1899
                        try:
0bb36cea68dc 18990 generate should know about SUNW_FILTER, FILTER and POSFLAG_1 elf tags
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2580
diff changeset
  1900
                                shutil.rmtree(os.path.join(g_tempdir,
0bb36cea68dc 18990 generate should know about SUNW_FILTER, FILTER and POSFLAG_1 elf tags
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2580
diff changeset
  1901
                                    "ips.test.%s" % os.getpid()))
0bb36cea68dc 18990 generate should know about SUNW_FILTER, FILTER and POSFLAG_1 elf tags
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2580
diff changeset
  1902
                        except OSError, e:
0bb36cea68dc 18990 generate should know about SUNW_FILTER, FILTER and POSFLAG_1 elf tags
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2580
diff changeset
  1903
                                if e.errno != errno.ENOENT:
0bb36cea68dc 18990 generate should know about SUNW_FILTER, FILTER and POSFLAG_1 elf tags
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2580
diff changeset
  1904
                                        raise
2499
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1905
                        return result
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1906
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1907
                assert suite_name is not None
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1908
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1909
                startTime = time.time()
2499
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1910
                outq = multiprocessing.Queue(jobs * 10)
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1911
                p_dict = {}
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1912
                try:
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1913
                        for i in range(0, jobs):
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1914
                                p_dict[i] = multiprocessing.Process(
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1915
                                    target=q_run,
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1916
                                    args=(inq, outq, i, self.output,
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1917
                                    baseline_filepath, self.bailonfail,
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1918
                                    self.show_on_expected_fail,
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1919
                                    self.archive_dir, self.coverage, port,
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1920
                                    suite_name))
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1921
                                p_dict[i].start()
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1922
                except KeyboardInterrupt:
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1923
                        self.__terminate_processes(jobs)
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1924
                try:
2499
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1925
                        while all_tests - finished_tests:
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1926
                                comm = outq.get(block=True)
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1927
                                remaining_time = None
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1928
                                if time_estimates:
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1929
                                        remaining_time = \
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1930
                                            self.__calc_remaining_time(
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1931
                                            all_tests - finished_tests,
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1932
                                            test_map, time_estimates,
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1933
                                            jobs, start_times)
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1934
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1935
                                if comm[0] == "START":
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1936
                                        if comm[1] not in all_tests:
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1937
                                                raise RuntimeError("Got "
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1938
                                                    "unexpected start "
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1939
                                                    "comm:%s" % (comm,))
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1940
                                        started_tests[comm[2]] = comm[1]
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1941
                                        start_times[comm[1]] = time.time()
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1942
                                        self.test_start_display(started_tests,
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1943
                                            remaining_time, p_dict, quiet)
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1944
                                elif comm[0] == "RESULT":
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1945
                                        partial_result = comm[3]
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1946
                                        result.combine(partial_result)
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1947
                                        finished_tests.add(comm[1])
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1948
                                        for n, r in \
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1949
                                            partial_result.baseline_failures:
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1950
                                                self.baseline.handleresult(n, r)
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1951
                                        if started_tests[comm[2]] != comm[1]:
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1952
                                                raise RuntimeError("mismatch")
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1953
                                        del started_tests[comm[2]]
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1954
                                        del start_times[comm[1]]
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1955
                                        self.test_done_display(result,
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1956
                                            all_tests, finished_tests,
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1957
                                            started_tests, total_tests, quiet,
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1958
                                            remaining_time, partial_result.text,
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1959
                                            comm)
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1960
                                else:
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1961
                                        raise RuntimeError("unexpected "
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1962
                                            "communication:%s" % (comm,))
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1963
                                if self.bailonfail and \
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1964
                                    (result.errors or result.failures):
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1965
                                        raise TestStopException()
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1966
                                # Check to make sure that all processes are
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1967
                                # still running.
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1968
                                broken = set()
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1969
                                for i in p_dict:
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1970
                                        if not p_dict[i].is_alive():
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1971
                                                broken.add(i)
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1972
                                if broken:
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1973
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1974
                                        print >> sys.stderr, "The following " \
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1975
                                            "processes have died, " \
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1976
                                            "terminating the others: %s" % \
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1977
                                            ",".join([
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1978
                                                str(p_dict[i].pid)
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1979
                                                for i in sorted(broken)
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1980
                                            ])
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1981
                                        raise TestStopException()
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1982
                        for i in range(0, jobs * 2):
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1983
                                inq.put("STOP")
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1984
                        for p in p_dict:
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1985
                                p_dict[p].join()
3192
13377dbd6773 18876698 Plan serialization for linked images does not support unicode in license actions
saurabh.vyas@oracle.com
parents: 3190
diff changeset
  1986
                except (KeyboardInterrupt, TestStopException):
2499
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1987
                        terminate = True
3192
13377dbd6773 18876698 Plan serialization for linked images does not support unicode in license actions
saurabh.vyas@oracle.com
parents: 3190
diff changeset
  1988
                except Exception as e:
2499
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1989
                        terminate = True
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1990
                        raise
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  1991
                finally:
2499
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1992
                        try:
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1993
                                result.stream = self.stream
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1994
                                stopTime = time.time()
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1995
                                timeTaken = stopTime - startTime
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1996
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1997
                                run = result.testsRun
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1998
                                if run > 0:
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  1999
                                        if self.output != OUTPUT_VERBOSE:
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2000
                                                result.printErrors()
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2001
                                                self.stream.write("# " +
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2002
                                                    result.separator2 + "\n")
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2003
                                        self.stream.write("\n# Ran %d test%s "
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2004
                                            "in %.3fs - skipped %d tests.\n" %
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2005
                                            (run, run != 1 and "s" or "",
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2006
                                            timeTaken, len(result.skips)))
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2007
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2008
                                        if result.wasSkipped() and \
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2009
                                            self.output == OUTPUT_VERBOSE:
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2010
                                                self.stream.write("Skipped "
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2011
                                                    "tests:\n")
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2012
                                                for test,reason in result.skips:
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2013
                                                        self.stream.write(
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2014
                                                            "%s: %s\n" %
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2015
                                                            (test, reason))
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2016
                                        self.stream.write("\n")
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2017
                                if not result.wasSuccessful():
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2018
                                        self.stream.write("FAILED (")
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2019
                                        success = result.num_successes
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2020
                                        mismatches = result.mismatches
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2021
                                        failed, errored = map(len,
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2022
                                            (result.failures, result.errors))
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2023
                                        self.stream.write("successes=%d, " %
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2024
                                            success)
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2025
                                        self.stream.write("failures=%d, " %
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2026
                                            failed)
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2027
                                        self.stream.write("errors=%d, " %
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2028
                                            errored)
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2029
                                        self.stream.write("mismatches=%d" %
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2030
                                            mismatches)
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2031
                                        self.stream.write(")\n")
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2032
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2033
                                self._do_timings(result, time_estimates)
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2034
                        finally:
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2035
                                if terminate:
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2036
                                        self.__terminate_processes(jobs)
2595
0bb36cea68dc 18990 generate should know about SUNW_FILTER, FILTER and POSFLAG_1 elf tags
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2580
diff changeset
  2037
                                shutil.rmtree(os.path.join(g_tempdir,
0bb36cea68dc 18990 generate should know about SUNW_FILTER, FILTER and POSFLAG_1 elf tags
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2580
diff changeset
  2038
                                    "ips.test.%s" % os.getpid()))
448
bcfa99ac18b0 2664 test suite baseline enhancements
Brad Hall <bhall@eng.sun.com>
parents: 436
diff changeset
  2039
                return result
502
3f98e94acc4a 2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents: 448
diff changeset
  2040
1101
35f360e2ee19 5247 Test suite should provide timing info
Brock Pytlik <bpytlik@sun.com>
parents: 1002
diff changeset
  2041
502
3f98e94acc4a 2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents: 448
diff changeset
  2042
class Pkg5TestSuite(unittest.TestSuite):
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2043
        """Test suite that extends unittest.TestSuite to handle persistent
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2044
        tests.  Persistent tests are ones that are able to only call their
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2045
        setUp/tearDown functions once per class, instead of before and after
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2046
        every test case.  Aside from actually running the test it defers the
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2047
        majority of its work to unittest.TestSuite.
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2048
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2049
        To make a test class into a persistent one, add this class
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2050
        variable declaration:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2051
                persistent_setup = True
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2052
        """
502
3f98e94acc4a 2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents: 448
diff changeset
  2053
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2054
        def __init__(self, tests=()):
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2055
                unittest.TestSuite.__init__(self, tests)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2056
                self.timing = {}
2339
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  2057
                self.__pid = os.getpid()
2499
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2058
                self.pkg_cmdpath = "TOXIC"
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2059
                self.__debug_output = g_debug_output
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2060
1890
011afb71c52a 15037 action parsing can't handle unicode objects which don't decode to ascii
Shawn Walker <shawn.walker@oracle.com>
parents: 1887
diff changeset
  2061
                # The site module deletes the function to change the
011afb71c52a 15037 action parsing can't handle unicode objects which don't decode to ascii
Shawn Walker <shawn.walker@oracle.com>
parents: 1887
diff changeset
  2062
                # default encoding so a forced reload of sys has to
011afb71c52a 15037 action parsing can't handle unicode objects which don't decode to ascii
Shawn Walker <shawn.walker@oracle.com>
parents: 1887
diff changeset
  2063
                # be done at least once.
011afb71c52a 15037 action parsing can't handle unicode objects which don't decode to ascii
Shawn Walker <shawn.walker@oracle.com>
parents: 1887
diff changeset
  2064
                reload(sys)
011afb71c52a 15037 action parsing can't handle unicode objects which don't decode to ascii
Shawn Walker <shawn.walker@oracle.com>
parents: 1887
diff changeset
  2065
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2066
        def cleanup_and_die(self, inst, info):
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2067
                print >> sys.stderr, \
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2068
                    "\nCtrl-C: Attempting cleanup during %s" % info
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2069
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2070
                if hasattr(inst, "killalldepots"):
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2071
                        print >> sys.stderr, "Killing depots..."
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2072
                        inst.killalldepots()
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2073
                print >> sys.stderr, "Stopping tests..."
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2074
                raise TestStopException()
502
3f98e94acc4a 2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents: 448
diff changeset
  2075
3f98e94acc4a 2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents: 448
diff changeset
  2076
        def run(self, result):
1101
35f360e2ee19 5247 Test suite should provide timing info
Brock Pytlik <bpytlik@sun.com>
parents: 1002
diff changeset
  2077
                self.timing = {}
502
3f98e94acc4a 2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents: 448
diff changeset
  2078
                inst = None
3f98e94acc4a 2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents: 448
diff changeset
  2079
                tdf = None
571
1a2452c33cb9 3476 Most cli test cases can't be run standalone anymore
Brad Hall <bhall@eng.sun.com>
parents: 516
diff changeset
  2080
                try:
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2081
                        persistent_setup = getattr(self._tests[0],
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2082
                            "persistent_setup", False)
571
1a2452c33cb9 3476 Most cli test cases can't be run standalone anymore
Brad Hall <bhall@eng.sun.com>
parents: 516
diff changeset
  2083
                except IndexError:
1890
011afb71c52a 15037 action parsing can't handle unicode objects which don't decode to ascii
Shawn Walker <shawn.walker@oracle.com>
parents: 1887
diff changeset
  2084
                        # No tests; that's ok.
571
1a2452c33cb9 3476 Most cli test cases can't be run standalone anymore
Brad Hall <bhall@eng.sun.com>
parents: 516
diff changeset
  2085
                        return
1a2452c33cb9 3476 Most cli test cases can't be run standalone anymore
Brad Hall <bhall@eng.sun.com>
parents: 516
diff changeset
  2086
1890
011afb71c52a 15037 action parsing can't handle unicode objects which don't decode to ascii
Shawn Walker <shawn.walker@oracle.com>
parents: 1887
diff changeset
  2087
                # This is needed because the import of some modules (such as
011afb71c52a 15037 action parsing can't handle unicode objects which don't decode to ascii
Shawn Walker <shawn.walker@oracle.com>
parents: 1887
diff changeset
  2088
                # pygtk or pango) causes the default encoding for Python to be
011afb71c52a 15037 action parsing can't handle unicode objects which don't decode to ascii
Shawn Walker <shawn.walker@oracle.com>
parents: 1887
diff changeset
  2089
                # changed which can can cause tests to succeed when they should
011afb71c52a 15037 action parsing can't handle unicode objects which don't decode to ascii
Shawn Walker <shawn.walker@oracle.com>
parents: 1887
diff changeset
  2090
                # fail due to unicode issues:
011afb71c52a 15037 action parsing can't handle unicode objects which don't decode to ascii
Shawn Walker <shawn.walker@oracle.com>
parents: 1887
diff changeset
  2091
                #     https://bugzilla.gnome.org/show_bug.cgi?id=132040
011afb71c52a 15037 action parsing can't handle unicode objects which don't decode to ascii
Shawn Walker <shawn.walker@oracle.com>
parents: 1887
diff changeset
  2092
                default_utf8 = getattr(self._tests[0], "default_utf8", False)
011afb71c52a 15037 action parsing can't handle unicode objects which don't decode to ascii
Shawn Walker <shawn.walker@oracle.com>
parents: 1887
diff changeset
  2093
                if not default_utf8:
011afb71c52a 15037 action parsing can't handle unicode objects which don't decode to ascii
Shawn Walker <shawn.walker@oracle.com>
parents: 1887
diff changeset
  2094
                        # Now reset to the default a standard Python
011afb71c52a 15037 action parsing can't handle unicode objects which don't decode to ascii
Shawn Walker <shawn.walker@oracle.com>
parents: 1887
diff changeset
  2095
                        # distribution uses.
011afb71c52a 15037 action parsing can't handle unicode objects which don't decode to ascii
Shawn Walker <shawn.walker@oracle.com>
parents: 1887
diff changeset
  2096
                        sys.setdefaultencoding("ascii")
011afb71c52a 15037 action parsing can't handle unicode objects which don't decode to ascii
Shawn Walker <shawn.walker@oracle.com>
parents: 1887
diff changeset
  2097
                else:
011afb71c52a 15037 action parsing can't handle unicode objects which don't decode to ascii
Shawn Walker <shawn.walker@oracle.com>
parents: 1887
diff changeset
  2098
                        sys.setdefaultencoding("utf-8")
011afb71c52a 15037 action parsing can't handle unicode objects which don't decode to ascii
Shawn Walker <shawn.walker@oracle.com>
parents: 1887
diff changeset
  2099
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2100
                def setUp_donothing():
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2101
                        pass
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2102
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2103
                def tearDown_donothing():
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2104
                        pass
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2105
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2106
                def setUp_dofail():
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2107
                        raise TestSkippedException(
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2108
                            "Persistent setUp Failed, skipping test.")
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2109
2499
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2110
                env_sanitize(self.pkg_cmdpath)
2339
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  2111
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2112
                if persistent_setup:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2113
                        setUpFailed = False
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2114
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2115
                        # Save a reference to the tearDown func and neuter
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2116
                        # normal per-test-function teardown.
502
3f98e94acc4a 2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents: 448
diff changeset
  2117
                        inst, tdf = self._tests[0].getTeardownFunc()
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2118
                        inst.reallytearDown = tdf
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2119
                        inst.tearDown = tearDown_donothing
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2120
1513
3ece69a26155 5032 make coverage should only report on the files in our gate
Danek Duvall <danek.duvall@sun.com>
parents: 1505
diff changeset
  2121
                        if result.coverage:
3ece69a26155 5032 make coverage should only report on the files in our gate
Danek Duvall <danek.duvall@sun.com>
parents: 1505
diff changeset
  2122
                                inst.coverage_cmd, inst.coverage_env = result.coverage
3ece69a26155 5032 make coverage should only report on the files in our gate
Danek Duvall <danek.duvall@sun.com>
parents: 1505
diff changeset
  2123
                        else:
3ece69a26155 5032 make coverage should only report on the files in our gate
Danek Duvall <danek.duvall@sun.com>
parents: 1505
diff changeset
  2124
                                inst.coverage_cmd, inst.coverage_env = "", {}
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2125
502
3f98e94acc4a 2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents: 448
diff changeset
  2126
                        try:
3f98e94acc4a 2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents: 448
diff changeset
  2127
                                inst.setUp()
3f98e94acc4a 2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents: 448
diff changeset
  2128
                        except KeyboardInterrupt:
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2129
                                self.cleanup_and_die(inst, "persistent setup")
502
3f98e94acc4a 2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents: 448
diff changeset
  2130
                        except:
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2131
                                result.addPersistentSetupError(inst, sys.exc_info())
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2132
                                setUpFailed = True
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2133
                                # XXX do cleanup?
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2134
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2135
                        # If the setUp function didn't work, then cause
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2136
                        # every test case to fail.
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2137
                        if setUpFailed:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2138
                                inst.setUp = setUp_dofail
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2139
                        else:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2140
                                inst.setUp = setUp_donothing
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2141
502
3f98e94acc4a 2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents: 448
diff changeset
  2142
                for test in self._tests:
3f98e94acc4a 2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents: 448
diff changeset
  2143
                        if result.shouldStop:
3f98e94acc4a 2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents: 448
diff changeset
  2144
                                break
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2145
                        real_test_name = test._testMethodName
2499
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2146
                        suite_name = test.suite_name
1101
35f360e2ee19 5247 Test suite should provide timing info
Brock Pytlik <bpytlik@sun.com>
parents: 1002
diff changeset
  2147
                        cname = test.__class__.__name__
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2148
2339
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  2149
                        #
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  2150
                        # Update test environment settings. We redo this
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  2151
                        # before running each test case since previously
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  2152
                        # executed test cases may have messed with these
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  2153
                        # environment settings.
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  2154
                        #
2499
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2155
                        env_sanitize(self.pkg_cmdpath, dv_keep=["smf_cmds_dir"])
2339
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  2156
502
3f98e94acc4a 2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents: 448
diff changeset
  2157
                        # Populate test with the data from the instance
3f98e94acc4a 2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents: 448
diff changeset
  2158
                        # already constructed, but update the method name.
3f98e94acc4a 2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents: 448
diff changeset
  2159
                        # We need to do this so that we have all the state
3f98e94acc4a 2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents: 448
diff changeset
  2160
                        # that the object is populated with when setUp() is
3f98e94acc4a 2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents: 448
diff changeset
  2161
                        # called (depot controller list, etc).
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2162
                        if persistent_setup:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2163
                                name = test._testMethodName
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2164
                                doc = test._testMethodDoc
2499
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2165
                                buf = test.get_debugbuf()
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2166
                                rtest = copy.copy(inst)
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2167
                                rtest._testMethodName = name
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2168
                                rtest._testMethodDoc = doc
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2169
                                rtest.persistent_setup_copy(inst)
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2170
                                rtest.set_debugbuf(buf)
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2171
                                setup_logging(rtest)
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2172
                        else:
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2173
                                rtest = test
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2174
1101
35f360e2ee19 5247 Test suite should provide timing info
Brock Pytlik <bpytlik@sun.com>
parents: 1002
diff changeset
  2175
                        test_start = time.time()
2499
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2176
                        rtest(result)
1101
35f360e2ee19 5247 Test suite should provide timing info
Brock Pytlik <bpytlik@sun.com>
parents: 1002
diff changeset
  2177
                        test_end = time.time()
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2178
                        self.timing[suite_name, cname, real_test_name] = \
1101
35f360e2ee19 5247 Test suite should provide timing info
Brock Pytlik <bpytlik@sun.com>
parents: 1002
diff changeset
  2179
                            test_end - test_start
2339
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  2180
2499
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2181
                        # If rtest is a copy of test, then we need to copy
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2182
                        # rtest's buffer back to test's so that it has the
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2183
                        # output from the run.
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2184
                        if persistent_setup:
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2185
                                test.set_debugbuf(rtest.get_debugbuf())
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2186
2580
92480b147363 2707 directory salvage doesn't deal with special files well
Danek Duvall <danek.duvall@oracle.com>
parents: 2550
diff changeset
  2187
                        for fs in getattr(rtest, "fs", ()):
92480b147363 2707 directory salvage doesn't deal with special files well
Danek Duvall <danek.duvall@oracle.com>
parents: 2550
diff changeset
  2188
                                subprocess.call(["/usr/sbin/umount", fs])
92480b147363 2707 directory salvage doesn't deal with special files well
Danek Duvall <danek.duvall@oracle.com>
parents: 2550
diff changeset
  2189
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2190
                if persistent_setup:
502
3f98e94acc4a 2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents: 448
diff changeset
  2191
                        try:
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2192
                                inst.reallytearDown()
502
3f98e94acc4a 2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents: 448
diff changeset
  2193
                        except KeyboardInterrupt:
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2194
                                self.cleanup_and_die(inst, "persistent teardown")
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2195
                        except:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2196
                                result.addPersistentTeardownError(inst, sys.exc_info())
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2197
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2198
                # Try to ensure that all depots have been nuked.
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2199
                if hasattr(inst, "killalldepots"):
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2200
                        inst.killalldepots()
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2201
2499
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2202
        def parallel_init(self, p, i, cov):
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2203
                for t in self._tests:
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2204
                        t.base_port = p
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2205
                        t.ident = i
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2206
                        t.coverage = cov
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2207
                        t.pkg_cmdpath = self.pkg_cmdpath
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2208
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2209
        def test_count(self):
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2210
                return len(self._tests)
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2211
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2212
        @property
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2213
        def tests(self):
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2214
                return [t for t in self._tests]
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2215
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2216
        def __set_debug_output(self, v):
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2217
                self.__debug_output = v
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2218
                for t in self._tests:
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2219
                        t.debug_output = v
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2220
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2221
        def __get_debug_output(self):
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2222
                return self.__debug_output
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2223
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2224
        debug_output = property(__get_debug_output, __set_debug_output)
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2225
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2226
        def get_debug_bufs(self):
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2227
                res = ""
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2228
                for t in self._tests:
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2229
                        res += "\n".join(
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2230
                            ["# %s" % l for l in t.get_debugbuf().splitlines()])
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2231
                        res += "\n"
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2232
                return res
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2233
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2234
2843
4e1d09017f2c 15722190 pkgrepo verify subcommand needed
Tim Foster <tim.s.foster@oracle.com>
parents: 2830
diff changeset
  2235
def get_su_wrap_user(uid_gid=False):
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2236
        for u in ["noaccess", "nobody"]:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2237
                try:
2843
4e1d09017f2c 15722190 pkgrepo verify subcommand needed
Tim Foster <tim.s.foster@oracle.com>
parents: 2830
diff changeset
  2238
                        pw = pwd.getpwnam(u)
4e1d09017f2c 15722190 pkgrepo verify subcommand needed
Tim Foster <tim.s.foster@oracle.com>
parents: 2830
diff changeset
  2239
                        if uid_gid:
4e1d09017f2c 15722190 pkgrepo verify subcommand needed
Tim Foster <tim.s.foster@oracle.com>
parents: 2830
diff changeset
  2240
                                return operator.attrgetter(
4e1d09017f2c 15722190 pkgrepo verify subcommand needed
Tim Foster <tim.s.foster@oracle.com>
parents: 2830
diff changeset
  2241
                                    'pw_uid', 'pw_gid')(pw)
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2242
                        return u
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2243
                except (KeyError, NameError):
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2244
                        pass
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2245
        raise RuntimeError("Unable to determine user for su.")
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2246
2843
4e1d09017f2c 15722190 pkgrepo verify subcommand needed
Tim Foster <tim.s.foster@oracle.com>
parents: 2830
diff changeset
  2247
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2248
class DepotTracebackException(Pkg5CommonException):
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2249
        def __init__(self, logfile, output):
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2250
                Pkg5CommonException.__init__(self)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2251
                self.__logfile = logfile
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2252
                self.__output = output
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2253
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2254
        def __str__(self):
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2255
                str = "During this test, a depot Traceback was detected.\n"
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2256
                str += "Log file: %s.\n" % self.__logfile
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2257
                str += "Log file output is:\n"
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2258
                str += self.format_output(None, self.__output)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2259
                return str
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2260
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2261
class TracebackException(Pkg5CommonException):
1736
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1730
diff changeset
  2262
        def __init__(self, command, output=None, comment=None, debug=None):
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2263
                Pkg5CommonException.__init__(self)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2264
                self.__command = command
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2265
                self.__output = output
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2266
                self.__comment = comment
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2267
                self.__debug = debug
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2268
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2269
        def __str__(self):
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2270
                if self.__comment is None and self.__output is None:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2271
                        return (Exception.__str__(self))
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2272
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2273
                str = ""
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2274
                str += self.format_comment(self.__comment)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2275
                str += self.format_output(self.__command, self.__output)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2276
                if self.__debug is not None and self.__debug != "":
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2277
                        str += self.format_debug(self.__debug)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2278
                return str
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2279
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2280
class UnexpectedExitCodeException(Pkg5CommonException):
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2281
        def __init__(self, command, expected, got, output=None, comment=None):
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2282
                Pkg5CommonException.__init__(self)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2283
                self.__command = command
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2284
                self.__output = output
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2285
                self.__expected = expected
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2286
                self.__got = got
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2287
                self.__comment = comment
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2288
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2289
        def __str__(self):
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2290
                if self.__comment is None and self.__output is None:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2291
                        return (Exception.__str__(self))
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2292
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2293
                str = ""
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2294
                str += self.format_comment(self.__comment)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2295
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2296
                str += "  Invoked: %s\n" % self.__command
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2297
                str += "  Expected exit status: %s.  Got: %d." % \
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2298
                    (self.__expected, self.__got)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2299
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2300
                str += self.format_output(self.__command, self.__output)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2301
                return str
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2302
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2303
        @property
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2304
        def exitcode(self):
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2305
                return self.__got
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2306
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2307
class PkgSendOpenException(Pkg5CommonException):
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2308
        def __init__(self, com = ""):
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2309
                Pkg5CommonException.__init__(self, com)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2310
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2311
class CliTestCase(Pkg5TestCase):
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2312
        bail_on_fail = False
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2313
2753
4d4b2324d1c0 7139940 cached manifests persist for packages not currently installed even when copy in repository changes
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2731
diff changeset
  2314
        image_files = []
4d4b2324d1c0 7139940 cached manifests persist for packages not currently installed even when copy in repository changes
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2731
diff changeset
  2315
2339
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  2316
        def setUp(self, image_count=1):
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2317
                Pkg5TestCase.setUp(self)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2318
2339
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  2319
                self.__imgs_path = {}
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  2320
                self.__imgs_index = -1
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  2321
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  2322
                for i in range(0, image_count):
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  2323
                        path = os.path.join(self.test_root, "image%d" % i)
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  2324
                        self.__imgs_path[i] = path
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  2325
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  2326
                self.set_image(0)
2158
5a688b5b92a3 15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents: 2144
diff changeset
  2327
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2328
        def tearDown(self):
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2329
                Pkg5TestCase.tearDown(self)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2330
2339
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  2331
        def persistent_setup_copy(self, orig):
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  2332
                Pkg5TestCase.persistent_setup_copy(self, orig)
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  2333
                self.__imgs_path = copy.copy(orig.__imgs_path)
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  2334
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  2335
        def set_image(self, ii):
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  2336
                # ii is the image index
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  2337
                if self.__imgs_index == ii:
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  2338
                        return
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  2339
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  2340
                self.__imgs_index = ii
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  2341
                path = self.__imgs_path[self.__imgs_index]
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  2342
                assert path and path != "/"
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  2343
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  2344
                self.debug("image %d selected: %s" % (ii, path))
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  2345
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  2346
        def set_img_path(self, path):
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  2347
                self.__imgs_path[self.__imgs_index] = path
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  2348
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  2349
        def img_index(self):
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  2350
                return self.__imgs_index
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  2351
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  2352
        def img_path(self, ii=None):
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  2353
                if ii != None:
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  2354
                        return self.__imgs_path[ii]
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  2355
                return self.__imgs_path[self.__imgs_index]
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  2356
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2357
        def get_img_path(self):
2339
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  2358
                # for backward compatibilty
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  2359
                return self.img_path()
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  2360
2476
25342deb3749 3262 symlink loops can cause operation traceback
Shawn Walker <shawn.walker@oracle.com>
parents: 2475
diff changeset
  2361
        def get_img_file_path(self, relpath):
25342deb3749 3262 symlink loops can cause operation traceback
Shawn Walker <shawn.walker@oracle.com>
parents: 2475
diff changeset
  2362
                """Given a path relative to root, return the absolute path of
25342deb3749 3262 symlink loops can cause operation traceback
Shawn Walker <shawn.walker@oracle.com>
parents: 2475
diff changeset
  2363
                the item in the image."""
25342deb3749 3262 symlink loops can cause operation traceback
Shawn Walker <shawn.walker@oracle.com>
parents: 2475
diff changeset
  2364
25342deb3749 3262 symlink loops can cause operation traceback
Shawn Walker <shawn.walker@oracle.com>
parents: 2475
diff changeset
  2365
                return os.path.join(self.img_path(), relpath)
25342deb3749 3262 symlink loops can cause operation traceback
Shawn Walker <shawn.walker@oracle.com>
parents: 2475
diff changeset
  2366
2629
8bea1388917e 7141603 up-to-date check can traceback if alt root image doesn't have executing pkg version
Shawn Walker <shawn.walker@oracle.com>
parents: 2627
diff changeset
  2367
        def get_img_api_obj(self, cmd_path=None, ii=None, img_path=None):
1895
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1890
diff changeset
  2368
                progresstracker = pkg.client.progress.NullProgressTracker()
2092
0ef66bf272d3 16852 pkg should look at its image for certs if active image lacks certs
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2089
diff changeset
  2369
                if not cmd_path:
2339
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  2370
                        cmd_path = os.path.join(self.img_path(), "pkg")
2629
8bea1388917e 7141603 up-to-date check can traceback if alt root image doesn't have executing pkg version
Shawn Walker <shawn.walker@oracle.com>
parents: 2627
diff changeset
  2371
                if not img_path:
8bea1388917e 7141603 up-to-date check can traceback if alt root image doesn't have executing pkg version
Shawn Walker <shawn.walker@oracle.com>
parents: 2627
diff changeset
  2372
                        img_path = self.img_path(ii=ii)
8bea1388917e 7141603 up-to-date check can traceback if alt root image doesn't have executing pkg version
Shawn Walker <shawn.walker@oracle.com>
parents: 2627
diff changeset
  2373
                res = pkg.client.api.ImageInterface(img_path,
1895
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1890
diff changeset
  2374
                    CLIENT_API_VERSION, progresstracker, lambda x: False,
2339
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  2375
                    PKG_CLIENT_NAME, cmdpath=cmd_path)
2092
0ef66bf272d3 16852 pkg should look at its image for certs if active image lacks certs
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2089
diff changeset
  2376
                return res
1895
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1890
diff changeset
  2377
2753
4d4b2324d1c0 7139940 cached manifests persist for packages not currently installed even when copy in repository changes
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2731
diff changeset
  2378
        def __setup_signing_files(self):
4d4b2324d1c0 7139940 cached manifests persist for packages not currently installed even when copy in repository changes
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2731
diff changeset
  2379
                if not getattr(self, "need_ro_data", False):
4d4b2324d1c0 7139940 cached manifests persist for packages not currently installed even when copy in repository changes
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2731
diff changeset
  2380
                        return
4d4b2324d1c0 7139940 cached manifests persist for packages not currently installed even when copy in repository changes
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2731
diff changeset
  2381
                # Set up the trust anchor directory
4d4b2324d1c0 7139940 cached manifests persist for packages not currently installed even when copy in repository changes
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2731
diff changeset
  2382
                self.ta_dir = os.path.join(self.img_path(), "etc/certs/CA")
4d4b2324d1c0 7139940 cached manifests persist for packages not currently installed even when copy in repository changes
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2731
diff changeset
  2383
                os.makedirs(self.ta_dir)
4d4b2324d1c0 7139940 cached manifests persist for packages not currently installed even when copy in repository changes
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2731
diff changeset
  2384
                for f in self.image_files:
4d4b2324d1c0 7139940 cached manifests persist for packages not currently installed even when copy in repository changes
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2731
diff changeset
  2385
                        with open(os.path.join(self.img_path(), f), "wb") as fh:
4d4b2324d1c0 7139940 cached manifests persist for packages not currently installed even when copy in repository changes
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2731
diff changeset
  2386
                                fh.close()
4d4b2324d1c0 7139940 cached manifests persist for packages not currently installed even when copy in repository changes
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2731
diff changeset
  2387
3048
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
  2388
        def image_create(self, repourl=None, destroy=True, fs=(),
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
  2389
            img_path=None, **kwargs):
1859
6e6e866921e7 529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents: 1839
diff changeset
  2390
                """A convenience wrapper for callers that only need basic image
6e6e866921e7 529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents: 1839
diff changeset
  2391
                creation functionality.  This wrapper creates a full (as opposed
6e6e866921e7 529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents: 1839
diff changeset
  2392
                to user) image using the pkg.client.api and returns the related
6e6e866921e7 529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents: 1839
diff changeset
  2393
                API object."""
6e6e866921e7 529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents: 1839
diff changeset
  2394
3048
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
  2395
                if img_path is None:
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
  2396
                        img_path = self.img_path()
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
  2397
2092
0ef66bf272d3 16852 pkg should look at its image for certs if active image lacks certs
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2089
diff changeset
  2398
                if destroy:
3048
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
  2399
                        self.image_destroy(img_path=img_path)
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
  2400
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
  2401
                mkdir_eexist_ok(img_path)
2339
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  2402
2580
92480b147363 2707 directory salvage doesn't deal with special files well
Danek Duvall <danek.duvall@oracle.com>
parents: 2550
diff changeset
  2403
                self.fs = set()
92480b147363 2707 directory salvage doesn't deal with special files well
Danek Duvall <danek.duvall@oracle.com>
parents: 2550
diff changeset
  2404
92480b147363 2707 directory salvage doesn't deal with special files well
Danek Duvall <danek.duvall@oracle.com>
parents: 2550
diff changeset
  2405
                force = False
92480b147363 2707 directory salvage doesn't deal with special files well
Danek Duvall <danek.duvall@oracle.com>
parents: 2550
diff changeset
  2406
                for path in fs:
3048
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
  2407
                        full_path = os.path.join(img_path,
2580
92480b147363 2707 directory salvage doesn't deal with special files well
Danek Duvall <danek.duvall@oracle.com>
parents: 2550
diff changeset
  2408
                            path.lstrip(os.path.sep))
92480b147363 2707 directory salvage doesn't deal with special files well
Danek Duvall <danek.duvall@oracle.com>
parents: 2550
diff changeset
  2409
                        os.makedirs(full_path)
92480b147363 2707 directory salvage doesn't deal with special files well
Danek Duvall <danek.duvall@oracle.com>
parents: 2550
diff changeset
  2410
                        self.cmdline_run("/usr/sbin/mount -F tmpfs swap " +
2720
66a86306e53e 7179255 pkg5 code coverage has rotted and doesn't work anymore
Dan Price <daniel.price@oracle.com>
parents: 2708
diff changeset
  2411
                            full_path, coverage=False)
2580
92480b147363 2707 directory salvage doesn't deal with special files well
Danek Duvall <danek.duvall@oracle.com>
parents: 2550
diff changeset
  2412
                        self.fs.add(full_path)
92480b147363 2707 directory salvage doesn't deal with special files well
Danek Duvall <danek.duvall@oracle.com>
parents: 2550
diff changeset
  2413
                        if path.lstrip(os.path.sep) == "var":
92480b147363 2707 directory salvage doesn't deal with special files well
Danek Duvall <danek.duvall@oracle.com>
parents: 2550
diff changeset
  2414
                                force = True
92480b147363 2707 directory salvage doesn't deal with special files well
Danek Duvall <danek.duvall@oracle.com>
parents: 2550
diff changeset
  2415
3048
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
  2416
                self.debug("image_create %s" % img_path)
1859
6e6e866921e7 529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents: 1839
diff changeset
  2417
                progtrack = pkg.client.progress.NullProgressTracker()
6e6e866921e7 529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents: 1839
diff changeset
  2418
                api_inst = pkg.client.api.image_create(PKG_CLIENT_NAME,
3048
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
  2419
                    CLIENT_API_VERSION, img_path,
1859
6e6e866921e7 529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents: 1839
diff changeset
  2420
                    pkg.client.api.IMG_TYPE_ENTIRE, False, repo_uri=repourl,
2580
92480b147363 2707 directory salvage doesn't deal with special files well
Danek Duvall <danek.duvall@oracle.com>
parents: 2550
diff changeset
  2421
                    progtrack=progtrack, force=force,
2339
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  2422
                    **kwargs)
2753
4d4b2324d1c0 7139940 cached manifests persist for packages not currently installed even when copy in repository changes
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2731
diff changeset
  2423
                self.__setup_signing_files()
1859
6e6e866921e7 529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents: 1839
diff changeset
  2424
                return api_inst
6e6e866921e7 529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents: 1839
diff changeset
  2425
2310
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  2426
        def pkg_image_create(self, repourl=None, prefix=None,
2816
17425ca1f195 7192183 nasty depot testing should be part of core testing
Dan Price <daniel.price@oracle.com>
parents: 2808
diff changeset
  2427
            additional_args="", exit=0, env_arg=None):
1859
6e6e866921e7 529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents: 1839
diff changeset
  2428
                """Executes pkg(1) client to create a full (as opposed to user)
6e6e866921e7 529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents: 1839
diff changeset
  2429
                image; returns exit code of client or raises an exception if
2580
92480b147363 2707 directory salvage doesn't deal with special files well
Danek Duvall <danek.duvall@oracle.com>
parents: 2550
diff changeset
  2430
                exit code doesn't match 'exit' or equals 99."""
1859
6e6e866921e7 529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents: 1839
diff changeset
  2431
2310
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  2432
                if repourl and prefix is None:
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  2433
                        prefix = "test"
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  2434
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2435
                self.image_destroy()
2339
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  2436
                os.mkdir(self.img_path())
2499
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2437
                cmdline = "%s image-create -F " % self.pkg_cmdpath
2310
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  2438
                if repourl:
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  2439
                        cmdline = "%s -p %s=%s " % (cmdline, prefix, repourl)
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  2440
                cmdline += additional_args
2339
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  2441
                cmdline = "%s %s" % (cmdline, self.img_path())
2816
17425ca1f195 7192183 nasty depot testing should be part of core testing
Dan Price <daniel.price@oracle.com>
parents: 2808
diff changeset
  2442
17425ca1f195 7192183 nasty depot testing should be part of core testing
Dan Price <daniel.price@oracle.com>
parents: 2808
diff changeset
  2443
                retcode = self.cmdline_run(cmdline, exit=exit, env_arg=env_arg)
17425ca1f195 7192183 nasty depot testing should be part of core testing
Dan Price <daniel.price@oracle.com>
parents: 2808
diff changeset
  2444
2753
4d4b2324d1c0 7139940 cached manifests persist for packages not currently installed even when copy in repository changes
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2731
diff changeset
  2445
                self.__setup_signing_files()
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2446
                return retcode
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2447
2896
317cfe39ab72 16172195 Unable to update T5 with S11u1 (FCS) and 288 zones to S11U1 SRU 3
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2864
diff changeset
  2448
        def image_clone(self, dst):
317cfe39ab72 16172195 Unable to update T5 with S11u1 (FCS) and 288 zones to S11U1 SRU 3
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2864
diff changeset
  2449
317cfe39ab72 16172195 Unable to update T5 with S11u1 (FCS) and 288 zones to S11U1 SRU 3
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2864
diff changeset
  2450
                # the currently selected image is the source
317cfe39ab72 16172195 Unable to update T5 with S11u1 (FCS) and 288 zones to S11U1 SRU 3
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2864
diff changeset
  2451
                src = self.img_index()
317cfe39ab72 16172195 Unable to update T5 with S11u1 (FCS) and 288 zones to S11U1 SRU 3
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2864
diff changeset
  2452
                src_path = self.img_path()
317cfe39ab72 16172195 Unable to update T5 with S11u1 (FCS) and 288 zones to S11U1 SRU 3
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2864
diff changeset
  2453
317cfe39ab72 16172195 Unable to update T5 with S11u1 (FCS) and 288 zones to S11U1 SRU 3
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2864
diff changeset
  2454
                # create an empty destination image
317cfe39ab72 16172195 Unable to update T5 with S11u1 (FCS) and 288 zones to S11U1 SRU 3
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2864
diff changeset
  2455
                self.set_image(dst)
317cfe39ab72 16172195 Unable to update T5 with S11u1 (FCS) and 288 zones to S11U1 SRU 3
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2864
diff changeset
  2456
                self.image_destroy()
317cfe39ab72 16172195 Unable to update T5 with S11u1 (FCS) and 288 zones to S11U1 SRU 3
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2864
diff changeset
  2457
                os.mkdir(self.img_path())
317cfe39ab72 16172195 Unable to update T5 with S11u1 (FCS) and 288 zones to S11U1 SRU 3
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2864
diff changeset
  2458
                dst_path = self.img_path()
317cfe39ab72 16172195 Unable to update T5 with S11u1 (FCS) and 288 zones to S11U1 SRU 3
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2864
diff changeset
  2459
317cfe39ab72 16172195 Unable to update T5 with S11u1 (FCS) and 288 zones to S11U1 SRU 3
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2864
diff changeset
  2460
                # reactivate the source image
317cfe39ab72 16172195 Unable to update T5 with S11u1 (FCS) and 288 zones to S11U1 SRU 3
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2864
diff changeset
  2461
                self.set_image(src)
317cfe39ab72 16172195 Unable to update T5 with S11u1 (FCS) and 288 zones to S11U1 SRU 3
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2864
diff changeset
  2462
317cfe39ab72 16172195 Unable to update T5 with S11u1 (FCS) and 288 zones to S11U1 SRU 3
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2864
diff changeset
  2463
                # populate the destination image
317cfe39ab72 16172195 Unable to update T5 with S11u1 (FCS) and 288 zones to S11U1 SRU 3
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2864
diff changeset
  2464
                cmdline = "cd %s; find . | cpio -pdm %s" % (src_path, dst_path)
317cfe39ab72 16172195 Unable to update T5 with S11u1 (FCS) and 288 zones to S11U1 SRU 3
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2864
diff changeset
  2465
                retcode = self.cmdline_run(cmdline, coverage=False)
317cfe39ab72 16172195 Unable to update T5 with S11u1 (FCS) and 288 zones to S11U1 SRU 3
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2864
diff changeset
  2466
3048
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
  2467
        def image_destroy(self, img_path=None):
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
  2468
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
  2469
                if img_path is None:
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
  2470
                        img_path = self.img_path()
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
  2471
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
  2472
                if os.path.exists(img_path):
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
  2473
                        self.debug("image_destroy %s" % img_path)
2339
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  2474
                        # Make sure we're not in the image.
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2475
                        os.chdir(self.test_root)
2580
92480b147363 2707 directory salvage doesn't deal with special files well
Danek Duvall <danek.duvall@oracle.com>
parents: 2550
diff changeset
  2476
                        for path in getattr(self, "fs", set()).copy():
2720
66a86306e53e 7179255 pkg5 code coverage has rotted and doesn't work anymore
Dan Price <daniel.price@oracle.com>
parents: 2708
diff changeset
  2477
                                self.cmdline_run("/usr/sbin/umount " + path,
66a86306e53e 7179255 pkg5 code coverage has rotted and doesn't work anymore
Dan Price <daniel.price@oracle.com>
parents: 2708
diff changeset
  2478
				    coverage=False)
2580
92480b147363 2707 directory salvage doesn't deal with special files well
Danek Duvall <danek.duvall@oracle.com>
parents: 2550
diff changeset
  2479
                                self.fs.remove(path)
3048
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
  2480
                        shutil.rmtree(img_path)
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2481
2047
5e1340de1aba 12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents: 2046
diff changeset
  2482
        def pkg(self, command, exit=0, comment="", prefix="", su_wrap=None,
2339
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  2483
            out=False, stderr=False, cmd_path=None, use_img_root=True,
3144
3c7d193a9571 18588974 solver can fail with faulty rejections for incorporates
saurabh.vyas@oracle.com
parents: 3063
diff changeset
  2484
            debug_smf=True, env_arg=None, coverage=True, handle=False,
3c7d193a9571 18588974 solver can fail with faulty rejections for incorporates
saurabh.vyas@oracle.com
parents: 3063
diff changeset
  2485
            assert_solution=True):
3048
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
  2486
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
  2487
                if isinstance(command, list):
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
  2488
                        cmdstr = " ".join(command)
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
  2489
                else:
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
  2490
                        cmdstr = command
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
  2491
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
  2492
                cmdline = []
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
  2493
2339
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  2494
                if not cmd_path:
2499
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  2495
                        cmd_path = self.pkg_cmdpath
3048
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
  2496
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
  2497
                cmdline.append(cmd_path)
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
  2498
3144
3c7d193a9571 18588974 solver can fail with faulty rejections for incorporates
saurabh.vyas@oracle.com
parents: 3063
diff changeset
  2499
                if (use_img_root and "-R" not in cmdstr and
3c7d193a9571 18588974 solver can fail with faulty rejections for incorporates
saurabh.vyas@oracle.com
parents: 3063
diff changeset
  2500
                    "image-create" not in cmdstr):
3048
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
  2501
                        cmdline.extend(("-R", self.get_img_path()))
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
  2502
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
  2503
                cmdline.extend(("-D", "plandesc_validate=1"))
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
  2504
                cmdline.extend(("-D", "manifest_validate=Always"))
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
  2505
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
  2506
                if debug_smf and "smf_cmds_dir" not in cmdstr:
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
  2507
                        cmdline.extend(("-D", "smf_cmds_dir=%s" %
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
  2508
                            DebugValues["smf_cmds_dir"]))
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
  2509
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
  2510
                if not isinstance(command, list):
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
  2511
                        cmdline = "%s %s" % (" ".join(cmdline), command)
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
  2512
                else:
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
  2513
                        cmdline.extend(command)
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
  2514
3144
3c7d193a9571 18588974 solver can fail with faulty rejections for incorporates
saurabh.vyas@oracle.com
parents: 3063
diff changeset
  2515
                rval = self.cmdline_run(cmdline, exit=exit, comment=comment,
2675
49931dc5f9b6 7140680 "pkg history" does not work in some localized locales
abhinandan.ekande@oracle.com
parents: 2656
diff changeset
  2516
                    prefix=prefix, su_wrap=su_wrap, out=out, stderr=stderr,
3048
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
  2517
                    env_arg=env_arg, coverage=coverage, handle=handle)
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2518
3144
3c7d193a9571 18588974 solver can fail with faulty rejections for incorporates
saurabh.vyas@oracle.com
parents: 3063
diff changeset
  2519
                if assert_solution:
3c7d193a9571 18588974 solver can fail with faulty rejections for incorporates
saurabh.vyas@oracle.com
parents: 3063
diff changeset
  2520
                        # Ensure solver never fails with 'No solution' by
3c7d193a9571 18588974 solver can fail with faulty rejections for incorporates
saurabh.vyas@oracle.com
parents: 3063
diff changeset
  2521
                        # default to prevent silent failures for the wrong
3c7d193a9571 18588974 solver can fail with faulty rejections for incorporates
saurabh.vyas@oracle.com
parents: 3063
diff changeset
  2522
                        # reason.
3c7d193a9571 18588974 solver can fail with faulty rejections for incorporates
saurabh.vyas@oracle.com
parents: 3063
diff changeset
  2523
                        for buf in (self.errout, self.output):
3c7d193a9571 18588974 solver can fail with faulty rejections for incorporates
saurabh.vyas@oracle.com
parents: 3063
diff changeset
  2524
                                self.assert_("No solution" not in buf,
3c7d193a9571 18588974 solver can fail with faulty rejections for incorporates
saurabh.vyas@oracle.com
parents: 3063
diff changeset
  2525
                                    msg="Solver could not find solution for "
3c7d193a9571 18588974 solver can fail with faulty rejections for incorporates
saurabh.vyas@oracle.com
parents: 3063
diff changeset
  2526
                                    "operation; set assert_solution=False if "
3c7d193a9571 18588974 solver can fail with faulty rejections for incorporates
saurabh.vyas@oracle.com
parents: 3063
diff changeset
  2527
                                    "this is expected when calling pkg().")
3c7d193a9571 18588974 solver can fail with faulty rejections for incorporates
saurabh.vyas@oracle.com
parents: 3063
diff changeset
  2528
3c7d193a9571 18588974 solver can fail with faulty rejections for incorporates
saurabh.vyas@oracle.com
parents: 3063
diff changeset
  2529
                return rval
3c7d193a9571 18588974 solver can fail with faulty rejections for incorporates
saurabh.vyas@oracle.com
parents: 3063
diff changeset
  2530
2985
58be3022b9ca 17626154 pkg verify fails for all packages containing ELF files
nishchaya.bahuguna@oracle.com
parents: 2966
diff changeset
  2531
        def pkg_verify(self, command, exit=0, comment="", prefix="",
58be3022b9ca 17626154 pkg verify fails for all packages containing ELF files
nishchaya.bahuguna@oracle.com
parents: 2966
diff changeset
  2532
            su_wrap=None, out=False, stderr=False, cmd_path=None,
58be3022b9ca 17626154 pkg verify fails for all packages containing ELF files
nishchaya.bahuguna@oracle.com
parents: 2966
diff changeset
  2533
            use_img_root=True, debug_smf=True, env_arg=None, coverage=True):
58be3022b9ca 17626154 pkg verify fails for all packages containing ELF files
nishchaya.bahuguna@oracle.com
parents: 2966
diff changeset
  2534
                """Wraps self.pkg(..) and checks that the 'verify' command run
58be3022b9ca 17626154 pkg verify fails for all packages containing ELF files
nishchaya.bahuguna@oracle.com
parents: 2966
diff changeset
  2535
                does not contain the string 'Unexpected Exception', indicating
58be3022b9ca 17626154 pkg verify fails for all packages containing ELF files
nishchaya.bahuguna@oracle.com
parents: 2966
diff changeset
  2536
                something has gone wrong during package verification."""
58be3022b9ca 17626154 pkg verify fails for all packages containing ELF files
nishchaya.bahuguna@oracle.com
parents: 2966
diff changeset
  2537
58be3022b9ca 17626154 pkg verify fails for all packages containing ELF files
nishchaya.bahuguna@oracle.com
parents: 2966
diff changeset
  2538
                cmd = "verify %s" % command
58be3022b9ca 17626154 pkg verify fails for all packages containing ELF files
nishchaya.bahuguna@oracle.com
parents: 2966
diff changeset
  2539
                res = self.pkg(command=cmd, exit=exit, comment=comment,
58be3022b9ca 17626154 pkg verify fails for all packages containing ELF files
nishchaya.bahuguna@oracle.com
parents: 2966
diff changeset
  2540
                    prefix=prefix, su_wrap=su_wrap, out=out, stderr=stderr,
58be3022b9ca 17626154 pkg verify fails for all packages containing ELF files
nishchaya.bahuguna@oracle.com
parents: 2966
diff changeset
  2541
                    cmd_path=cmd_path, use_img_root=use_img_root,
58be3022b9ca 17626154 pkg verify fails for all packages containing ELF files
nishchaya.bahuguna@oracle.com
parents: 2966
diff changeset
  2542
                    debug_smf=debug_smf, env_arg=env_arg, coverage=coverage)
58be3022b9ca 17626154 pkg verify fails for all packages containing ELF files
nishchaya.bahuguna@oracle.com
parents: 2966
diff changeset
  2543
                if "Unexpected Exception" in self.output:
58be3022b9ca 17626154 pkg verify fails for all packages containing ELF files
nishchaya.bahuguna@oracle.com
parents: 2966
diff changeset
  2544
                        raise TracebackException(cmd, self.output,
58be3022b9ca 17626154 pkg verify fails for all packages containing ELF files
nishchaya.bahuguna@oracle.com
parents: 2966
diff changeset
  2545
                            "Unexpected errors encountered while verifying.")
58be3022b9ca 17626154 pkg verify fails for all packages containing ELF files
nishchaya.bahuguna@oracle.com
parents: 2966
diff changeset
  2546
                return res
58be3022b9ca 17626154 pkg verify fails for all packages containing ELF files
nishchaya.bahuguna@oracle.com
parents: 2966
diff changeset
  2547
2816
17425ca1f195 7192183 nasty depot testing should be part of core testing
Dan Price <daniel.price@oracle.com>
parents: 2808
diff changeset
  2548
        def pkgdepend_resolve(self, args, exit=0, comment="", su_wrap=False,
17425ca1f195 7192183 nasty depot testing should be part of core testing
Dan Price <daniel.price@oracle.com>
parents: 2808
diff changeset
  2549
            env_arg=None):
2158
5a688b5b92a3 15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents: 2144
diff changeset
  2550
                ops = ""
5a688b5b92a3 15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents: 2144
diff changeset
  2551
                if "-R" not in args:
5a688b5b92a3 15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents: 2144
diff changeset
  2552
                        ops = "-R %s" % self.get_img_path()
5a688b5b92a3 15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents: 2144
diff changeset
  2553
                cmdline = "%s/usr/bin/pkgdepend %s resolve %s" % (
5a688b5b92a3 15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents: 2144
diff changeset
  2554
                    g_proto_area, ops, args)
2381
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2373
diff changeset
  2555
                return self.cmdline_run(cmdline, comment=comment, exit=exit,
2816
17425ca1f195 7192183 nasty depot testing should be part of core testing
Dan Price <daniel.price@oracle.com>
parents: 2808
diff changeset
  2556
                    su_wrap=su_wrap, env_arg=env_arg)
17425ca1f195 7192183 nasty depot testing should be part of core testing
Dan Price <daniel.price@oracle.com>
parents: 2808
diff changeset
  2557
17425ca1f195 7192183 nasty depot testing should be part of core testing
Dan Price <daniel.price@oracle.com>
parents: 2808
diff changeset
  2558
        def pkgdepend_generate(self, args, exit=0, comment="", su_wrap=False,
17425ca1f195 7192183 nasty depot testing should be part of core testing
Dan Price <daniel.price@oracle.com>
parents: 2808
diff changeset
  2559
            env_arg=None):
1968
c0540b1e4f7e 8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents: 1949
diff changeset
  2560
                cmdline = "%s/usr/bin/pkgdepend generate %s" % (g_proto_area,
c0540b1e4f7e 8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents: 1949
diff changeset
  2561
                    args)
2381
45a20c3a277a 11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2373
diff changeset
  2562
                return self.cmdline_run(cmdline, comment=comment, exit=exit,
2816
17425ca1f195 7192183 nasty depot testing should be part of core testing
Dan Price <daniel.price@oracle.com>
parents: 2808
diff changeset
  2563
                    su_wrap=su_wrap, env_arg=env_arg)
17425ca1f195 7192183 nasty depot testing should be part of core testing
Dan Price <daniel.price@oracle.com>
parents: 2808
diff changeset
  2564
2863
3ada267d5a98 15702381 pkgdiff should accept stdin as a source for a manifest
Shawn Walker <shawn.walker@oracle.com>
parents: 2852
diff changeset
  2565
        def pkgdiff(self, command, comment="", exit=0, su_wrap=False,
3ada267d5a98 15702381 pkgdiff should accept stdin as a source for a manifest
Shawn Walker <shawn.walker@oracle.com>
parents: 2852
diff changeset
  2566
            env_arg=None, stderr=False, out=False):
3ada267d5a98 15702381 pkgdiff should accept stdin as a source for a manifest
Shawn Walker <shawn.walker@oracle.com>
parents: 2852
diff changeset
  2567
                cmdline = "%s/usr/bin/pkgdiff %s" % (g_proto_area, command)
3ada267d5a98 15702381 pkgdiff should accept stdin as a source for a manifest
Shawn Walker <shawn.walker@oracle.com>
parents: 2852
diff changeset
  2568
                return self.cmdline_run(cmdline, comment=comment, exit=exit,
3ada267d5a98 15702381 pkgdiff should accept stdin as a source for a manifest
Shawn Walker <shawn.walker@oracle.com>
parents: 2852
diff changeset
  2569
                    su_wrap=su_wrap, env_arg=env_arg, out=out, stderr=stderr)
3ada267d5a98 15702381 pkgdiff should accept stdin as a source for a manifest
Shawn Walker <shawn.walker@oracle.com>
parents: 2852
diff changeset
  2570
2816
17425ca1f195 7192183 nasty depot testing should be part of core testing
Dan Price <daniel.price@oracle.com>
parents: 2808
diff changeset
  2571
        def pkgfmt(self, args, exit=0, su_wrap=False, env_arg=None):
2478
34959e45030b 18740 resolve's line echoing decisions need work
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2476
diff changeset
  2572
                cmd="%s/usr/bin/pkgfmt %s" % (g_proto_area, args)
2816
17425ca1f195 7192183 nasty depot testing should be part of core testing
Dan Price <daniel.price@oracle.com>
parents: 2808
diff changeset
  2573
                self.cmdline_run(cmd, exit=exit, su_wrap=su_wrap,
17425ca1f195 7192183 nasty depot testing should be part of core testing
Dan Price <daniel.price@oracle.com>
parents: 2808
diff changeset
  2574
                    env_arg=env_arg)
17425ca1f195 7192183 nasty depot testing should be part of core testing
Dan Price <daniel.price@oracle.com>
parents: 2808
diff changeset
  2575
17425ca1f195 7192183 nasty depot testing should be part of core testing
Dan Price <daniel.price@oracle.com>
parents: 2808
diff changeset
  2576
        def pkglint(self, args, exit=0, comment="", testrc=True,
17425ca1f195 7192183 nasty depot testing should be part of core testing
Dan Price <daniel.price@oracle.com>
parents: 2808
diff changeset
  2577
            env_arg=None):
2085
10a27146ebc2 16802 pkglint should check the value of info.classification in manifests
Tim Foster <tim.s.foster@oracle.com>
parents: 2081
diff changeset
  2578
                if testrc:
10a27146ebc2 16802 pkglint should check the value of info.classification in manifests
Tim Foster <tim.s.foster@oracle.com>
parents: 2081
diff changeset
  2579
                        rcpath = "%s/pkglintrc" % self.test_root
2081
f2189c4a03c4 16824 pkglint should remove its workaround for 16811
Tim Foster <tim.s.foster@oracle.com>
parents: 2073
diff changeset
  2580
                        cmdline = "%s/usr/bin/pkglint -f %s %s" % \
f2189c4a03c4 16824 pkglint should remove its workaround for 16811
Tim Foster <tim.s.foster@oracle.com>
parents: 2073
diff changeset
  2581
                            (g_proto_area, rcpath, args)
f2189c4a03c4 16824 pkglint should remove its workaround for 16811
Tim Foster <tim.s.foster@oracle.com>
parents: 2073
diff changeset
  2582
                else:
f2189c4a03c4 16824 pkglint should remove its workaround for 16811
Tim Foster <tim.s.foster@oracle.com>
parents: 2073
diff changeset
  2583
                        cmdline = "%s/usr/bin/pkglint %s" % (g_proto_area, args)
2046
2522cde7adc2 13536 We need a way to audit one or more packages
Tim Foster <tim.s.foster@oracle.com>
parents: 2034
diff changeset
  2584
                return self.cmdline_run(cmdline, exit=exit, out=True,
2816
17425ca1f195 7192183 nasty depot testing should be part of core testing
Dan Price <daniel.price@oracle.com>
parents: 2808
diff changeset
  2585
                    comment=comment, stderr=True, env_arg=env_arg)
2046
2522cde7adc2 13536 We need a way to audit one or more packages
Tim Foster <tim.s.foster@oracle.com>
parents: 2034
diff changeset
  2586
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2587
        def pkgrecv(self, server_url=None, command=None, exit=0, out=False,
2864
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  2588
            comment="", env_arg=None, su_wrap=False):
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2589
                args = []
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2590
                if server_url:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2591
                        args.append("-s %s" % server_url)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2592
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2593
                if command:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2594
                        args.append(command)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2595
1968
c0540b1e4f7e 8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents: 1949
diff changeset
  2596
                cmdline = "%s/usr/bin/pkgrecv %s" % (g_proto_area,
c0540b1e4f7e 8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents: 1949
diff changeset
  2597
                    " ".join(args))
2864
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  2598
1968
c0540b1e4f7e 8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents: 1949
diff changeset
  2599
                return self.cmdline_run(cmdline, comment=comment, exit=exit,
2864
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  2600
                    out=out, su_wrap=su_wrap, env_arg=env_arg)
2816
17425ca1f195 7192183 nasty depot testing should be part of core testing
Dan Price <daniel.price@oracle.com>
parents: 2808
diff changeset
  2601
17425ca1f195 7192183 nasty depot testing should be part of core testing
Dan Price <daniel.price@oracle.com>
parents: 2808
diff changeset
  2602
        def pkgmerge(self, args, comment="", exit=0, su_wrap=False,
17425ca1f195 7192183 nasty depot testing should be part of core testing
Dan Price <daniel.price@oracle.com>
parents: 2808
diff changeset
  2603
            env_arg=None):
2240
de59b73f1428 14965 merge should be productized
Shawn Walker <shawn.walker@oracle.com>
parents: 2223
diff changeset
  2604
                cmdline = "%s/usr/bin/pkgmerge %s" % (g_proto_area, args)
de59b73f1428 14965 merge should be productized
Shawn Walker <shawn.walker@oracle.com>
parents: 2223
diff changeset
  2605
                return self.cmdline_run(cmdline, comment=comment, exit=exit,
2816
17425ca1f195 7192183 nasty depot testing should be part of core testing
Dan Price <daniel.price@oracle.com>
parents: 2808
diff changeset
  2606
                    su_wrap=su_wrap, env_arg=env_arg)
17425ca1f195 7192183 nasty depot testing should be part of core testing
Dan Price <daniel.price@oracle.com>
parents: 2808
diff changeset
  2607
17425ca1f195 7192183 nasty depot testing should be part of core testing
Dan Price <daniel.price@oracle.com>
parents: 2808
diff changeset
  2608
        def pkgrepo(self, command, comment="", exit=0, su_wrap=False,
2966
6a97d8a803d3 16297554 pkg history fails when time travelling
thejaswini.k@oracle.com
parents: 2938
diff changeset
  2609
            env_arg=None, stderr=False, out=False, debug_hash=None):
6a97d8a803d3 16297554 pkg history fails when time travelling
thejaswini.k@oracle.com
parents: 2938
diff changeset
  2610
                if debug_hash:
6a97d8a803d3 16297554 pkg history fails when time travelling
thejaswini.k@oracle.com
parents: 2938
diff changeset
  2611
                        debug_arg = "-D hash=%s " % debug_hash
6a97d8a803d3 16297554 pkg history fails when time travelling
thejaswini.k@oracle.com
parents: 2938
diff changeset
  2612
                else:
6a97d8a803d3 16297554 pkg history fails when time travelling
thejaswini.k@oracle.com
parents: 2938
diff changeset
  2613
                        debug_arg = ""
6a97d8a803d3 16297554 pkg history fails when time travelling
thejaswini.k@oracle.com
parents: 2938
diff changeset
  2614
6a97d8a803d3 16297554 pkg history fails when time travelling
thejaswini.k@oracle.com
parents: 2938
diff changeset
  2615
                cmdline = "%s/usr/bin/pkgrepo %s%s" % (g_proto_area, debug_arg,
6a97d8a803d3 16297554 pkg history fails when time travelling
thejaswini.k@oracle.com
parents: 2938
diff changeset
  2616
                    command)
1968
c0540b1e4f7e 8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents: 1949
diff changeset
  2617
                return self.cmdline_run(cmdline, comment=comment, exit=exit,
2852
5650587d9468 15807357 need an Apache-based pkg.depotd
Tim Foster <tim.s.foster@oracle.com>
parents: 2843
diff changeset
  2618
                    su_wrap=su_wrap, env_arg=env_arg, out=out, stderr=stderr)
2816
17425ca1f195 7192183 nasty depot testing should be part of core testing
Dan Price <daniel.price@oracle.com>
parents: 2808
diff changeset
  2619
2928
71a6862183d8 16992741 New publication tool, which reverts pkgs in repo if content hasn't changed
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2910
diff changeset
  2620
        def pkgsurf(self, command, comment="", exit=0, su_wrap=False,
71a6862183d8 16992741 New publication tool, which reverts pkgs in repo if content hasn't changed
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2910
diff changeset
  2621
            env_arg=None, stderr=False, out=False):
71a6862183d8 16992741 New publication tool, which reverts pkgs in repo if content hasn't changed
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2910
diff changeset
  2622
                cmdline = "%s/usr/bin/pkgsurf %s" % (g_proto_area, command)
71a6862183d8 16992741 New publication tool, which reverts pkgs in repo if content hasn't changed
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2910
diff changeset
  2623
                return self.cmdline_run(cmdline, comment=comment, exit=exit,
71a6862183d8 16992741 New publication tool, which reverts pkgs in repo if content hasn't changed
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2910
diff changeset
  2624
                    su_wrap=su_wrap, env_arg=env_arg, out=out, stderr=stderr)
71a6862183d8 16992741 New publication tool, which reverts pkgs in repo if content hasn't changed
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2910
diff changeset
  2625
2816
17425ca1f195 7192183 nasty depot testing should be part of core testing
Dan Price <daniel.price@oracle.com>
parents: 2808
diff changeset
  2626
        def pkgsign(self, depot_url, command, exit=0, comment="",
2966
6a97d8a803d3 16297554 pkg history fails when time travelling
thejaswini.k@oracle.com
parents: 2938
diff changeset
  2627
            env_arg=None, debug_hash=None):
2026
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 1970
diff changeset
  2628
                args = []
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 1970
diff changeset
  2629
                if depot_url:
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 1970
diff changeset
  2630
                        args.append("-s %s" % depot_url)
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 1970
diff changeset
  2631
2966
6a97d8a803d3 16297554 pkg history fails when time travelling
thejaswini.k@oracle.com
parents: 2938
diff changeset
  2632
                if debug_hash:
6a97d8a803d3 16297554 pkg history fails when time travelling
thejaswini.k@oracle.com
parents: 2938
diff changeset
  2633
                        args.append("-D hash=%s" % debug_hash)
6a97d8a803d3 16297554 pkg history fails when time travelling
thejaswini.k@oracle.com
parents: 2938
diff changeset
  2634
2026
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 1970
diff changeset
  2635
                if command:
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 1970
diff changeset
  2636
                        args.append(command)
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 1970
diff changeset
  2637
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 1970
diff changeset
  2638
                cmdline = "%s/usr/bin/pkgsign %s" % (g_proto_area,
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 1970
diff changeset
  2639
                    " ".join(args))
2816
17425ca1f195 7192183 nasty depot testing should be part of core testing
Dan Price <daniel.price@oracle.com>
parents: 2808
diff changeset
  2640
                return self.cmdline_run(cmdline, comment=comment, exit=exit,
17425ca1f195 7192183 nasty depot testing should be part of core testing
Dan Price <daniel.price@oracle.com>
parents: 2808
diff changeset
  2641
                    env_arg=env_arg)
17425ca1f195 7192183 nasty depot testing should be part of core testing
Dan Price <daniel.price@oracle.com>
parents: 2808
diff changeset
  2642
2966
6a97d8a803d3 16297554 pkg history fails when time travelling
thejaswini.k@oracle.com
parents: 2938
diff changeset
  2643
        def pkgsign_simple(self, depot_url, pkg_name, exit=0, env_arg=None,
6a97d8a803d3 16297554 pkg history fails when time travelling
thejaswini.k@oracle.com
parents: 2938
diff changeset
  2644
            debug_hash=None):
2753
4d4b2324d1c0 7139940 cached manifests persist for packages not currently installed even when copy in repository changes
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2731
diff changeset
  2645
                chain_cert_path = os.path.join(self.chain_certs_dir,
4d4b2324d1c0 7139940 cached manifests persist for packages not currently installed even when copy in repository changes
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2731
diff changeset
  2646
                    "ch1_ta3_cert.pem")
4d4b2324d1c0 7139940 cached manifests persist for packages not currently installed even when copy in repository changes
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2731
diff changeset
  2647
                sign_args = "-k %(key)s -c %(cert)s -i %(ch1)s %(name)s" % {
4d4b2324d1c0 7139940 cached manifests persist for packages not currently installed even when copy in repository changes
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2731
diff changeset
  2648
                    "name": pkg_name,
4d4b2324d1c0 7139940 cached manifests persist for packages not currently installed even when copy in repository changes
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2731
diff changeset
  2649
                    "key": os.path.join(self.keys_dir, "cs1_ch1_ta3_key.pem"),
4d4b2324d1c0 7139940 cached manifests persist for packages not currently installed even when copy in repository changes
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2731
diff changeset
  2650
                    "cert": os.path.join(self.cs_dir, "cs1_ch1_ta3_cert.pem"),
4d4b2324d1c0 7139940 cached manifests persist for packages not currently installed even when copy in repository changes
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2731
diff changeset
  2651
                    "ch1": chain_cert_path,
4d4b2324d1c0 7139940 cached manifests persist for packages not currently installed even when copy in repository changes
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2731
diff changeset
  2652
                }
2816
17425ca1f195 7192183 nasty depot testing should be part of core testing
Dan Price <daniel.price@oracle.com>
parents: 2808
diff changeset
  2653
                return self.pkgsign(depot_url, sign_args, exit=exit,
2966
6a97d8a803d3 16297554 pkg history fails when time travelling
thejaswini.k@oracle.com
parents: 2938
diff changeset
  2654
                    env_arg=env_arg, debug_hash=debug_hash)
2753
4d4b2324d1c0 7139940 cached manifests persist for packages not currently installed even when copy in repository changes
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2731
diff changeset
  2655
2456
063737b8ee9b 9809 pkgsend publish should take bundle files as sources for files
Shawn Walker <shawn.walker@oracle.com>
parents: 2453
diff changeset
  2656
        def pkgsend(self, depot_url="", command="", exit=0, comment="",
2966
6a97d8a803d3 16297554 pkg history fails when time travelling
thejaswini.k@oracle.com
parents: 2938
diff changeset
  2657
            allow_timestamp=False, env_arg=None, su_wrap=False,
6a97d8a803d3 16297554 pkg history fails when time travelling
thejaswini.k@oracle.com
parents: 2938
diff changeset
  2658
            debug_hash=None):
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2659
                args = []
2456
063737b8ee9b 9809 pkgsend publish should take bundle files as sources for files
Shawn Walker <shawn.walker@oracle.com>
parents: 2453
diff changeset
  2660
                if allow_timestamp:
063737b8ee9b 9809 pkgsend publish should take bundle files as sources for files
Shawn Walker <shawn.walker@oracle.com>
parents: 2453
diff changeset
  2661
                        args.append("-D allow-timestamp")
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2662
                if depot_url:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2663
                        args.append("-s " + depot_url)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2664
2966
6a97d8a803d3 16297554 pkg history fails when time travelling
thejaswini.k@oracle.com
parents: 2938
diff changeset
  2665
                # debug_hash lets us choose the type of hash attributes that
6a97d8a803d3 16297554 pkg history fails when time travelling
thejaswini.k@oracle.com
parents: 2938
diff changeset
  2666
                # should be added to this package on publication. Valid values
3063
bbaaf1579de3 15744850 no actuators are run when pkg manipulates a booted NGZ image from the GZ
thejaswini.k@oracle.com
parents: 3048
diff changeset
  2667
                # are: sha1, sha256, sha1+sha256, sha512_256, sha1+sha512_256
2966
6a97d8a803d3 16297554 pkg history fails when time travelling
thejaswini.k@oracle.com
parents: 2938
diff changeset
  2668
                if debug_hash:
6a97d8a803d3 16297554 pkg history fails when time travelling
thejaswini.k@oracle.com
parents: 2938
diff changeset
  2669
                        args.append("-D hash=%s" % debug_hash)
6a97d8a803d3 16297554 pkg history fails when time travelling
thejaswini.k@oracle.com
parents: 2938
diff changeset
  2670
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2671
                if command:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2672
                        args.append(command)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2673
1968
c0540b1e4f7e 8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents: 1949
diff changeset
  2674
                prefix = "cd %s;" % self.test_root
2183
21ae45e8dfcf 17581 There should be a way of removing a package as part of upgrade
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents: 2158
diff changeset
  2675
                cmdline = "%s/usr/bin/pkgsend %s" % (g_proto_area,
1968
c0540b1e4f7e 8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents: 1949
diff changeset
  2676
                    " ".join(args))
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2677
1968
c0540b1e4f7e 8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents: 1949
diff changeset
  2678
                retcode, out = self.cmdline_run(cmdline, comment=comment,
2816
17425ca1f195 7192183 nasty depot testing should be part of core testing
Dan Price <daniel.price@oracle.com>
parents: 2808
diff changeset
  2679
                    exit=exit, out=True, prefix=prefix, raise_error=False,
2843
4e1d09017f2c 15722190 pkgrepo verify subcommand needed
Tim Foster <tim.s.foster@oracle.com>
parents: 2830
diff changeset
  2680
                    env_arg=env_arg, su_wrap=su_wrap)
1968
c0540b1e4f7e 8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents: 1949
diff changeset
  2681
                errout = self.errout
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2682
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2683
                cmdop = command.split(' ')[0]
2026
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 1970
diff changeset
  2684
                if cmdop in ("open", "append") and retcode == 0:
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2685
                        out = out.rstrip()
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2686
                        assert out.startswith("export PKG_TRANS_ID=")
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2687
                        arr = out.split("=")
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2688
                        assert arr
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2689
                        out = arr[1]
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2690
                        os.environ["PKG_TRANS_ID"] = out
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2691
                        self.debug("$ export PKG_TRANS_ID=%s" % out)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2692
                        # retcode != 0 will be handled below
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2693
1968
c0540b1e4f7e 8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents: 1949
diff changeset
  2694
                published = None
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2695
                if (cmdop == "close" and retcode == 0) or cmdop == "publish":
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2696
                        os.environ["PKG_TRANS_ID"] = ""
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2697
                        self.debug("$ export PKG_TRANS_ID=")
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2698
                        for l in out.splitlines():
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2699
                                if l.startswith("pkg:/"):
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2700
                                        published = l
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2701
                                        break
1839
53bdcdd547cb 11023 DirectoryBundle emits bad paths if basedir has trailing /
Shawn Walker <shawn.walker@oracle.com>
parents: 1832
diff changeset
  2702
                elif (cmdop == "generate" and retcode == 0):
53bdcdd547cb 11023 DirectoryBundle emits bad paths if basedir has trailing /
Shawn Walker <shawn.walker@oracle.com>
parents: 1832
diff changeset
  2703
                        published = out
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2704
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2705
                if retcode == 99:
2608
2231afa43dc7 19104 CliTestCase.pkgsend needs to display traceback when pkgsend tracesback
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2603
diff changeset
  2706
                        raise TracebackException(cmdline, out + errout, comment)
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2707
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2708
                if retcode != exit:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2709
                        raise UnexpectedExitCodeException(cmdline, exit,
2028
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  2710
                            retcode, out + errout, comment)
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2711
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2712
                return retcode, published
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2713
1968
c0540b1e4f7e 8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents: 1949
diff changeset
  2714
        def pkgsend_bulk(self, depot_url, commands, exit=0, comment="",
2966
6a97d8a803d3 16297554 pkg history fails when time travelling
thejaswini.k@oracle.com
parents: 2938
diff changeset
  2715
            no_catalog=False, refresh_index=False, su_wrap=False,
6a97d8a803d3 16297554 pkg history fails when time travelling
thejaswini.k@oracle.com
parents: 2938
diff changeset
  2716
            debug_hash=None):
1968
c0540b1e4f7e 8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents: 1949
diff changeset
  2717
                """ Send a series of packaging commands; useful  for quickly
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2718
                    doing a bulk-load of stuff into the repo.  All commands are
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2719
                    expected to work; if not, the transaction is abandoned.  If
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2720
                    'exit' is set, then if none of the actions triggers that
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2721
                    exit code, an UnexpectedExitCodeException is raised.
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2722
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2723
                    A list containing the fmris of any packages that were
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2724
                    published as a result of the commands executed will be
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2725
                    returned; it will be empty if none were. """
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2726
1895
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1890
diff changeset
  2727
                if isinstance(commands, (list, tuple)):
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1890
diff changeset
  2728
                        commands = "".join(commands)
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1890
diff changeset
  2729
1968
c0540b1e4f7e 8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents: 1949
diff changeset
  2730
                extra_opts = []
c0540b1e4f7e 8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents: 1949
diff changeset
  2731
                if no_catalog:
c0540b1e4f7e 8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents: 1949
diff changeset
  2732
                        extra_opts.append("--no-catalog")
c0540b1e4f7e 8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents: 1949
diff changeset
  2733
                extra_opts = " ".join(extra_opts)
c0540b1e4f7e 8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents: 1949
diff changeset
  2734
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2735
                plist = []
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2736
                try:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2737
                        accumulate = []
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2738
                        current_fmri = None
2046
2522cde7adc2 13536 We need a way to audit one or more packages
Tim Foster <tim.s.foster@oracle.com>
parents: 2034
diff changeset
  2739
                        retcode = None
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2740
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2741
                        for line in commands.split("\n"):
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2742
                                line = line.strip()
1839
53bdcdd547cb 11023 DirectoryBundle emits bad paths if basedir has trailing /
Shawn Walker <shawn.walker@oracle.com>
parents: 1832
diff changeset
  2743
53bdcdd547cb 11023 DirectoryBundle emits bad paths if basedir has trailing /
Shawn Walker <shawn.walker@oracle.com>
parents: 1832
diff changeset
  2744
                                # pkgsend_bulk can't be used w/ import or
53bdcdd547cb 11023 DirectoryBundle emits bad paths if basedir has trailing /
Shawn Walker <shawn.walker@oracle.com>
parents: 1832
diff changeset
  2745
                                # generate.
53bdcdd547cb 11023 DirectoryBundle emits bad paths if basedir has trailing /
Shawn Walker <shawn.walker@oracle.com>
parents: 1832
diff changeset
  2746
                                assert not line.startswith("import"), \
53bdcdd547cb 11023 DirectoryBundle emits bad paths if basedir has trailing /
Shawn Walker <shawn.walker@oracle.com>
parents: 1832
diff changeset
  2747
                                    "pkgsend_bulk cannot be used with import"
53bdcdd547cb 11023 DirectoryBundle emits bad paths if basedir has trailing /
Shawn Walker <shawn.walker@oracle.com>
parents: 1832
diff changeset
  2748
                                assert not line.startswith("generate"), \
53bdcdd547cb 11023 DirectoryBundle emits bad paths if basedir has trailing /
Shawn Walker <shawn.walker@oracle.com>
parents: 1832
diff changeset
  2749
                                    "pkgsend_bulk cannot be used with generate"
53bdcdd547cb 11023 DirectoryBundle emits bad paths if basedir has trailing /
Shawn Walker <shawn.walker@oracle.com>
parents: 1832
diff changeset
  2750
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2751
                                if line == "":
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2752
                                        continue
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2753
                                if line.startswith("add"):
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2754
                                        self.assert_(current_fmri != None,
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2755
                                            "Missing open in pkgsend string")
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2756
                                        accumulate.append(line[4:])
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2757
                                        continue
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2758
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2759
                                if current_fmri: # send any content seen so far (can be 0)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2760
                                        fd, f_path = tempfile.mkstemp(dir=self.test_root)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2761
                                        for l in accumulate:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2762
                                                os.write(fd, "%s\n" % l)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2763
                                        os.close(fd)
2843
4e1d09017f2c 15722190 pkgrepo verify subcommand needed
Tim Foster <tim.s.foster@oracle.com>
parents: 2830
diff changeset
  2764
                                        if su_wrap:
4e1d09017f2c 15722190 pkgrepo verify subcommand needed
Tim Foster <tim.s.foster@oracle.com>
parents: 2830
diff changeset
  2765
                                                os.chown(f_path,
4e1d09017f2c 15722190 pkgrepo verify subcommand needed
Tim Foster <tim.s.foster@oracle.com>
parents: 2830
diff changeset
  2766
                                                    *get_su_wrap_user(
4e1d09017f2c 15722190 pkgrepo verify subcommand needed
Tim Foster <tim.s.foster@oracle.com>
parents: 2830
diff changeset
  2767
                                                    uid_gid=True))
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2768
                                        try:
2456
063737b8ee9b 9809 pkgsend publish should take bundle files as sources for files
Shawn Walker <shawn.walker@oracle.com>
parents: 2453
diff changeset
  2769
                                                cmd = "publish %s -d %s %s" % (
063737b8ee9b 9809 pkgsend publish should take bundle files as sources for files
Shawn Walker <shawn.walker@oracle.com>
parents: 2453
diff changeset
  2770
                                                    extra_opts, self.test_root,
063737b8ee9b 9809 pkgsend publish should take bundle files as sources for files
Shawn Walker <shawn.walker@oracle.com>
parents: 2453
diff changeset
  2771
                                                    f_path)
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2772
                                                current_fmri = None
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2773
                                                accumulate = []
2456
063737b8ee9b 9809 pkgsend publish should take bundle files as sources for files
Shawn Walker <shawn.walker@oracle.com>
parents: 2453
diff changeset
  2774
                                                # Various tests rely on the
063737b8ee9b 9809 pkgsend publish should take bundle files as sources for files
Shawn Walker <shawn.walker@oracle.com>
parents: 2453
diff changeset
  2775
                                                # ability to specify version
063737b8ee9b 9809 pkgsend publish should take bundle files as sources for files
Shawn Walker <shawn.walker@oracle.com>
parents: 2453
diff changeset
  2776
                                                # down to timestamp for ease
063737b8ee9b 9809 pkgsend publish should take bundle files as sources for files
Shawn Walker <shawn.walker@oracle.com>
parents: 2453
diff changeset
  2777
                                                # of testing or because they're
063737b8ee9b 9809 pkgsend publish should take bundle files as sources for files
Shawn Walker <shawn.walker@oracle.com>
parents: 2453
diff changeset
  2778
                                                # actually testing timestamp
063737b8ee9b 9809 pkgsend publish should take bundle files as sources for files
Shawn Walker <shawn.walker@oracle.com>
parents: 2453
diff changeset
  2779
                                                # package behaviour.
2073
9fcacc9e5eaa 16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents: 2047
diff changeset
  2780
                                                retcode, published = \
2456
063737b8ee9b 9809 pkgsend publish should take bundle files as sources for files
Shawn Walker <shawn.walker@oracle.com>
parents: 2453
diff changeset
  2781
                                                    self.pkgsend(depot_url, cmd,
2843
4e1d09017f2c 15722190 pkgrepo verify subcommand needed
Tim Foster <tim.s.foster@oracle.com>
parents: 2830
diff changeset
  2782
                                                    allow_timestamp=True,
2966
6a97d8a803d3 16297554 pkg history fails when time travelling
thejaswini.k@oracle.com
parents: 2938
diff changeset
  2783
                                                    su_wrap=su_wrap,
6a97d8a803d3 16297554 pkg history fails when time travelling
thejaswini.k@oracle.com
parents: 2938
diff changeset
  2784
                                                    debug_hash=debug_hash)
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2785
                                                if retcode == 0 and published:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2786
                                                        plist.append(published)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2787
                                        except:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2788
                                                os.remove(f_path)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2789
                                                raise
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2790
                                        os.remove(f_path)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2791
                                if line.startswith("open"):
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2792
                                        current_fmri = line[5:].strip()
2456
063737b8ee9b 9809 pkgsend publish should take bundle files as sources for files
Shawn Walker <shawn.walker@oracle.com>
parents: 2453
diff changeset
  2793
                                        if commands.find("pkg.fmri") == -1:
063737b8ee9b 9809 pkgsend publish should take bundle files as sources for files
Shawn Walker <shawn.walker@oracle.com>
parents: 2453
diff changeset
  2794
                                                # If no explicit pkg.fmri set
063737b8ee9b 9809 pkgsend publish should take bundle files as sources for files
Shawn Walker <shawn.walker@oracle.com>
parents: 2453
diff changeset
  2795
                                                # action was found, add one.
063737b8ee9b 9809 pkgsend publish should take bundle files as sources for files
Shawn Walker <shawn.walker@oracle.com>
parents: 2453
diff changeset
  2796
                                                accumulate.append("set "
063737b8ee9b 9809 pkgsend publish should take bundle files as sources for files
Shawn Walker <shawn.walker@oracle.com>
parents: 2453
diff changeset
  2797
                                                    "name=pkg.fmri value=%s" %
063737b8ee9b 9809 pkgsend publish should take bundle files as sources for files
Shawn Walker <shawn.walker@oracle.com>
parents: 2453
diff changeset
  2798
                                                    current_fmri)
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2799
2028
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  2800
                        if exit == 0 and refresh_index:
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  2801
                                self.pkgrepo("-s %s refresh --no-catalog" %
2966
6a97d8a803d3 16297554 pkg history fails when time travelling
thejaswini.k@oracle.com
parents: 2938
diff changeset
  2802
                                    depot_url, su_wrap=su_wrap,
6a97d8a803d3 16297554 pkg history fails when time travelling
thejaswini.k@oracle.com
parents: 2938
diff changeset
  2803
                                    debug_hash=debug_hash)
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2804
                except UnexpectedExitCodeException, e:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2805
                        if e.exitcode != exit:
502
3f98e94acc4a 2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents: 448
diff changeset
  2806
                                raise
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2807
                        retcode = e.exitcode
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2808
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2809
                if retcode != exit:
2028
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  2810
                        raise UnexpectedExitCodeException(line, exit, retcode,
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  2811
                            self.output + self.errout)
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2812
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2813
                return plist
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2814
2026
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 1970
diff changeset
  2815
        def merge(self, args=EmptyI, exit=0):
2625
b87892e2e294 7137237 importer: exit stage left
Danek Duvall <danek.duvall@oracle.com>
parents: 2612
diff changeset
  2816
                cmd = "%s/usr/bin/pkgmerge %s" % (g_proto_area, " ".join(args))
2026
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 1970
diff changeset
  2817
                self.cmdline_run(cmd, exit=exit)
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 1970
diff changeset
  2818
2310
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  2819
        def sysrepo(self, args, exit=0, out=False, stderr=False, comment="",
2816
17425ca1f195 7192183 nasty depot testing should be part of core testing
Dan Price <daniel.price@oracle.com>
parents: 2808
diff changeset
  2820
            env_arg=None, fill_missing_args=True):
2310
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  2821
                ops = ""
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  2822
                if "-R" not in args:
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  2823
                        args += " -R %s" % self.get_img_path()
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  2824
                if "-c" not in args:
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  2825
                        args += " -c %s" % os.path.join(self.test_root,
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  2826
                            "sysrepo_cache")
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  2827
                if "-l" not in args:
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  2828
                        args += " -l %s" % os.path.join(self.test_root,
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  2829
                            "sysrepo_logs")
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  2830
                if "-p" not in args and fill_missing_args:
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  2831
                        args += " -p %s" % self.next_free_port
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  2832
                if "-r" not in args:
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  2833
                        args += " -r %s" % os.path.join(self.test_root,
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  2834
                            "sysrepo_runtime")
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  2835
                if "-t" not in args:
2852
5650587d9468 15807357 need an Apache-based pkg.depotd
Tim Foster <tim.s.foster@oracle.com>
parents: 2843
diff changeset
  2836
                        args += " -t %s" % self.sysrepo_template_dir
2310
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  2837
2816
17425ca1f195 7192183 nasty depot testing should be part of core testing
Dan Price <daniel.price@oracle.com>
parents: 2808
diff changeset
  2838
                cmdline = "%s/usr/lib/pkg.sysrepo %s" % (g_proto_area, args)
17425ca1f195 7192183 nasty depot testing should be part of core testing
Dan Price <daniel.price@oracle.com>
parents: 2808
diff changeset
  2839
                if env_arg is None:
17425ca1f195 7192183 nasty depot testing should be part of core testing
Dan Price <daniel.price@oracle.com>
parents: 2808
diff changeset
  2840
                        env_arg = {}
17425ca1f195 7192183 nasty depot testing should be part of core testing
Dan Price <daniel.price@oracle.com>
parents: 2808
diff changeset
  2841
                env_arg["PKG5_TEST_ENV"] = "1"
2310
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  2842
                return self.cmdline_run(cmdline, comment=comment, exit=exit,
2816
17425ca1f195 7192183 nasty depot testing should be part of core testing
Dan Price <daniel.price@oracle.com>
parents: 2808
diff changeset
  2843
                    out=out, stderr=stderr, env_arg=env_arg)
2310
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  2844
2852
5650587d9468 15807357 need an Apache-based pkg.depotd
Tim Foster <tim.s.foster@oracle.com>
parents: 2843
diff changeset
  2845
        def snooze(self, sleeptime=10800, show_stack=True):
5650587d9468 15807357 need an Apache-based pkg.depotd
Tim Foster <tim.s.foster@oracle.com>
parents: 2843
diff changeset
  2846
                """A convenient method to cause test execution to pause for
5650587d9468 15807357 need an Apache-based pkg.depotd
Tim Foster <tim.s.foster@oracle.com>
parents: 2843
diff changeset
  2847
                up to 'sleeptime' seconds, which can be helpful during testcase
5650587d9468 15807357 need an Apache-based pkg.depotd
Tim Foster <tim.s.foster@oracle.com>
parents: 2843
diff changeset
  2848
                development.  sleeptime defaults to 3 hours."""
5650587d9468 15807357 need an Apache-based pkg.depotd
Tim Foster <tim.s.foster@oracle.com>
parents: 2843
diff changeset
  2849
                self.debug("YAWN ... going to sleep now\n")
5650587d9468 15807357 need an Apache-based pkg.depotd
Tim Foster <tim.s.foster@oracle.com>
parents: 2843
diff changeset
  2850
                if show_stack:
5650587d9468 15807357 need an Apache-based pkg.depotd
Tim Foster <tim.s.foster@oracle.com>
parents: 2843
diff changeset
  2851
                        self.debug("\n\n\n")
5650587d9468 15807357 need an Apache-based pkg.depotd
Tim Foster <tim.s.foster@oracle.com>
parents: 2843
diff changeset
  2852
                        self.debug("".join(traceback.format_stack()))
5650587d9468 15807357 need an Apache-based pkg.depotd
Tim Foster <tim.s.foster@oracle.com>
parents: 2843
diff changeset
  2853
                time.sleep(sleeptime)
5650587d9468 15807357 need an Apache-based pkg.depotd
Tim Foster <tim.s.foster@oracle.com>
parents: 2843
diff changeset
  2854
5650587d9468 15807357 need an Apache-based pkg.depotd
Tim Foster <tim.s.foster@oracle.com>
parents: 2843
diff changeset
  2855
        def depotconfig(self, args, exit=0, out=False, stderr=False, comment="",
5650587d9468 15807357 need an Apache-based pkg.depotd
Tim Foster <tim.s.foster@oracle.com>
parents: 2843
diff changeset
  2856
            env_arg=None, fill_missing_args=True, debug_smf=True):
5650587d9468 15807357 need an Apache-based pkg.depotd
Tim Foster <tim.s.foster@oracle.com>
parents: 2843
diff changeset
  2857
                """Run pkg.depot-config, with command line arguments in args.
5650587d9468 15807357 need an Apache-based pkg.depotd
Tim Foster <tim.s.foster@oracle.com>
parents: 2843
diff changeset
  2858
                If fill_missing_args is set, we use default settings for several
5650587d9468 15807357 need an Apache-based pkg.depotd
Tim Foster <tim.s.foster@oracle.com>
parents: 2843
diff changeset
  2859
                arguments to point to template, logs, cache and proto areas
5650587d9468 15807357 need an Apache-based pkg.depotd
Tim Foster <tim.s.foster@oracle.com>
parents: 2843
diff changeset
  2860
                within our test root."""
5650587d9468 15807357 need an Apache-based pkg.depotd
Tim Foster <tim.s.foster@oracle.com>
parents: 2843
diff changeset
  2861
3063
bbaaf1579de3 15744850 no actuators are run when pkg manipulates a booted NGZ image from the GZ
thejaswini.k@oracle.com
parents: 3048
diff changeset
  2862
                if "-S" not in args and "-d " not in args and fill_missing_args:
2852
5650587d9468 15807357 need an Apache-based pkg.depotd
Tim Foster <tim.s.foster@oracle.com>
parents: 2843
diff changeset
  2863
                        args += " -S "
3063
bbaaf1579de3 15744850 no actuators are run when pkg manipulates a booted NGZ image from the GZ
thejaswini.k@oracle.com
parents: 3048
diff changeset
  2864
                if "-c " not in args and fill_missing_args:
2852
5650587d9468 15807357 need an Apache-based pkg.depotd
Tim Foster <tim.s.foster@oracle.com>
parents: 2843
diff changeset
  2865
                        args += " -c %s" % os.path.join(self.test_root,
5650587d9468 15807357 need an Apache-based pkg.depotd
Tim Foster <tim.s.foster@oracle.com>
parents: 2843
diff changeset
  2866
                            "depot_cache")
5650587d9468 15807357 need an Apache-based pkg.depotd
Tim Foster <tim.s.foster@oracle.com>
parents: 2843
diff changeset
  2867
                if "-l" not in args:
5650587d9468 15807357 need an Apache-based pkg.depotd
Tim Foster <tim.s.foster@oracle.com>
parents: 2843
diff changeset
  2868
                        args += " -l %s" % os.path.join(self.test_root,
5650587d9468 15807357 need an Apache-based pkg.depotd
Tim Foster <tim.s.foster@oracle.com>
parents: 2843
diff changeset
  2869
                            "depot_logs")
5650587d9468 15807357 need an Apache-based pkg.depotd
Tim Foster <tim.s.foster@oracle.com>
parents: 2843
diff changeset
  2870
                if "-p" not in args and "-F" not in args and fill_missing_args:
5650587d9468 15807357 need an Apache-based pkg.depotd
Tim Foster <tim.s.foster@oracle.com>
parents: 2843
diff changeset
  2871
                        args += " -p %s" % self.depot_port
5650587d9468 15807357 need an Apache-based pkg.depotd
Tim Foster <tim.s.foster@oracle.com>
parents: 2843
diff changeset
  2872
                if "-r" not in args:
5650587d9468 15807357 need an Apache-based pkg.depotd
Tim Foster <tim.s.foster@oracle.com>
parents: 2843
diff changeset
  2873
                        args += " -r %s" % os.path.join(self.test_root,
5650587d9468 15807357 need an Apache-based pkg.depotd
Tim Foster <tim.s.foster@oracle.com>
parents: 2843
diff changeset
  2874
                            "depot_runtime")
5650587d9468 15807357 need an Apache-based pkg.depotd
Tim Foster <tim.s.foster@oracle.com>
parents: 2843
diff changeset
  2875
                if "-T" not in args:
5650587d9468 15807357 need an Apache-based pkg.depotd
Tim Foster <tim.s.foster@oracle.com>
parents: 2843
diff changeset
  2876
                        args += " -T %s" % self.depot_template_dir
5650587d9468 15807357 need an Apache-based pkg.depotd
Tim Foster <tim.s.foster@oracle.com>
parents: 2843
diff changeset
  2877
5650587d9468 15807357 need an Apache-based pkg.depotd
Tim Foster <tim.s.foster@oracle.com>
parents: 2843
diff changeset
  2878
                if debug_smf and "smf_cmds_dir" not in args:
5650587d9468 15807357 need an Apache-based pkg.depotd
Tim Foster <tim.s.foster@oracle.com>
parents: 2843
diff changeset
  2879
                        args += " --debug smf_cmds_dir=%s" % \
5650587d9468 15807357 need an Apache-based pkg.depotd
Tim Foster <tim.s.foster@oracle.com>
parents: 2843
diff changeset
  2880
                            DebugValues["smf_cmds_dir"]
5650587d9468 15807357 need an Apache-based pkg.depotd
Tim Foster <tim.s.foster@oracle.com>
parents: 2843
diff changeset
  2881
5650587d9468 15807357 need an Apache-based pkg.depotd
Tim Foster <tim.s.foster@oracle.com>
parents: 2843
diff changeset
  2882
                cmdline = "%s/usr/lib/pkg.depot-config %s" % (g_proto_area,
5650587d9468 15807357 need an Apache-based pkg.depotd
Tim Foster <tim.s.foster@oracle.com>
parents: 2843
diff changeset
  2883
                    args)
5650587d9468 15807357 need an Apache-based pkg.depotd
Tim Foster <tim.s.foster@oracle.com>
parents: 2843
diff changeset
  2884
                if env_arg is None:
5650587d9468 15807357 need an Apache-based pkg.depotd
Tim Foster <tim.s.foster@oracle.com>
parents: 2843
diff changeset
  2885
                        env_arg = {}
5650587d9468 15807357 need an Apache-based pkg.depotd
Tim Foster <tim.s.foster@oracle.com>
parents: 2843
diff changeset
  2886
                env_arg["PKG5_TEST_PROTO"] = g_proto_area
5650587d9468 15807357 need an Apache-based pkg.depotd
Tim Foster <tim.s.foster@oracle.com>
parents: 2843
diff changeset
  2887
                return self.cmdline_run(cmdline, comment=comment, exit=exit,
5650587d9468 15807357 need an Apache-based pkg.depotd
Tim Foster <tim.s.foster@oracle.com>
parents: 2843
diff changeset
  2888
                    out=out, stderr=stderr, env_arg=env_arg)
5650587d9468 15807357 need an Apache-based pkg.depotd
Tim Foster <tim.s.foster@oracle.com>
parents: 2843
diff changeset
  2889
2028
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  2890
        def copy_repository(self, src, dest, pub_map):
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2891
                """Copies the packages from the src repository to a new
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2892
                destination repository that will be created at dest.  In
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2893
                addition, any packages from the src_pub will be assigned
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2894
                to the dest_pub during the copy.  The new repository will
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2895
                not have a catalog or search indices, so a depot server
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2896
                pointed at the new repository must be started with the
2028
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  2897
                --rebuild option.
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  2898
                """
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2899
2097
068cc63b4d6e 17055 image configuration should use pkg.config classes
Shawn Walker <shawn.walker@oracle.com>
parents: 2092
diff changeset
  2900
                # Preserve destination repository's configuration if it exists.
2028
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  2901
                dest_cfg = os.path.join(dest, "pkg5.repository")
1736
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1730
diff changeset
  2902
                dest_cfg_data = None
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1730
diff changeset
  2903
                if os.path.exists(dest_cfg):
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1730
diff changeset
  2904
                        with open(dest_cfg, "rb") as f:
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1730
diff changeset
  2905
                                dest_cfg_data = f.read()
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2906
                shutil.rmtree(dest, True)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2907
                os.makedirs(dest, mode=0755)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2908
1736
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1730
diff changeset
  2909
                # Ensure config is written back out.
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1730
diff changeset
  2910
                if dest_cfg_data:
2073
9fcacc9e5eaa 16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents: 2047
diff changeset
  2911
                        with open(dest_cfg, "wb") as f:
9fcacc9e5eaa 16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents: 2047
diff changeset
  2912
                                f.write(dest_cfg_data)
1736
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1730
diff changeset
  2913
2028
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  2914
                def copy_manifests(src_root, dest_root):
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  2915
                        # Now copy each manifest and replace any references to
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  2916
                        # the old publisher with that of the new publisher as
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  2917
                        # they are copied.
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  2918
                        src_pkg_root = os.path.join(src_root, "pkg")
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  2919
                        dest_pkg_root = os.path.join(dest_root, "pkg")
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  2920
                        for stem in os.listdir(src_pkg_root):
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  2921
                                src_pkg_path = os.path.join(src_pkg_root, stem)
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  2922
                                dest_pkg_path = os.path.join(dest_pkg_root,
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  2923
                                    stem)
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  2924
                                for mname in os.listdir(src_pkg_path):
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  2925
                                        # Ensure destination manifest directory
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  2926
                                        # exists.
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  2927
                                        if not os.path.isdir(dest_pkg_path):
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  2928
                                                os.makedirs(dest_pkg_path,
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  2929
                                                    mode=0755)
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2930
2028
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  2931
                                        msrc = open(os.path.join(src_pkg_path,
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  2932
                                            mname), "rb")
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  2933
                                        mdest = open(os.path.join(dest_pkg_path,
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  2934
                                            mname), "wb")
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  2935
                                        for l in msrc:
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  2936
                                                if l.find("pkg://") == -1:
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  2937
                                                        mdest.write(l)
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  2938
                                                        continue
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  2939
                                                nl = l
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  2940
                                                for src_pub in pub_map:
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  2941
                                                        nl = nl.replace(
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  2942
                                                            src_pub,
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  2943
                                                            pub_map[src_pub])
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  2944
                                                mdest.write(nl)
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  2945
                                        msrc.close()
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  2946
                                        mdest.close()
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2947
2028
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  2948
                src_pub_root = os.path.join(src, "publisher")
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  2949
                if os.path.exists(src_pub_root):
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  2950
                        dest_pub_root = os.path.join(dest, "publisher")
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  2951
                        for pub in os.listdir(src_pub_root):
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  2952
                                if pub not in pub_map:
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  2953
                                        continue
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  2954
                                src_root = os.path.join(src_pub_root, pub)
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  2955
                                dest_root = os.path.join(dest_pub_root,
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  2956
                                    pub_map[pub])
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  2957
                                for entry in os.listdir(src_root):
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  2958
                                        # Skip the catalog, index, and pkg
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  2959
                                        # directories as they will be copied
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  2960
                                        # manually.
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  2961
                                        if entry not in ("catalog", "index",
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  2962
                                            "pkg", "tmp", "trans"):
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  2963
                                                spath = os.path.join(src_root,
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  2964
                                                    entry)
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  2965
                                                dpath = os.path.join(dest_root,
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  2966
                                                    entry)
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  2967
                                                shutil.copytree(spath, dpath)
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  2968
                                                continue
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  2969
                                        if entry != "pkg":
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  2970
                                                continue
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  2971
                                        copy_manifests(src_root, dest_root)
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  2972
2339
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  2973
        def get_img_manifest_cache_dir(self, pfmri, ii=None):
2475
77cfb483dd88 18486 package operations can fail during cache cleanup
Shawn Walker <shawn.walker@oracle.com>
parents: 2456
diff changeset
  2974
                """Returns the path to the manifest cache directory for the
77cfb483dd88 18486 package operations can fail during cache cleanup
Shawn Walker <shawn.walker@oracle.com>
parents: 2456
diff changeset
  2975
                given fmri."""
2144
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2097
diff changeset
  2976
2339
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  2977
                img = self.get_img_api_obj(ii=ii).img
2144
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2097
diff changeset
  2978
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2097
diff changeset
  2979
                if not pfmri.publisher:
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2097
diff changeset
  2980
                        # Allow callers to not specify a fully-qualified FMRI
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2097
diff changeset
  2981
                        # if it can be asssumed which publisher likely has
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2097
diff changeset
  2982
                        # the package.
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2097
diff changeset
  2983
                        pubs = [
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2097
diff changeset
  2984
                            p.prefix
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2097
diff changeset
  2985
                            for p in img.gen_publishers(inc_disabled=True)
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2097
diff changeset
  2986
                        ]
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2097
diff changeset
  2987
                        assert len(pubs) == 1
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2097
diff changeset
  2988
                        pfmri.publisher = pubs[0]
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2097
diff changeset
  2989
                return img.get_manifest_dir(pfmri)
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2097
diff changeset
  2990
2339
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  2991
        def get_img_manifest_path(self, pfmri):
2073
9fcacc9e5eaa 16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents: 2047
diff changeset
  2992
                """Returns the path to the manifest for the given fmri."""
2026
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 1970
diff changeset
  2993
2339
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  2994
                img = self.get_img_api_obj().img
2026
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 1970
diff changeset
  2995
2144
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2097
diff changeset
  2996
                if not pfmri.publisher:
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2097
diff changeset
  2997
                        # Allow callers to not specify a fully-qualified FMRI
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2097
diff changeset
  2998
                        # if it can be asssumed which publisher likely has
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2097
diff changeset
  2999
                        # the package.
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2097
diff changeset
  3000
                        pubs = [
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2097
diff changeset
  3001
                            p.prefix
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2097
diff changeset
  3002
                            for p in img.gen_publishers(inc_disabled=True)
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2097
diff changeset
  3003
                        ]
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2097
diff changeset
  3004
                        assert len(pubs) == 1
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2097
diff changeset
  3005
                        pfmri.publisher = pubs[0]
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2097
diff changeset
  3006
                return img.get_manifest_path(pfmri)
2026
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 1970
diff changeset
  3007
2339
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  3008
        def get_img_manifest(self, pfmri):
1755
8e1ed1373f93 9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents: 1736
diff changeset
  3009
                """Retrieves the client's cached copy of the manifest for the
8e1ed1373f93 9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents: 1736
diff changeset
  3010
                given package FMRI and returns it as a string.  Callers are
8e1ed1373f93 9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents: 1736
diff changeset
  3011
                responsible for all error handling."""
8e1ed1373f93 9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents: 1736
diff changeset
  3012
2339
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  3013
                mpath = self.get_img_manifest_path(pfmri)
1755
8e1ed1373f93 9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents: 1736
diff changeset
  3014
                with open(mpath, "rb") as f:
8e1ed1373f93 9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents: 1736
diff changeset
  3015
                        return f.read()
8e1ed1373f93 9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents: 1736
diff changeset
  3016
2339
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  3017
        def write_img_manifest(self, pfmri, mdata):
1755
8e1ed1373f93 9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents: 1736
diff changeset
  3018
                """Overwrites the client's cached copy of the manifest for the
8e1ed1373f93 9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents: 1736
diff changeset
  3019
                given package FMRI using the provided string.  Callers are
8e1ed1373f93 9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents: 1736
diff changeset
  3020
                responsible for all error handling."""
8e1ed1373f93 9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents: 1736
diff changeset
  3021
2339
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  3022
                mpath = self.get_img_manifest_path(pfmri)
3048
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
  3023
                mdir = os.path.dirname(mpath)
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
  3024
                mcdir = self.get_img_manifest_cache_dir(pfmri)
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
  3025
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
  3026
                # Dump the manifest directories for the package to ensure any
1755
8e1ed1373f93 9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents: 1736
diff changeset
  3027
                # cached information related to it is gone.
8e1ed1373f93 9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents: 1736
diff changeset
  3028
                shutil.rmtree(mdir, True)
3048
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
  3029
                shutil.rmtree(mcdir, True)
1755
8e1ed1373f93 9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents: 1736
diff changeset
  3030
                self.assert_(not os.path.exists(mdir))
3048
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
  3031
                self.assert_(not os.path.exists(mcdir))
1755
8e1ed1373f93 9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents: 1736
diff changeset
  3032
                os.makedirs(mdir, mode=0755)
3048
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
  3033
                os.makedirs(mcdir, mode=0755)
1755
8e1ed1373f93 9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents: 1736
diff changeset
  3034
8e1ed1373f93 9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents: 1736
diff changeset
  3035
                # Finally, write the new manifest.
8e1ed1373f93 9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents: 1736
diff changeset
  3036
                with open(mpath, "wb") as f:
8e1ed1373f93 9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents: 1736
diff changeset
  3037
                        f.write(mdata)
8e1ed1373f93 9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents: 1736
diff changeset
  3038
2339
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  3039
        def validate_fsobj_attrs(self, act, target=None):
1832
df15686547e4 6795 pkg fix should fix file modes for some preserved files
Shawn Walker <shawn.walker@oracle.com>
parents: 1795
diff changeset
  3040
                """Used to verify that the target item's mode, attrs, timestamp,
df15686547e4 6795 pkg fix should fix file modes for some preserved files
Shawn Walker <shawn.walker@oracle.com>
parents: 1795
diff changeset
  3041
                etc. match as expected.  The actual"""
df15686547e4 6795 pkg fix should fix file modes for some preserved files
Shawn Walker <shawn.walker@oracle.com>
parents: 1795
diff changeset
  3042
df15686547e4 6795 pkg fix should fix file modes for some preserved files
Shawn Walker <shawn.walker@oracle.com>
parents: 1795
diff changeset
  3043
                if act.name not in ("file", "dir"):
df15686547e4 6795 pkg fix should fix file modes for some preserved files
Shawn Walker <shawn.walker@oracle.com>
parents: 1795
diff changeset
  3044
                        return
df15686547e4 6795 pkg fix should fix file modes for some preserved files
Shawn Walker <shawn.walker@oracle.com>
parents: 1795
diff changeset
  3045
2339
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  3046
                img_path = self.img_path()
1832
df15686547e4 6795 pkg fix should fix file modes for some preserved files
Shawn Walker <shawn.walker@oracle.com>
parents: 1795
diff changeset
  3047
                if not target:
df15686547e4 6795 pkg fix should fix file modes for some preserved files
Shawn Walker <shawn.walker@oracle.com>
parents: 1795
diff changeset
  3048
                        target = act.attrs["path"]
df15686547e4 6795 pkg fix should fix file modes for some preserved files
Shawn Walker <shawn.walker@oracle.com>
parents: 1795
diff changeset
  3049
df15686547e4 6795 pkg fix should fix file modes for some preserved files
Shawn Walker <shawn.walker@oracle.com>
parents: 1795
diff changeset
  3050
                fpath = os.path.join(img_path, target)
df15686547e4 6795 pkg fix should fix file modes for some preserved files
Shawn Walker <shawn.walker@oracle.com>
parents: 1795
diff changeset
  3051
                lstat = os.lstat(fpath)
df15686547e4 6795 pkg fix should fix file modes for some preserved files
Shawn Walker <shawn.walker@oracle.com>
parents: 1795
diff changeset
  3052
df15686547e4 6795 pkg fix should fix file modes for some preserved files
Shawn Walker <shawn.walker@oracle.com>
parents: 1795
diff changeset
  3053
                # Verify owner.
df15686547e4 6795 pkg fix should fix file modes for some preserved files
Shawn Walker <shawn.walker@oracle.com>
parents: 1795
diff changeset
  3054
                expected = portable.get_user_by_name(act.attrs["owner"], None,
df15686547e4 6795 pkg fix should fix file modes for some preserved files
Shawn Walker <shawn.walker@oracle.com>
parents: 1795
diff changeset
  3055
                    False)
df15686547e4 6795 pkg fix should fix file modes for some preserved files
Shawn Walker <shawn.walker@oracle.com>
parents: 1795
diff changeset
  3056
                actual = lstat.st_uid
df15686547e4 6795 pkg fix should fix file modes for some preserved files
Shawn Walker <shawn.walker@oracle.com>
parents: 1795
diff changeset
  3057
                self.assertEqual(expected, actual)
df15686547e4 6795 pkg fix should fix file modes for some preserved files
Shawn Walker <shawn.walker@oracle.com>
parents: 1795
diff changeset
  3058
df15686547e4 6795 pkg fix should fix file modes for some preserved files
Shawn Walker <shawn.walker@oracle.com>
parents: 1795
diff changeset
  3059
                # Verify group.
df15686547e4 6795 pkg fix should fix file modes for some preserved files
Shawn Walker <shawn.walker@oracle.com>
parents: 1795
diff changeset
  3060
                expected = portable.get_group_by_name(act.attrs["group"], None,
df15686547e4 6795 pkg fix should fix file modes for some preserved files
Shawn Walker <shawn.walker@oracle.com>
parents: 1795
diff changeset
  3061
                    False)
df15686547e4 6795 pkg fix should fix file modes for some preserved files
Shawn Walker <shawn.walker@oracle.com>
parents: 1795
diff changeset
  3062
                actual = lstat.st_gid
df15686547e4 6795 pkg fix should fix file modes for some preserved files
Shawn Walker <shawn.walker@oracle.com>
parents: 1795
diff changeset
  3063
                self.assertEqual(expected, actual)
df15686547e4 6795 pkg fix should fix file modes for some preserved files
Shawn Walker <shawn.walker@oracle.com>
parents: 1795
diff changeset
  3064
df15686547e4 6795 pkg fix should fix file modes for some preserved files
Shawn Walker <shawn.walker@oracle.com>
parents: 1795
diff changeset
  3065
                # Verify mode.
df15686547e4 6795 pkg fix should fix file modes for some preserved files
Shawn Walker <shawn.walker@oracle.com>
parents: 1795
diff changeset
  3066
                expected = int(act.attrs["mode"], 8)
df15686547e4 6795 pkg fix should fix file modes for some preserved files
Shawn Walker <shawn.walker@oracle.com>
parents: 1795
diff changeset
  3067
                actual = stat.S_IMODE(lstat.st_mode)
df15686547e4 6795 pkg fix should fix file modes for some preserved files
Shawn Walker <shawn.walker@oracle.com>
parents: 1795
diff changeset
  3068
                self.assertEqual(expected, actual)
df15686547e4 6795 pkg fix should fix file modes for some preserved files
Shawn Walker <shawn.walker@oracle.com>
parents: 1795
diff changeset
  3069
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3070
        def validate_html_file(self, fname, exit=0, comment="",
2603
6b463bf6de94 19064 pkg BUI needs another update
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2595
diff changeset
  3071
            options="-utf8 -quiet", drop_prop_attrs=False):
6b463bf6de94 19064 pkg BUI needs another update
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2595
diff changeset
  3072
                """ Run a html file specified by fname through a html validator
6b463bf6de94 19064 pkg BUI needs another update
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2595
diff changeset
  3073
                    (tidy). The drop_prop_attrs parameter can be used to ignore 
6b463bf6de94 19064 pkg BUI needs another update
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2595
diff changeset
  3074
                    proprietary attributes which would otherwise make tidy fail.
6b463bf6de94 19064 pkg BUI needs another update
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2595
diff changeset
  3075
                """
6b463bf6de94 19064 pkg BUI needs another update
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2595
diff changeset
  3076
                if drop_prop_attrs:
2693
cfee571ea6d5 7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents: 2690
diff changeset
  3077
                        tfname = fname + ".tmp"
cfee571ea6d5 7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents: 2690
diff changeset
  3078
                        os.rename(fname, tfname)
cfee571ea6d5 7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents: 2690
diff changeset
  3079
                        moptions = options + " --drop-proprietary-attributes y"
2603
6b463bf6de94 19064 pkg BUI needs another update
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2595
diff changeset
  3080
                        cmdline = "tidy %s %s > %s" % (moptions, tfname, fname)
6b463bf6de94 19064 pkg BUI needs another update
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2595
diff changeset
  3081
                        self.cmdline_run(cmdline, comment=comment,
6b463bf6de94 19064 pkg BUI needs another update
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2595
diff changeset
  3082
                            coverage=False, exit=exit, raise_error=False)
2693
cfee571ea6d5 7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents: 2690
diff changeset
  3083
                        os.unlink(tfname)
2603
6b463bf6de94 19064 pkg BUI needs another update
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2595
diff changeset
  3084
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3085
                cmdline = "tidy %s %s" % (options, fname)
2026
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 1970
diff changeset
  3086
                return self.cmdline_run(cmdline, comment=comment,
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 1970
diff changeset
  3087
                    coverage=False, exit=exit)
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3088
2028
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  3089
        def create_repo(self, repodir, properties=EmptyDict, version=None):
1895
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1890
diff changeset
  3090
                """ Convenience routine to help subclasses create a package
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1890
diff changeset
  3091
                    repository.  Returns a pkg.server.repository.Repository
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1890
diff changeset
  3092
                    object. """
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1890
diff changeset
  3093
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1890
diff changeset
  3094
                # Note that this must be deferred until after PYTHONPATH
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1890
diff changeset
  3095
                # is set up.
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1890
diff changeset
  3096
                import pkg.server.repository as sr
2028
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  3097
                try:
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  3098
                        repo = sr.repository_create(repodir,
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  3099
                            properties=properties, version=version)
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  3100
                        self.debug("created repository %s" % repodir)
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  3101
                except sr.RepositoryExistsError:
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  3102
                        # Already exists.
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  3103
                        repo = sr.Repository(root=repodir,
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  3104
                            properties=properties)
1895
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1890
diff changeset
  3105
                return repo
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1890
diff changeset
  3106
1968
c0540b1e4f7e 8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents: 1949
diff changeset
  3107
        def get_repo(self, repodir, read_only=False):
c0540b1e4f7e 8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents: 1949
diff changeset
  3108
                """ Convenience routine to help subclasses retrieve a
c0540b1e4f7e 8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents: 1949
diff changeset
  3109
                    pkg.server.repository.Repository object for a given
c0540b1e4f7e 8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents: 1949
diff changeset
  3110
                    path. """
c0540b1e4f7e 8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents: 1949
diff changeset
  3111
c0540b1e4f7e 8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents: 1949
diff changeset
  3112
                # Note that this must be deferred until after PYTHONPATH
c0540b1e4f7e 8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents: 1949
diff changeset
  3113
                # is set up.
c0540b1e4f7e 8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents: 1949
diff changeset
  3114
                import pkg.server.repository as sr
2028
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  3115
                return sr.Repository(read_only=read_only, root=repodir)
1968
c0540b1e4f7e 8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents: 1949
diff changeset
  3116
1895
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1890
diff changeset
  3117
        def prep_depot(self, port, repodir, logpath, refresh_index=False,
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1890
diff changeset
  3118
            debug_features=EmptyI, properties=EmptyI, start=False):
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1890
diff changeset
  3119
                """ Convenience routine to help subclasses prepare
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3120
                    depots.  Returns a depotcontroller. """
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3121
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3122
                # Note that this must be deferred until after PYTHONPATH
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3123
                # is set up.
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3124
                import pkg.depotcontroller as depotcontroller
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3125
1895
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1890
diff changeset
  3126
                self.debug("prep_depot: set depot port %d" % port)
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1890
diff changeset
  3127
                self.debug("prep_depot: set depot repository %s" % repodir)
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1890
diff changeset
  3128
                self.debug("prep_depot: set depot log to %s" % logpath)
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3129
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3130
                dc = depotcontroller.DepotController(
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3131
                    wrapper_start=self.coverage_cmd.split(),
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3132
                    env=self.coverage_env)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3133
                dc.set_depotd_path(g_proto_area + "/usr/lib/pkg.depotd")
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3134
                dc.set_depotd_content_root(g_proto_area + "/usr/share/lib/pkg")
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3135
                for f in debug_features:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3136
                        dc.set_debug_feature(f)
1895
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1890
diff changeset
  3137
                dc.set_repodir(repodir)
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3138
                dc.set_logpath(logpath)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3139
                dc.set_port(port)
1736
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1730
diff changeset
  3140
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3141
                for section in properties:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3142
                        for prop, val in properties[section].iteritems():
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3143
                                dc.set_property(section, prop, val)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3144
                if refresh_index:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3145
                        dc.set_refresh_index()
1895
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1890
diff changeset
  3146
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1890
diff changeset
  3147
                if start:
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1890
diff changeset
  3148
                        # If the caller requested the depot be started, then let
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1890
diff changeset
  3149
                        # the depot process create the repository.
2720
66a86306e53e 7179255 pkg5 code coverage has rotted and doesn't work anymore
Dan Price <daniel.price@oracle.com>
parents: 2708
diff changeset
  3150
                        self.debug("prep_depot: starting depot")
66a86306e53e 7179255 pkg5 code coverage has rotted and doesn't work anymore
Dan Price <daniel.price@oracle.com>
parents: 2708
diff changeset
  3151
                        try:
66a86306e53e 7179255 pkg5 code coverage has rotted and doesn't work anymore
Dan Price <daniel.price@oracle.com>
parents: 2708
diff changeset
  3152
                                dc.start()
66a86306e53e 7179255 pkg5 code coverage has rotted and doesn't work anymore
Dan Price <daniel.price@oracle.com>
parents: 2708
diff changeset
  3153
                        except Exception, e:
66a86306e53e 7179255 pkg5 code coverage has rotted and doesn't work anymore
Dan Price <daniel.price@oracle.com>
parents: 2708
diff changeset
  3154
                                self.debug("prep_depot: failed to start "
66a86306e53e 7179255 pkg5 code coverage has rotted and doesn't work anymore
Dan Price <daniel.price@oracle.com>
parents: 2708
diff changeset
  3155
                                    "depot!: %s" % e)
66a86306e53e 7179255 pkg5 code coverage has rotted and doesn't work anymore
Dan Price <daniel.price@oracle.com>
parents: 2708
diff changeset
  3156
                                raise
1895
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1890
diff changeset
  3157
                        self.debug("depot on port %s started" % port)
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1890
diff changeset
  3158
                else:
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1890
diff changeset
  3159
                        # Otherwise, create the repository with the assumption
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1890
diff changeset
  3160
                        # that the caller wants that at the least, but doesn't
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1890
diff changeset
  3161
                        # need the depot server (yet).
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1890
diff changeset
  3162
                        self.create_repo(repodir, properties=properties)
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3163
                return dc
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3164
2028
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  3165
        def wait_repo(self, repodir, timeout=5.0):
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  3166
                """Wait for the specified repository to complete its current
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  3167
                operations before continuing."""
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  3168
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  3169
                check_interval = 0.20
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  3170
                time.sleep(check_interval)
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  3171
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  3172
                begintime = time.time()
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  3173
                ready = False
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  3174
                while (time.time() - begintime) <= timeout:
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  3175
                        status = self.get_repo(repodir).get_status()
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  3176
                        rdata = status.get("repository", {})
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  3177
                        repo_status = rdata.get("status", "")
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  3178
                        if repo_status == "online":
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  3179
                                for pubdata in rdata.get("publishers",
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  3180
                                    {}).values():
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  3181
                                        if pubdata.get("status", "") != "online":
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  3182
                                                ready = False
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  3183
                                                break
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  3184
                                else:
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  3185
                                        # All repository stores were ready.
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  3186
                                        ready = True
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  3187
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  3188
                        if not ready:
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  3189
                                time.sleep(check_interval)
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  3190
                        else:
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  3191
                                break
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  3192
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  3193
                if not ready:
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  3194
                        raise RuntimeError("Repository readiness "
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  3195
                            "timeout exceeded.")
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  3196
2339
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  3197
        def _api_attach(self, api_obj, catch_wsie=True, **kwargs):
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  3198
                self.debug("attach: %s" % str(kwargs))
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  3199
                for pd in api_obj.gen_plan_attach(**kwargs):
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  3200
                        continue
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  3201
                self._api_finish(api_obj, catch_wsie=catch_wsie)
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  3202
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  3203
        def _api_detach(self, api_obj, catch_wsie=True, **kwargs):
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  3204
                self.debug("detach: %s" % str(kwargs))
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  3205
                for pd in api_obj.gen_plan_detach(**kwargs):
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  3206
                        continue
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  3207
                self._api_finish(api_obj, catch_wsie=catch_wsie)
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  3208
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  3209
        def _api_sync(self, api_obj, catch_wsie=True, **kwargs):
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  3210
                self.debug("sync: %s" % str(kwargs))
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  3211
                for pd in api_obj.gen_plan_sync(**kwargs):
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  3212
                        continue
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  3213
                self._api_finish(api_obj, catch_wsie=catch_wsie)
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  3214
2627
b2198703ee08 7140797 package plan object should be easier to serialize
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2625
diff changeset
  3215
        def _api_install(self, api_obj, pkg_list, catch_wsie=True,
2681
29aba686b970 7140060 install and update should allow multiple pattern matches when they intersect
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2675
diff changeset
  3216
            show_licenses=False, accept_licenses=False, noexecute=False,
29aba686b970 7140060 install and update should allow multiple pattern matches when they intersect
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2675
diff changeset
  3217
            **kwargs):
1886
650a8de627ae 15777 pkgdep resolve should provide an option to only resolve against the manifests provided
Brock Pytlik <bpytlik@sun.com>
parents: 1859
diff changeset
  3218
                self.debug("install %s" % " ".join(pkg_list))
2627
b2198703ee08 7140797 package plan object should be easier to serialize
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2625
diff changeset
  3219
2690
11a8cae074e0 7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2681
diff changeset
  3220
                plan = None
2681
29aba686b970 7140060 install and update should allow multiple pattern matches when they intersect
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2675
diff changeset
  3221
                for pd in api_obj.gen_plan_install(pkg_list,
29aba686b970 7140060 install and update should allow multiple pattern matches when they intersect
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2675
diff changeset
  3222
                    noexecute=noexecute, **kwargs):
2690
11a8cae074e0 7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2681
diff changeset
  3223
11a8cae074e0 7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2681
diff changeset
  3224
                        if plan is not None:
11a8cae074e0 7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2681
diff changeset
  3225
                                continue
11a8cae074e0 7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2681
diff changeset
  3226
                        plan = api_obj.describe()
11a8cae074e0 7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2681
diff changeset
  3227
3048
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
  3228
                        # update license status
2690
11a8cae074e0 7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2681
diff changeset
  3229
                        for pfmri, src, dest, accepted, displayed in \
11a8cae074e0 7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2681
diff changeset
  3230
                            plan.get_licenses():
11a8cae074e0 7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2681
diff changeset
  3231
                                api_obj.set_plan_license_status(pfmri,
11a8cae074e0 7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2681
diff changeset
  3232
                                    dest.license,
11a8cae074e0 7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2681
diff changeset
  3233
                                    displayed=show_licenses,
11a8cae074e0 7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2681
diff changeset
  3234
                                    accepted=accept_licenses)
2627
b2198703ee08 7140797 package plan object should be easier to serialize
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2625
diff changeset
  3235
2681
29aba686b970 7140060 install and update should allow multiple pattern matches when they intersect
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2675
diff changeset
  3236
                if noexecute:
29aba686b970 7140060 install and update should allow multiple pattern matches when they intersect
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2675
diff changeset
  3237
                        return
29aba686b970 7140060 install and update should allow multiple pattern matches when they intersect
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2675
diff changeset
  3238
2690
11a8cae074e0 7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2681
diff changeset
  3239
                self._api_finish(api_obj, catch_wsie=catch_wsie)
2339
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  3240
3063
bbaaf1579de3 15744850 no actuators are run when pkg manipulates a booted NGZ image from the GZ
thejaswini.k@oracle.com
parents: 3048
diff changeset
  3241
        def _api_revert(self, api_obj, args, catch_wsie=True, noexecute=False,
bbaaf1579de3 15744850 no actuators are run when pkg manipulates a booted NGZ image from the GZ
thejaswini.k@oracle.com
parents: 3048
diff changeset
  3242
            **kwargs):
bbaaf1579de3 15744850 no actuators are run when pkg manipulates a booted NGZ image from the GZ
thejaswini.k@oracle.com
parents: 3048
diff changeset
  3243
                self.debug("revert %s" % " ".join(args))
bbaaf1579de3 15744850 no actuators are run when pkg manipulates a booted NGZ image from the GZ
thejaswini.k@oracle.com
parents: 3048
diff changeset
  3244
                for pd in api_obj.gen_plan_revert(args, **kwargs):
bbaaf1579de3 15744850 no actuators are run when pkg manipulates a booted NGZ image from the GZ
thejaswini.k@oracle.com
parents: 3048
diff changeset
  3245
                        continue
bbaaf1579de3 15744850 no actuators are run when pkg manipulates a booted NGZ image from the GZ
thejaswini.k@oracle.com
parents: 3048
diff changeset
  3246
                if noexecute:
bbaaf1579de3 15744850 no actuators are run when pkg manipulates a booted NGZ image from the GZ
thejaswini.k@oracle.com
parents: 3048
diff changeset
  3247
                        return
bbaaf1579de3 15744850 no actuators are run when pkg manipulates a booted NGZ image from the GZ
thejaswini.k@oracle.com
parents: 3048
diff changeset
  3248
                self._api_finish(api_obj, catch_wsie=catch_wsie)
bbaaf1579de3 15744850 no actuators are run when pkg manipulates a booted NGZ image from the GZ
thejaswini.k@oracle.com
parents: 3048
diff changeset
  3249
2339
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  3250
        def _api_uninstall(self, api_obj, pkg_list, catch_wsie=True, **kwargs):
1886
650a8de627ae 15777 pkgdep resolve should provide an option to only resolve against the manifests provided
Brock Pytlik <bpytlik@sun.com>
parents: 1859
diff changeset
  3251
                self.debug("uninstall %s" % " ".join(pkg_list))
2382
b91a97e46434 18413 recursive uninstall functionality should be removed
Shawn Walker <shawn.walker@oracle.com>
parents: 2381
diff changeset
  3252
                for pd in api_obj.gen_plan_uninstall(pkg_list, **kwargs):
2339
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  3253
                        continue
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  3254
                self._api_finish(api_obj, catch_wsie=catch_wsie)
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  3255
2681
29aba686b970 7140060 install and update should allow multiple pattern matches when they intersect
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2675
diff changeset
  3256
        def _api_update(self, api_obj, catch_wsie=True, noexecute=False,
29aba686b970 7140060 install and update should allow multiple pattern matches when they intersect
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2675
diff changeset
  3257
            **kwargs):
2089
c8b9d6341530 2775 pkg should provide a way to downgrade (reinstall) packages
Shawn Walker <shawn.walker@oracle.com>
parents: 2085
diff changeset
  3258
                self.debug("planning update")
2681
29aba686b970 7140060 install and update should allow multiple pattern matches when they intersect
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2675
diff changeset
  3259
                for pd in api_obj.gen_plan_update(noexecute=noexecute,
29aba686b970 7140060 install and update should allow multiple pattern matches when they intersect
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2675
diff changeset
  3260
                    **kwargs):
2339
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  3261
                        continue
2681
29aba686b970 7140060 install and update should allow multiple pattern matches when they intersect
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2675
diff changeset
  3262
                if noexecute:
29aba686b970 7140060 install and update should allow multiple pattern matches when they intersect
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2675
diff changeset
  3263
                        return
2339
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  3264
                self._api_finish(api_obj, catch_wsie=catch_wsie)
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  3265
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  3266
        def _api_change_varcets(self, api_obj, catch_wsie=True, **kwargs):
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  3267
                self.debug("change varcets: %s" % str(kwargs))
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  3268
                for pd in api_obj.gen_plan_change_varcets(**kwargs):
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  3269
                        continue
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  3270
                self._api_finish(api_obj, catch_wsie=catch_wsie)
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  3271
2690
11a8cae074e0 7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2681
diff changeset
  3272
        def _api_finish(self, api_obj, catch_wsie=True):
2627
b2198703ee08 7140797 package plan object should be easier to serialize
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2625
diff changeset
  3273
1886
650a8de627ae 15777 pkgdep resolve should provide an option to only resolve against the manifests provided
Brock Pytlik <bpytlik@sun.com>
parents: 1859
diff changeset
  3274
                api_obj.prepare()
2339
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  3275
                try:
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  3276
                        api_obj.execute_plan()
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  3277
                except apx.WrapSuccessfulIndexingException:
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  3278
                        if not catch_wsie:
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  3279
                                raise
1886
650a8de627ae 15777 pkgdep resolve should provide an option to only resolve against the manifests provided
Brock Pytlik <bpytlik@sun.com>
parents: 1859
diff changeset
  3280
                api_obj.reset()
650a8de627ae 15777 pkgdep resolve should provide an option to only resolve against the manifests provided
Brock Pytlik <bpytlik@sun.com>
parents: 1859
diff changeset
  3281
2274
1c8cd2ff57d3 17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents: 2272
diff changeset
  3282
        def file_inode(self, path):
1c8cd2ff57d3 17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents: 2272
diff changeset
  3283
                """Return the inode number of a file in the image."""
1c8cd2ff57d3 17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents: 2272
diff changeset
  3284
1c8cd2ff57d3 17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents: 2272
diff changeset
  3285
                file_path = os.path.join(self.get_img_path(), path)
1c8cd2ff57d3 17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents: 2272
diff changeset
  3286
                st = os.stat(file_path)
1c8cd2ff57d3 17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents: 2272
diff changeset
  3287
                return st.st_ino
1c8cd2ff57d3 17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents: 2272
diff changeset
  3288
1c8cd2ff57d3 17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents: 2272
diff changeset
  3289
        def file_size(self, path):
1c8cd2ff57d3 17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents: 2272
diff changeset
  3290
                """Return the size of a file in the image."""
1c8cd2ff57d3 17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents: 2272
diff changeset
  3291
1c8cd2ff57d3 17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents: 2272
diff changeset
  3292
                file_path = os.path.join(self.get_img_path(), path)
1c8cd2ff57d3 17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents: 2272
diff changeset
  3293
                st = os.stat(file_path)
1c8cd2ff57d3 17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents: 2272
diff changeset
  3294
                return st.st_size
1c8cd2ff57d3 17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents: 2272
diff changeset
  3295
1c8cd2ff57d3 17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents: 2272
diff changeset
  3296
        def file_chmod(self, path, mode):
1c8cd2ff57d3 17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents: 2272
diff changeset
  3297
                """Change the mode of a file in the image."""
1c8cd2ff57d3 17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents: 2272
diff changeset
  3298
1c8cd2ff57d3 17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents: 2272
diff changeset
  3299
                file_path = os.path.join(self.get_img_path(), path)
1c8cd2ff57d3 17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents: 2272
diff changeset
  3300
                os.chmod(file_path, mode)
1c8cd2ff57d3 17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents: 2272
diff changeset
  3301
1c8cd2ff57d3 17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents: 2272
diff changeset
  3302
        def file_exists(self, path):
1c8cd2ff57d3 17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents: 2272
diff changeset
  3303
                """Assert the existence of a file in the image."""
1c8cd2ff57d3 17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents: 2272
diff changeset
  3304
1c8cd2ff57d3 17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents: 2272
diff changeset
  3305
                file_path = os.path.join(self.get_img_path(), path)
1c8cd2ff57d3 17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents: 2272
diff changeset
  3306
                if not os.path.isfile(file_path):
1c8cd2ff57d3 17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents: 2272
diff changeset
  3307
                        self.assert_(False, "File %s does not exist" % path)
1c8cd2ff57d3 17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents: 2272
diff changeset
  3308
1c8cd2ff57d3 17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents: 2272
diff changeset
  3309
        def file_doesnt_exist(self, path):
1c8cd2ff57d3 17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents: 2272
diff changeset
  3310
                """Assert the non-existence of a file in the image."""
1c8cd2ff57d3 17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents: 2272
diff changeset
  3311
1c8cd2ff57d3 17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents: 2272
diff changeset
  3312
                file_path = os.path.join(self.get_img_path(), path)
1c8cd2ff57d3 17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents: 2272
diff changeset
  3313
                if os.path.exists(file_path):
1c8cd2ff57d3 17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents: 2272
diff changeset
  3314
                        self.assert_(False, "File %s exists" % path)
1c8cd2ff57d3 17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents: 2272
diff changeset
  3315
1c8cd2ff57d3 17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents: 2272
diff changeset
  3316
        def file_remove(self, path):
1c8cd2ff57d3 17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents: 2272
diff changeset
  3317
                """Remove a file in the image."""
1c8cd2ff57d3 17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents: 2272
diff changeset
  3318
1c8cd2ff57d3 17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents: 2272
diff changeset
  3319
                file_path = os.path.join(self.get_img_path(), path)
1c8cd2ff57d3 17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents: 2272
diff changeset
  3320
                portable.remove(file_path)
1c8cd2ff57d3 17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents: 2272
diff changeset
  3321
3063
bbaaf1579de3 15744850 no actuators are run when pkg manipulates a booted NGZ image from the GZ
thejaswini.k@oracle.com
parents: 3048
diff changeset
  3322
        def file_contains(self, path, string, appearances=1):
2274
1c8cd2ff57d3 17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents: 2272
diff changeset
  3323
                """Assert the existence of a string in a file in the image."""
1c8cd2ff57d3 17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents: 2272
diff changeset
  3324
1c8cd2ff57d3 17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents: 2272
diff changeset
  3325
                file_path = os.path.join(self.get_img_path(), path)
1c8cd2ff57d3 17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents: 2272
diff changeset
  3326
                try:
1c8cd2ff57d3 17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents: 2272
diff changeset
  3327
                        f = file(file_path)
1c8cd2ff57d3 17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents: 2272
diff changeset
  3328
                except:
1c8cd2ff57d3 17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents: 2272
diff changeset
  3329
                        self.assert_(False,
1c8cd2ff57d3 17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents: 2272
diff changeset
  3330
                            "File %s does not exist or contain %s" %
1c8cd2ff57d3 17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents: 2272
diff changeset
  3331
                            (path, string))
1c8cd2ff57d3 17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents: 2272
diff changeset
  3332
1c8cd2ff57d3 17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents: 2272
diff changeset
  3333
                for line in f:
1c8cd2ff57d3 17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents: 2272
diff changeset
  3334
                        if string in line:
3063
bbaaf1579de3 15744850 no actuators are run when pkg manipulates a booted NGZ image from the GZ
thejaswini.k@oracle.com
parents: 3048
diff changeset
  3335
                                appearances -= 1
bbaaf1579de3 15744850 no actuators are run when pkg manipulates a booted NGZ image from the GZ
thejaswini.k@oracle.com
parents: 3048
diff changeset
  3336
                                if appearances == 0:
bbaaf1579de3 15744850 no actuators are run when pkg manipulates a booted NGZ image from the GZ
thejaswini.k@oracle.com
parents: 3048
diff changeset
  3337
                                        f.close()
bbaaf1579de3 15744850 no actuators are run when pkg manipulates a booted NGZ image from the GZ
thejaswini.k@oracle.com
parents: 3048
diff changeset
  3338
                                        break
2274
1c8cd2ff57d3 17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents: 2272
diff changeset
  3339
                else:
1c8cd2ff57d3 17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents: 2272
diff changeset
  3340
                        f.close()
1c8cd2ff57d3 17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents: 2272
diff changeset
  3341
                        self.assert_(False, "File %s does not contain %s" %
1c8cd2ff57d3 17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents: 2272
diff changeset
  3342
                            (path, string))
1c8cd2ff57d3 17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents: 2272
diff changeset
  3343
1c8cd2ff57d3 17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents: 2272
diff changeset
  3344
        def file_doesnt_contain(self, path, string):
1c8cd2ff57d3 17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents: 2272
diff changeset
  3345
                """Assert the non-existence of a string in a file in the
1c8cd2ff57d3 17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents: 2272
diff changeset
  3346
                image."""
1c8cd2ff57d3 17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents: 2272
diff changeset
  3347
1c8cd2ff57d3 17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents: 2272
diff changeset
  3348
                file_path = os.path.join(self.get_img_path(), path)
1c8cd2ff57d3 17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents: 2272
diff changeset
  3349
                f = file(file_path)
1c8cd2ff57d3 17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents: 2272
diff changeset
  3350
                for line in f:
1c8cd2ff57d3 17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents: 2272
diff changeset
  3351
                        if string in line:
1c8cd2ff57d3 17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents: 2272
diff changeset
  3352
                                f.close()
1c8cd2ff57d3 17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents: 2272
diff changeset
  3353
                                self.assert_(False, "File %s contains %s" %
1c8cd2ff57d3 17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents: 2272
diff changeset
  3354
                                    (path, string))
1c8cd2ff57d3 17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents: 2272
diff changeset
  3355
                else:
1c8cd2ff57d3 17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents: 2272
diff changeset
  3356
                        f.close()
1c8cd2ff57d3 17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents: 2272
diff changeset
  3357
1c8cd2ff57d3 17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents: 2272
diff changeset
  3358
        def file_append(self, path, string):
1c8cd2ff57d3 17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents: 2272
diff changeset
  3359
                """Append a line to a file in the image."""
1c8cd2ff57d3 17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents: 2272
diff changeset
  3360
1c8cd2ff57d3 17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents: 2272
diff changeset
  3361
                file_path = os.path.join(self.get_img_path(), path)
1c8cd2ff57d3 17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents: 2272
diff changeset
  3362
                with open(file_path, "a+") as f:
1c8cd2ff57d3 17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents: 2272
diff changeset
  3363
                        f.write("\n%s\n" % string)
1c8cd2ff57d3 17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents: 2272
diff changeset
  3364
2753
4d4b2324d1c0 7139940 cached manifests persist for packages not currently installed even when copy in repository changes
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2731
diff changeset
  3365
        def seed_ta_dir(self, certs, dest_dir=None):
4d4b2324d1c0 7139940 cached manifests persist for packages not currently installed even when copy in repository changes
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2731
diff changeset
  3366
                if isinstance(certs, basestring):
4d4b2324d1c0 7139940 cached manifests persist for packages not currently installed even when copy in repository changes
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2731
diff changeset
  3367
                        certs = [certs]
4d4b2324d1c0 7139940 cached manifests persist for packages not currently installed even when copy in repository changes
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2731
diff changeset
  3368
                if not dest_dir:
4d4b2324d1c0 7139940 cached manifests persist for packages not currently installed even when copy in repository changes
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2731
diff changeset
  3369
                        dest_dir = self.ta_dir
4d4b2324d1c0 7139940 cached manifests persist for packages not currently installed even when copy in repository changes
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2731
diff changeset
  3370
                self.assert_(dest_dir)
4d4b2324d1c0 7139940 cached manifests persist for packages not currently installed even when copy in repository changes
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2731
diff changeset
  3371
                self.assert_(self.raw_trust_anchor_dir)
4d4b2324d1c0 7139940 cached manifests persist for packages not currently installed even when copy in repository changes
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2731
diff changeset
  3372
                for c in certs:
4d4b2324d1c0 7139940 cached manifests persist for packages not currently installed even when copy in repository changes
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2731
diff changeset
  3373
                        name = "%s_cert.pem" % c
4d4b2324d1c0 7139940 cached manifests persist for packages not currently installed even when copy in repository changes
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2731
diff changeset
  3374
                        portable.copyfile(
4d4b2324d1c0 7139940 cached manifests persist for packages not currently installed even when copy in repository changes
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2731
diff changeset
  3375
                            os.path.join(self.raw_trust_anchor_dir, name),
4d4b2324d1c0 7139940 cached manifests persist for packages not currently installed even when copy in repository changes
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2731
diff changeset
  3376
                            os.path.join(dest_dir, name))
4d4b2324d1c0 7139940 cached manifests persist for packages not currently installed even when copy in repository changes
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2731
diff changeset
  3377
1895
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1890
diff changeset
  3378
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3379
class ManyDepotTestCase(CliTestCase):
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3380
1895
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1890
diff changeset
  3381
        def __init__(self, methodName="runTest"):
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3382
                super(ManyDepotTestCase, self).__init__(methodName)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3383
                self.dcs = {}
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3384
2339
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  3385
        def setUp(self, publishers, debug_features=EmptyI, start_depots=False,
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  3386
            image_count=1):
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  3387
                CliTestCase.setUp(self, image_count=image_count)
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3388
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3389
                self.debug("setup: %s" % self.id())
1895
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1890
diff changeset
  3390
                self.debug("creating %d repo(s)" % len(publishers))
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3391
                self.debug("publishers: %s" % publishers)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3392
                self.debug("debug_features: %s" % list(debug_features))
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3393
                self.dcs = {}
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3394
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3395
                for n, pub in enumerate(publishers):
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3396
                        i = n + 1
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3397
                        testdir = os.path.join(self.test_root)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3398
2028
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  3399
                        try:
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  3400
                                os.makedirs(testdir, 0755)
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  3401
                        except OSError, e:
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  3402
                                if e.errno != errno.EEXIST:
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  3403
                                        raise e
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3404
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3405
                        depot_logfile = os.path.join(testdir,
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3406
                            "depot_logfile%d" % i)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3407
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3408
                        props = { "publisher": { "prefix": pub } }
1895
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1890
diff changeset
  3409
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1890
diff changeset
  3410
                        # We pick an arbitrary base port.  This could be more
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1890
diff changeset
  3411
                        # automated in the future.
2028
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  3412
                        repodir = os.path.join(testdir, "repo_contents%d" % i)
2310
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  3413
                        self.dcs[i] = self.prep_depot(self.next_free_port,
2272
d81ea073d050 3617 Testsuite should allow choice for base port to use
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2240
diff changeset
  3414
                            repodir,
1895
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1890
diff changeset
  3415
                            depot_logfile, debug_features=debug_features,
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1890
diff changeset
  3416
                            properties=props, start=start_depots)
2272
d81ea073d050 3617 Testsuite should allow choice for base port to use
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2240
diff changeset
  3417
                        self.next_free_port += 1
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3418
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3419
        def check_traceback(self, logpath):
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3420
                """ Scan logpath looking for tracebacks.
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3421
                    Raise a DepotTracebackException if one is seen.
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3422
                """
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3423
                self.debug("check for depot tracebacks in %s" % logpath)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3424
                logfile = open(logpath, "r")
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3425
                output = logfile.read()
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3426
                for line in output.splitlines():
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3427
                        if line.find("Traceback") > -1:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3428
                                raise DepotTracebackException(logpath, output)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3429
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3430
        def restart_depots(self):
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3431
                self.debug("restarting %d depot(s)" % len(self.dcs))
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3432
                for i in sorted(self.dcs.keys()):
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3433
                        dc = self.dcs[i]
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3434
                        self.debug("stopping depot at url: %s" % dc.get_depot_url())
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3435
                        dc.stop()
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3436
                        self.debug("starting depot at url: %s" % dc.get_depot_url())
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3437
                        dc.start()
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3438
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3439
        def killall_sighandler(self, signum, frame):
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3440
                print >> sys.stderr, \
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3441
                    "Ctrl-C: I'm killing depots, please wait.\n"
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3442
                print self
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3443
                self.signalled = True
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3444
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3445
        def killalldepots(self):
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3446
                self.signalled = False
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3447
                self.debug("killalldepots: %s" % self.id())
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3448
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3449
                oldhdlr = signal.signal(signal.SIGINT, self.killall_sighandler)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3450
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3451
                try:
1895
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1890
diff changeset
  3452
                        check_dc = []
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3453
                        for i in sorted(self.dcs.keys()):
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3454
                                dc = self.dcs[i]
1895
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1890
diff changeset
  3455
                                if not dc.started:
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1890
diff changeset
  3456
                                        continue
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1890
diff changeset
  3457
                                check_dc.append(dc)
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1890
diff changeset
  3458
                                path = dc.get_repodir()
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3459
                                self.debug("stopping depot at url: %s, %s" % \
1895
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1890
diff changeset
  3460
                                    (dc.get_depot_url(), path))
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3461
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3462
                                status = 0
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3463
                                try:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3464
                                        status = dc.kill()
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3465
                                except Exception:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3466
                                        pass
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3467
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3468
                                if status:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3469
                                        self.debug("depot: %s" % status)
1895
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1890
diff changeset
  3470
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1890
diff changeset
  3471
                        for dc in check_dc:
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3472
                                try:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3473
                                        self.check_traceback(dc.get_logpath())
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3474
                                except Exception:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3475
                                        pass
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3476
                finally:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3477
                        signal.signal(signal.SIGINT, oldhdlr)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3478
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3479
                self.dcs = {}
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3480
                if self.signalled:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3481
                        raise KeyboardInterrupt("Ctrl-C while killing depots.")
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3482
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3483
        def tearDown(self):
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3484
                self.debug("ManyDepotTestCase.tearDown: %s" % self.id())
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3485
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3486
                self.killalldepots()
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3487
                CliTestCase.tearDown(self)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3488
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3489
        def run(self, result=None):
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3490
                if result is None:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3491
                        result = self.defaultTestResult()
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3492
                CliTestCase.run(self, result)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3493
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  3494
2830
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  3495
class ApacheDepotTestCase(ManyDepotTestCase):
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  3496
        """A TestCase that uses one or more Apache instances in the course of
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  3497
        its work, along with potentially one or more DepotControllers.
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  3498
        """
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  3499
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  3500
        def __init__(self, methodName="runTest"):
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  3501
                super(ManyDepotTestCase, self).__init__(methodName)
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  3502
                self.dcs = {}
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  3503
                self.acs = {}
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  3504
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  3505
        def register_apache_controller(self, name, ac):
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  3506
                """Registers an ApacheController with this TestCase.
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  3507
                We include this method here to make it easier to kill any
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  3508
                instances of Apache that were left floating around at the end
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  3509
                of the test.
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  3510
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  3511
                We enforce the use of this method in
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  3512
                <ApacheController>.start() by refusing to start instances until
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  3513
                they are registered, which makes the test suite as a whole more
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  3514
                resilient, when setting up and tearing down test classes."""
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  3515
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  3516
                if name in self.acs:
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  3517
                        # registering an Apache controller that is already
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  3518
                        # registered causes us to kill the existing controller
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  3519
                        # first.
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  3520
                        try:
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  3521
                                self.acs[name].stop()
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  3522
                        except Exception, e:
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  3523
                                try:
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  3524
                                        self.acs[name].kill()
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  3525
                                except Exception, e:
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  3526
                                        pass
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  3527
                self.acs[name] = ac
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  3528
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  3529
        def __get_ac(self):
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  3530
                """If we only use a single ApacheController, self.ac will
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  3531
                return that controller, otherwise we return None."""
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  3532
                if self.acs and len(self.acs) == 1:
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  3533
                        return self.acs[self.acs.keys()[0]]
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  3534
                else:
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  3535
                        return None
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  3536
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  3537
        def killalldepots(self):
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  3538
                try:
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  3539
                        ManyDepotTestCase.killalldepots(self)
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  3540
                finally:
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  3541
                        for name, ac in self.acs.items():
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  3542
                                self.debug("stopping apache controller %s" %
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  3543
                                    name)
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  3544
                                try:
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  3545
                                        ac.stop()
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  3546
                                except Exception, e :
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  3547
                                        try:
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  3548
                                                self.debug("killing apache "
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  3549
                                                    "instance %s" % name)
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  3550
                                                ac.kill()
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  3551
                                        except Exception, e:
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  3552
                                                self.debug("Unable to kill "
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  3553
                                                    "apache instance %s. This "
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  3554
                                                    "could cause subsequent "
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  3555
                                                    "tests to fail." % name)
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  3556
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  3557
        # ac is a readonly property which returns a registered ApacheController
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  3558
        # provided there is exactly one registered, for convenience of writing
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  3559
        # test cases.
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  3560
        ac = property(fget=__get_ac)
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  3561
2864
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3562
class HTTPSTestClass(ApacheDepotTestCase):
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3563
        # Tests in this suite use the read only data directory.
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3564
        need_ro_data = True
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3565
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3566
        def pkg(self, command, *args, **kwargs):
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3567
                # The value for ssl_ca_file is pulled from DebugValues because
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3568
                # ssl_ca_file needs to be set there so the api object calls work
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3569
                # as desired.
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3570
                command = "--debug ssl_ca_file=%s %s" % \
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3571
                    (DebugValues["ssl_ca_file"], command)
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3572
                return ApacheDepotTestCase.pkg(self, command,
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3573
                    *args, **kwargs)
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3574
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3575
        def pkgrecv(self, command, *args, **kwargs):
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3576
                # The value for ssl_ca_file is pulled from DebugValues because
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3577
                # ssl_ca_file needs to be set there so the api object calls work
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3578
                # as desired.
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3579
                command = "%s --debug ssl_ca_file=%s" % \
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3580
                    (command, DebugValues["ssl_ca_file"])
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3581
                return ApacheDepotTestCase.pkgrecv(self, command,
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3582
                    *args, **kwargs)
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3583
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3584
        def pkgsend(self, command, *args, **kwargs):
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3585
                # The value for ssl_ca_file is pulled from DebugValues because
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3586
                # ssl_ca_file needs to be set there so the api object calls work
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3587
                # as desired.
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3588
                command = "%s --debug ssl_ca_file=%s" % \
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3589
                    (command, DebugValues["ssl_ca_file"])
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3590
                return ApacheDepotTestCase.pkgsend(self, command,
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3591
                    *args, **kwargs)
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3592
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3593
        def pkgrepo(self, command, *args, **kwargs):
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3594
                # The value for ssl_ca_file is pulled from DebugValues because
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3595
                # ssl_ca_file needs to be set there so the api object calls work
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3596
                # as desired.
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3597
                command = "--debug ssl_ca_file=%s %s" % \
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3598
                    (DebugValues["ssl_ca_file"], command)
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3599
                return ApacheDepotTestCase.pkgrepo(self, command,
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3600
                    *args, **kwargs)
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3601
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3602
        def seed_ta_dir(self, certs, dest_dir=None):
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3603
                if isinstance(certs, basestring):
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3604
                        certs = [certs]
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3605
                if not dest_dir:
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3606
                        dest_dir = self.ta_dir
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3607
                self.assert_(dest_dir)
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3608
                self.assert_(self.raw_trust_anchor_dir)
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3609
                for c in certs:
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3610
                        name = "%s_cert.pem" % c
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3611
                        portable.copyfile(
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3612
                            os.path.join(self.raw_trust_anchor_dir, name),
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3613
                            os.path.join(dest_dir, name))
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3614
                        DebugValues["ssl_ca_file"] = os.path.join(dest_dir,
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3615
                            name)
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3616
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3617
        def get_cli_cert(self, publisher):
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3618
                ta = self.pub_ta_map[publisher]
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3619
                return "cs1_ta%d_cert.pem" % ta
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3620
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3621
        def get_cli_key(self, publisher):
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3622
                ta = self.pub_ta_map[publisher]
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3623
                return "cs1_ta%d_key.pem" % ta
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3624
3048
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
  3625
        def get_pub_ta(self, publisher):
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
  3626
                ta = self.pub_ta_map[publisher]
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
  3627
                return "ta%d" % ta
2aecfba95fe8 16986557 prefixes should be omitted from output of facet and variant
saurabh.vyas@oracle.com
parents: 2985
diff changeset
  3628
2864
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3629
        def setUp(self, publishers, start_depots=True):
3063
bbaaf1579de3 15744850 no actuators are run when pkg manipulates a booted NGZ image from the GZ
thejaswini.k@oracle.com
parents: 3048
diff changeset
  3630
2864
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3631
                # We only have 5 usable CA certs and there are not many usecases
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3632
                # for setting up more than 5 different SSL-secured depots.
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3633
                assert len(publishers) < 6
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3634
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3635
                # Maintains a mapping of which TA is used for which publisher
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3636
                self.pub_ta_map = {}
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3637
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3638
                ApacheDepotTestCase.setUp(self, publishers,
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3639
                    start_depots=True)
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3640
                self.testdata_dir = os.path.join(self.test_root, "testdata")
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3641
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3642
                # Set up the directories that apache needs.
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3643
                self.apache_dir = os.path.join(self.test_root, "apache")
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3644
                os.makedirs(self.apache_dir)
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3645
                self.apache_log_dir = os.path.join(self.apache_dir,
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3646
                    "apache_logs")
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3647
                os.makedirs(self.apache_log_dir)
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3648
                self.apache_content_dir = os.path.join(self.apache_dir,
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3649
                    "apache_content")
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3650
                self.pidfile = os.path.join(self.apache_dir, "httpd.pid")
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3651
                self.common_config_dir = os.path.join(self.test_root,
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3652
                    "apache-serve")
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3653
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3654
                # Choose ports for apache to run on.
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3655
                self.https_port = self.next_free_port
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3656
                self.next_free_port += 1
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3657
                self.proxy_port = self.next_free_port
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3658
                self.next_free_port += 1
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3659
                self.bad_proxy_port = self.next_free_port
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3660
                self.next_free_port += 1
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3661
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3662
                # Set up the paths to the certificates that will be needed.
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3663
                self.path_to_certs = os.path.join(self.ro_data_root,
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3664
                    "signing_certs", "produced")
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3665
                self.keys_dir = os.path.join(self.path_to_certs, "keys")
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3666
                self.cs_dir = os.path.join(self.path_to_certs,
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3667
                    "code_signing_certs")
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3668
                self.chain_certs_dir = os.path.join(self.path_to_certs,
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3669
                    "chain_certs")
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3670
                self.pub_cas_dir = os.path.join(self.path_to_certs,
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3671
                    "publisher_cas")
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3672
                self.inter_certs_dir = os.path.join(self.path_to_certs,
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3673
                    "inter_certs")
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3674
                self.raw_trust_anchor_dir = os.path.join(self.path_to_certs,
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3675
                    "trust_anchors")
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3676
                self.crl_dir = os.path.join(self.path_to_certs, "crl")
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3677
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3678
                location_tags = ""
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3679
                # Usable CA certs are ta6 to ta11 with the exception of ta7.
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3680
                # We already checked that not more than 5 publishers have been
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3681
                # requested.
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3682
                count = 6
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3683
                for dc in self.dcs:
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3684
                        # Create a <Location> tag for each publisher. The server
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3685
                        # path is set to the publisher name.
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3686
                        if count == 7:
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3687
                                # TA7 needs password to unlock cert, don't use
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3688
                                count += 1
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3689
                        dc_pub = self.dcs[dc].get_property("publisher",
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3690
                            "prefix")
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3691
                        self.pub_ta_map[dc_pub] = count
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3692
                        loc_dict = {
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3693
                            "server-path":dc_pub,
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3694
                            "server-ca-taname":"ta%d" % count,
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3695
                            "ssl-special":"%{SSL_CLIENT_I_DN_OU}",
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3696
                            "proxied-server":self.dcs[dc].get_depot_url(),
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3697
                        }
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3698
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3699
                        location_tags += loc_tag % (loc_dict)
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3700
                        count += 1
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3701
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3702
                conf_dict = {
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3703
                    "common_log_format": "%h %l %u %t \\\"%r\\\" %>s %b",
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3704
                    "https_port": self.https_port,
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3705
                    "proxy_port": self.proxy_port,
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3706
                    "bad_proxy_port": self.bad_proxy_port,
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3707
                    "log_locs": self.apache_log_dir,
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3708
                    "pidfile": self.pidfile,
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3709
                    "port": self.https_port,
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3710
                    "serve_root": self.apache_content_dir,
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3711
                    "server-ssl-cert":os.path.join(self.cs_dir,
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3712
                        "cs1_ta7_cert.pem"),
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3713
                    "server-ssl-key":os.path.join(self.keys_dir,
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3714
                        "cs1_ta7_key.pem"),
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3715
                    "server-ca-cert":os.path.join(self.path_to_certs, "combined_cas.pem"),
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3716
                    "location-tags":location_tags,
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3717
                }
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3718
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3719
                self.https_conf_path = os.path.join(self.test_root,
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3720
                    "https.conf")
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3721
                with open(self.https_conf_path, "wb") as fh:
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3722
                        fh.write(self.https_conf % conf_dict)
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3723
                
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3724
                ac = ApacheController(self.https_conf_path,
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3725
                    self.https_port, self.common_config_dir, https=True,
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3726
                    testcase=self)
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3727
                self.register_apache_controller("default", ac)
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3728
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3729
        https_conf = """\
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3730
# Configuration and logfile names: If the filenames you specify for many
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3731
# of the server's control files begin with "/" (or "drive:/" for Win32), the
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3732
# server will use that explicit path.  If the filenames do *not* begin
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3733
# with "/", the value of ServerRoot is prepended -- so "/var/apache2/2.2/logs/foo_log"
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3734
# with ServerRoot set to "/usr/apache2/2.2" will be interpreted by the
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3735
# server as "/usr/apache2/2.2//var/apache2/2.2/logs/foo_log".
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3736
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3737
#
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3738
# ServerRoot: The top of the directory tree under which the server's
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3739
# configuration, error, and log files are kept.
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3740
#
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3741
# Do not add a slash at the end of the directory path.  If you point
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3742
# ServerRoot at a non-local disk, be sure to point the LockFile directive
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3743
# at a local disk.  If you wish to share the same ServerRoot for multiple
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3744
# httpd daemons, you will need to change at least LockFile and PidFile.
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3745
#
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3746
ServerRoot "/usr/apache2/2.2"
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3747
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3748
PidFile "%(pidfile)s"
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3749
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3750
#
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3751
# Listen: Allows you to bind Apache to specific IP addresses and/or
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3752
# ports, instead of the default. See also the <VirtualHost>
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3753
# directive.
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3754
#
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3755
# Change this to Listen on specific IP addresses as shown below to 
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3756
# prevent Apache from glomming onto all bound IP addresses.
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3757
#
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3758
Listen 0.0.0.0:%(https_port)s
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3759
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3760
# We also make ourselves a general-purpose proxy. This is not needed for the
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3761
# SSL reverse-proxying to the pkg.depotd, but allows us to test that pkg(1)
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3762
# can communicate to HTTPS origins using a proxy.
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3763
Listen 0.0.0.0:%(proxy_port)s
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3764
Listen 0.0.0.0:%(bad_proxy_port)s
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3765
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3766
#
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3767
# Dynamic Shared Object (DSO) Support
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3768
#
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3769
# To be able to use the functionality of a module which was built as a DSO you
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3770
# have to place corresponding `LoadModule' lines within the appropriate 
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3771
# (32-bit or 64-bit module) /etc/apache2/2.2/conf.d/modules-*.load file so that
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3772
# the directives contained in it are actually available _before_ they are used.
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3773
#
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3774
<IfDefine 64bit>
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3775
Include /etc/apache2/2.2/conf.d/modules-64.load
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3776
</IfDefine>
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3777
<IfDefine !64bit>
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3778
Include /etc/apache2/2.2/conf.d/modules-32.load
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3779
</IfDefine>
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3780
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3781
<IfModule !mpm_netware_module>
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3782
#
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3783
# If you wish httpd to run as a different user or group, you must run
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3784
# httpd as root initially and it will switch.  
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3785
#
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3786
# User/Group: The name (or #number) of the user/group to run httpd as.
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3787
# It is usually good practice to create a dedicated user and group for
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3788
# running httpd, as with most system services.
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3789
#
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3790
User webservd
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3791
Group webservd
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3792
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3793
</IfModule>
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3794
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3795
# 'Main' server configuration
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3796
#
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3797
# The directives in this section set up the values used by the 'main'
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3798
# server, which responds to any requests that aren't handled by a
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3799
# <VirtualHost> definition.  These values also provide defaults for
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3800
# any <VirtualHost> containers you may define later in the file.
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3801
#
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3802
# All of these directives may appear inside <VirtualHost> containers,
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3803
# in which case these default settings will be overridden for the
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3804
# virtual host being defined.
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3805
#
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3806
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3807
#
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3808
# ServerName gives the name and port that the server uses to identify itself.
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3809
# This can often be determined automatically, but we recommend you specify
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3810
# it explicitly to prevent problems during startup.
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3811
#
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3812
# If your host doesn't have a registered DNS name, enter its IP address here.
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3813
#
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3814
ServerName 127.0.0.1
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3815
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3816
#
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3817
# DocumentRoot: The directory out of which you will serve your
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3818
# documents. By default, all requests are taken from this directory, but
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3819
# symbolic links and aliases may be used to point to other locations.
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3820
#
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3821
DocumentRoot "/"
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3822
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3823
#
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3824
# Each directory to which Apache has access can be configured with respect
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3825
# to which services and features are allowed and/or disabled in that
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3826
# directory (and its subdirectories). 
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3827
#
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3828
# First, we configure the "default" to be a very restrictive set of 
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3829
# features.  
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3830
#
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3831
<Directory />
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3832
    Options None
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3833
    AllowOverride None
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3834
    Order deny,allow
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3835
    Deny from all
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3836
</Directory>
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3837
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3838
#
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3839
# Note that from this point forward you must specifically allow
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3840
# particular features to be enabled - so if something's not working as
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3841
# you might expect, make sure that you have specifically enabled it
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3842
# below.
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3843
#
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3844
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3845
#
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3846
# This should be changed to whatever you set DocumentRoot to.
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3847
#
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3848
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3849
#
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3850
# DirectoryIndex: sets the file that Apache will serve if a directory
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3851
# is requested.
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3852
#
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3853
<IfModule dir_module>
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3854
    DirectoryIndex index.html
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3855
</IfModule>
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3856
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3857
#
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3858
# The following lines prevent .htaccess and .htpasswd files from being 
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3859
# viewed by Web clients. 
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3860
#
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3861
<FilesMatch "^\.ht">
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3862
    Order allow,deny
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3863
    Deny from all
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3864
    Satisfy All
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3865
</FilesMatch>
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3866
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3867
#
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3868
# ErrorLog: The location of the error log file.
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3869
# If you do not specify an ErrorLog directive within a <VirtualHost>
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3870
# container, error messages relating to that virtual host will be
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3871
# logged here.  If you *do* define an error logfile for a <VirtualHost>
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3872
# container, that host's errors will be logged there and not here.
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3873
#
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3874
ErrorLog "%(log_locs)s/error_log"
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3875
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3876
#
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3877
# LogLevel: Control the number of messages logged to the error_log.
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3878
# Possible values include: debug, info, notice, warn, error, crit,
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3879
# alert, emerg.
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3880
#
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3881
LogLevel debug
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3882
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3883
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3884
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3885
<IfModule log_config_module>
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3886
    #
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3887
    # The following directives define some format nicknames for use with
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3888
    # a CustomLog directive (see below).
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3889
    #
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3890
    LogFormat "%(common_log_format)s" common
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3891
    LogFormat "PROXY %(common_log_format)s" proxylog
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3892
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3893
    #
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3894
    # The location and format of the access logfile (Common Logfile Format).
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3895
    # If you do not define any access logfiles within a <VirtualHost>
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3896
    # container, they will be logged here.  Contrariwise, if you *do*
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3897
    # define per-<VirtualHost> access logfiles, transactions will be
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3898
    # logged therein and *not* in this file.
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3899
    #
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3900
    CustomLog "%(log_locs)s/access_log" common
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3901
</IfModule>
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3902
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3903
#
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3904
# DefaultType: the default MIME type the server will use for a document
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3905
# if it cannot otherwise determine one, such as from filename extensions.
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3906
# If your server contains mostly text or HTML documents, "text/plain" is
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3907
# a good value.  If most of your content is binary, such as applications
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3908
# or images, you may want to use "application/octet-stream" instead to
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3909
# keep browsers from trying to display binary files as though they are
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3910
# text.
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3911
#
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3912
DefaultType text/plain
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3913
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3914
<IfModule mime_module>
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3915
    #
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3916
    # TypesConfig points to the file containing the list of mappings from
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3917
    # filename extension to MIME-type.
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3918
    #
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3919
    TypesConfig /etc/apache2/2.2/mime.types
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3920
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3921
    #
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3922
    # AddType allows you to add to or override the MIME configuration
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3923
    # file specified in TypesConfig for specific file types.
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3924
    #
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3925
    AddType application/x-compress .Z
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3926
    AddType application/x-gzip .gz .tgz
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3927
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3928
    # Add a new mime.type for .p5i file extension so that clicking on
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3929
    # this file type on a web page launches PackageManager in a Webinstall mode.
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3930
    AddType application/vnd.pkg5.info .p5i
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3931
</IfModule>
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3932
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3933
#
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3934
# Note: The following must must be present to support
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3935
#       starting without SSL on platforms with no /dev/random equivalent
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3936
#       but a statically compiled-in mod_ssl.
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3937
#
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3938
<IfModule ssl_module>
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3939
SSLRandomSeed startup builtin
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3940
SSLRandomSeed connect builtin
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3941
</IfModule>
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3942
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3943
<VirtualHost 0.0.0.0:%(https_port)s>
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3944
        AllowEncodedSlashes On
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3945
        ProxyRequests Off
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3946
        MaxKeepAliveRequests 10000
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3947
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3948
        SSLEngine On
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3949
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3950
        # Cert paths
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3951
        SSLCertificateFile %(server-ssl-cert)s
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3952
        SSLCertificateKeyFile %(server-ssl-key)s
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3953
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3954
        # Combined product CA certs for client verification
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3955
        SSLCACertificateFile %(server-ca-cert)s
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3956
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3957
	SSLVerifyClient require
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3958
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3959
        %(location-tags)s
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3960
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3961
</VirtualHost>
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3962
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3963
#
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3964
# We configure this Apache instance as a general-purpose HTTP proxy, accepting
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3965
# requests from localhost, and allowing CONNECTs to our HTTPS port
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3966
#
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3967
<VirtualHost 0.0.0.0:%(proxy_port)s>
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3968
        <Proxy *>
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3969
                Order Deny,Allow
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3970
                Deny from all
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3971
                Allow from 127.0.0.1
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3972
        </Proxy>
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3973
        AllowCONNECT %(https_port)s
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3974
        ProxyRequests on
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3975
        CustomLog "%(log_locs)s/proxy_access_log" proxylog
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3976
</VirtualHost>
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3977
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3978
<VirtualHost 0.0.0.0:%(bad_proxy_port)s>
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3979
        <Proxy *>
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3980
                Order Deny,Allow
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3981
                Deny from all
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3982
                Allow from 127.0.0.1
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3983
        </Proxy>
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3984
#  We purposely prevent this proxy from being able to connect to our SSL
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3985
#  port, making sure that when we point pkg(1) to this bad proxy, operations
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3986
#  will fail - the following line is commented out:
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3987
#        AllowCONNECT %(https_port)s
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3988
        ProxyRequests on
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3989
        CustomLog "%(log_locs)s/badproxy_access_log" proxylog
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3990
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3991
</VirtualHost>
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3992
"""
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3993
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3994
loc_tag = """
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3995
        <Location /%(server-path)s>
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3996
                SSLVerifyDepth 1
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3997
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3998
	        # The client's certificate must pass verification, and must have
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  3999
	        # a CN which matches this repository.
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  4000
                SSLRequire ( %(ssl-special)s =~ m/%(server-ca-taname)s/ )
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  4001
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  4002
                # set max to number of threads in depot
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  4003
                ProxyPass %(proxied-server)s nocanon max=500
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  4004
        </Location>
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  4005
"""
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  4006
2830
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  4007
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4008
class SingleDepotTestCase(ManyDepotTestCase):
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4009
1895
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1890
diff changeset
  4010
        def setUp(self, debug_features=EmptyI, publisher="test",
2339
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  4011
            start_depot=False, image_count=1):
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4012
                ManyDepotTestCase.setUp(self, [publisher],
2339
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  4013
                    debug_features=debug_features, start_depots=start_depot,
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  4014
                    image_count=image_count)
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4015
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4016
        def __get_dc(self):
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4017
                if self.dcs:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4018
                        return self.dcs[1]
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4019
                else:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4020
                        return None
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4021
1895
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1890
diff changeset
  4022
        @property
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1890
diff changeset
  4023
        def durl(self):
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1890
diff changeset
  4024
                return self.dc.get_depot_url()
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1890
diff changeset
  4025
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1890
diff changeset
  4026
        @property
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1890
diff changeset
  4027
        def rurl(self):
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1890
diff changeset
  4028
                return self.dc.get_repo_url()
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1890
diff changeset
  4029
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4030
        # dc is a readonly property which is an alias for self.dcs[1],
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4031
        # for convenience of writing test cases.
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4032
        dc = property(fget=__get_dc)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4033
2864
96d3957712da 16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents: 2863
diff changeset
  4034
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4035
class SingleDepotTestCaseCorruptImage(SingleDepotTestCase):
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4036
        """ A class which allows manipulation of the image directory that
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4037
        SingleDepotTestCase creates. Specifically, it supports removing one
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4038
        or more of the files or subdirectories inside an image (publisher,
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4039
        cfg_cache, etc...) in a controlled way.
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4040
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4041
        To add a new directory or file to be corrupted, it will be necessary
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4042
        to update corrupt_image_create to recognize a new option in config
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4043
        and perform the appropriate action (removing the directory or file
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4044
        for example).
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4045
        """
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4046
1895
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1890
diff changeset
  4047
        def setUp(self, debug_features=EmptyI, publisher="test",
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1890
diff changeset
  4048
            start_depot=False):
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4049
                SingleDepotTestCase.setUp(self, debug_features=debug_features,
1895
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1890
diff changeset
  4050
                    publisher=publisher, start_depot=start_depot)
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4051
2339
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  4052
                self.__imgs_path_backup = {}
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  4053
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4054
        def tearDown(self):
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4055
                SingleDepotTestCase.tearDown(self)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4056
2339
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  4057
        def backup_img_path(self, ii=None):
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  4058
                if ii != None:
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  4059
                        return self.__imgs_path_backup[ii]
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  4060
                return self.__imgs_path_backup[self.img_index()]
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4061
2092
0ef66bf272d3 16852 pkg should look at its image for certs if active image lacks certs
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2089
diff changeset
  4062
        def corrupt_image_create(self, repourl, config, subdirs, prefix="test",
2488
010931d9cabe 18688 pkg clients shouldn't attempt to find an image at startup
Shawn Walker <shawn.walker@oracle.com>
parents: 2478
diff changeset
  4063
            destroy=True):
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4064
                """ Creates two levels of directories under the original image
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4065
                directory. In the first level (called bad), it builds a "corrupt
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4066
                image" which means it builds subdirectories the subdirectories
2158
5a688b5b92a3 15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents: 2144
diff changeset
  4067
                specified by subdirs (essentially determining whether a user
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4068
                image or a full image will be built). It populates these
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4069
                subdirectories with a partial image directory stucture as
2158
5a688b5b92a3 15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents: 2144
diff changeset
  4070
                specified by config. As another subdirectory of bad, it
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4071
                creates a subdirectory called final which represents the
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4072
                directory the command was actually run from (which is why
2092
0ef66bf272d3 16852 pkg should look at its image for certs if active image lacks certs
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2089
diff changeset
  4073
                img_path is set to that location). Existing image destruction
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4074
                was made optional to allow testing of two images installed next
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4075
                to each other (a user and full image created in the same
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4076
                directory for example). """
2339
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  4077
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  4078
                ii = self.img_index()
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  4079
                if ii not in self.__imgs_path_backup:
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  4080
                        self.__imgs_path_backup[ii] = self.img_path()
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  4081
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  4082
                self.set_img_path(os.path.join(self.img_path(), "bad"))
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4083
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4084
                if destroy:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4085
                        self.image_destroy()
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4086
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4087
                for s in subdirs:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4088
                        if s == "var/pkg":
2816
17425ca1f195 7192183 nasty depot testing should be part of core testing
Dan Price <daniel.price@oracle.com>
parents: 2808
diff changeset
  4089
                                cmdline = "image-create -F -p %s=%s %s" % \
2339
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  4090
                                    (prefix, repourl, self.img_path())
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4091
                        elif s == ".org.opensolaris,pkg":
2816
17425ca1f195 7192183 nasty depot testing should be part of core testing
Dan Price <daniel.price@oracle.com>
parents: 2808
diff changeset
  4092
                                cmdline = "image-create -U -p %s=%s %s" % \
2339
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  4093
                                    (prefix, repourl, self.img_path())
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4094
                        else:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4095
                                raise RuntimeError("Got unknown subdir option:"
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4096
                                    "%s\n" % s)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4097
2816
17425ca1f195 7192183 nasty depot testing should be part of core testing
Dan Price <daniel.price@oracle.com>
parents: 2808
diff changeset
  4098
                        cmdline = self.pkg_cmdpath + " " + cmdline
17425ca1f195 7192183 nasty depot testing should be part of core testing
Dan Price <daniel.price@oracle.com>
parents: 2808
diff changeset
  4099
                        self.cmdline_run(cmdline, exit=0)
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4100
2339
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  4101
                        tmpDir = os.path.join(self.img_path(), s)
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4102
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4103
                        # This is where the actual corruption of the
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4104
                        # image takes place. A normal image was created
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4105
                        # above and this goes in and removes critical
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4106
                        # directories and files.
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4107
                        if "publisher_absent" in config or \
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4108
                           "publisher_empty" in config:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4109
                                shutil.rmtree(os.path.join(tmpDir, "publisher"))
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4110
                        if "known_absent" in config or \
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4111
                           "known_empty" in config:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4112
                                shutil.rmtree(os.path.join(tmpDir, "state",
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4113
                                    "known"))
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4114
                        if "known_empty" in config:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4115
                                os.mkdir(os.path.join(tmpDir, "state", "known"))
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4116
                        if "publisher_empty" in config:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4117
                                os.mkdir(os.path.join(tmpDir, "publisher"))
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4118
                        if "cfg_cache_absent" in config:
2144
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2097
diff changeset
  4119
                                os.remove(os.path.join(tmpDir, "pkg5.image"))
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4120
                        if "index_absent" in config:
2144
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2097
diff changeset
  4121
                                shutil.rmtree(os.path.join(tmpDir, "cache",
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2097
diff changeset
  4122
                                    "index"))
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4123
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4124
                # Make find root start at final. (See the doc string for
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4125
                # more explanation.)
2339
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  4126
                cmd_path = os.path.join(self.img_path(), "final")
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4127
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4128
                os.mkdir(cmd_path)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4129
                return cmd_path
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4130
2339
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  4131
def debug(s):
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  4132
        s = str(s)
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  4133
        for x in s.splitlines():
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  4134
                if g_debug_output:
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  4135
                        print >> sys.stderr, "# %s" % x
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  4136
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  4137
def mkdir_eexist_ok(p):
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  4138
        try:
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  4139
                os.mkdir(p)
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  4140
        except OSError, e:
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  4141
                if e.errno != errno.EEXIST:
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  4142
                        raise e
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  4143
2499
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  4144
def env_sanitize(pkg_cmdpath, dv_keep=None):
2364
7598ee41dcbc 18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2339
diff changeset
  4145
        if dv_keep == None:
7598ee41dcbc 18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2339
diff changeset
  4146
                dv_keep = []
7598ee41dcbc 18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2339
diff changeset
  4147
7598ee41dcbc 18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2339
diff changeset
  4148
        dv_saved = {}
7598ee41dcbc 18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2339
diff changeset
  4149
        for dv in dv_keep:
7598ee41dcbc 18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2339
diff changeset
  4150
                # save some DebugValues settings
7598ee41dcbc 18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2339
diff changeset
  4151
                dv_saved[dv] = DebugValues[dv]
7598ee41dcbc 18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2339
diff changeset
  4152
7598ee41dcbc 18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2339
diff changeset
  4153
        # clear any existing DebugValues settings
7598ee41dcbc 18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2339
diff changeset
  4154
        DebugValues.clear()
7598ee41dcbc 18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2339
diff changeset
  4155
7598ee41dcbc 18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2339
diff changeset
  4156
        # clear misc environment variables
7598ee41dcbc 18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2339
diff changeset
  4157
        for e in ["PKG_CMDPATH"]:
7598ee41dcbc 18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2339
diff changeset
  4158
                if e in os.environ:
7598ee41dcbc 18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2339
diff changeset
  4159
                        del os.environ[e]
7598ee41dcbc 18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2339
diff changeset
  4160
7598ee41dcbc 18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2339
diff changeset
  4161
        # Set image path to a path that's not actually an
7598ee41dcbc 18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2339
diff changeset
  4162
        # image to force failure of tests that don't
7598ee41dcbc 18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2339
diff changeset
  4163
        # explicitly provide an image root either through the
7598ee41dcbc 18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2339
diff changeset
  4164
        # default behaviour of the pkg() helper routine or
7598ee41dcbc 18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2339
diff changeset
  4165
        # another method.
7598ee41dcbc 18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2339
diff changeset
  4166
        os.environ["PKG_IMAGE"] = g_tempdir
7598ee41dcbc 18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2339
diff changeset
  4167
7598ee41dcbc 18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2339
diff changeset
  4168
        # Test suite should never attempt to access the
7598ee41dcbc 18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2339
diff changeset
  4169
        # live root image.
7598ee41dcbc 18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2339
diff changeset
  4170
        os.environ["PKG_NO_LIVE_ROOT"] = "1"
7598ee41dcbc 18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2339
diff changeset
  4171
7598ee41dcbc 18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2339
diff changeset
  4172
        # Pkg interfaces should never know they are being
7598ee41dcbc 18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2339
diff changeset
  4173
        # run from within the test suite.
7598ee41dcbc 18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2339
diff changeset
  4174
        os.environ["PKG_NO_RUNPY_CMDPATH"] = "1"
7598ee41dcbc 18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2339
diff changeset
  4175
2690
11a8cae074e0 7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2681
diff changeset
  4176
        # verify PlanDescription serialization and that the PlanDescription
11a8cae074e0 7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2681
diff changeset
  4177
        # isn't modified while we're preparing to for execution.
11a8cae074e0 7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2681
diff changeset
  4178
        DebugValues["plandesc_validate"] = 1
11a8cae074e0 7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2681
diff changeset
  4179
        os.environ["PKG_PLANDESC_VALIDATE"] = "1"
2364
7598ee41dcbc 18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2339
diff changeset
  4180
7598ee41dcbc 18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2339
diff changeset
  4181
        # Pretend that we're being run from the fakeroot image.
2499
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  4182
        assert pkg_cmdpath != "TOXIC"
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  4183
        DebugValues["simulate_cmdpath"] = pkg_cmdpath
2364
7598ee41dcbc 18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2339
diff changeset
  4184
7598ee41dcbc 18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2339
diff changeset
  4185
        # Update the path to smf commands
7598ee41dcbc 18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2339
diff changeset
  4186
        for dv in dv_keep:
7598ee41dcbc 18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2339
diff changeset
  4187
                DebugValues[dv] = dv_saved[dv]
7598ee41dcbc 18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2339
diff changeset
  4188
7598ee41dcbc 18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2339
diff changeset
  4189
        # always get detailed data from the solver
7598ee41dcbc 18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2339
diff changeset
  4190
        DebugValues["plan"] = True
7598ee41dcbc 18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2339
diff changeset
  4191
2499
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  4192
def fakeroot_create():
2364
7598ee41dcbc 18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2339
diff changeset
  4193
7598ee41dcbc 18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2339
diff changeset
  4194
        test_root = os.path.join(g_tempdir, "ips.test.%d" % os.getpid())
2499
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  4195
        fakeroot = os.path.join(test_root, "fakeroot")
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  4196
        cmd_path = os.path.join(fakeroot, "pkg")
2339
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  4197
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  4198
        try:
2499
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  4199
                os.stat(cmd_path)
2339
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  4200
        except OSError, e:
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  4201
                pass
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  4202
        else:
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  4203
                # fakeroot already exists
2595
0bb36cea68dc 18990 generate should know about SUNW_FILTER, FILTER and POSFLAG_1 elf tags
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2580
diff changeset
  4204
                raise RuntimeError("The fakeroot shouldn't already exist.\n"
0bb36cea68dc 18990 generate should know about SUNW_FILTER, FILTER and POSFLAG_1 elf tags
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2580
diff changeset
  4205
                    "Path is:%s" % cmd_path)
2339
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  4206
2364
7598ee41dcbc 18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2339
diff changeset
  4207
        # when creating the fakeroot we want to make sure pkg doesn't
7598ee41dcbc 18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2339
diff changeset
  4208
        # touch the real root.
2499
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  4209
        env_sanitize(cmd_path)
2364
7598ee41dcbc 18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2339
diff changeset
  4210
2339
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  4211
        #
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  4212
        # When accessing images via the pkg apis those apis will try
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  4213
        # to access the image containing the command from which the
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  4214
        # apis were invoked.  Normally when running the test suite the
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  4215
        # command is run.py in a developers workspace, and that
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  4216
        # workspace lives in the root image.  But accessing the root
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  4217
        # image during a test suite run is verboten.  Hence, here we
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  4218
        # create a temporary image from which we can run the pkg
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  4219
        # command.
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  4220
        #
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  4221
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  4222
        # create directories
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  4223
        mkdir_eexist_ok(test_root)
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  4224
        mkdir_eexist_ok(fakeroot)
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  4225
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  4226
        debug("fakeroot image create %s" % fakeroot)
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  4227
        progtrack = pkg.client.progress.NullProgressTracker()
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  4228
        api_inst = pkg.client.api.image_create(PKG_CLIENT_NAME,
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  4229
            CLIENT_API_VERSION, fakeroot,
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  4230
            pkg.client.api.IMG_TYPE_ENTIRE, False,
2499
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  4231
            progtrack=progtrack, cmdpath=cmd_path)
2339
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  4232
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  4233
        #
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  4234
        # put a copy of the pkg command in our fake root directory.
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  4235
        # we do this because when recursive linked image commands are
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  4236
        # run, the pkg interfaces may fork and exec additional copies
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  4237
        # of pkg(1), and in this case we want them to run the copy of
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  4238
        # pkg from the fake root.
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  4239
        #
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  4240
        fakeroot_cmdpath = os.path.join(fakeroot, "pkg")
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  4241
        shutil.copy(os.path.join(g_proto_area, "usr", "bin", "pkg"),
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  4242
            fakeroot_cmdpath)
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  4243
2499
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  4244
        return fakeroot, fakeroot_cmdpath
2339
aa5954c06b9d 16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents: 2319
diff changeset
  4245
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4246
def eval_assert_raises(ex_type, eval_ex_func, func, *args):
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4247
        try:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4248
                func(*args)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4249
        except ex_type, e:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4250
                print str(e)
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4251
                if not eval_ex_func(e):
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4252
                        raise
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4253
        else:
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1516
diff changeset
  4254
                raise RuntimeError("Function did not raise exception.")
2310
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4255
2830
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  4256
class ApacheStateException(Exception):
2310
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4257
        pass
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4258
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4259
class ApacheController(object):
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4260
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4261
        def __init__(self, conf, port, work_dir, testcase=None, https=False):
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4262
                """
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4263
                The 'conf' parameter is a path to a httpd.conf file.  The 'port'
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4264
                parameter is a port to run on.  The 'work_dir' is a temporary
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4265
                directory to store runtime state.  The 'testcase' parameter is
2830
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  4266
                the ApacheDepotTestCase to use when writing output.  The 'https'
2310
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4267
                parameter is a boolean indicating whether this instance expects
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4268
                to be contacted via https or not.
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4269
                """
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4270
2830
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  4271
                self.apachectl = "/usr/apache2/2.2/bin/httpd.worker"
2310
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4272
                if not os.path.exists(work_dir):
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4273
                        os.makedirs(work_dir)
2852
5650587d9468 15807357 need an Apache-based pkg.depotd
Tim Foster <tim.s.foster@oracle.com>
parents: 2843
diff changeset
  4274
                self.__conf_path = os.path.join(work_dir, "httpd.conf")
2310
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4275
                self.__port = port
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4276
                self.__repo_hdl = None
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4277
                self.__starttime = 0
2830
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  4278
                self.__state = "stopped"
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  4279
                if not testcase:
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  4280
                        raise RuntimeError("No testcase parameter specified")
2310
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4281
                self.__tc = testcase
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4282
                prefix = "http"
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4283
                if https:
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4284
                        prefix = "https"
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4285
                self.__url = "%s://localhost:%d" % (prefix, self.__port)
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4286
                portable.copyfile(conf, self.__conf_path)
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4287
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4288
        def __set_conf(self, path):
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4289
                portable.copyfile(path, self.__conf_path)
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4290
                if self.__state == "started":
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4291
                        self.restart()
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4292
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4293
        def __get_conf(self):
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4294
                return self.__conf_path
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4295
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4296
        conf = property(__get_conf, __set_conf)
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4297
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4298
        def _network_ping(self):
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4299
                try:
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4300
                        urllib2.urlopen(self.__url)
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4301
                except urllib2.HTTPError, e:
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4302
                        if e.code == httplib.FORBIDDEN:
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4303
                                return True
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4304
                        return False
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4305
                except urllib2.URLError, e:
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4306
                        if isinstance(e.reason, ssl.SSLError):
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4307
                                return True
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4308
                        return False
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4309
                return True
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4310
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4311
        def debug(self, msg):
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4312
                if self.__tc:
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4313
                        self.__tc.debug(msg)
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4314
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4315
        def debugresult(self, result, expected, msg):
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4316
                if self.__tc:
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4317
                        self.__tc.debugresult(result, expected, msg)
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4318
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4319
        def start(self):
2830
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  4320
                if self not in self.__tc.acs.values():
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  4321
                        # An attempt to start an ApacheController that has not
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  4322
                        # been registered can result in it not getting cleaned
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  4323
                        # up properly when the test completes, which can cause
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  4324
                        # other tests to fail. We don't allow that to happen.
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  4325
                        raise RuntimeError(
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  4326
                            "This ApacheController has not been registered with"
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  4327
                            " the ApacheDepotTestCase %s using "
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  4328
                            "set_apache_controller(name, ac)" % self.__tc)
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  4329
2310
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4330
                if self._network_ping():
2830
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  4331
                        raise ApacheStateException("A depot (or some " +
2310
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4332
                            "other network process) seems to be " +
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4333
                            "running on port %d already!" % self.__port)
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4334
                cmdline = ["/usr/bin/setpgrp", self.apachectl, "-f",
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4335
                    self.__conf_path, "-k", "start", "-DFOREGROUND"]
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4336
                try:
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4337
                        self.__starttime = time.time()
2852
5650587d9468 15807357 need an Apache-based pkg.depotd
Tim Foster <tim.s.foster@oracle.com>
parents: 2843
diff changeset
  4338
                        # change the state so that we try to do work in
5650587d9468 15807357 need an Apache-based pkg.depotd
Tim Foster <tim.s.foster@oracle.com>
parents: 2843
diff changeset
  4339
                        # self.stop() in the face of a False result from
5650587d9468 15807357 need an Apache-based pkg.depotd
Tim Foster <tim.s.foster@oracle.com>
parents: 2843
diff changeset
  4340
                        # is_alive()
5650587d9468 15807357 need an Apache-based pkg.depotd
Tim Foster <tim.s.foster@oracle.com>
parents: 2843
diff changeset
  4341
                        self.__state = "starting"
2310
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4342
                        self.debug(" ".join(cmdline))
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4343
                        self.__repo_hdl = subprocess.Popen(cmdline, shell=False,
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4344
                                stdout=subprocess.PIPE,
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4345
                                stderr=subprocess.PIPE)
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4346
                        if self.__repo_hdl is None:
2852
5650587d9468 15807357 need an Apache-based pkg.depotd
Tim Foster <tim.s.foster@oracle.com>
parents: 2843
diff changeset
  4347
                                self.__state = "stopped"
2830
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  4348
                                raise ApacheStateException("Could not start "
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  4349
                                    "apache")
2310
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4350
                        begintime = time.time()
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4351
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4352
                        check_interval = 0.20
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4353
                        contact = False
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4354
                        while (time.time() - begintime) <= 40.0:
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4355
                                rc = self.__repo_hdl.poll()
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4356
                                if rc is not None:
2852
5650587d9468 15807357 need an Apache-based pkg.depotd
Tim Foster <tim.s.foster@oracle.com>
parents: 2843
diff changeset
  4357
                                        self.__state = "stopped"
2830
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  4358
                                        raise ApacheStateException("Apache "
2310
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4359
                                            "exited unexpectedly while "
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4360
                                            "starting (exit code %d)" % rc)
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4361
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4362
                                if self.is_alive():
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4363
                                        contact = True
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4364
                                        break
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4365
                                time.sleep(check_interval)
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4366
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4367
                        if contact == False:
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4368
                                self.stop()
2830
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  4369
                                raise ApacheStateException("Apache did not "
2310
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4370
                                    "respond to repeated attempts to make "
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4371
                                    "contact")
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4372
                        self.__state = "started"
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4373
                except KeyboardInterrupt:
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4374
                        if self.__repo_hdl:
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4375
                                self.kill(now=True)
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4376
                        raise
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4377
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4378
        def kill(self, now=False):
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4379
                if not self.__repo_hdl:
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4380
                        return
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4381
                try:
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4382
                        lifetime = time.time() - self.__starttime
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4383
                        if now == False and lifetime < 1.0:
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4384
                                time.sleep(1.0 - lifetime)
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4385
                finally:
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4386
                        try:
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4387
                                os.kill(-1 * self.__repo_hdl.pid,
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4388
                                    signal.SIGKILL)
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4389
                        except OSError:
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4390
                                pass
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4391
                        self.__repo_hdl.wait()
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4392
                        self.__state = "killed"
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4393
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4394
        def stop(self):
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4395
                if self.__state == "stopped":
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4396
                        return
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4397
                cmdline = [self.apachectl, "-f", self.__conf_path, "-k",
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4398
                    "stop"]
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4399
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4400
                try:
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4401
                        hdl = subprocess.Popen(cmdline, shell=False,
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4402
                            stdout=subprocess.PIPE,
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4403
                            stderr=subprocess.PIPE)
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4404
                        stop_output, stop_errout = hdl.communicate()
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4405
                        stop_retcode = hdl.returncode
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4406
2499
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  4407
                        self.debugresult(stop_retcode, 0, stop_output)
2310
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4408
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4409
                        if stop_errout != "":
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4410
                                self.debug(stop_errout)
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4411
                        if stop_output != "":
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4412
                                self.debug(stop_output)
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4413
2499
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  4414
                        if stop_retcode != 0:
2310
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4415
                                self.kill(now=True)
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4416
                        else:
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4417
                                self.__state = "stopped"
2499
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  4418
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  4419
                        # Ensure that the apache process gets shutdown
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  4420
                        begintime = time.time()
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  4421
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  4422
                        check_interval = 0.20
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  4423
                        stopped = False
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  4424
                        while (time.time() - begintime) <= 40.0:
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  4425
                                rc = self.__repo_hdl.poll()
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  4426
                                if rc is not None:
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  4427
                                        stopped = True
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  4428
                                        break
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  4429
                                time.sleep(check_interval)
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  4430
                        if not stopped:
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  4431
                                self.kill(now=True)
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  4432
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  4433
                        # retrieve output from the apache process we've just
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  4434
                        # stopped
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  4435
                        output, errout = self.__repo_hdl.communicate()
683824f135a1 18636 a single test suite run should be parallelizable
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2493
diff changeset
  4436
                        self.debug(errout)
2310
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4437
                except KeyboardInterrupt:
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4438
                        self.kill(now=True)
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4439
                        raise
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4440
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4441
        def restart(self):
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4442
                self.stop()
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4443
                self.start()
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4444
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4445
        def chld_sighandler(self, signum, frame):
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4446
                pass
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4447
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4448
        def killall_sighandler(self, signum, frame):
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4449
                print >> sys.stderr, \
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4450
                    "Ctrl-C: I'm killing depots, please wait.\n"
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4451
                print self
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4452
                self.signalled = True
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4453
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4454
        def is_alive(self):
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4455
                """ First, check that the depot process seems to be alive.
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4456
                    Then make a little HTTP request to see if the depot is
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4457
                    responsive to requests """
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4458
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4459
                if self.__repo_hdl == None:
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4460
                        return False
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4461
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4462
                status = self.__repo_hdl.poll()
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4463
                if status != None:
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4464
                        return False
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4465
                return self._network_ping()
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4466
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4467
        @property
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4468
        def url(self):
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4469
                return self.__url
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4470
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4471
class SysrepoController(ApacheController):
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4472
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4473
        def __init__(self, conf, port, work_dir, testcase=None, https=False):
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4474
                ApacheController.__init__(self, conf, port, work_dir,
3063
bbaaf1579de3 15744850 no actuators are run when pkg manipulates a booted NGZ image from the GZ
thejaswini.k@oracle.com
parents: 3048
diff changeset
  4475
                    testcase=testcase, https=https)
2830
ef033a81a335 15785921 test suite should use apache worker mpm rather than prefork
Tim Foster <tim.s.foster@oracle.com>
parents: 2816
diff changeset
  4476
                self.apachectl = "/usr/apache2/2.2/bin/64/httpd.worker"
2310
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4477
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4478
        def _network_ping(self):
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4479
                try:
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4480
                        urllib2.urlopen(urlparse.urljoin(self.url, "syspub/0"))
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4481
                except urllib2.HTTPError, e:
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4482
                        if e.code == httplib.FORBIDDEN:
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4483
                                return True
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4484
                        return False
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4485
                except urllib2.URLError:
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4486
                        return False
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2306
diff changeset
  4487
                return True
2852
5650587d9468 15807357 need an Apache-based pkg.depotd
Tim Foster <tim.s.foster@oracle.com>
parents: 2843
diff changeset
  4488
5650587d9468 15807357 need an Apache-based pkg.depotd
Tim Foster <tim.s.foster@oracle.com>
parents: 2843
diff changeset
  4489
5650587d9468 15807357 need an Apache-based pkg.depotd
Tim Foster <tim.s.foster@oracle.com>
parents: 2843
diff changeset
  4490
class HttpDepotController(ApacheController):
5650587d9468 15807357 need an Apache-based pkg.depotd
Tim Foster <tim.s.foster@oracle.com>
parents: 2843
diff changeset
  4491
5650587d9468 15807357 need an Apache-based pkg.depotd
Tim Foster <tim.s.foster@oracle.com>
parents: 2843
diff changeset
  4492
        def __init__(self, conf, port, work_dir, testcase=None, https=False):
5650587d9468 15807357 need an Apache-based pkg.depotd
Tim Foster <tim.s.foster@oracle.com>
parents: 2843
diff changeset
  4493
                ApacheController.__init__(self, conf, port, work_dir,
3063
bbaaf1579de3 15744850 no actuators are run when pkg manipulates a booted NGZ image from the GZ
thejaswini.k@oracle.com
parents: 3048
diff changeset
  4494
                    testcase=testcase, https=https)
2852
5650587d9468 15807357 need an Apache-based pkg.depotd
Tim Foster <tim.s.foster@oracle.com>
parents: 2843
diff changeset
  4495
                self.apachectl = "/usr/apache2/2.2/bin/64/httpd.worker"
5650587d9468 15807357 need an Apache-based pkg.depotd
Tim Foster <tim.s.foster@oracle.com>
parents: 2843
diff changeset
  4496
5650587d9468 15807357 need an Apache-based pkg.depotd
Tim Foster <tim.s.foster@oracle.com>
parents: 2843
diff changeset
  4497
        def _network_ping(self):
5650587d9468 15807357 need an Apache-based pkg.depotd
Tim Foster <tim.s.foster@oracle.com>
parents: 2843
diff changeset
  4498
                try:
2966
6a97d8a803d3 16297554 pkg history fails when time travelling
thejaswini.k@oracle.com
parents: 2938
diff changeset
  4499
                        # Ping the versions URL, rather than the default /
6a97d8a803d3 16297554 pkg history fails when time travelling
thejaswini.k@oracle.com
parents: 2938
diff changeset
  4500
                        # so that we don't initialize the BUI code yet.
6a97d8a803d3 16297554 pkg history fails when time travelling
thejaswini.k@oracle.com
parents: 2938
diff changeset
  4501
                        urllib2.urlopen(urlparse.urljoin(self.url,
6a97d8a803d3 16297554 pkg history fails when time travelling
thejaswini.k@oracle.com
parents: 2938
diff changeset
  4502
                            "versions/0"))
2852
5650587d9468 15807357 need an Apache-based pkg.depotd
Tim Foster <tim.s.foster@oracle.com>
parents: 2843
diff changeset
  4503
                except urllib2.HTTPError, e:
5650587d9468 15807357 need an Apache-based pkg.depotd
Tim Foster <tim.s.foster@oracle.com>
parents: 2843
diff changeset
  4504
                        if e.code == httplib.FORBIDDEN:
5650587d9468 15807357 need an Apache-based pkg.depotd
Tim Foster <tim.s.foster@oracle.com>
parents: 2843
diff changeset
  4505
                                return True
5650587d9468 15807357 need an Apache-based pkg.depotd
Tim Foster <tim.s.foster@oracle.com>
parents: 2843
diff changeset
  4506
                        return False
5650587d9468 15807357 need an Apache-based pkg.depotd
Tim Foster <tim.s.foster@oracle.com>
parents: 2843
diff changeset
  4507
                except urllib2.URLError:
5650587d9468 15807357 need an Apache-based pkg.depotd
Tim Foster <tim.s.foster@oracle.com>
parents: 2843
diff changeset
  4508
                        return False
5650587d9468 15807357 need an Apache-based pkg.depotd
Tim Foster <tim.s.foster@oracle.com>
parents: 2843
diff changeset
  4509
                return True
5650587d9468 15807357 need an Apache-based pkg.depotd
Tim Foster <tim.s.foster@oracle.com>
parents: 2843
diff changeset
  4510