author | Bart Smaalders <Bart.Smaalders@Sun.COM> |
Fri, 05 Feb 2010 13:07:38 -0800 | |
changeset 1731 | a76f8a1fc049 |
parent 1715 | 8f305f0a6864 |
child 1890 | 011afb71c52a |
permissions | -rw-r--r-- |
1516
8c950a3b4171
10485 move pkg(5) to Python 2.6
Rich Burridge <rich.burridge@sun.com>
parents:
1507
diff
changeset
|
1 |
#!/usr/bin/python |
1369
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
2 |
# -*- coding: utf-8 -*- |
181 | 3 |
# |
4 |
# CDDL HEADER START |
|
5 |
# |
|
6 |
# The contents of this file are subject to the terms of the |
|
7 |
# Common Development and Distribution License (the "License"). |
|
8 |
# You may not use this file except in compliance with the License. |
|
9 |
# |
|
10 |
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE |
|
11 |
# or http://www.opensolaris.org/os/licensing. |
|
12 |
# See the License for the specific language governing permissions |
|
13 |
# and limitations under the License. |
|
14 |
# |
|
15 |
# When distributing Covered Code, include this CDDL HEADER in each |
|
16 |
# file and include the License file at usr/src/OPENSOLARIS.LICENSE. |
|
17 |
# If applicable, add the following below this CDDL HEADER, with the |
|
18 |
# fields enclosed by brackets "[]" replaced with your own identifying |
|
19 |
# information: Portions Copyright [yyyy] [name of copyright owner] |
|
20 |
# |
|
21 |
# CDDL HEADER END |
|
22 |
# |
|
23 |
||
1699
d4dd1d534a62
14181 catalog lazy-loader skips pkg.renamed actions
Shawn Walker <srw@sun.com>
parents:
1606
diff
changeset
|
24 |
# Copyright 2010 Sun Microsystems, Inc. All rights reserved. |
181 | 25 |
# Use is subject to license terms. |
26 |
||
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1710
diff
changeset
|
27 |
import testutils |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1710
diff
changeset
|
28 |
if __name__ == "__main__": |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1710
diff
changeset
|
29 |
testutils.setup_environment("../../../proto") |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1710
diff
changeset
|
30 |
import pkg5unittest |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1710
diff
changeset
|
31 |
|
814
76909c2cad8f
5603 server catalog permissions should be 644, not 600
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
526
diff
changeset
|
32 |
import datetime |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
33 |
import errno |
215
c10719939c6d
245 Need incremental update mechanism for the catalog
johansen <johansen@sun.com>
parents:
195
diff
changeset
|
34 |
import os |
814
76909c2cad8f
5603 server catalog permissions should be 644, not 600
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
526
diff
changeset
|
35 |
import shutil |
76909c2cad8f
5603 server catalog permissions should be 644, not 600
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
526
diff
changeset
|
36 |
import stat |
76909c2cad8f
5603 server catalog permissions should be 644, not 600
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
526
diff
changeset
|
37 |
import sys |
76909c2cad8f
5603 server catalog permissions should be 644, not 600
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
526
diff
changeset
|
38 |
import tempfile |
289
c2e63370fb2b
160 Make IPS cross-platform for use across other supported OS's
Tom Mueller <Tom.Mueller@Sun.COM>
parents:
267
diff
changeset
|
39 |
import time |
814
76909c2cad8f
5603 server catalog permissions should be 644, not 600
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
526
diff
changeset
|
40 |
import unittest |
430
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
419
diff
changeset
|
41 |
|
1369
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
42 |
import pkg.actions |
181 | 43 |
import pkg.fmri as fmri |
44 |
import pkg.catalog as catalog |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
45 |
import pkg.client.api_errors as api_errors |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
46 |
import pkg.manifest as manifest |
1507
b956ea23d3a6
11735 pkg history data files should not be executable
Richard Lowe <richlowe@richlowe.net>
parents:
1472
diff
changeset
|
47 |
import pkg.misc as misc |
879
3e4622a4c074
2747 make per-package progress output work on Windows
Tom Mueller <Tom.Mueller@sun.com>
parents:
852
diff
changeset
|
48 |
import pkg.portable as portable |
1369
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
49 |
import pkg.variant as variant |
181 | 50 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
51 |
|
430
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
419
diff
changeset
|
52 |
class TestCatalog(pkg5unittest.Pkg5TestCase): |
1537 | 53 |
"""Tests for all catalog functionality.""" |
54 |
||
181 | 55 |
def setUp(self): |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1710
diff
changeset
|
56 |
pkg5unittest.Pkg5TestCase.setUp(self) |
181 | 57 |
|
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1710
diff
changeset
|
58 |
self.paths = [self.test_root] |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
59 |
self.c = catalog.Catalog(log_updates=True) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
60 |
self.nversions = 0 |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
61 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
62 |
stems = {} |
181 | 63 |
for f in [ |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
64 |
fmri.PkgFmri("pkg:/[email protected],5.11-1:20000101T120000Z"), |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
65 |
fmri.PkgFmri("pkg:/[email protected],5.11-1:20000101T120010Z"), |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
66 |
fmri.PkgFmri("pkg:/[email protected],5.11-1.1:20000101T120020Z"), |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
67 |
fmri.PkgFmri("pkg:/[email protected],5.11-1.2:20000101T120030Z"), |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
68 |
fmri.PkgFmri("pkg:/[email protected],5.11-2:20000101T120040Z"), |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
69 |
fmri.PkgFmri("pkg:/[email protected],5.11-1:20000101T120040Z"), |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
70 |
fmri.PkgFmri("pkg:/[email protected],5.11-1:20000101T120050Z"), |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
71 |
fmri.PkgFmri("pkg:/[email protected],5.11-1.2:20000101T120051Z"), |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
72 |
fmri.PkgFmri("pkg:/[email protected],5.11-1.2.3:20000101T120052Z"), |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
73 |
fmri.PkgFmri("pkg:/[email protected],5.11-1:20000101T120040Z"), |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
74 |
fmri.PkgFmri("pkg:/[email protected],5.11-1:20000101T120040Z"), |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
75 |
fmri.PkgFmri("pkg:/[email protected],5.11-1:20000101T120014Z") |
181 | 76 |
]: |
1537 | 77 |
if f.pkg_name == "apkg": |
78 |
f.set_publisher("extra") |
|
79 |
elif f.pkg_name == "zpkg": |
|
80 |
f.set_publisher("contrib.opensolaris.org") |
|
81 |
else: |
|
82 |
f.set_publisher("opensolaris.org") |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
83 |
self.c.add_package(f) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
84 |
self.nversions += 1 |
1537 | 85 |
stems[f.get_pkg_stem()] = None |
86 |
||
87 |
# And for good measure, ensure that one of the publishers has |
|
88 |
# a package with the exact same name and version as another |
|
89 |
# publisher's package. |
|
90 |
f = fmri.PkgFmri("pkg://extra/[email protected],5.11-1:20000101T120040Z") |
|
91 |
stems[f.get_pkg_stem()] = None |
|
92 |
self.c.add_package(f) |
|
93 |
self.nversions += 1 |
|
94 |
||
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
95 |
self.npkgs = len(stems) |
181 | 96 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
97 |
def create_test_dir(self, name): |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
98 |
"""Creates a temporary directory with the specified name for |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
99 |
test usage and returns its absolute path.""" |
195
b23d0425f0f7
11 use FMRIs with fully specified authorities internally
johansen <johansen@sun.com>
parents:
181
diff
changeset
|
100 |
|
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1710
diff
changeset
|
101 |
target = os.path.join(self.test_root, name) |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
102 |
try: |
1507
b956ea23d3a6
11735 pkg history data files should not be executable
Richard Lowe <richlowe@richlowe.net>
parents:
1472
diff
changeset
|
103 |
os.makedirs(target, misc.PKG_DIR_MODE) |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
104 |
except OSError, e: |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
105 |
if e.errno != errno.EEXIST: |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
106 |
raise e |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
107 |
return os.path.abspath(target) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
108 |
|
1387
b82c5aaacf0c
11625 catalog.append traceback if src contains more than base part
Shawn Walker <srw@sun.com>
parents:
1369
diff
changeset
|
109 |
def __gen_manifest(self, f): |
b82c5aaacf0c
11625 catalog.append traceback if src contains more than base part
Shawn Walker <srw@sun.com>
parents:
1369
diff
changeset
|
110 |
m = manifest.Manifest() |
1699
d4dd1d534a62
14181 catalog lazy-loader skips pkg.renamed actions
Shawn Walker <srw@sun.com>
parents:
1606
diff
changeset
|
111 |
lines = ( |
1387
b82c5aaacf0c
11625 catalog.append traceback if src contains more than base part
Shawn Walker <srw@sun.com>
parents:
1369
diff
changeset
|
112 |
"depend [email protected] type=require\n" |
b82c5aaacf0c
11625 catalog.append traceback if src contains more than base part
Shawn Walker <srw@sun.com>
parents:
1369
diff
changeset
|
113 |
"set name=facet.devel value=true\n" |
1537 | 114 |
"set name=info.classification " |
115 |
"""value="Desktop (GNOME)/Application" """ |
|
116 |
"""value="org.opensolaris.category.2009:GNOME (Desktop)"\n""" |
|
117 |
"set name=info.classification " |
|
118 |
"""value="Sparc Application" variant.arch=sparc\n""" |
|
119 |
"set name=info.classification " |
|
120 |
"""value="i386 Application" variant.arch=i386\n""" |
|
1387
b82c5aaacf0c
11625 catalog.append traceback if src contains more than base part
Shawn Walker <srw@sun.com>
parents:
1369
diff
changeset
|
121 |
"set name=variant.arch value=i386 value=sparc\n" |
b82c5aaacf0c
11625 catalog.append traceback if src contains more than base part
Shawn Walker <srw@sun.com>
parents:
1369
diff
changeset
|
122 |
"set name=pkg.fmri value=\"%s\"\n" |
b82c5aaacf0c
11625 catalog.append traceback if src contains more than base part
Shawn Walker <srw@sun.com>
parents:
1369
diff
changeset
|
123 |
"set name=pkg.summary value=\"Summary %s\"\n" |
b82c5aaacf0c
11625 catalog.append traceback if src contains more than base part
Shawn Walker <srw@sun.com>
parents:
1369
diff
changeset
|
124 |
"set name=pkg.summary value=\"Sparc Summary %s\"" |
b82c5aaacf0c
11625 catalog.append traceback if src contains more than base part
Shawn Walker <srw@sun.com>
parents:
1369
diff
changeset
|
125 |
" variant.arch=sparc\n" |
b82c5aaacf0c
11625 catalog.append traceback if src contains more than base part
Shawn Walker <srw@sun.com>
parents:
1369
diff
changeset
|
126 |
"set name=pkg.summary:th value=\"ซอฟต์แวร์ %s\"\n" |
b82c5aaacf0c
11625 catalog.append traceback if src contains more than base part
Shawn Walker <srw@sun.com>
parents:
1369
diff
changeset
|
127 |
"set name=pkg.description value=\"Desc %s\"\n" % \ |
1699
d4dd1d534a62
14181 catalog lazy-loader skips pkg.renamed actions
Shawn Walker <srw@sun.com>
parents:
1606
diff
changeset
|
128 |
(f, f, f, f, f)) |
d4dd1d534a62
14181 catalog lazy-loader skips pkg.renamed actions
Shawn Walker <srw@sun.com>
parents:
1606
diff
changeset
|
129 |
|
d4dd1d534a62
14181 catalog lazy-loader skips pkg.renamed actions
Shawn Walker <srw@sun.com>
parents:
1606
diff
changeset
|
130 |
if f.pkg_name == "zpkg": |
1731
a76f8a1fc049
13241 pkg install triggers system incorporation update
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1715
diff
changeset
|
131 |
lines += "set name=pkg.depend.install-hold value=test\n" |
1699
d4dd1d534a62
14181 catalog lazy-loader skips pkg.renamed actions
Shawn Walker <srw@sun.com>
parents:
1606
diff
changeset
|
132 |
lines += "set name=pkg.renamed value=true\n" |
d4dd1d534a62
14181 catalog lazy-loader skips pkg.renamed actions
Shawn Walker <srw@sun.com>
parents:
1606
diff
changeset
|
133 |
else: |
d4dd1d534a62
14181 catalog lazy-loader skips pkg.renamed actions
Shawn Walker <srw@sun.com>
parents:
1606
diff
changeset
|
134 |
lines += "set name=pkg.obsolete value=true\n" |
d4dd1d534a62
14181 catalog lazy-loader skips pkg.renamed actions
Shawn Walker <srw@sun.com>
parents:
1606
diff
changeset
|
135 |
m.set_content(lines, signatures=True) |
d4dd1d534a62
14181 catalog lazy-loader skips pkg.renamed actions
Shawn Walker <srw@sun.com>
parents:
1606
diff
changeset
|
136 |
|
1387
b82c5aaacf0c
11625 catalog.append traceback if src contains more than base part
Shawn Walker <srw@sun.com>
parents:
1369
diff
changeset
|
137 |
return m |
b82c5aaacf0c
11625 catalog.append traceback if src contains more than base part
Shawn Walker <srw@sun.com>
parents:
1369
diff
changeset
|
138 |
|
1369
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
139 |
def __test_catalog_actions(self, nc, pkg_src_list): |
1699
d4dd1d534a62
14181 catalog lazy-loader skips pkg.renamed actions
Shawn Walker <srw@sun.com>
parents:
1606
diff
changeset
|
140 |
def expected_dependency(f): |
d4dd1d534a62
14181 catalog lazy-loader skips pkg.renamed actions
Shawn Walker <srw@sun.com>
parents:
1606
diff
changeset
|
141 |
expected = [ |
1369
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
142 |
"depend [email protected] type=require", |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
143 |
"set name=facet.devel value=true", |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
144 |
"set name=variant.arch value=i386 value=sparc", |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
145 |
] |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
146 |
|
1699
d4dd1d534a62
14181 catalog lazy-loader skips pkg.renamed actions
Shawn Walker <srw@sun.com>
parents:
1606
diff
changeset
|
147 |
if f.pkg_name == "zpkg": |
1731
a76f8a1fc049
13241 pkg install triggers system incorporation update
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1715
diff
changeset
|
148 |
expected.append("set name=pkg.depend.install-hold " |
a76f8a1fc049
13241 pkg install triggers system incorporation update
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1715
diff
changeset
|
149 |
"value=test") |
1699
d4dd1d534a62
14181 catalog lazy-loader skips pkg.renamed actions
Shawn Walker <srw@sun.com>
parents:
1606
diff
changeset
|
150 |
expected.append("set name=pkg.renamed " |
d4dd1d534a62
14181 catalog lazy-loader skips pkg.renamed actions
Shawn Walker <srw@sun.com>
parents:
1606
diff
changeset
|
151 |
"value=true") |
d4dd1d534a62
14181 catalog lazy-loader skips pkg.renamed actions
Shawn Walker <srw@sun.com>
parents:
1606
diff
changeset
|
152 |
else: |
d4dd1d534a62
14181 catalog lazy-loader skips pkg.renamed actions
Shawn Walker <srw@sun.com>
parents:
1606
diff
changeset
|
153 |
expected.append("set name=pkg.obsolete " |
d4dd1d534a62
14181 catalog lazy-loader skips pkg.renamed actions
Shawn Walker <srw@sun.com>
parents:
1606
diff
changeset
|
154 |
"value=true") |
d4dd1d534a62
14181 catalog lazy-loader skips pkg.renamed actions
Shawn Walker <srw@sun.com>
parents:
1606
diff
changeset
|
155 |
return expected |
d4dd1d534a62
14181 catalog lazy-loader skips pkg.renamed actions
Shawn Walker <srw@sun.com>
parents:
1606
diff
changeset
|
156 |
|
1369
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
157 |
def expected_summary(f): |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
158 |
return [ |
1537 | 159 |
('set name=info.classification ' |
160 |
'value="Desktop (GNOME)/Application" ' |
|
161 |
'value="org.opensolaris.category.2009:GNOME (Desktop)"'), |
|
162 |
("set name=info.classification " |
|
163 |
"""value="i386 Application" variant.arch=i386"""), |
|
1369
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
164 |
"set name=pkg.summary value=\"Summary %s\"" % f, |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
165 |
"set name=pkg.description value=\"Desc %s\"" % f, |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
166 |
] |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
167 |
|
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
168 |
def expected_all_variant_summary(f): |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
169 |
return [ |
1537 | 170 |
('set name=info.classification ' |
171 |
'value="Desktop (GNOME)/Application" ' |
|
172 |
'value="org.opensolaris.category.2009:GNOME (Desktop)"'), |
|
173 |
("set name=info.classification " |
|
174 |
"""value="Sparc Application" variant.arch=sparc"""), |
|
175 |
("set name=info.classification " |
|
176 |
"""value="i386 Application" variant.arch=i386"""), |
|
1369
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
177 |
"set name=pkg.summary value=\"Summary %s\"" % f, |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
178 |
("set name=pkg.summary value=\"Sparc Summary %s\"" |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
179 |
" variant.arch=sparc" % f), |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
180 |
"set name=pkg.description value=\"Desc %s\"" % f, |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
181 |
] |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
182 |
|
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
183 |
def expected_all_locale_summary(f): |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
184 |
# The comparison has to be sorted for this case. |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
185 |
return sorted([ |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
186 |
"set name=pkg.summary value=\"Summary %s\"" % f, |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
187 |
"set name=pkg.description value=\"Desc %s\"" % f, |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
188 |
"set name=pkg.summary:th value=\"ซอฟต์แวร์ %s\"" % f, |
1537 | 189 |
('set name=info.classification ' |
190 |
'value="Desktop (GNOME)/Application" ' |
|
191 |
'value="org.opensolaris.category.2009:GNOME (Desktop)"'), |
|
192 |
("set name=info.classification " |
|
193 |
"""value="i386 Application" variant.arch=i386"""), |
|
194 |
]) |
|
195 |
||
196 |
def expected_categories(f): |
|
197 |
# The comparison has to be sorted for this case. |
|
198 |
return set([ |
|
199 |
("", "Desktop (GNOME)/Application"), |
|
200 |
("org.opensolaris.category.2009", "GNOME (Desktop)"), |
|
201 |
("", "i386 Application"), |
|
202 |
]) |
|
203 |
||
204 |
def expected_all_variant_categories(f): |
|
205 |
# The comparison has to be sorted for this case. |
|
206 |
return set([ |
|
207 |
("", "Desktop (GNOME)/Application"), |
|
208 |
("org.opensolaris.category.2009", "GNOME (Desktop)"), |
|
209 |
("", "i386 Application"), |
|
210 |
("", "Sparc Application"), |
|
1369
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
211 |
]) |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
212 |
|
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
213 |
# Next, ensure its populated. |
1537 | 214 |
def ordered(a, b): |
215 |
rval = cmp(a.pkg_name, b.pkg_name) |
|
216 |
if rval != 0: |
|
217 |
return rval |
|
218 |
rval = cmp(a.publisher, b.publisher) |
|
219 |
if rval != 0: |
|
220 |
return rval |
|
221 |
return cmp(a.version, b.version) * -1 |
|
222 |
self.assertEqual([f for f in nc.fmris(ordered=True)], |
|
223 |
sorted(pkg_src_list, cmp=ordered)) |
|
1369
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
224 |
|
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
225 |
# This case should raise an AssertionError. |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
226 |
try: |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
227 |
for f, actions in nc.actions([]): |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
228 |
break |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
229 |
except AssertionError: |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
230 |
pass |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
231 |
else: |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
232 |
raise RuntimeError("actions() did not raise expected " |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
233 |
"exception") |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
234 |
|
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
235 |
variants = variant.Variants() |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
236 |
variants["variant.arch"] = "i386" |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
237 |
excludes = [variants.allow_action] |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
238 |
locales = set(("C", "th")) |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
239 |
|
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
240 |
# This case should only return the dependency-related actions. |
1537 | 241 |
def validate_dep(f, actions): |
1369
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
242 |
returned = [] |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
243 |
for a in actions: |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
244 |
self.assertTrue(isinstance(a, |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
245 |
pkg.actions.generic.Action)) |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
246 |
returned.append(str(a)) |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
247 |
|
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
248 |
var = nc.get_entry_variants(f, "variant.arch") |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
249 |
vars = nc.get_entry_all_variants(f) |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
250 |
if f.pkg_name == "apkg": |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
251 |
# No actions should be returned for this case, |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
252 |
# as the callback will return an empty manifest. |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
253 |
self.assertEqual(returned, []) |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
254 |
self.assertEqual(var, None) |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
255 |
self.assertEqual([v for v in vars], []) |
1537 | 256 |
return |
1369
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
257 |
|
1699
d4dd1d534a62
14181 catalog lazy-loader skips pkg.renamed actions
Shawn Walker <srw@sun.com>
parents:
1606
diff
changeset
|
258 |
expected = expected_dependency(f) |
1369
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
259 |
self.assertEqual(returned, expected) |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
260 |
self.assertEqual(var, ["i386", "sparc"]) |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
261 |
self.assertEqual([(n, vs) for n, vs in vars], |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
262 |
[("variant.arch", ["i386", "sparc"])]) |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
263 |
|
1537 | 264 |
for f, actions in nc.actions([nc.DEPENDENCY]): |
265 |
validate_dep(f, actions) |
|
266 |
||
267 |
latest = [f for f in nc.fmris(last=True)] |
|
268 |
for f, actions in nc.actions([nc.DEPENDENCY], last=True): |
|
269 |
self.assert_(f in latest) |
|
270 |
validate_dep(f, actions) |
|
271 |
||
272 |
latest = [ |
|
273 |
(pub, stem, ver) |
|
274 |
for pub, stem, ver in nc.tuples(last=True) |
|
275 |
] |
|
276 |
for (pub, stem, ver), entry, actions in nc.entry_actions( |
|
277 |
[nc.DEPENDENCY], last=True): |
|
278 |
self.assert_((pub, stem, ver) in latest) |
|
279 |
f = fmri.PkgFmri("%s@%s" % (stem, ver), publisher=pub) |
|
280 |
validate_dep(f, actions) |
|
281 |
||
1369
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
282 |
# This case should only return the summary-related actions (but |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
283 |
# for all variants). |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
284 |
for f, actions in nc.actions([nc.SUMMARY]): |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
285 |
returned = [] |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
286 |
for a in actions: |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
287 |
self.assertTrue(isinstance(a, |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
288 |
pkg.actions.generic.Action)) |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
289 |
returned.append(str(a)) |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
290 |
|
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
291 |
if f.pkg_name == "apkg": |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
292 |
# No actions should be returned for this case, |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
293 |
# as the callback will return an empty manifest. |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
294 |
self.assertEqual(returned, []) |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
295 |
continue |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
296 |
|
1507
b956ea23d3a6
11735 pkg history data files should not be executable
Richard Lowe <richlowe@richlowe.net>
parents:
1472
diff
changeset
|
297 |
expected = expected_all_variant_summary(f) |
1369
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
298 |
self.assertEqual(returned, expected) |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
299 |
|
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
300 |
# This case should only return the summary-related actions (but |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
301 |
# for 'C' and 'th' locales and without sparc variants). |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
302 |
for f, actions in nc.actions([nc.SUMMARY], excludes=excludes, |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
303 |
locales=locales): |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
304 |
returned = [] |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
305 |
for a in actions: |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
306 |
self.assertTrue(isinstance(a, |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
307 |
pkg.actions.generic.Action)) |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
308 |
returned.append(str(a)) |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
309 |
|
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
310 |
if f.pkg_name == "apkg": |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
311 |
# No actions should be returned for this case, |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
312 |
# as the callback will return an empty manifest. |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
313 |
self.assertEqual(returned, []) |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
314 |
continue |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
315 |
|
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
316 |
returned.sort() |
1507
b956ea23d3a6
11735 pkg history data files should not be executable
Richard Lowe <richlowe@richlowe.net>
parents:
1472
diff
changeset
|
317 |
expected = expected_all_locale_summary(f) |
1369
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
318 |
self.assertEqual(returned, expected) |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
319 |
|
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
320 |
# This case should only return the summary-related actions (but |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
321 |
# without sparc variants). |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
322 |
for f, actions in nc.actions([nc.SUMMARY], excludes=excludes): |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
323 |
returned = [] |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
324 |
for a in actions: |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
325 |
self.assertTrue(isinstance(a, |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
326 |
pkg.actions.generic.Action)) |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
327 |
returned.append(str(a)) |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
328 |
|
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
329 |
if f.pkg_name == "apkg": |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
330 |
# No actions should be returned for this case, |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
331 |
# as the callback will return an empty manifest. |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
332 |
self.assertEqual(returned, []) |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
333 |
continue |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
334 |
|
1507
b956ea23d3a6
11735 pkg history data files should not be executable
Richard Lowe <richlowe@richlowe.net>
parents:
1472
diff
changeset
|
335 |
expected = expected_summary(f) |
1369
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
336 |
self.assertEqual(returned, expected) |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
337 |
|
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
338 |
# Verify that retrieving a single entry's actions works as well. |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
339 |
f = pkg_src_list[0] |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
340 |
try: |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
341 |
for a in nc.get_entry_actions(f, []): |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
342 |
break |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
343 |
except AssertionError: |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
344 |
pass |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
345 |
else: |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
346 |
raise RuntimeError("get_entry_actions() did not raise " |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
347 |
"expected exception") |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
348 |
|
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
349 |
# This case should only return the dependency-related actions. |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
350 |
returned = [ |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
351 |
str(a) |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
352 |
for a in nc.get_entry_actions(f, [nc.DEPENDENCY]) |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
353 |
] |
1699
d4dd1d534a62
14181 catalog lazy-loader skips pkg.renamed actions
Shawn Walker <srw@sun.com>
parents:
1606
diff
changeset
|
354 |
expected = expected_dependency(f) |
1369
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
355 |
self.assertEqual(returned, expected) |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
356 |
|
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
357 |
# This case should only return the summary-related actions (but |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
358 |
# for all variants). |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
359 |
returned = [ |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
360 |
str(a) |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
361 |
for a in nc.get_entry_actions(f, [nc.SUMMARY]) |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
362 |
] |
1507
b956ea23d3a6
11735 pkg history data files should not be executable
Richard Lowe <richlowe@richlowe.net>
parents:
1472
diff
changeset
|
363 |
expected = expected_all_variant_summary(f) |
1369
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
364 |
self.assertEqual(returned, expected) |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
365 |
|
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
366 |
# This case should only return the summary-related actions (but |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
367 |
# for 'C' and 'th' locales and without sparc variants). |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
368 |
returned = sorted([ |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
369 |
str(a) |
1507
b956ea23d3a6
11735 pkg history data files should not be executable
Richard Lowe <richlowe@richlowe.net>
parents:
1472
diff
changeset
|
370 |
for a in nc.get_entry_actions(f, [nc.SUMMARY], |
1369
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
371 |
excludes=excludes, locales=locales) |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
372 |
]) |
1507
b956ea23d3a6
11735 pkg history data files should not be executable
Richard Lowe <richlowe@richlowe.net>
parents:
1472
diff
changeset
|
373 |
expected = expected_all_locale_summary(f) |
1369
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
374 |
self.assertEqual(returned, expected) |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
375 |
|
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
376 |
# This case should only return the summary-related actions (but |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
377 |
# without sparc variants). |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
378 |
returned = [ |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
379 |
str(a) |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
380 |
for a in nc.get_entry_actions(f, [nc.SUMMARY], |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
381 |
excludes=excludes) |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
382 |
] |
1507
b956ea23d3a6
11735 pkg history data files should not be executable
Richard Lowe <richlowe@richlowe.net>
parents:
1472
diff
changeset
|
383 |
expected = expected_summary(f) |
1369
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
384 |
self.assertEqual(returned, expected) |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
385 |
|
1537 | 386 |
# This case should return the categories used (but without sparc |
387 |
# variants). |
|
388 |
returned = nc.categories(excludes=excludes) |
|
389 |
expected = expected_categories(f) |
|
390 |
self.assertEqual(returned, expected) |
|
391 |
||
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
392 |
def test_01_attrs(self): |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
393 |
self.assertEqual(self.npkgs, self.c.package_count) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
394 |
self.assertEqual(self.nversions, self.c.package_version_count) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
395 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
396 |
def test_02_extract_matching_fmris(self): |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
397 |
"""Verify that the filtering logic provided by |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
398 |
extract_matching_fmris works as expected.""" |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
399 |
|
181 | 400 |
cf = fmri.PkgFmri("pkg:/[email protected],5.10-1:20070101T120000Z") |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
401 |
cl = catalog.extract_matching_fmris(self.c.fmris(), |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
402 |
patterns=[cf])[0] |
852
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
403 |
self.assertEqual(len(cl), 7) |
181 | 404 |
|
405 |
cf = fmri.PkgFmri("pkg:/[email protected],5.11-1:20061231T120000Z") |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
406 |
cl = catalog.extract_matching_fmris(self.c.fmris(), |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
407 |
patterns=[cf])[0] |
852
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
408 |
self.assertEqual(len(cl), 7) |
181 | 409 |
|
410 |
cf = fmri.PkgFmri("pkg:/[email protected],5.11-2") |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
411 |
cl = catalog.extract_matching_fmris(self.c.fmris(), |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
412 |
patterns=[cf])[0] |
852
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
413 |
self.assertEqual(len(cl), 5) |
181 | 414 |
|
415 |
cf = fmri.PkgFmri("pkg:/[email protected],5.11-3") |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
416 |
cl = catalog.extract_matching_fmris(self.c.fmris(), |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
417 |
patterns=[cf])[0] |
852
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
418 |
self.assertEqual(len(cl), 4) |
181 | 419 |
|
852
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
420 |
# First, verify that passing a single version pattern |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
421 |
# works as expected. |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
422 |
|
1537 | 423 |
# Sorts by stem, then version, then publisher. |
424 |
def extract_order(a, b): |
|
425 |
res = cmp(a.pkg_name, b.pkg_name) |
|
426 |
if res != 0: |
|
427 |
return res |
|
428 |
res = cmp(a.version, b.version) * -1 |
|
429 |
if res != 0: |
|
430 |
return res |
|
431 |
return cmp(a.publisher, b.publisher) |
|
432 |
||
852
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
433 |
# This is a dict containing the set of fmris that are expected |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
434 |
# to be returned by extract_matching_fmris keyed by version |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
435 |
# pattern. |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
436 |
versions = { |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
437 |
"*": ["pkg:/[email protected],5.11-1:20000101T120040Z", |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
438 |
"pkg:/[email protected],5.11-1:20000101T120000Z", |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
439 |
"pkg:/[email protected],5.11-1:20000101T120010Z", |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
440 |
"pkg:/[email protected],5.11-1.1:20000101T120020Z", |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
441 |
"pkg:/[email protected],5.11-1.2:20000101T120030Z", |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
442 |
"pkg:/[email protected],5.11-2:20000101T120040Z", |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
443 |
"pkg:/[email protected],5.11-1:20000101T120040Z", |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
444 |
"pkg:/[email protected],5.11-1:20000101T120050Z", |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
445 |
"pkg:/[email protected],5.11-1.2:20000101T120051Z", |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
446 |
"pkg:/[email protected],5.11-1.2.3:20000101T120052Z", |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
447 |
"pkg:/[email protected],5.11-1:20000101T120014Z", |
1537 | 448 |
"pkg:/[email protected],5.11-1:20000101T120040Z", |
852
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
449 |
"pkg:/[email protected],5.11-1:20000101T120040Z"], |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
450 |
"1.0": ["pkg:/[email protected],5.11-1:20000101T120040Z", |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
451 |
"pkg:/[email protected],5.11-1:20000101T120000Z", |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
452 |
"pkg:/[email protected],5.11-1:20000101T120010Z", |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
453 |
"pkg:/[email protected],5.11-1.1:20000101T120020Z", |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
454 |
"pkg:/[email protected],5.11-1.2:20000101T120030Z", |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
455 |
"pkg:/[email protected],5.11-2:20000101T120040Z", |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
456 |
"pkg:/[email protected],5.11-1:20000101T120014Z", |
1537 | 457 |
"pkg:/[email protected],5.11-1:20000101T120040Z", |
852
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
458 |
"pkg:/[email protected],5.11-1:20000101T120040Z"], |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
459 |
"1.1": ["pkg:/[email protected],5.11-1:20000101T120040Z"], |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
460 |
"*.1": ["pkg:/[email protected],5.11-1:20000101T120040Z"], |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
461 |
"3.*": ["pkg:/[email protected],5.11-1:20000101T120050Z", |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
462 |
"pkg:/[email protected],5.11-1.2:20000101T120051Z", |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
463 |
"pkg:/[email protected],5.11-1.2.3:20000101T120052Z"], |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
464 |
"3.2.*": ["pkg:/[email protected],5.11-1:20000101T120050Z", |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
465 |
"pkg:/[email protected],5.11-1.2:20000101T120051Z", |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
466 |
"pkg:/[email protected],5.11-1.2.3:20000101T120052Z"], |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
467 |
"3.*.*": ["pkg:/[email protected],5.11-1:20000101T120050Z", |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
468 |
"pkg:/[email protected],5.11-1.2:20000101T120051Z", |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
469 |
"pkg:/[email protected],5.11-1.2.3:20000101T120052Z"], |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
470 |
"*,5.11": ["pkg:/[email protected],5.11-1:20000101T120040Z", |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
471 |
"pkg:/[email protected],5.11-1:20000101T120000Z", |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
472 |
"pkg:/[email protected],5.11-1:20000101T120010Z", |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
473 |
"pkg:/[email protected],5.11-1.1:20000101T120020Z", |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
474 |
"pkg:/[email protected],5.11-1.2:20000101T120030Z", |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
475 |
"pkg:/[email protected],5.11-2:20000101T120040Z", |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
476 |
"pkg:/[email protected],5.11-1:20000101T120040Z", |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
477 |
"pkg:/[email protected],5.11-1:20000101T120050Z", |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
478 |
"pkg:/[email protected],5.11-1.2:20000101T120051Z", |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
479 |
"pkg:/[email protected],5.11-1.2.3:20000101T120052Z", |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
480 |
"pkg:/[email protected],5.11-1:20000101T120014Z", |
1537 | 481 |
"pkg:/[email protected],5.11-1:20000101T120040Z", |
852
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
482 |
"pkg:/[email protected],5.11-1:20000101T120040Z"], |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
483 |
"*,*-*": ["pkg:/[email protected],5.11-1:20000101T120040Z", |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
484 |
"pkg:/[email protected],5.11-1:20000101T120000Z", |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
485 |
"pkg:/[email protected],5.11-1:20000101T120010Z", |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
486 |
"pkg:/[email protected],5.11-1.1:20000101T120020Z", |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
487 |
"pkg:/[email protected],5.11-1.2:20000101T120030Z", |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
488 |
"pkg:/[email protected],5.11-2:20000101T120040Z", |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
489 |
"pkg:/[email protected],5.11-1:20000101T120040Z", |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
490 |
"pkg:/[email protected],5.11-1:20000101T120050Z", |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
491 |
"pkg:/[email protected],5.11-1.2:20000101T120051Z", |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
492 |
"pkg:/[email protected],5.11-1.2.3:20000101T120052Z", |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
493 |
"pkg:/[email protected],5.11-1:20000101T120014Z", |
1537 | 494 |
"pkg:/[email protected],5.11-1:20000101T120040Z", |
852
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
495 |
"pkg:/[email protected],5.11-1:20000101T120040Z"], |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
496 |
"*,*-*.2": ["pkg:/[email protected],5.11-1.2:20000101T120030Z", |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
497 |
"pkg:/[email protected],5.11-1.2:20000101T120051Z"], |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
498 |
"*,*-*.*.3": ["pkg:/[email protected],5.11-1.2.3:20000101T120052Z"], |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
499 |
"*,*-1": ["pkg:/[email protected],5.11-1:20000101T120040Z", |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
500 |
"pkg:/[email protected],5.11-1:20000101T120000Z", |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
501 |
"pkg:/[email protected],5.11-1:20000101T120010Z", |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
502 |
"pkg:/[email protected],5.11-1:20000101T120040Z", |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
503 |
"pkg:/[email protected],5.11-1:20000101T120050Z", |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
504 |
"pkg:/[email protected],5.11-1:20000101T120014Z", |
1537 | 505 |
"pkg:/[email protected],5.11-1:20000101T120040Z", |
852
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
506 |
"pkg:/[email protected],5.11-1:20000101T120040Z"], |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
507 |
"*,*-1.2": ["pkg:/[email protected],5.11-1.2:20000101T120030Z", |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
508 |
"pkg:/[email protected],5.11-1.2:20000101T120051Z"], |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
509 |
"*,*-1.2.*": ["pkg:/[email protected],5.11-1.2:20000101T120030Z", |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
510 |
"pkg:/[email protected],5.11-1.2:20000101T120051Z", |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
511 |
"pkg:/[email protected],5.11-1.2.3:20000101T120052Z"], |
1537 | 512 |
"*,*-*:*": ["pkg:/[email protected],5.11-1:20000101T120040Z", |
852
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
513 |
"pkg:/[email protected],5.11-1:20000101T120000Z", |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
514 |
"pkg:/[email protected],5.11-1:20000101T120010Z", |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
515 |
"pkg:/[email protected],5.11-1.1:20000101T120020Z", |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
516 |
"pkg:/[email protected],5.11-1.2:20000101T120030Z", |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
517 |
"pkg:/[email protected],5.11-2:20000101T120040Z", |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
518 |
"pkg:/[email protected],5.11-1:20000101T120040Z", |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
519 |
"pkg:/[email protected],5.11-1:20000101T120050Z", |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
520 |
"pkg:/[email protected],5.11-1.2:20000101T120051Z", |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
521 |
"pkg:/[email protected],5.11-1.2.3:20000101T120052Z", |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
522 |
"pkg:/[email protected],5.11-1:20000101T120014Z", |
1537 | 523 |
"pkg:/[email protected],5.11-1:20000101T120040Z", |
524 |
"pkg:/[email protected],5.11-1:20000101T120040Z"], |
|
525 |
} |
|
526 |
||
527 |
for pat in versions: |
|
528 |
chash = {} |
|
529 |
rlist = [] |
|
530 |
for f in catalog.extract_matching_fmris(self.c.fmris(), |
|
531 |
counthash=chash, versions=[pat])[0]: |
|
532 |
f.set_publisher(None) |
|
533 |
rlist.append(f) |
|
534 |
||
535 |
# Custom sort the returned and expected to avoid having |
|
536 |
# to define test data in extract order. The primary |
|
537 |
# interest here is in what is returned, not the order. |
|
538 |
rlist = sorted([ |
|
539 |
fmri.PkgFmri(f.get_fmri(anarchy=True)) |
|
540 |
for f in rlist |
|
541 |
]) |
|
542 |
rlist = [f.get_fmri() for f in rlist] |
|
543 |
||
544 |
elist = sorted([ |
|
545 |
fmri.PkgFmri(e) |
|
546 |
for e in versions[pat] |
|
547 |
]) |
|
548 |
elist = [f.get_fmri() for f in elist] |
|
549 |
||
550 |
# Verify that the list of matches are the same. |
|
551 |
self.assertEqual(rlist, elist) |
|
552 |
||
553 |
# Verify that the same number of matches was returned |
|
554 |
# in the counthash. |
|
555 |
self.assertEqual(chash[pat], len(versions[pat])) |
|
556 |
||
557 |
# Last, verify that providing multiple versions for a single |
|
558 |
# call returns the expected results. |
|
559 |
||
560 |
# This is a dict containing the set of fmris that are expected |
|
561 |
# to be returned by extract_matching_fmris keyed by version |
|
562 |
# pattern. |
|
563 |
versions = { |
|
564 |
"*,*-1": ["pkg:/[email protected],5.11-1:20000101T120040Z", |
|
565 |
"pkg:/[email protected],5.11-1:20000101T120000Z", |
|
566 |
"pkg:/[email protected],5.11-1:20000101T120010Z", |
|
567 |
"pkg:/[email protected],5.11-1:20000101T120040Z", |
|
568 |
"pkg:/[email protected],5.11-1:20000101T120050Z", |
|
569 |
"pkg:/[email protected],5.11-1:20000101T120014Z", |
|
570 |
"pkg:/[email protected],5.11-1:20000101T120040Z", |
|
852
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
571 |
"pkg:/[email protected],5.11-1:20000101T120040Z"], |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
572 |
"*,*-*:*": ["pkg:/[email protected],5.11-1:20000101T120040Z", |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
573 |
"pkg:/[email protected],5.11-1:20000101T120000Z", |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
574 |
"pkg:/[email protected],5.11-1:20000101T120010Z", |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
575 |
"pkg:/[email protected],5.11-1.1:20000101T120020Z", |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
576 |
"pkg:/[email protected],5.11-1.2:20000101T120030Z", |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
577 |
"pkg:/[email protected],5.11-2:20000101T120040Z", |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
578 |
"pkg:/[email protected],5.11-1:20000101T120040Z", |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
579 |
"pkg:/[email protected],5.11-1:20000101T120050Z", |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
580 |
"pkg:/[email protected],5.11-1.2:20000101T120051Z", |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
581 |
"pkg:/[email protected],5.11-1.2.3:20000101T120052Z", |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
582 |
"pkg:/[email protected],5.11-1:20000101T120014Z", |
1537 | 583 |
"pkg:/[email protected],5.11-1:20000101T120040Z", |
852
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
584 |
"pkg:/[email protected],5.11-1:20000101T120040Z"], |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
585 |
} |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
586 |
|
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
587 |
elist = [ |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
588 |
"pkg:/[email protected],5.11-1:20000101T120040Z", |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
589 |
"pkg:/[email protected],5.11-1:20000101T120000Z", |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
590 |
"pkg:/[email protected],5.11-1:20000101T120010Z", |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
591 |
"pkg:/[email protected],5.11-1.1:20000101T120020Z", |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
592 |
"pkg:/[email protected],5.11-1.2:20000101T120030Z", |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
593 |
"pkg:/[email protected],5.11-2:20000101T120040Z", |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
594 |
"pkg:/[email protected],5.11-1:20000101T120040Z", |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
595 |
"pkg:/[email protected],5.11-1:20000101T120050Z", |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
596 |
"pkg:/[email protected],5.11-1.2:20000101T120051Z", |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
597 |
"pkg:/[email protected],5.11-1.2.3:20000101T120052Z", |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
598 |
"pkg:/[email protected],5.11-1:20000101T120014Z", |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
599 |
"pkg:/[email protected],5.11-1:20000101T120040Z", |
1537 | 600 |
"pkg:/[email protected],5.11-1:20000101T120040Z", |
852
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
601 |
] |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
602 |
|
1537 | 603 |
rlist = catalog.extract_matching_fmris(self.c.fmris(), |
604 |
counthash=chash, versions=versions.keys())[0] |
|
605 |
rlist = sorted([ |
|
606 |
fmri.PkgFmri(f.get_fmri(anarchy=True)) |
|
607 |
for f in rlist |
|
608 |
]) |
|
609 |
rlist = [f.get_fmri() for f in rlist] |
|
852
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
610 |
|
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
611 |
# Verify that the list of matches are the same. |
1537 | 612 |
self.assertEqual(rlist, elist) |
852
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
613 |
|
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
614 |
for pat in versions: |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
615 |
# Verify that the same number of matches was returned |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
616 |
# in the counthash. |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
617 |
self.assertEqual(chash[pat], len(versions[pat])) |
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
618 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
619 |
def test_03_permissions(self): |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
620 |
"""Verify that new catalogs are created with a mode of 644 and |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
621 |
that old catalogs will have their mode forcibly changed, unless |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
622 |
read_only is specified, in which case an exception is raised. |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
623 |
See bug 5603 for a documented case.""" |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
624 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
625 |
# Catalog files should have this mode. |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
626 |
mode = stat.S_IRUSR|stat.S_IWUSR|stat.S_IRGRP|stat.S_IROTH |
1369
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
627 |
# Windows doesn't have group or other permissions, so they |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
628 |
# are set to be the same as for the owner |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
629 |
if portable.ostype == "windows": |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
630 |
mode |= stat.S_IWGRP|stat.S_IWOTH |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
631 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
632 |
# Catalog files should not have this mode. |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
633 |
bad_mode = stat.S_IRUSR|stat.S_IWUSR |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
634 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
635 |
# Test new catalog case. |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
636 |
cpath = self.create_test_dir("test-04") |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
637 |
c = catalog.Catalog(meta_root=cpath, log_updates=True) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
638 |
c.add_package(fmri.PkgFmri( |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
639 |
"pkg://opensolaris.org/[email protected],5.11-1:20000101T120000Z")) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
640 |
c.save() |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
641 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
642 |
for fname in c.signatures: |
1407
56042994e222
8049 leading / not stripped from file action path on Windows
Tom Mueller <Tom.Mueller@sun.com>
parents:
1387
diff
changeset
|
643 |
fn = os.path.join(c.meta_root, fname) |
56042994e222
8049 leading / not stripped from file action path on Windows
Tom Mueller <Tom.Mueller@sun.com>
parents:
1387
diff
changeset
|
644 |
portable.assert_mode(fn, mode) |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
645 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
646 |
# Now test old catalog case. |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
647 |
for fname in c.signatures: |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
648 |
os.chmod(os.path.join(c.meta_root, fname), bad_mode) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
649 |
c = catalog.Catalog(meta_root=cpath, log_updates=True) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
650 |
for fname in c.signatures: |
1407
56042994e222
8049 leading / not stripped from file action path on Windows
Tom Mueller <Tom.Mueller@sun.com>
parents:
1387
diff
changeset
|
651 |
fn = os.path.join(c.meta_root, fname) |
56042994e222
8049 leading / not stripped from file action path on Windows
Tom Mueller <Tom.Mueller@sun.com>
parents:
1387
diff
changeset
|
652 |
portable.assert_mode(fn, mode) |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
653 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
654 |
# Need to add an fmri to it and then re-test the permissions |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
655 |
# since this causes the catalog file to be re-created. |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
656 |
c.add_package(fmri.PkgFmri( |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
657 |
"pkg://opensolaris.org/[email protected],5.11-1:20000101T120000Z")) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
658 |
c.save() |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
659 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
660 |
for fname in c.signatures: |
1407
56042994e222
8049 leading / not stripped from file action path on Windows
Tom Mueller <Tom.Mueller@sun.com>
parents:
1387
diff
changeset
|
661 |
fn = os.path.join(c.meta_root, fname) |
56042994e222
8049 leading / not stripped from file action path on Windows
Tom Mueller <Tom.Mueller@sun.com>
parents:
1387
diff
changeset
|
662 |
portable.assert_mode(fn, mode) |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
663 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
664 |
# Finally, test read_only old catalog case. |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
665 |
for fname in c.signatures: |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
666 |
os.chmod(os.path.join(c.meta_root, fname), bad_mode) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
667 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
668 |
self.assertRaises(api_errors.BadCatalogPermissions, |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
669 |
catalog.Catalog, meta_root=c.meta_root, read_only=True) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
670 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
671 |
def test_04_store_and_validate(self): |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
672 |
"""Test catalog storage, retrieval, and validation.""" |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
673 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
674 |
cpath = self.create_test_dir("test-05") |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
675 |
c = catalog.Catalog(meta_root=cpath, log_updates=True) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
676 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
677 |
# Verify that a newly created catalog has no signature data. |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
678 |
for file, sigs in c.signatures.iteritems(): |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
679 |
self.assertEqual(len(sigs), 0) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
680 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
681 |
# Verify that a newly created catalog will validate since no |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
682 |
# signature data is present. |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
683 |
c.validate() |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
684 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
685 |
# Verify catalog storage and retrieval works. |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
686 |
c.add_package(fmri.PkgFmri("pkg://opensolaris.org/" |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
687 |
"[email protected],5.11-1:20000101T120000Z")) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
688 |
c.save() |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
689 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
690 |
# Get a copy of the signature data. |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
691 |
old_sigs = c.signatures |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
692 |
|
1358
6fec8fbc15a6
11324 package state written to parent boot environment during image-update
Shawn Walker <srw@sun.com>
parents:
1352
diff
changeset
|
693 |
# Verify that a catalog will have signature data after save(). |
6fec8fbc15a6
11324 package state written to parent boot environment during image-update
Shawn Walker <srw@sun.com>
parents:
1352
diff
changeset
|
694 |
self.assertTrue(len(old_sigs) >= 1) |
6fec8fbc15a6
11324 package state written to parent boot environment during image-update
Shawn Walker <srw@sun.com>
parents:
1352
diff
changeset
|
695 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
696 |
# Verify that expected entries are present. |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
697 |
self.assertTrue("catalog.attrs" in old_sigs) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
698 |
self.assertTrue("catalog.base.C" in old_sigs) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
699 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
700 |
updates = 0 |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
701 |
for file, sigs in old_sigs.iteritems(): |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
702 |
self.assertTrue(len(sigs) >= 1) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
703 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
704 |
if file.startswith("update."): |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
705 |
updates += 1 |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
706 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
707 |
# Only one updatelog should exist. |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
708 |
self.assertEqual(updates, 1) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
709 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
710 |
# Next, retrieve the stored catalog. |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
711 |
c = catalog.Catalog(meta_root=cpath, log_updates=True) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
712 |
pkg_list = [f for f in c.fmris()] |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
713 |
self.assertEqual(pkg_list, [fmri.PkgFmri( |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
714 |
"pkg://opensolaris.org/[email protected],5.11-1:20000101T120000Z")]) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
715 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
716 |
# Verify that a stored catalog will validate, and that its |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
717 |
# current signatures match its previous signatures. |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
718 |
c.validate() |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
719 |
self.assertEqual(old_sigs, c.signatures) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
720 |
|
1358
6fec8fbc15a6
11324 package state written to parent boot environment during image-update
Shawn Walker <srw@sun.com>
parents:
1352
diff
changeset
|
721 |
# Finally, test that a catalog created with sign=False won't |
6fec8fbc15a6
11324 package state written to parent boot environment during image-update
Shawn Walker <srw@sun.com>
parents:
1352
diff
changeset
|
722 |
# have any signature data after being saved. |
6fec8fbc15a6
11324 package state written to parent boot environment during image-update
Shawn Walker <srw@sun.com>
parents:
1352
diff
changeset
|
723 |
c = catalog.Catalog(sign=False) |
6fec8fbc15a6
11324 package state written to parent boot environment during image-update
Shawn Walker <srw@sun.com>
parents:
1352
diff
changeset
|
724 |
c.save() |
6fec8fbc15a6
11324 package state written to parent boot environment during image-update
Shawn Walker <srw@sun.com>
parents:
1352
diff
changeset
|
725 |
self.assertEqual(c.signatures, { "catalog.attrs": {} }) |
6fec8fbc15a6
11324 package state written to parent boot environment during image-update
Shawn Walker <srw@sun.com>
parents:
1352
diff
changeset
|
726 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
727 |
def test_05_retrieval(self): |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
728 |
"""Verify that various catalog retrieval methods work as |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
729 |
expected.""" |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
730 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
731 |
vers = {} |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
732 |
fmris = {} |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
733 |
for f in self.c.fmris(): |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
734 |
vers.setdefault(f.pkg_name, []) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
735 |
vers[f.pkg_name].append(f.version) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
736 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
737 |
fmris.setdefault(f.pkg_name, {}) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
738 |
fmris[f.pkg_name].setdefault(str(f.version), []) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
739 |
fmris[f.pkg_name][str(f.version)].append(f) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
740 |
|
1537 | 741 |
# test names() |
742 |
self.assertEqual(self.c.names(), set(["apkg", "test", "zpkg"])) |
|
743 |
self.assertEqual(self.c.names(pubs=["extra", |
|
744 |
"opensolaris.org"]), set(["apkg", "test", "zpkg"])) |
|
745 |
self.assertEqual(self.c.names(pubs=["extra", |
|
746 |
"contrib.opensolaris.org"]), set(["apkg", "zpkg"])) |
|
747 |
self.assertEqual(self.c.names(pubs=["opensolaris.org"]), |
|
748 |
set(["test"])) |
|
749 |
||
750 |
# test pkg_names() |
|
751 |
expected = [ |
|
752 |
("extra", "apkg"), |
|
753 |
("opensolaris.org", "test"), |
|
754 |
("contrib.opensolaris.org", "zpkg"), |
|
755 |
("extra", "zpkg"), |
|
756 |
] |
|
757 |
||
758 |
for pubs in ([], ["extra", "opensolaris.org"], ["extra"], |
|
759 |
["bobcat"]): |
|
760 |
elist = [ |
|
761 |
e for e in expected |
|
762 |
if not pubs or e[0] in pubs |
|
763 |
] |
|
764 |
rlist = [e for e in self.c.pkg_names(pubs=pubs)] |
|
765 |
self.assertEqual(rlist, elist) |
|
766 |
||
767 |
def fmri_order(a, b): |
|
768 |
rval = cmp(a.pkg_name, b.pkg_name) |
|
769 |
if rval != 0: |
|
770 |
return rval |
|
771 |
rval = cmp(a.publisher, b.publisher) |
|
772 |
if rval != 0: |
|
773 |
return rval |
|
774 |
return cmp(a.version, b.version) * -1 |
|
775 |
||
776 |
def tuple_order(a, b): |
|
777 |
apub, astem, aver = a |
|
778 |
bpub, bstem, bver = b |
|
779 |
rval = cmp(astem, bstem) |
|
780 |
if rval != 0: |
|
781 |
return rval |
|
782 |
rval = cmp(apub, bpub) |
|
783 |
if rval != 0: |
|
784 |
return rval |
|
785 |
aver = version.Version(aver, "5.11") |
|
786 |
bver = version.Version(bver, "5.11") |
|
787 |
return cmp(aver, bver) * -1 |
|
788 |
||
789 |
def tuple_entry_order(a, b): |
|
790 |
(apub, astem, aver), entry = a |
|
791 |
(bpub, bstem, bver), entry = b |
|
792 |
rval = cmp(astem, bstem) |
|
793 |
if rval != 0: |
|
794 |
return rval |
|
795 |
rval = cmp(apub, bpub) |
|
796 |
if rval != 0: |
|
797 |
return rval |
|
798 |
aver = version.Version(aver, "5.11") |
|
799 |
bver = version.Version(bver, "5.11") |
|
800 |
return cmp(aver, bver) * -1 |
|
801 |
||
802 |
# test fmris() |
|
803 |
for pubs in ([], ["extra", "opensolaris.org"], ["extra"], |
|
804 |
["bobcat"]): |
|
805 |
# Check base functionality. |
|
806 |
elist = [ |
|
807 |
f for f in self.c.fmris() |
|
808 |
if not pubs or f.publisher in pubs |
|
809 |
] |
|
810 |
rlist = [e for e in self.c.fmris(pubs=pubs)] |
|
811 |
self.assertEqual(rlist, elist) |
|
812 |
||
813 |
# Check last functionality. |
|
814 |
elist = {} |
|
815 |
for f in self.c.fmris(pubs=pubs): |
|
816 |
if f.get_pkg_stem() not in elist or \ |
|
817 |
f.version > elist[f.get_pkg_stem()].version: |
|
818 |
elist[f.get_pkg_stem()] = f |
|
819 |
elist = sorted(elist.values()) |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
820 |
|
1537 | 821 |
rlist = sorted([f for f in self.c.fmris(last=True, |
822 |
pubs=pubs)]) |
|
823 |
self.assertEqual(rlist, elist) |
|
824 |
||
825 |
# Check ordered functionality. |
|
826 |
elist.sort(cmp=fmri_order) |
|
827 |
||
828 |
rlist = [f for f in self.c.fmris(last=True, |
|
829 |
ordered=True, pubs=pubs)] |
|
830 |
self.assertEqual(rlist, elist) |
|
831 |
||
832 |
# test entries(), tuple_entries() |
|
833 |
for pubs in ([], ["extra", "opensolaris.org"], ["extra"], |
|
834 |
["bobcat"]): |
|
835 |
# Check base functionality. |
|
836 |
elist = [(f, {}) for f in self.c.fmris(pubs=pubs)] |
|
837 |
rlist = [e for e in self.c.entries(pubs=pubs)] |
|
838 |
self.assertEqual(rlist, elist) |
|
839 |
||
840 |
# Check last functionality. |
|
841 |
elist = {} |
|
842 |
for f in self.c.fmris(pubs=pubs): |
|
843 |
if f.get_pkg_stem() not in elist or \ |
|
844 |
f.version > elist[f.get_pkg_stem()].version: |
|
845 |
elist[f.get_pkg_stem()] = f |
|
846 |
elist = [(f, {}) for f in sorted(elist.values(), |
|
847 |
cmp=fmri_order)] |
|
848 |
rlist = [e for e in self.c.entries(last=True, |
|
849 |
ordered=True, pubs=pubs)] |
|
850 |
self.assertEqual(rlist, elist) |
|
851 |
||
852 |
# Check base functionality. |
|
853 |
elist = [] |
|
854 |
for f in self.c.fmris(pubs=pubs): |
|
855 |
pub, stem, ver = f.tuple() |
|
856 |
ver = str(ver) |
|
857 |
elist.append(((pub, stem, ver), {})) |
|
858 |
rlist = [e for e in self.c.tuple_entries(pubs=pubs)] |
|
859 |
self.assertEqual(rlist, elist) |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
860 |
|
1537 | 861 |
# Check last functionality. |
862 |
elist = {} |
|
863 |
for f in self.c.fmris(pubs=pubs): |
|
864 |
if f.get_pkg_stem() not in elist or \ |
|
865 |
f.version > elist[f.get_pkg_stem()].version: |
|
866 |
elist[f.get_pkg_stem()] = f |
|
867 |
||
868 |
nlist = [] |
|
869 |
for f in sorted(elist.values()): |
|
870 |
pub, stem, ver = f.tuple() |
|
871 |
ver = str(ver) |
|
872 |
nlist.append(((pub, stem, ver), {})) |
|
873 |
elist = sorted(nlist, cmp=tuple_entry_order) |
|
874 |
nlist = None |
|
875 |
rlist = [e for e in self.c.tuple_entries(last=True, |
|
876 |
ordered=True, pubs=pubs)] |
|
877 |
self.assertEqual(rlist, elist) |
|
878 |
||
879 |
# test entries_by_version() and fmris_by_version() |
|
880 |
for pubs in ([], ["extra", "opensolaris.org"], ["extra"]): |
|
881 |
for name in fmris: |
|
882 |
for ver, entries in self.c.entries_by_version( |
|
883 |
name, pubs=pubs): |
|
884 |
flist = [ |
|
885 |
f[1] for f in entries |
|
886 |
if not pubs or f[0].publisher in pubs |
|
887 |
] |
|
888 |
elist = [ |
|
889 |
{} for f in entries |
|
890 |
if not pubs or f[0].publisher in pubs |
|
891 |
] |
|
892 |
self.assertEqual(flist, elist) |
|
893 |
||
894 |
for ver, pfmris in self.c.fmris_by_version(name, |
|
895 |
pubs=pubs): |
|
896 |
elist = [ |
|
897 |
f for f in fmris[name][str(ver)] |
|
898 |
if not pubs or f.publisher in pubs |
|
899 |
] |
|
900 |
self.assertEqual(pfmris, elist) |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
901 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
902 |
def test_06_operations(self): |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
903 |
"""Verify that catalog operations work as expected.""" |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
904 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
905 |
# Three sample packages used to verify that catalog data |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
906 |
# is populated as expected: |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
907 |
p1_fmri = fmri.PkgFmri("pkg://opensolaris.org/" |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
908 |
"[email protected],5.11-1:20000101T120000Z") |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
909 |
p1_man = manifest.Manifest() |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
910 |
p1_man.set_fmri(None, p1_fmri) |
1472
c50eb141435a
12128 client should pipeline manifest retrieval
johansen <johansen@sun.com>
parents:
1463
diff
changeset
|
911 |
p1_man.set_content("", signatures=True) |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
912 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
913 |
p2_fmri = fmri.PkgFmri("pkg://opensolaris.org/" |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
914 |
"[email protected],5.11-1:20000101T130000Z") |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
915 |
p2_man = manifest.Manifest() |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
916 |
p2_man.set_fmri(None, p2_fmri) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
917 |
p2_man.set_content("set name=fmri value=%s\n" |
1472
c50eb141435a
12128 client should pipeline manifest retrieval
johansen <johansen@sun.com>
parents:
1463
diff
changeset
|
918 |
"depend type=require [email protected]\n" % p2_fmri.get_fmri(), |
c50eb141435a
12128 client should pipeline manifest retrieval
johansen <johansen@sun.com>
parents:
1463
diff
changeset
|
919 |
signatures=True) |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
920 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
921 |
p3_fmri = fmri.PkgFmri("pkg://opensolaris.org/" |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
922 |
"[email protected],5.11-1:20000101T140000Z") |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
923 |
p3_man = manifest.Manifest() |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
924 |
p3_man.set_fmri(None, p2_fmri) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
925 |
p3_man.set_content("set name=fmri value=%s\n" |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
926 |
"set description=\"Example Description\"\n" |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
927 |
"set pkg.description=\"Example pkg.Description\"\n" |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
928 |
"set summary=\"Example Summary\"\n" |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
929 |
"set pkg.summary=\"Example pkg.Summary\"\n" |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
930 |
"set name=info.classification value=\"org.opensolaris." |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
931 |
"category.2008:Applications/Sound and Video\"\n" % \ |
1472
c50eb141435a
12128 client should pipeline manifest retrieval
johansen <johansen@sun.com>
parents:
1463
diff
changeset
|
932 |
p3_fmri.get_fmri(), signatures=True) |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
933 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
934 |
# Create and prep an empty catalog. |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
935 |
cpath = self.create_test_dir("test-06") |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
936 |
cat = catalog.Catalog(meta_root=cpath, log_updates=True) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
937 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
938 |
# Populate the catalog and then verify the Manifest signatures |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
939 |
# for each entry are correct. |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
940 |
cat.add_package(p1_fmri, manifest=p1_man) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
941 |
sigs = p1_man.signatures |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
942 |
cat_sigs = dict( |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
943 |
(s, v) |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
944 |
for s, v in cat.get_entry_signatures(p1_fmri) |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
945 |
) |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
946 |
self.assertEqual(sigs, cat_sigs) |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
947 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
948 |
cat.add_package(p2_fmri, manifest=p2_man) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
949 |
sigs = p2_man.signatures |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
950 |
cat_sigs = dict( |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
951 |
(s, v) |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
952 |
for s, v in cat.get_entry_signatures(p2_fmri) |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
953 |
) |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
954 |
self.assertEqual(sigs, cat_sigs) |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
955 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
956 |
cat.add_package(p3_fmri, manifest=p3_man) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
957 |
sigs = p3_man.signatures |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
958 |
cat_sigs = dict( |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
959 |
(s, v) |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
960 |
for s, v in cat.get_entry_signatures(p3_fmri) |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
961 |
) |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
962 |
self.assertEqual(sigs, cat_sigs) |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
963 |
|
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
964 |
# Next, verify that removal of an FMRI not in the catalog will |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
965 |
# raise the expected exception. Do this by removing an FMRI |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
966 |
# and then attempting to remove it again. |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
967 |
cat.remove_package(p3_fmri) |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
968 |
self.assertRaises(api_errors.UnknownCatalogEntry, |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
969 |
cat.remove_package, p3_fmri) |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
970 |
|
1710
139720e2e756
1668 image locking needed to prevent race conditions
Shawn Walker <srw@sun.com>
parents:
1699
diff
changeset
|
971 |
# Verify that update_entry will update base metadata and update |
139720e2e756
1668 image locking needed to prevent race conditions
Shawn Walker <srw@sun.com>
parents:
1699
diff
changeset
|
972 |
# the last_modified timestamp of the catalog and base part. |
139720e2e756
1668 image locking needed to prevent race conditions
Shawn Walker <srw@sun.com>
parents:
1699
diff
changeset
|
973 |
base = cat.get_part("catalog.base.C") |
139720e2e756
1668 image locking needed to prevent race conditions
Shawn Walker <srw@sun.com>
parents:
1699
diff
changeset
|
974 |
orig_cat_lm = cat.last_modified |
139720e2e756
1668 image locking needed to prevent race conditions
Shawn Walker <srw@sun.com>
parents:
1699
diff
changeset
|
975 |
orig_base_lm = base.last_modified |
139720e2e756
1668 image locking needed to prevent race conditions
Shawn Walker <srw@sun.com>
parents:
1699
diff
changeset
|
976 |
|
139720e2e756
1668 image locking needed to prevent race conditions
Shawn Walker <srw@sun.com>
parents:
1699
diff
changeset
|
977 |
# Update logging has to be disabled for this to work. |
139720e2e756
1668 image locking needed to prevent race conditions
Shawn Walker <srw@sun.com>
parents:
1699
diff
changeset
|
978 |
cat.log_updates = False |
139720e2e756
1668 image locking needed to prevent race conditions
Shawn Walker <srw@sun.com>
parents:
1699
diff
changeset
|
979 |
|
139720e2e756
1668 image locking needed to prevent race conditions
Shawn Walker <srw@sun.com>
parents:
1699
diff
changeset
|
980 |
cat.update_entry(p2_fmri, { "foo": True }) |
139720e2e756
1668 image locking needed to prevent race conditions
Shawn Walker <srw@sun.com>
parents:
1699
diff
changeset
|
981 |
|
139720e2e756
1668 image locking needed to prevent race conditions
Shawn Walker <srw@sun.com>
parents:
1699
diff
changeset
|
982 |
entry = cat.get_entry(p2_fmri) |
139720e2e756
1668 image locking needed to prevent race conditions
Shawn Walker <srw@sun.com>
parents:
1699
diff
changeset
|
983 |
self.assertEqual(entry["metadata"], { "foo": True }) |
139720e2e756
1668 image locking needed to prevent race conditions
Shawn Walker <srw@sun.com>
parents:
1699
diff
changeset
|
984 |
|
139720e2e756
1668 image locking needed to prevent race conditions
Shawn Walker <srw@sun.com>
parents:
1699
diff
changeset
|
985 |
self.assert_(cat.last_modified > orig_cat_lm) |
139720e2e756
1668 image locking needed to prevent race conditions
Shawn Walker <srw@sun.com>
parents:
1699
diff
changeset
|
986 |
self.assert_(base.last_modified > orig_base_lm) |
139720e2e756
1668 image locking needed to prevent race conditions
Shawn Walker <srw@sun.com>
parents:
1699
diff
changeset
|
987 |
|
139720e2e756
1668 image locking needed to prevent race conditions
Shawn Walker <srw@sun.com>
parents:
1699
diff
changeset
|
988 |
part_lm = cat.parts[base.name]["last-modified"] |
139720e2e756
1668 image locking needed to prevent race conditions
Shawn Walker <srw@sun.com>
parents:
1699
diff
changeset
|
989 |
self.assert_(base.last_modified == part_lm) |
139720e2e756
1668 image locking needed to prevent race conditions
Shawn Walker <srw@sun.com>
parents:
1699
diff
changeset
|
990 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
991 |
def test_07_updates(self): |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
992 |
"""Verify that catalog updates are applied as expected.""" |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
993 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
994 |
# First, start by creating and populating the original catalog. |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
995 |
cpath = self.create_test_dir("test-07-orig") |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
996 |
orig = catalog.Catalog(meta_root=cpath, log_updates=True) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
997 |
orig.save() |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
998 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
999 |
# Next, duplicate the original for testing, and load it. |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1710
diff
changeset
|
1000 |
dup1_path = os.path.join(self.test_root, "test-07-dup1") |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
1001 |
shutil.copytree(cpath, dup1_path) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
1002 |
dup1 = catalog.Catalog(meta_root=dup1_path) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
1003 |
dup1.validate() |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
1004 |
|
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
1005 |
# No catalog updates should be needed. |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
1006 |
self.assertEqual(dup1.get_updates_needed(orig.meta_root), None) |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
1007 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
1008 |
# Add some packages to the original. |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
1009 |
pkg_src_list = [ |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
1010 |
fmri.PkgFmri("pkg://opensolaris.org/" |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
1011 |
"[email protected],5.11-1:20000101T120000Z"), |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
1012 |
] |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
1013 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
1014 |
for f in pkg_src_list: |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
1015 |
orig.add_package(f) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
1016 |
orig.save() |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
1017 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
1018 |
# Check the expected number of package versions in each catalog. |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
1019 |
self.assertEqual(orig.package_version_count, 1) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
1020 |
self.assertEqual(dup1.package_version_count, 0) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
1021 |
|
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
1022 |
# Only the new catalog parts should be listed as updates. |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
1023 |
updates = dup1.get_updates_needed(orig.meta_root) |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
1024 |
self.assertEqual(updates, set(["catalog.base.C"])) |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
1025 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
1026 |
# Now copy the existing catalog so that a baseline exists for |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
1027 |
# incremental update testing. |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
1028 |
shutil.rmtree(dup1_path) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
1029 |
shutil.copytree(cpath, dup1_path) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
1030 |
|
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
1031 |
def apply_updates(src, dest): |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
1032 |
# Next, determine the updates that could be made to the |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
1033 |
# duplicate based on the original. |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
1034 |
updates = dest.get_updates_needed(src.meta_root) |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
1035 |
|
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
1036 |
# Verify that the updates available to the original |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
1037 |
# catalog are the same as the updated needed to update |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
1038 |
# the duplicate. |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
1039 |
self.assertEqual(src.updates.keys(), updates) |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
1040 |
|
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
1041 |
# Apply original catalog's updates to the duplicate. |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
1042 |
dest.apply_updates(src.meta_root) |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
1043 |
|
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
1044 |
# Verify the contents. |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
1045 |
self.assertEqual(dest.package_version_count, |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
1046 |
src.package_version_count) |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
1047 |
self.assertEqual([f for f in dest.fmris()], |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
1048 |
[f for f in src.fmris()]) |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
1049 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
1050 |
# Add some packages to the original. |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
1051 |
pkg_src_list = [ |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
1052 |
fmri.PkgFmri("pkg://opensolaris.org/" |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
1053 |
"[email protected],5.11-1:20000101T120010Z"), |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
1054 |
fmri.PkgFmri("pkg://opensolaris.org/" |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
1055 |
"[email protected],5.11-1.1:20000101T120020Z"), |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
1056 |
] |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
1057 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
1058 |
for f in pkg_src_list: |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
1059 |
orig.add_package(f) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
1060 |
orig.save() |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
1061 |
|
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
1062 |
# Load the duplicate and ensure it contains the expected data. |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
1063 |
dup1 = catalog.Catalog(meta_root=dup1_path) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
1064 |
self.assertEqual(dup1.package_version_count, 1) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
1065 |
dup1.validate() |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
1066 |
|
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
1067 |
# Apply the updates and verify. |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
1068 |
apply_updates(orig, dup1) |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
1069 |
|
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
1070 |
# Now remove the packages that were added during the last |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
1071 |
# update. |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
1072 |
for f in pkg_src_list: |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
1073 |
orig.remove_package(f) |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
1074 |
orig.save() |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
1075 |
|
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
1076 |
# Apply the updates and verify. |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
1077 |
self.assertEqual(orig.package_version_count, 1) |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
1078 |
apply_updates(orig, dup1) |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
1079 |
|
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
1080 |
# Now add back one of the packages removed. |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
1081 |
for f in pkg_src_list: |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
1082 |
orig.add_package(f) |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
1083 |
break |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
1084 |
orig.save() |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
1085 |
|
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
1086 |
# Apply the updates and verify. |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
1087 |
self.assertEqual(orig.package_version_count, 2) |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
1088 |
apply_updates(orig, dup1) |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
1089 |
|
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
1090 |
# Now remove the package we just added and add back both |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
1091 |
# packages we first removed and attempt to update. |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
1092 |
for f in pkg_src_list: |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
1093 |
orig.remove_package(f) |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
1094 |
break |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
1095 |
for f in pkg_src_list: |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
1096 |
orig.add_package(f) |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
1097 |
orig.save() |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
1098 |
|
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
1099 |
# Apply the updates and verify. |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
1100 |
self.assertEqual(orig.package_version_count, 3) |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
1101 |
apply_updates(orig, dup1) |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
1102 |
|
1369
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1103 |
def test_08_append(self): |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1104 |
"""Verify that append functionality works as expected.""" |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1105 |
|
1387
b82c5aaacf0c
11625 catalog.append traceback if src contains more than base part
Shawn Walker <srw@sun.com>
parents:
1369
diff
changeset
|
1106 |
# First, populate a new catalog with the entries from the test |
b82c5aaacf0c
11625 catalog.append traceback if src contains more than base part
Shawn Walker <srw@sun.com>
parents:
1369
diff
changeset
|
1107 |
# base one using synthesized manifest data. |
b82c5aaacf0c
11625 catalog.append traceback if src contains more than base part
Shawn Walker <srw@sun.com>
parents:
1369
diff
changeset
|
1108 |
c = catalog.Catalog() |
b82c5aaacf0c
11625 catalog.append traceback if src contains more than base part
Shawn Walker <srw@sun.com>
parents:
1369
diff
changeset
|
1109 |
for f in self.c.fmris(): |
b82c5aaacf0c
11625 catalog.append traceback if src contains more than base part
Shawn Walker <srw@sun.com>
parents:
1369
diff
changeset
|
1110 |
c.add_package(f, manifest=self.__gen_manifest(f)) |
b82c5aaacf0c
11625 catalog.append traceback if src contains more than base part
Shawn Walker <srw@sun.com>
parents:
1369
diff
changeset
|
1111 |
|
b82c5aaacf0c
11625 catalog.append traceback if src contains more than base part
Shawn Walker <srw@sun.com>
parents:
1369
diff
changeset
|
1112 |
# Next, test that basic append functionality works. |
1369
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1113 |
nc = catalog.Catalog() |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1114 |
nc.append(c) |
1463
0ef25025d601
12340 catalog storage performance regression
Shawn Walker <srw@sun.com>
parents:
1431
diff
changeset
|
1115 |
nc.finalize(pfmris=set([f for f in c.fmris()])) |
1369
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1116 |
|
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1117 |
self.assertEqual([f for f in c.fmris()], |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1118 |
[f for f in nc.fmris()]) |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1119 |
self.assertEqual(c.package_version_count, |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1120 |
nc.package_version_count) |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1121 |
|
1387
b82c5aaacf0c
11625 catalog.append traceback if src contains more than base part
Shawn Walker <srw@sun.com>
parents:
1369
diff
changeset
|
1122 |
for f, entry in nc.entries(info_needed=[nc.DEPENDENCY, |
b82c5aaacf0c
11625 catalog.append traceback if src contains more than base part
Shawn Walker <srw@sun.com>
parents:
1369
diff
changeset
|
1123 |
nc.SUMMARY], locales=set(("C", "th"))): |
1369
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1124 |
self.assertTrue("metadata" not in entry) |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1125 |
|
1387
b82c5aaacf0c
11625 catalog.append traceback if src contains more than base part
Shawn Walker <srw@sun.com>
parents:
1369
diff
changeset
|
1126 |
m = self.__gen_manifest(f) |
b82c5aaacf0c
11625 catalog.append traceback if src contains more than base part
Shawn Walker <srw@sun.com>
parents:
1369
diff
changeset
|
1127 |
expected = sorted( |
b82c5aaacf0c
11625 catalog.append traceback if src contains more than base part
Shawn Walker <srw@sun.com>
parents:
1369
diff
changeset
|
1128 |
s.strip() for s in m.as_lines() |
b82c5aaacf0c
11625 catalog.append traceback if src contains more than base part
Shawn Walker <srw@sun.com>
parents:
1369
diff
changeset
|
1129 |
if not s.startswith("set name=pkg.fmri") |
b82c5aaacf0c
11625 catalog.append traceback if src contains more than base part
Shawn Walker <srw@sun.com>
parents:
1369
diff
changeset
|
1130 |
) |
b82c5aaacf0c
11625 catalog.append traceback if src contains more than base part
Shawn Walker <srw@sun.com>
parents:
1369
diff
changeset
|
1131 |
returned = sorted(entry["actions"]) |
b82c5aaacf0c
11625 catalog.append traceback if src contains more than base part
Shawn Walker <srw@sun.com>
parents:
1369
diff
changeset
|
1132 |
self.assertEqual(expected, returned) |
b82c5aaacf0c
11625 catalog.append traceback if src contains more than base part
Shawn Walker <srw@sun.com>
parents:
1369
diff
changeset
|
1133 |
|
1369
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1134 |
# Next, test that callbacks work as expected. |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1135 |
pkg_list = [] |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1136 |
for f in c.fmris(): |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1137 |
if f.pkg_name == "apkg": |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1138 |
continue |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1139 |
pkg_list.append(f) |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1140 |
|
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1141 |
def append_cb(cat, f, entry): |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1142 |
if f.pkg_name == "apkg": |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1143 |
return False, None |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1144 |
return True, { "states": [] } |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1145 |
|
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1146 |
nc = catalog.Catalog() |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1147 |
nc.append(c, cb=append_cb) |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1148 |
nc.finalize() |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1149 |
|
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1150 |
for f, entry in nc.entries(): |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1151 |
self.assertNotEqual(f.pkg_name, "apkg") |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1152 |
self.assertTrue("states" in entry["metadata"]) |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1153 |
|
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1154 |
# Next, check that an append for a single FMRI works with a |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1155 |
# callback. |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1156 |
def cb_true(x, y, z): |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1157 |
return True, None |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1158 |
|
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1159 |
def cb_false(x, y, z): |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1160 |
return False, None |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1161 |
|
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1162 |
for f in c.fmris(): |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1163 |
if f.pkg_name == "apkg": |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1164 |
nc.append(c, cb=cb_false, pfmri=f) |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1165 |
break |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1166 |
nc.finalize() |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1167 |
|
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1168 |
for f, entry in nc.entries(): |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1169 |
self.assertNotEqual(f.pkg_name, "apkg") |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1170 |
self.assertTrue("states" in entry["metadata"]) |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1171 |
|
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1172 |
for f in c.fmris(): |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1173 |
if f.pkg_name == "apkg": |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1174 |
nc.append(c, cb=cb_true, pfmri=f) |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1175 |
break |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1176 |
nc.finalize() |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1177 |
|
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1178 |
self.assertEqual([f for f in c.fmris()], |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1179 |
[f for f in nc.fmris()]) |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1180 |
self.assertEqual(c.package_version_count, |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1181 |
nc.package_version_count) |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1182 |
|
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1183 |
def test_09_actions(self): |
1537 | 1184 |
"""Verify that the actions-related catalog functions work as |
1185 |
expected.""" |
|
1369
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1186 |
|
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1187 |
pkg_src_list = [ |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1188 |
fmri.PkgFmri("pkg://opensolaris.org/" |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1189 |
"[email protected],5.11-1:20000101T120010Z"), |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1190 |
fmri.PkgFmri("pkg://opensolaris.org/" |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1191 |
"[email protected],5.11-1.1:20000101T120020Z"), |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1192 |
fmri.PkgFmri("pkg://opensolaris.org/" |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1193 |
"[email protected],5.11-1:20000101T120040Z"), |
1537 | 1194 |
fmri.PkgFmri("pkg://extra/" |
1195 |
"[email protected],5.11-1:20000101T120040Z"), |
|
1196 |
fmri.PkgFmri("pkg://extra/[email protected],5.11-1:20000101T120040Z") |
|
1369
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1197 |
] |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1198 |
|
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
1199 |
def manifest_cb(cat, f): |
1387
b82c5aaacf0c
11625 catalog.append traceback if src contains more than base part
Shawn Walker <srw@sun.com>
parents:
1369
diff
changeset
|
1200 |
if f.pkg_name == "apkg": |
1472
c50eb141435a
12128 client should pipeline manifest retrieval
johansen <johansen@sun.com>
parents:
1463
diff
changeset
|
1201 |
m = manifest.Manifest() |
c50eb141435a
12128 client should pipeline manifest retrieval
johansen <johansen@sun.com>
parents:
1463
diff
changeset
|
1202 |
m.set_content("", signatures=True) |
c50eb141435a
12128 client should pipeline manifest retrieval
johansen <johansen@sun.com>
parents:
1463
diff
changeset
|
1203 |
return m |
1387
b82c5aaacf0c
11625 catalog.append traceback if src contains more than base part
Shawn Walker <srw@sun.com>
parents:
1369
diff
changeset
|
1204 |
return self.__gen_manifest(f) |
b82c5aaacf0c
11625 catalog.append traceback if src contains more than base part
Shawn Walker <srw@sun.com>
parents:
1369
diff
changeset
|
1205 |
|
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
1206 |
def ret_man(f): |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
1207 |
return manifest_cb(None, f) |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
1208 |
|
1369
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1209 |
# First, create a catalog (with callback) and populate it |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1210 |
# using only FMRIs. |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
1211 |
nc = catalog.Catalog(manifest_cb=manifest_cb) |
1369
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1212 |
for f in pkg_src_list: |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1213 |
nc.add_package(f) |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1214 |
self.__test_catalog_actions(nc, pkg_src_list) |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1215 |
|
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1216 |
# Second, create a catalog (without callback) and populate it |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1217 |
# using FMRIs and Manifests. |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1218 |
nc = catalog.Catalog() |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1219 |
for f in pkg_src_list: |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1220 |
nc.add_package(f, manifest=ret_man(f)) |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1221 |
self.__test_catalog_actions(nc, pkg_src_list) |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1222 |
|
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1223 |
# Third, create a catalog (with callback), but populate it |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1224 |
# using FMRIs and Manifests. |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1407
diff
changeset
|
1225 |
nc = catalog.Catalog(manifest_cb=manifest_cb) |
1369
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1226 |
for f in pkg_src_list: |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1227 |
nc.add_package(f, manifest=ret_man(f)) |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1228 |
self.__test_catalog_actions(nc, pkg_src_list) |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1229 |
|
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1230 |
# Fourth, create a catalog (no callback) and populate it |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1231 |
# using only FMRIs. |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1232 |
nc = catalog.Catalog() |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1233 |
for f in pkg_src_list: |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1234 |
nc.add_package(f) |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1235 |
|
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1236 |
# These cases should not return any actions. |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1237 |
for f, actions in nc.actions([nc.DEPENDENCY]): |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1238 |
returned = [a for a in actions] |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1239 |
self.assertEqual(returned, []) |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1240 |
|
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1241 |
returned = nc.get_entry_actions(f, [nc.DEPENDENCY]) |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1242 |
self.assertEqual(list(returned), []) |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1243 |
|
1606
7966bbfe38b7
13457 pkg refresh can fail for v0 repository with duplicate entry error
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
1244 |
def test_10_destroy(self): |
7966bbfe38b7
13457 pkg refresh can fail for v0 repository with duplicate entry error
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
1245 |
|
7966bbfe38b7
13457 pkg refresh can fail for v0 repository with duplicate entry error
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
1246 |
pkg_src_list = [ |
7966bbfe38b7
13457 pkg refresh can fail for v0 repository with duplicate entry error
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
1247 |
fmri.PkgFmri("pkg://opensolaris.org/" |
7966bbfe38b7
13457 pkg refresh can fail for v0 repository with duplicate entry error
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
1248 |
"[email protected],5.11-1:20000101T120010Z"), |
7966bbfe38b7
13457 pkg refresh can fail for v0 repository with duplicate entry error
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
1249 |
fmri.PkgFmri("pkg://opensolaris.org/" |
7966bbfe38b7
13457 pkg refresh can fail for v0 repository with duplicate entry error
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
1250 |
"[email protected],5.11-1.1:20000101T120020Z"), |
7966bbfe38b7
13457 pkg refresh can fail for v0 repository with duplicate entry error
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
1251 |
fmri.PkgFmri("pkg://opensolaris.org/" |
7966bbfe38b7
13457 pkg refresh can fail for v0 repository with duplicate entry error
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
1252 |
"[email protected],5.11-1:20000101T120040Z"), |
7966bbfe38b7
13457 pkg refresh can fail for v0 repository with duplicate entry error
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
1253 |
fmri.PkgFmri("pkg://extra/" |
7966bbfe38b7
13457 pkg refresh can fail for v0 repository with duplicate entry error
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
1254 |
"[email protected],5.11-1:20000101T120040Z"), |
7966bbfe38b7
13457 pkg refresh can fail for v0 repository with duplicate entry error
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
1255 |
fmri.PkgFmri("pkg://extra/[email protected],5.11-1:20000101T120040Z") |
7966bbfe38b7
13457 pkg refresh can fail for v0 repository with duplicate entry error
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
1256 |
] |
7966bbfe38b7
13457 pkg refresh can fail for v0 repository with duplicate entry error
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
1257 |
|
7966bbfe38b7
13457 pkg refresh can fail for v0 repository with duplicate entry error
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
1258 |
def manifest_cb(cat, f): |
7966bbfe38b7
13457 pkg refresh can fail for v0 repository with duplicate entry error
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
1259 |
if f.pkg_name == "apkg": |
7966bbfe38b7
13457 pkg refresh can fail for v0 repository with duplicate entry error
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
1260 |
m = manifest.Manifest() |
7966bbfe38b7
13457 pkg refresh can fail for v0 repository with duplicate entry error
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
1261 |
m.set_content("", signatures=True) |
7966bbfe38b7
13457 pkg refresh can fail for v0 repository with duplicate entry error
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
1262 |
return m |
7966bbfe38b7
13457 pkg refresh can fail for v0 repository with duplicate entry error
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
1263 |
return self.__gen_manifest(f) |
7966bbfe38b7
13457 pkg refresh can fail for v0 repository with duplicate entry error
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
1264 |
|
7966bbfe38b7
13457 pkg refresh can fail for v0 repository with duplicate entry error
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
1265 |
def ret_man(f): |
7966bbfe38b7
13457 pkg refresh can fail for v0 repository with duplicate entry error
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
1266 |
return manifest_cb(None, f) |
7966bbfe38b7
13457 pkg refresh can fail for v0 repository with duplicate entry error
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
1267 |
|
7966bbfe38b7
13457 pkg refresh can fail for v0 repository with duplicate entry error
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
1268 |
# First, create a catalog (with callback) and populate it |
7966bbfe38b7
13457 pkg refresh can fail for v0 repository with duplicate entry error
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
1269 |
# using only FMRIs. |
7966bbfe38b7
13457 pkg refresh can fail for v0 repository with duplicate entry error
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
1270 |
cpath = self.create_test_dir("test-10") |
7966bbfe38b7
13457 pkg refresh can fail for v0 repository with duplicate entry error
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
1271 |
nc = catalog.Catalog(meta_root=cpath) |
7966bbfe38b7
13457 pkg refresh can fail for v0 repository with duplicate entry error
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
1272 |
for f in pkg_src_list: |
7966bbfe38b7
13457 pkg refresh can fail for v0 repository with duplicate entry error
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
1273 |
nc.add_package(f, manifest=ret_man(f)) |
7966bbfe38b7
13457 pkg refresh can fail for v0 repository with duplicate entry error
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
1274 |
|
7966bbfe38b7
13457 pkg refresh can fail for v0 repository with duplicate entry error
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
1275 |
# Now verify that destroy really destroys the catalog. |
7966bbfe38b7
13457 pkg refresh can fail for v0 repository with duplicate entry error
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
1276 |
nc.destroy() |
7966bbfe38b7
13457 pkg refresh can fail for v0 repository with duplicate entry error
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
1277 |
|
7966bbfe38b7
13457 pkg refresh can fail for v0 repository with duplicate entry error
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
1278 |
# Verify that destroy actually emptied the catalog. |
7966bbfe38b7
13457 pkg refresh can fail for v0 repository with duplicate entry error
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
1279 |
self.assertEqual(nc.package_count, 0) |
7966bbfe38b7
13457 pkg refresh can fail for v0 repository with duplicate entry error
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
1280 |
self.assertEqual(list(nc.fmris()), []) |
7966bbfe38b7
13457 pkg refresh can fail for v0 repository with duplicate entry error
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
1281 |
self.assertEqual(nc.parts, {}) |
7966bbfe38b7
13457 pkg refresh can fail for v0 repository with duplicate entry error
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
1282 |
self.assertEqual(nc.updates, {}) |
7966bbfe38b7
13457 pkg refresh can fail for v0 repository with duplicate entry error
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
1283 |
self.assertEqual(nc.signatures, { "catalog.attrs": {} }) |
7966bbfe38b7
13457 pkg refresh can fail for v0 repository with duplicate entry error
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
1284 |
|
7966bbfe38b7
13457 pkg refresh can fail for v0 repository with duplicate entry error
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
1285 |
# Next, re-create the catalog and then delete a few arbitrary |
7966bbfe38b7
13457 pkg refresh can fail for v0 repository with duplicate entry error
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
1286 |
# parts (specifically, the attrs file). |
7966bbfe38b7
13457 pkg refresh can fail for v0 repository with duplicate entry error
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
1287 |
cpath = self.create_test_dir("test-10") |
7966bbfe38b7
13457 pkg refresh can fail for v0 repository with duplicate entry error
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
1288 |
nc = catalog.Catalog(manifest_cb=manifest_cb, meta_root=cpath) |
7966bbfe38b7
13457 pkg refresh can fail for v0 repository with duplicate entry error
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
1289 |
for f in pkg_src_list: |
7966bbfe38b7
13457 pkg refresh can fail for v0 repository with duplicate entry error
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
1290 |
nc.add_package(f, manifest=ret_man(f)) |
7966bbfe38b7
13457 pkg refresh can fail for v0 repository with duplicate entry error
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
1291 |
nc.save() |
7966bbfe38b7
13457 pkg refresh can fail for v0 repository with duplicate entry error
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
1292 |
|
7966bbfe38b7
13457 pkg refresh can fail for v0 repository with duplicate entry error
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
1293 |
# Now remove arbitrary files. |
7966bbfe38b7
13457 pkg refresh can fail for v0 repository with duplicate entry error
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
1294 |
for fname in ("catalog.attrs", "catalog.dependency.C", |
7966bbfe38b7
13457 pkg refresh can fail for v0 repository with duplicate entry error
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
1295 |
"catalog.summary.C"): |
7966bbfe38b7
13457 pkg refresh can fail for v0 repository with duplicate entry error
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
1296 |
pname = os.path.join(nc.meta_root, fname) |
7966bbfe38b7
13457 pkg refresh can fail for v0 repository with duplicate entry error
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
1297 |
portable.remove(pname) |
7966bbfe38b7
13457 pkg refresh can fail for v0 repository with duplicate entry error
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
1298 |
|
7966bbfe38b7
13457 pkg refresh can fail for v0 repository with duplicate entry error
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
1299 |
# Verify that destroy actually removes the files. |
7966bbfe38b7
13457 pkg refresh can fail for v0 repository with duplicate entry error
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
1300 |
nc = catalog.Catalog(meta_root=cpath) |
7966bbfe38b7
13457 pkg refresh can fail for v0 repository with duplicate entry error
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
1301 |
nc.destroy() |
7966bbfe38b7
13457 pkg refresh can fail for v0 repository with duplicate entry error
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
1302 |
|
7966bbfe38b7
13457 pkg refresh can fail for v0 repository with duplicate entry error
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
1303 |
for fname in os.listdir(nc.meta_root): |
7966bbfe38b7
13457 pkg refresh can fail for v0 repository with duplicate entry error
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
1304 |
self.assertFalse(fname.startswith("catalog.") or \ |
7966bbfe38b7
13457 pkg refresh can fail for v0 repository with duplicate entry error
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
1305 |
fname.startswith("update.")) |
7966bbfe38b7
13457 pkg refresh can fail for v0 repository with duplicate entry error
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
1306 |
|
852
96c4a4dace99
5999 catalog.extract_matching_fmris - version filtering not correct
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
814
diff
changeset
|
1307 |
|
430
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
419
diff
changeset
|
1308 |
class TestEmptyCatalog(pkg5unittest.Pkg5TestCase): |
1537 | 1309 |
"""Basic functionality tests for empty catalogs.""" |
1310 |
||
195
b23d0425f0f7
11 use FMRIs with fully specified authorities internally
johansen <johansen@sun.com>
parents:
181
diff
changeset
|
1311 |
def setUp(self): |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
1312 |
self.c = catalog.Catalog() |
215
c10719939c6d
245 Need incremental update mechanism for the catalog
johansen <johansen@sun.com>
parents:
195
diff
changeset
|
1313 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
1314 |
def test_01_attrs(self): |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
1315 |
self.assertEqual(self.c.package_count, 0) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
1316 |
self.assertEqual(self.c.package_version_count, 0) |
215
c10719939c6d
245 Need incremental update mechanism for the catalog
johansen <johansen@sun.com>
parents:
195
diff
changeset
|
1317 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
1318 |
def test_02_extract_matching_fmris(self): |
215
c10719939c6d
245 Need incremental update mechanism for the catalog
johansen <johansen@sun.com>
parents:
195
diff
changeset
|
1319 |
cf = fmri.PkgFmri("pkg:/[email protected],5.10-1:20070101T120000Z") |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
1320 |
cl = catalog.extract_matching_fmris(self.c.fmris(), |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
1321 |
patterns=[cf])[0] |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1288
diff
changeset
|
1322 |
self.assertEqual(len(cl), 0) |
215
c10719939c6d
245 Need incremental update mechanism for the catalog
johansen <johansen@sun.com>
parents:
195
diff
changeset
|
1323 |
|
1369
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1324 |
def test_03_actions(self): |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1325 |
returned = [ |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1326 |
(f, actions) |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1327 |
for f, actions in self.c.actions([self.c.DEPENDENCY]) |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1328 |
] |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1329 |
self.assertEqual(returned, []) |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1330 |
|
215
c10719939c6d
245 Need incremental update mechanism for the catalog
johansen <johansen@sun.com>
parents:
195
diff
changeset
|
1331 |
|
181 | 1332 |
if __name__ == "__main__": |
1333 |
unittest.main() |