author | Shawn Walker <srw@sun.com> |
Thu, 11 Jun 2009 15:58:51 -0500 | |
changeset 1143 | 71becfca5cfd |
parent 1133 | 2c28e4526a6e |
child 1352 | 5c92c9d342ef |
permissions | -rw-r--r-- |
581 | 1 |
#!/usr/bin/python2.4 |
2 |
# |
|
3 |
# CDDL HEADER START |
|
4 |
# |
|
5 |
# The contents of this file are subject to the terms of the |
|
6 |
# Common Development and Distribution License (the "License"). |
|
7 |
# You may not use this file except in compliance with the License. |
|
8 |
# |
|
9 |
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE |
|
10 |
# or http://www.opensolaris.org/os/licensing. |
|
11 |
# See the License for the specific language governing permissions |
|
12 |
# and limitations under the License. |
|
13 |
# |
|
14 |
# When distributing Covered Code, include this CDDL HEADER in each |
|
15 |
# file and include the License file at usr/src/OPENSOLARIS.LICENSE. |
|
16 |
# If applicable, add the following below this CDDL HEADER, with the |
|
17 |
# fields enclosed by brackets "[]" replaced with your own identifying |
|
18 |
# information: Portions Copyright [yyyy] [name of copyright owner] |
|
19 |
# |
|
20 |
# CDDL HEADER END |
|
21 |
# |
|
22 |
||
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
683
diff
changeset
|
23 |
# |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
683
diff
changeset
|
24 |
# Copyright 2009 Sun Microsystems, Inc. All rights reserved. |
581 | 25 |
# Use is subject to license terms. |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
683
diff
changeset
|
26 |
# |
581 | 27 |
|
28 |
import testutils |
|
29 |
if __name__ == "__main__": |
|
938
eeb932b9b44e
7336 putback for 5871 missed a few vestiges of authority
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
926
diff
changeset
|
30 |
testutils.setup_environment("../../../proto") |
581 | 31 |
|
938
eeb932b9b44e
7336 putback for 5871 missed a few vestiges of authority
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
926
diff
changeset
|
32 |
import os |
eeb932b9b44e
7336 putback for 5871 missed a few vestiges of authority
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
926
diff
changeset
|
33 |
import shutil |
581 | 34 |
import unittest |
938
eeb932b9b44e
7336 putback for 5871 missed a few vestiges of authority
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
926
diff
changeset
|
35 |
|
581 | 36 |
|
37 |
class TestPkgImageCreateBasics(testutils.SingleDepotTestCase): |
|
38 |
# Only start/stop the depot once (instead of for every test) |
|
39 |
persistent_depot = True |
|
40 |
||
41 |
def test_basic(self): |
|
42 |
""" Create an image, verify it. """ |
|
43 |
||
44 |
durl = self.dc.get_depot_url() |
|
45 |
self.image_create(durl) |
|
46 |
self.pkg("verify") |
|
47 |
||
48 |
def test_image_create_bad_opts(self): |
|
938
eeb932b9b44e
7336 putback for 5871 missed a few vestiges of authority
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
926
diff
changeset
|
49 |
"""Test some bad cli options.""" |
581 | 50 |
|
51 |
self.pkg("image-create -@", exit=2) |
|
52 |
self.pkg("image-create --bozo", exit=2) |
|
53 |
self.pkg("image-create", exit=2) |
|
54 |
||
55 |
def test_766(self): |
|
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
683
diff
changeset
|
56 |
"""Bug 766: image-create without publisher prefix specified.""" |
581 | 57 |
|
58 |
durl = self.dc.get_depot_url() |
|
59 |
||
60 |
pkgsend_data = """ |
|
61 |
open [email protected] |
|
62 |
close |
|
63 |
""" |
|
64 |
self.pkgsend_bulk(durl, pkgsend_data) |
|
65 |
||
66 |
self.assertRaises(testutils.UnexpectedExitCodeException, |
|
67 |
self.image_create, durl, "") |
|
68 |
||
582
303fa3b78f93
3588 Ensure that users don't image-create over top of an image
Brad Hall <bhall@eng.sun.com>
parents:
581
diff
changeset
|
69 |
def test_3588(self): |
303fa3b78f93
3588 Ensure that users don't image-create over top of an image
Brad Hall <bhall@eng.sun.com>
parents:
581
diff
changeset
|
70 |
"""Bug 3588: Make sure we can't create an image where one |
303fa3b78f93
3588 Ensure that users don't image-create over top of an image
Brad Hall <bhall@eng.sun.com>
parents:
581
diff
changeset
|
71 |
already exists""" |
303fa3b78f93
3588 Ensure that users don't image-create over top of an image
Brad Hall <bhall@eng.sun.com>
parents:
581
diff
changeset
|
72 |
durl = self.dc.get_depot_url() |
938
eeb932b9b44e
7336 putback for 5871 missed a few vestiges of authority
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
926
diff
changeset
|
73 |
self.pkg("image-create -p mydepot=%s %s/3588_image" % ( |
582
303fa3b78f93
3588 Ensure that users don't image-create over top of an image
Brad Hall <bhall@eng.sun.com>
parents:
581
diff
changeset
|
74 |
durl, self.get_img_path())) |
938
eeb932b9b44e
7336 putback for 5871 missed a few vestiges of authority
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
926
diff
changeset
|
75 |
self.pkg("image-create -p mydepot=%s %s/3588_image" % |
582
303fa3b78f93
3588 Ensure that users don't image-create over top of an image
Brad Hall <bhall@eng.sun.com>
parents:
581
diff
changeset
|
76 |
(durl, self.get_img_path()), exit=1) |
303fa3b78f93
3588 Ensure that users don't image-create over top of an image
Brad Hall <bhall@eng.sun.com>
parents:
581
diff
changeset
|
77 |
|
303fa3b78f93
3588 Ensure that users don't image-create over top of an image
Brad Hall <bhall@eng.sun.com>
parents:
581
diff
changeset
|
78 |
def test_3588_1(self): |
303fa3b78f93
3588 Ensure that users don't image-create over top of an image
Brad Hall <bhall@eng.sun.com>
parents:
581
diff
changeset
|
79 |
"""Bug 3588: Make sure we can create an image where one |
303fa3b78f93
3588 Ensure that users don't image-create over top of an image
Brad Hall <bhall@eng.sun.com>
parents:
581
diff
changeset
|
80 |
already exists with the -f (force) flag""" |
303fa3b78f93
3588 Ensure that users don't image-create over top of an image
Brad Hall <bhall@eng.sun.com>
parents:
581
diff
changeset
|
81 |
durl = self.dc.get_depot_url() |
938
eeb932b9b44e
7336 putback for 5871 missed a few vestiges of authority
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
926
diff
changeset
|
82 |
self.pkg("image-create -p mydepot=%s %s/3588_image_1" % ( |
582
303fa3b78f93
3588 Ensure that users don't image-create over top of an image
Brad Hall <bhall@eng.sun.com>
parents:
581
diff
changeset
|
83 |
durl, self.get_img_path())) |
938
eeb932b9b44e
7336 putback for 5871 missed a few vestiges of authority
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
926
diff
changeset
|
84 |
self.pkg("image-create -f -p mydepot=%s %s/3588_image_1" % |
582
303fa3b78f93
3588 Ensure that users don't image-create over top of an image
Brad Hall <bhall@eng.sun.com>
parents:
581
diff
changeset
|
85 |
(durl, self.get_img_path())) |
303fa3b78f93
3588 Ensure that users don't image-create over top of an image
Brad Hall <bhall@eng.sun.com>
parents:
581
diff
changeset
|
86 |
|
303fa3b78f93
3588 Ensure that users don't image-create over top of an image
Brad Hall <bhall@eng.sun.com>
parents:
581
diff
changeset
|
87 |
def test_3588_2(self): |
1133
2c28e4526a6e
8720 image-create with a non-absolute path can cause strange results
Shawn Walker <srw@sun.com>
parents:
1086
diff
changeset
|
88 |
"""Bug 3588: Make sure we can't create an image where a |
582
303fa3b78f93
3588 Ensure that users don't image-create over top of an image
Brad Hall <bhall@eng.sun.com>
parents:
581
diff
changeset
|
89 |
non-empty directory exists""" |
303fa3b78f93
3588 Ensure that users don't image-create over top of an image
Brad Hall <bhall@eng.sun.com>
parents:
581
diff
changeset
|
90 |
durl = self.dc.get_depot_url() |
303fa3b78f93
3588 Ensure that users don't image-create over top of an image
Brad Hall <bhall@eng.sun.com>
parents:
581
diff
changeset
|
91 |
p = os.path.join(self.get_img_path(), "3588_2_image") |
303fa3b78f93
3588 Ensure that users don't image-create over top of an image
Brad Hall <bhall@eng.sun.com>
parents:
581
diff
changeset
|
92 |
os.mkdir(p) |
303fa3b78f93
3588 Ensure that users don't image-create over top of an image
Brad Hall <bhall@eng.sun.com>
parents:
581
diff
changeset
|
93 |
os.system("touch %s/%s" % (p, "somefile")) |
938
eeb932b9b44e
7336 putback for 5871 missed a few vestiges of authority
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
926
diff
changeset
|
94 |
self.pkg("image-create -p mydepot=%s %s" % (durl, p), exit=1) |
eeb932b9b44e
7336 putback for 5871 missed a few vestiges of authority
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
926
diff
changeset
|
95 |
self.pkg("image-create -f -p mydepot=%s %s" % (durl, p)) |
eeb932b9b44e
7336 putback for 5871 missed a few vestiges of authority
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
926
diff
changeset
|
96 |
|
eeb932b9b44e
7336 putback for 5871 missed a few vestiges of authority
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
926
diff
changeset
|
97 |
def test_4_options(self): |
eeb932b9b44e
7336 putback for 5871 missed a few vestiges of authority
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
926
diff
changeset
|
98 |
"""Verify that all of the options for specifying publisher |
eeb932b9b44e
7336 putback for 5871 missed a few vestiges of authority
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
926
diff
changeset
|
99 |
information work as expected for image-create.""" |
eeb932b9b44e
7336 putback for 5871 missed a few vestiges of authority
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
926
diff
changeset
|
100 |
|
eeb932b9b44e
7336 putback for 5871 missed a few vestiges of authority
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
926
diff
changeset
|
101 |
img_path = os.path.join(self.get_test_prefix(), "test_4_img") |
eeb932b9b44e
7336 putback for 5871 missed a few vestiges of authority
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
926
diff
changeset
|
102 |
for opt in ("-a", "-p", "--publisher"): |
eeb932b9b44e
7336 putback for 5871 missed a few vestiges of authority
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
926
diff
changeset
|
103 |
durl = self.dc.get_depot_url() |
eeb932b9b44e
7336 putback for 5871 missed a few vestiges of authority
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
926
diff
changeset
|
104 |
self.pkg("image-create %s mydepot=%s %s" % (opt, durl, |
eeb932b9b44e
7336 putback for 5871 missed a few vestiges of authority
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
926
diff
changeset
|
105 |
img_path)) |
eeb932b9b44e
7336 putback for 5871 missed a few vestiges of authority
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
926
diff
changeset
|
106 |
shutil.rmtree(img_path) |
eeb932b9b44e
7336 putback for 5871 missed a few vestiges of authority
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
926
diff
changeset
|
107 |
|
1086
16500d7bf1ca
8321 image_create should not validate publisher uri
Shawn Walker <srw@sun.com>
parents:
938
diff
changeset
|
108 |
def test_5_bad_values_no_image(self): |
16500d7bf1ca
8321 image_create should not validate publisher uri
Shawn Walker <srw@sun.com>
parents:
938
diff
changeset
|
109 |
"""Verify that an invalid publisher URI or other piece of |
16500d7bf1ca
8321 image_create should not validate publisher uri
Shawn Walker <srw@sun.com>
parents:
938
diff
changeset
|
110 |
information provided to image-create will not result in an |
16500d7bf1ca
8321 image_create should not validate publisher uri
Shawn Walker <srw@sun.com>
parents:
938
diff
changeset
|
111 |
empty image being created despite failure.""" |
16500d7bf1ca
8321 image_create should not validate publisher uri
Shawn Walker <srw@sun.com>
parents:
938
diff
changeset
|
112 |
|
16500d7bf1ca
8321 image_create should not validate publisher uri
Shawn Walker <srw@sun.com>
parents:
938
diff
changeset
|
113 |
p = os.path.join(self.get_img_path(), "test_5_image") |
16500d7bf1ca
8321 image_create should not validate publisher uri
Shawn Walker <srw@sun.com>
parents:
938
diff
changeset
|
114 |
self.pkg("image-create -p test=InvalidURI %s" % p, exit=1) |
16500d7bf1ca
8321 image_create should not validate publisher uri
Shawn Walker <srw@sun.com>
parents:
938
diff
changeset
|
115 |
self.assertFalse(os.path.exists(p)) |
16500d7bf1ca
8321 image_create should not validate publisher uri
Shawn Walker <srw@sun.com>
parents:
938
diff
changeset
|
116 |
|
1133
2c28e4526a6e
8720 image-create with a non-absolute path can cause strange results
Shawn Walker <srw@sun.com>
parents:
1086
diff
changeset
|
117 |
def test_6_relative_root_create(self): |
2c28e4526a6e
8720 image-create with a non-absolute path can cause strange results
Shawn Walker <srw@sun.com>
parents:
1086
diff
changeset
|
118 |
"""Verify that an image with a relative path for the root is |
2c28e4526a6e
8720 image-create with a non-absolute path can cause strange results
Shawn Walker <srw@sun.com>
parents:
1086
diff
changeset
|
119 |
created correctly.""" |
2c28e4526a6e
8720 image-create with a non-absolute path can cause strange results
Shawn Walker <srw@sun.com>
parents:
1086
diff
changeset
|
120 |
|
2c28e4526a6e
8720 image-create with a non-absolute path can cause strange results
Shawn Walker <srw@sun.com>
parents:
1086
diff
changeset
|
121 |
pwd = os.getcwd() |
2c28e4526a6e
8720 image-create with a non-absolute path can cause strange results
Shawn Walker <srw@sun.com>
parents:
1086
diff
changeset
|
122 |
durl = self.dc.get_depot_url() |
2c28e4526a6e
8720 image-create with a non-absolute path can cause strange results
Shawn Walker <srw@sun.com>
parents:
1086
diff
changeset
|
123 |
img_path = "test_6_image" |
2c28e4526a6e
8720 image-create with a non-absolute path can cause strange results
Shawn Walker <srw@sun.com>
parents:
1086
diff
changeset
|
124 |
abs_img_path = os.path.join(self.get_test_prefix(), img_path) |
2c28e4526a6e
8720 image-create with a non-absolute path can cause strange results
Shawn Walker <srw@sun.com>
parents:
1086
diff
changeset
|
125 |
|
2c28e4526a6e
8720 image-create with a non-absolute path can cause strange results
Shawn Walker <srw@sun.com>
parents:
1086
diff
changeset
|
126 |
# Now verify that the image root isn't duplicated within the |
2c28e4526a6e
8720 image-create with a non-absolute path can cause strange results
Shawn Walker <srw@sun.com>
parents:
1086
diff
changeset
|
127 |
# specified image root if the specified root doesn't already |
2c28e4526a6e
8720 image-create with a non-absolute path can cause strange results
Shawn Walker <srw@sun.com>
parents:
1086
diff
changeset
|
128 |
# exist. |
2c28e4526a6e
8720 image-create with a non-absolute path can cause strange results
Shawn Walker <srw@sun.com>
parents:
1086
diff
changeset
|
129 |
os.chdir(self.get_test_prefix()) |
2c28e4526a6e
8720 image-create with a non-absolute path can cause strange results
Shawn Walker <srw@sun.com>
parents:
1086
diff
changeset
|
130 |
self.pkg("image-create -p mydepot=%s %s" % (durl, img_path)) |
2c28e4526a6e
8720 image-create with a non-absolute path can cause strange results
Shawn Walker <srw@sun.com>
parents:
1086
diff
changeset
|
131 |
os.chdir(pwd) |
2c28e4526a6e
8720 image-create with a non-absolute path can cause strange results
Shawn Walker <srw@sun.com>
parents:
1086
diff
changeset
|
132 |
self.assertFalse(os.path.exists(os.path.join(abs_img_path, img_path))) |
2c28e4526a6e
8720 image-create with a non-absolute path can cause strange results
Shawn Walker <srw@sun.com>
parents:
1086
diff
changeset
|
133 |
shutil.rmtree(abs_img_path) |
2c28e4526a6e
8720 image-create with a non-absolute path can cause strange results
Shawn Walker <srw@sun.com>
parents:
1086
diff
changeset
|
134 |
|
2c28e4526a6e
8720 image-create with a non-absolute path can cause strange results
Shawn Walker <srw@sun.com>
parents:
1086
diff
changeset
|
135 |
# Now verify that the image root isn't duplicated within the |
2c28e4526a6e
8720 image-create with a non-absolute path can cause strange results
Shawn Walker <srw@sun.com>
parents:
1086
diff
changeset
|
136 |
# specified image root if the specified root already exists. |
2c28e4526a6e
8720 image-create with a non-absolute path can cause strange results
Shawn Walker <srw@sun.com>
parents:
1086
diff
changeset
|
137 |
os.chdir(self.get_test_prefix()) |
2c28e4526a6e
8720 image-create with a non-absolute path can cause strange results
Shawn Walker <srw@sun.com>
parents:
1086
diff
changeset
|
138 |
os.mkdir(img_path) |
2c28e4526a6e
8720 image-create with a non-absolute path can cause strange results
Shawn Walker <srw@sun.com>
parents:
1086
diff
changeset
|
139 |
self.pkg("image-create -p mydepot=%s %s" % (durl, img_path)) |
2c28e4526a6e
8720 image-create with a non-absolute path can cause strange results
Shawn Walker <srw@sun.com>
parents:
1086
diff
changeset
|
140 |
os.chdir(pwd) |
2c28e4526a6e
8720 image-create with a non-absolute path can cause strange results
Shawn Walker <srw@sun.com>
parents:
1086
diff
changeset
|
141 |
self.assertFalse(os.path.exists(os.path.join(abs_img_path, img_path))) |
2c28e4526a6e
8720 image-create with a non-absolute path can cause strange results
Shawn Walker <srw@sun.com>
parents:
1086
diff
changeset
|
142 |
shutil.rmtree(abs_img_path) |
2c28e4526a6e
8720 image-create with a non-absolute path can cause strange results
Shawn Walker <srw@sun.com>
parents:
1086
diff
changeset
|
143 |
|
1143
71becfca5cfd
8777 image-create traceback with --no-refresh
Shawn Walker <srw@sun.com>
parents:
1133
diff
changeset
|
144 |
def test_7_image_create_no_refresh(self): |
71becfca5cfd
8777 image-create traceback with --no-refresh
Shawn Walker <srw@sun.com>
parents:
1133
diff
changeset
|
145 |
"""Verify that image-create --no-refresh works as expected. |
71becfca5cfd
8777 image-create traceback with --no-refresh
Shawn Walker <srw@sun.com>
parents:
1133
diff
changeset
|
146 |
See bug 8777 for related issue.""" |
71becfca5cfd
8777 image-create traceback with --no-refresh
Shawn Walker <srw@sun.com>
parents:
1133
diff
changeset
|
147 |
|
71becfca5cfd
8777 image-create traceback with --no-refresh
Shawn Walker <srw@sun.com>
parents:
1133
diff
changeset
|
148 |
durl = self.dc.get_depot_url() |
71becfca5cfd
8777 image-create traceback with --no-refresh
Shawn Walker <srw@sun.com>
parents:
1133
diff
changeset
|
149 |
|
71becfca5cfd
8777 image-create traceback with --no-refresh
Shawn Walker <srw@sun.com>
parents:
1133
diff
changeset
|
150 |
pkgsend_data = """ |
71becfca5cfd
8777 image-create traceback with --no-refresh
Shawn Walker <srw@sun.com>
parents:
1133
diff
changeset
|
151 |
open [email protected] |
71becfca5cfd
8777 image-create traceback with --no-refresh
Shawn Walker <srw@sun.com>
parents:
1133
diff
changeset
|
152 |
close |
71becfca5cfd
8777 image-create traceback with --no-refresh
Shawn Walker <srw@sun.com>
parents:
1133
diff
changeset
|
153 |
""" |
71becfca5cfd
8777 image-create traceback with --no-refresh
Shawn Walker <srw@sun.com>
parents:
1133
diff
changeset
|
154 |
self.pkgsend_bulk(durl, pkgsend_data) |
71becfca5cfd
8777 image-create traceback with --no-refresh
Shawn Walker <srw@sun.com>
parents:
1133
diff
changeset
|
155 |
|
71becfca5cfd
8777 image-create traceback with --no-refresh
Shawn Walker <srw@sun.com>
parents:
1133
diff
changeset
|
156 |
# First, check to be certain that an image-create --no-refresh |
71becfca5cfd
8777 image-create traceback with --no-refresh
Shawn Walker <srw@sun.com>
parents:
1133
diff
changeset
|
157 |
# will succeed. |
71becfca5cfd
8777 image-create traceback with --no-refresh
Shawn Walker <srw@sun.com>
parents:
1133
diff
changeset
|
158 |
self.image_create(durl, prefix="norefresh", |
71becfca5cfd
8777 image-create traceback with --no-refresh
Shawn Walker <srw@sun.com>
parents:
1133
diff
changeset
|
159 |
additional_args="--no-refresh") |
71becfca5cfd
8777 image-create traceback with --no-refresh
Shawn Walker <srw@sun.com>
parents:
1133
diff
changeset
|
160 |
self.pkg("list --no-refresh -a | grep baz", exit=1) |
71becfca5cfd
8777 image-create traceback with --no-refresh
Shawn Walker <srw@sun.com>
parents:
1133
diff
changeset
|
161 |
|
71becfca5cfd
8777 image-create traceback with --no-refresh
Shawn Walker <srw@sun.com>
parents:
1133
diff
changeset
|
162 |
# Finally, verify that using set-publisher will cause a refresh |
71becfca5cfd
8777 image-create traceback with --no-refresh
Shawn Walker <srw@sun.com>
parents:
1133
diff
changeset
|
163 |
# which in turn should cause 'baz' to be listed. |
71becfca5cfd
8777 image-create traceback with --no-refresh
Shawn Walker <srw@sun.com>
parents:
1133
diff
changeset
|
164 |
self.pkg("set-publisher -O %s norefresh" % durl) |
71becfca5cfd
8777 image-create traceback with --no-refresh
Shawn Walker <srw@sun.com>
parents:
1133
diff
changeset
|
165 |
self.pkg("list --no-refresh -a | grep baz") |
71becfca5cfd
8777 image-create traceback with --no-refresh
Shawn Walker <srw@sun.com>
parents:
1133
diff
changeset
|
166 |
|
582
303fa3b78f93
3588 Ensure that users don't image-create over top of an image
Brad Hall <bhall@eng.sun.com>
parents:
581
diff
changeset
|
167 |
|
303fa3b78f93
3588 Ensure that users don't image-create over top of an image
Brad Hall <bhall@eng.sun.com>
parents:
581
diff
changeset
|
168 |
class TestImageCreateNoDepot(testutils.CliTestCase): |
303fa3b78f93
3588 Ensure that users don't image-create over top of an image
Brad Hall <bhall@eng.sun.com>
parents:
581
diff
changeset
|
169 |
persistent_depot = True |
303fa3b78f93
3588 Ensure that users don't image-create over top of an image
Brad Hall <bhall@eng.sun.com>
parents:
581
diff
changeset
|
170 |
def test_bad_image_create(self): |
303fa3b78f93
3588 Ensure that users don't image-create over top of an image
Brad Hall <bhall@eng.sun.com>
parents:
581
diff
changeset
|
171 |
""" Create image from non-existent server """ |
303fa3b78f93
3588 Ensure that users don't image-create over top of an image
Brad Hall <bhall@eng.sun.com>
parents:
581
diff
changeset
|
172 |
|
938
eeb932b9b44e
7336 putback for 5871 missed a few vestiges of authority
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
926
diff
changeset
|
173 |
# |
eeb932b9b44e
7336 putback for 5871 missed a few vestiges of authority
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
926
diff
changeset
|
174 |
# Currently port 4 is unassigned by IANA and we |
eeb932b9b44e
7336 putback for 5871 missed a few vestiges of authority
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
926
diff
changeset
|
175 |
# Can just hope that it never gets assigned. |
eeb932b9b44e
7336 putback for 5871 missed a few vestiges of authority
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
926
diff
changeset
|
176 |
# We choose localhost because, well, we think |
eeb932b9b44e
7336 putback for 5871 missed a few vestiges of authority
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
926
diff
changeset
|
177 |
# it will be universally able to be looked up. |
eeb932b9b44e
7336 putback for 5871 missed a few vestiges of authority
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
926
diff
changeset
|
178 |
# |
582
303fa3b78f93
3588 Ensure that users don't image-create over top of an image
Brad Hall <bhall@eng.sun.com>
parents:
581
diff
changeset
|
179 |
durl = "http://localhost:4" |
938
eeb932b9b44e
7336 putback for 5871 missed a few vestiges of authority
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
926
diff
changeset
|
180 |
self.assertRaises(testutils.UnexpectedExitCodeException, \ |
eeb932b9b44e
7336 putback for 5871 missed a few vestiges of authority
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
926
diff
changeset
|
181 |
self.image_create, durl) |
582
303fa3b78f93
3588 Ensure that users don't image-create over top of an image
Brad Hall <bhall@eng.sun.com>
parents:
581
diff
changeset
|
182 |
|
303fa3b78f93
3588 Ensure that users don't image-create over top of an image
Brad Hall <bhall@eng.sun.com>
parents:
581
diff
changeset
|
183 |
def test_765(self): |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
683
diff
changeset
|
184 |
"""Bug 765: malformed publisher URL.""" |
582
303fa3b78f93
3588 Ensure that users don't image-create over top of an image
Brad Hall <bhall@eng.sun.com>
parents:
581
diff
changeset
|
185 |
|
303fa3b78f93
3588 Ensure that users don't image-create over top of an image
Brad Hall <bhall@eng.sun.com>
parents:
581
diff
changeset
|
186 |
durl = "bar=baz" |
303fa3b78f93
3588 Ensure that users don't image-create over top of an image
Brad Hall <bhall@eng.sun.com>
parents:
581
diff
changeset
|
187 |
self.assertRaises(testutils.UnexpectedExitCodeException, \ |
303fa3b78f93
3588 Ensure that users don't image-create over top of an image
Brad Hall <bhall@eng.sun.com>
parents:
581
diff
changeset
|
188 |
self.image_create, durl) |
303fa3b78f93
3588 Ensure that users don't image-create over top of an image
Brad Hall <bhall@eng.sun.com>
parents:
581
diff
changeset
|
189 |
|
303fa3b78f93
3588 Ensure that users don't image-create over top of an image
Brad Hall <bhall@eng.sun.com>
parents:
581
diff
changeset
|
190 |
def test_763a(self): |
938
eeb932b9b44e
7336 putback for 5871 missed a few vestiges of authority
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
926
diff
changeset
|
191 |
"""Bug 763, traceback 1: no -p option given to image-create.""" |
582
303fa3b78f93
3588 Ensure that users don't image-create over top of an image
Brad Hall <bhall@eng.sun.com>
parents:
581
diff
changeset
|
192 |
|
303fa3b78f93
3588 Ensure that users don't image-create over top of an image
Brad Hall <bhall@eng.sun.com>
parents:
581
diff
changeset
|
193 |
self.assertRaises(testutils.UnexpectedExitCodeException, \ |
303fa3b78f93
3588 Ensure that users don't image-create over top of an image
Brad Hall <bhall@eng.sun.com>
parents:
581
diff
changeset
|
194 |
self.pkg, "image-create foo") |
303fa3b78f93
3588 Ensure that users don't image-create over top of an image
Brad Hall <bhall@eng.sun.com>
parents:
581
diff
changeset
|
195 |
|
303fa3b78f93
3588 Ensure that users don't image-create over top of an image
Brad Hall <bhall@eng.sun.com>
parents:
581
diff
changeset
|
196 |
def test_763c(self): |
938
eeb932b9b44e
7336 putback for 5871 missed a few vestiges of authority
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
926
diff
changeset
|
197 |
"""Bug 763, traceback 3: -p given to image-create, but no |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
683
diff
changeset
|
198 |
publisher specified.""" |
582
303fa3b78f93
3588 Ensure that users don't image-create over top of an image
Brad Hall <bhall@eng.sun.com>
parents:
581
diff
changeset
|
199 |
|
303fa3b78f93
3588 Ensure that users don't image-create over top of an image
Brad Hall <bhall@eng.sun.com>
parents:
581
diff
changeset
|
200 |
self.assertRaises(testutils.UnexpectedExitCodeException, \ |
938
eeb932b9b44e
7336 putback for 5871 missed a few vestiges of authority
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
926
diff
changeset
|
201 |
self.pkg, "image-create -p foo") |
582
303fa3b78f93
3588 Ensure that users don't image-create over top of an image
Brad Hall <bhall@eng.sun.com>
parents:
581
diff
changeset
|
202 |
|
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
683
diff
changeset
|
203 |
def test_bad_publisher_options(self): |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
683
diff
changeset
|
204 |
"""More tests that abuse the publisher prefix and URL.""" |
582
303fa3b78f93
3588 Ensure that users don't image-create over top of an image
Brad Hall <bhall@eng.sun.com>
parents:
581
diff
changeset
|
205 |
|
303fa3b78f93
3588 Ensure that users don't image-create over top of an image
Brad Hall <bhall@eng.sun.com>
parents:
581
diff
changeset
|
206 |
self.assertRaises(testutils.UnexpectedExitCodeException, \ |
938
eeb932b9b44e
7336 putback for 5871 missed a few vestiges of authority
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
926
diff
changeset
|
207 |
self.pkg, "image-create -p $%^8" + ("=http://%s1" % |
683
5e5d509f00e3
4422 t_pkg_authority pinging extant node accidentally
Brock Pytlik <bpytlik@sun.com>
parents:
582
diff
changeset
|
208 |
self.bogus_url)) |
582
303fa3b78f93
3588 Ensure that users don't image-create over top of an image
Brad Hall <bhall@eng.sun.com>
parents:
581
diff
changeset
|
209 |
|
303fa3b78f93
3588 Ensure that users don't image-create over top of an image
Brad Hall <bhall@eng.sun.com>
parents:
581
diff
changeset
|
210 |
self.assertRaises(testutils.UnexpectedExitCodeException, \ |
938
eeb932b9b44e
7336 putback for 5871 missed a few vestiges of authority
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
926
diff
changeset
|
211 |
self.pkg, "image-create -p test1=http://$%^8") |
582
303fa3b78f93
3588 Ensure that users don't image-create over top of an image
Brad Hall <bhall@eng.sun.com>
parents:
581
diff
changeset
|
212 |
|
303fa3b78f93
3588 Ensure that users don't image-create over top of an image
Brad Hall <bhall@eng.sun.com>
parents:
581
diff
changeset
|
213 |
self.assertRaises(testutils.UnexpectedExitCodeException, \ |
938
eeb932b9b44e
7336 putback for 5871 missed a few vestiges of authority
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
926
diff
changeset
|
214 |
self.pkg, "image-create -p test1=http://%s1:abcde" % |
683
5e5d509f00e3
4422 t_pkg_authority pinging extant node accidentally
Brock Pytlik <bpytlik@sun.com>
parents:
582
diff
changeset
|
215 |
self.bogus_url) |
582
303fa3b78f93
3588 Ensure that users don't image-create over top of an image
Brad Hall <bhall@eng.sun.com>
parents:
581
diff
changeset
|
216 |
|
303fa3b78f93
3588 Ensure that users don't image-create over top of an image
Brad Hall <bhall@eng.sun.com>
parents:
581
diff
changeset
|
217 |
self.assertRaises(testutils.UnexpectedExitCodeException, \ |
938
eeb932b9b44e
7336 putback for 5871 missed a few vestiges of authority
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
926
diff
changeset
|
218 |
self.pkg, "image-create -p test1=ftp://%s1" % |
683
5e5d509f00e3
4422 t_pkg_authority pinging extant node accidentally
Brock Pytlik <bpytlik@sun.com>
parents:
582
diff
changeset
|
219 |
self.bogus_url) |
582
303fa3b78f93
3588 Ensure that users don't image-create over top of an image
Brad Hall <bhall@eng.sun.com>
parents:
581
diff
changeset
|
220 |
|
938
eeb932b9b44e
7336 putback for 5871 missed a few vestiges of authority
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
926
diff
changeset
|
221 |
|
582
303fa3b78f93
3588 Ensure that users don't image-create over top of an image
Brad Hall <bhall@eng.sun.com>
parents:
581
diff
changeset
|
222 |
if __name__ == "__main__": |
303fa3b78f93
3588 Ensure that users don't image-create over top of an image
Brad Hall <bhall@eng.sun.com>
parents:
581
diff
changeset
|
223 |
unittest.main() |