author | Ethan Quach <Ethan.Quach@sun.com> |
Tue, 31 May 2011 14:21:09 -0700 | |
changeset 1160 | 6f7e708c38ec |
parent 1116 | 29e34d65ceef |
child 1561 | 35464141ab57 |
permissions | -rw-r--r-- |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
1 |
#!/usr/bin/python2.6 |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
2 |
# |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
3 |
# CDDL HEADER START |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
4 |
# |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
5 |
# The contents of this file are subject to the terms of the |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
6 |
# Common Development and Distribution License (the "License"). |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
7 |
# You may not use this file except in compliance with the License. |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
8 |
# |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
9 |
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
10 |
# or http://www.opensolaris.org/os/licensing. |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
11 |
# See the License for the specific language governing permissions |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
12 |
# and limitations under the License. |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
13 |
# |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
14 |
# When distributing Covered Code, include this CDDL HEADER in each |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
15 |
# file and include the License file at usr/src/OPENSOLARIS.LICENSE. |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
16 |
# If applicable, add the following below this CDDL HEADER, with the |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
17 |
# fields enclosed by brackets "[]" replaced with your own identifying |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
18 |
# information: Portions Copyright [yyyy] [name of copyright owner] |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
19 |
# |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
20 |
# CDDL HEADER END |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
21 |
# |
1116
29e34d65ceef
7040960 Missing usr/src/cmd/ai-webserver/export_profile.py in slim_source cause slim unit test failure.
William Schumann <william.schumann@sun.com>
parents:
1087
diff
changeset
|
22 |
# Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
23 |
# |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
24 |
|
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
25 |
''' |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
26 |
To run these tests, see the instructions in usr/src/tools/tests/README. |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
27 |
Remember that since the proto area is used for the PYTHONPATH, the gate |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
28 |
must be rebuilt for these tests to pick up any changes in the tested code. |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
29 |
|
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
30 |
''' |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
31 |
|
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
32 |
import gettext |
966
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
33 |
import os |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
34 |
import tempfile |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
35 |
import unittest |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
36 |
|
966
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
37 |
from sqlite3 import dbapi2 as sqlite3 |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
38 |
|
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
39 |
import osol_install.auto_install.AI_database as AIdb |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
40 |
|
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
41 |
# Eventually bring names into convention. |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
42 |
# pylint: disable-msg=C0103 |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
43 |
|
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
44 |
gettext.install("ai-test") |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
45 |
|
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
46 |
|
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
47 |
class MockDataBase(object): |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
48 |
'''Class for mock database ''' |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
49 |
def __init__(self): |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
50 |
self.queue = MockQueue() |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
51 |
|
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
52 |
def getQueue(self): |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
53 |
''' Return request queue ''' |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
54 |
return self.queue |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
55 |
|
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
56 |
|
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
57 |
class MockQueue(object): |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
58 |
'''Class for mock database ''' |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
59 |
|
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
60 |
def __init__(self): |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
61 |
self.criteria = None |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
62 |
|
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
63 |
# Disable unused-args message here as this is a dummy function. |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
64 |
# Disable "method could be a function" errors as inappropriate here. |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
65 |
# pylint: disable-msg=W0613,R0201 |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
66 |
def put(self, query): |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
67 |
'''Dummy put method''' |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
68 |
return |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
69 |
|
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
70 |
|
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
71 |
class MockQuery(object): |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
72 |
'''Class for mock query ''' |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
73 |
def __init__(self): |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
74 |
self.query = None |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
75 |
|
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
76 |
# Disable "method could be a function" errors as inappropriate here. |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
77 |
# Disable unused-args message here as this is a dummy function. |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
78 |
# pylint: disable-msg=W0613, R0201 |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
79 |
def __call__(self, query, commit=False): |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
80 |
self.query = query |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
81 |
return self |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
82 |
|
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
83 |
def waitAns(self): |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
84 |
'''Dummy waitAns method''' |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
85 |
return |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
86 |
|
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
87 |
def getResponse(self): |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
88 |
'''Dummy getResponse method''' |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
89 |
return |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
90 |
|
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
91 |
|
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
92 |
class MockGetCriteria(object): |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
93 |
'''Class for mock getCriteria ''' |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
94 |
def __init__(self): |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
95 |
self.crit_stripped = ["arch", "mem", "ipv4", "mac"] |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
96 |
self.crit_unstripped = ["MINmem", "MINipv4", "MINmac", |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
97 |
"MAXmem", "MAXipv4", "MAXmac", "arch"] |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
98 |
|
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
99 |
# Disable unused-args message here as this is a dummy function. |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
100 |
# pylint: disable-msg=W0613 |
1116
29e34d65ceef
7040960 Missing usr/src/cmd/ai-webserver/export_profile.py in slim_source cause slim unit test failure.
William Schumann <william.schumann@sun.com>
parents:
1087
diff
changeset
|
101 |
def __call__(self, queue, table=AIdb.MANIFESTS_TABLE, onlyUsed=False, |
29e34d65ceef
7040960 Missing usr/src/cmd/ai-webserver/export_profile.py in slim_source cause slim unit test failure.
William Schumann <william.schumann@sun.com>
parents:
1087
diff
changeset
|
102 |
strip=False): |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
103 |
if strip: |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
104 |
return self.crit_stripped |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
105 |
else: |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
106 |
return self.crit_unstripped |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
107 |
|
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
108 |
|
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
109 |
class MockDataFiles(object): |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
110 |
'''Class for mock DataFiles''' |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
111 |
def __init__(self): |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
112 |
self.criteria = None |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
113 |
self.database = MockDataBase() |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
114 |
|
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
115 |
|
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
116 |
class getSpecificCriteria(unittest.TestCase): |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
117 |
'''Tests for getSpecificCriteria''' |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
118 |
|
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
119 |
def setUp(self): |
878
ab329590d9ca
6985193 installadm incorrectly pads ip addresses with zeros
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
862
diff
changeset
|
120 |
'''unit test set up''' |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
121 |
self.aidb_DBrequest = AIdb.DBrequest |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
122 |
self.mockquery = MockQuery() |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
123 |
AIdb.DBrequest = self.mockquery |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
124 |
self.files = MockDataFiles() |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
125 |
|
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
126 |
def tearDown(self): |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
127 |
'''unit test tear down |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
128 |
Functions originally saved in setUp are restored to their |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
129 |
original values. |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
130 |
''' |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
131 |
AIdb.DBrequest = self.aidb_DBrequest |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
132 |
|
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
133 |
def test_arch_no_exclude(self): |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
134 |
'''Verify arch query string with no exclude option''' |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
135 |
criteria = "arch" |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
136 |
queue = self.files.database.getQueue() |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
137 |
AIdb.getSpecificCriteria(queue, criteria) |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
138 |
expect_query = "SELECT arch FROM manifests WHERE arch IS NOT NULL" |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
139 |
self.assertEquals(expect_query, self.mockquery.query) |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
140 |
|
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
141 |
def test_arch_exclude(self): |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
142 |
'''Verify arch query string with exclude option''' |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
143 |
criteria = "arch" |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
144 |
queue = self.files.database.getQueue() |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
145 |
AIdb.getSpecificCriteria(queue, criteria, excludeManifests=["suexml"]) |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
146 |
expect_query = "SELECT arch FROM manifests WHERE arch IS NOT NULL " + \ |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
147 |
"AND name IS NOT 'suexml'" |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
148 |
self.assertEquals(expect_query, self.mockquery.query) |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
149 |
|
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
150 |
def test_MINipv4(self): |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
151 |
'''Verify single MIN query string ''' |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
152 |
criteria = "MINipv4" |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
153 |
queue = self.files.database.getQueue() |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
154 |
AIdb.getSpecificCriteria(queue, criteria) |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
155 |
expect_query = "SELECT MINipv4 FROM manifests WHERE MINipv4 IS " + \ |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
156 |
"NOT NULL" |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
157 |
self.assertEquals(expect_query, self.mockquery.query) |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
158 |
|
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
159 |
def test_MAXipv4(self): |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
160 |
'''Verify single MAX query string ''' |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
161 |
criteria = "MAXipv4" |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
162 |
queue = self.files.database.getQueue() |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
163 |
AIdb.getSpecificCriteria(queue, criteria) |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
164 |
expect_query = "SELECT MAXipv4 FROM manifests WHERE MAXipv4 IS " + \ |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
165 |
"NOT NULL" |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
166 |
self.assertEquals(expect_query, self.mockquery.query) |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
167 |
|
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
168 |
def test_MIN_MAXmem(self): |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
169 |
'''Verify mem range query string ''' |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
170 |
criteria = "MINmem" |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
171 |
criteria2 = "MAXmem" |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
172 |
queue = self.files.database.getQueue() |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
173 |
AIdb.getSpecificCriteria(queue, criteria, criteria2=criteria2) |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
174 |
expect_query = "SELECT MINmem, MAXmem FROM manifests WHERE " + \ |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
175 |
"(MINmem IS NOT NULL OR MAXmem IS NOT NULL)" |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
176 |
self.assertEquals(expect_query, self.mockquery.query) |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
177 |
|
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
178 |
def test_MIN_MAXmac(self): |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
179 |
'''Verify mac range query string ''' |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
180 |
criteria = "MINmac" |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
181 |
criteria2 = "MAXmac" |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
182 |
queue = self.files.database.getQueue() |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
183 |
AIdb.getSpecificCriteria(queue, criteria, criteria2=criteria2) |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
184 |
expect_query = "SELECT HEX(MINmac), HEX(MAXmac) FROM manifests " + \ |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
185 |
"WHERE (MINmac IS NOT NULL OR MAXmac IS NOT NULL)" |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
186 |
self.assertEquals(expect_query, self.mockquery.query) |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
187 |
|
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
188 |
|
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
189 |
class isRangeCriteria(unittest.TestCase): |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
190 |
'''Tests for isRangeCriteria''' |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
191 |
|
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
192 |
def setUp(self): |
878
ab329590d9ca
6985193 installadm incorrectly pads ip addresses with zeros
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
862
diff
changeset
|
193 |
'''unit test set up''' |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
194 |
self.aidb_getCriteria = AIdb.getCriteria |
966
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
195 |
AIdb.getCriteria = MockGetCriteria() |
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
196 |
self.files = MockDataFiles() |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
197 |
|
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
198 |
def tearDown(self): |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
199 |
'''unit test tear down |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
200 |
Functions originally saved in setUp are restored to their |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
201 |
original values. |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
202 |
''' |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
203 |
AIdb.getCriteria = self.aidb_getCriteria |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
204 |
|
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
205 |
def test_arch_not_range(self): |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
206 |
'''Verify arch returns false for range''' |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
207 |
is_range_criteria = AIdb.isRangeCriteria(self.files.database, "arch") |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
208 |
self.assertFalse(is_range_criteria) |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
209 |
|
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
210 |
def test_ipv4_is_range(self): |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
211 |
'''Verify ipv4 returns true for range''' |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
212 |
is_range_criteria = AIdb.isRangeCriteria(self.files.database, "ipv4") |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
213 |
self.assertTrue(is_range_criteria) |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
214 |
|
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
215 |
def test_mac_is_range(self): |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
216 |
'''Verify mac returns true for range''' |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
217 |
is_range_criteria = AIdb.isRangeCriteria(self.files.database, "mac") |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
218 |
self.assertTrue(is_range_criteria) |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
219 |
|
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
220 |
def test_mem_is_range(self): |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
221 |
'''Verify mem returns true for range''' |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
222 |
is_range_criteria = AIdb.isRangeCriteria(self.files.database, "mem") |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
223 |
self.assertTrue(is_range_criteria) |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
224 |
|
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
225 |
|
878
ab329590d9ca
6985193 installadm incorrectly pads ip addresses with zeros
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
862
diff
changeset
|
226 |
class formatValue(unittest.TestCase): |
ab329590d9ca
6985193 installadm incorrectly pads ip addresses with zeros
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
862
diff
changeset
|
227 |
'''Tests for formatValue''' |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
228 |
|
878
ab329590d9ca
6985193 installadm incorrectly pads ip addresses with zeros
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
862
diff
changeset
|
229 |
def setUp(self): |
ab329590d9ca
6985193 installadm incorrectly pads ip addresses with zeros
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
862
diff
changeset
|
230 |
'''unit test set up''' |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
231 |
self.ipv4 = '10000002015' |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
232 |
self.mac = '080027510CC7' |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
233 |
self.network = '172021239000' |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
234 |
self.arch = 'i86pc' |
878
ab329590d9ca
6985193 installadm incorrectly pads ip addresses with zeros
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
862
diff
changeset
|
235 |
self.platform = 'i386' |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
236 |
self.cpu = 'sun4u' |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
237 |
self.mem = '1024' |
878
ab329590d9ca
6985193 installadm incorrectly pads ip addresses with zeros
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
862
diff
changeset
|
238 |
|
ab329590d9ca
6985193 installadm incorrectly pads ip addresses with zeros
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
862
diff
changeset
|
239 |
def tearDown(self): |
ab329590d9ca
6985193 installadm incorrectly pads ip addresses with zeros
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
862
diff
changeset
|
240 |
'''unit test tear down''' |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
241 |
self.ipv4 = None |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
242 |
self.mac = None |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
243 |
self.network = None |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
244 |
self.arch = None |
878
ab329590d9ca
6985193 installadm incorrectly pads ip addresses with zeros
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
862
diff
changeset
|
245 |
self.platform = None |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
246 |
self.cpu = None |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
247 |
self.mem = None |
878
ab329590d9ca
6985193 installadm incorrectly pads ip addresses with zeros
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
862
diff
changeset
|
248 |
|
ab329590d9ca
6985193 installadm incorrectly pads ip addresses with zeros
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
862
diff
changeset
|
249 |
def test_arch_formatValue(self): |
ab329590d9ca
6985193 installadm incorrectly pads ip addresses with zeros
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
862
diff
changeset
|
250 |
'''Ensure that ipv4 criteria is formatted appropriately''' |
ab329590d9ca
6985193 installadm incorrectly pads ip addresses with zeros
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
862
diff
changeset
|
251 |
fmt = AIdb.formatValue('MINipv4', self.ipv4) |
ab329590d9ca
6985193 installadm incorrectly pads ip addresses with zeros
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
862
diff
changeset
|
252 |
for octet in fmt.split('.'): |
ab329590d9ca
6985193 installadm incorrectly pads ip addresses with zeros
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
862
diff
changeset
|
253 |
self.assertEqual(octet, str(int(octet))) |
ab329590d9ca
6985193 installadm incorrectly pads ip addresses with zeros
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
862
diff
changeset
|
254 |
|
ab329590d9ca
6985193 installadm incorrectly pads ip addresses with zeros
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
862
diff
changeset
|
255 |
def test_mac_formatValue(self): |
ab329590d9ca
6985193 installadm incorrectly pads ip addresses with zeros
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
862
diff
changeset
|
256 |
'''Ensure that mac criteria is formatted appropriately''' |
ab329590d9ca
6985193 installadm incorrectly pads ip addresses with zeros
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
862
diff
changeset
|
257 |
fmt = AIdb.formatValue('MINmac', self.mac) |
ab329590d9ca
6985193 installadm incorrectly pads ip addresses with zeros
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
862
diff
changeset
|
258 |
for k, bits in enumerate(fmt.split(':')): |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
259 |
self.assertEqual(bits, self.mac[k * 2:(k * 2) + 2]) |
878
ab329590d9ca
6985193 installadm incorrectly pads ip addresses with zeros
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
862
diff
changeset
|
260 |
|
ab329590d9ca
6985193 installadm incorrectly pads ip addresses with zeros
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
862
diff
changeset
|
261 |
def test_mem_formatValue(self): |
ab329590d9ca
6985193 installadm incorrectly pads ip addresses with zeros
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
862
diff
changeset
|
262 |
'''Ensure that memory criteria is formatted appropriately''' |
ab329590d9ca
6985193 installadm incorrectly pads ip addresses with zeros
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
862
diff
changeset
|
263 |
fmt = AIdb.formatValue('MINmem', self.mem) |
ab329590d9ca
6985193 installadm incorrectly pads ip addresses with zeros
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
862
diff
changeset
|
264 |
self.assertEqual(fmt.split(' ')[0], self.mem) |
ab329590d9ca
6985193 installadm incorrectly pads ip addresses with zeros
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
862
diff
changeset
|
265 |
self.assertEqual(fmt.split(' ')[1], 'MB') |
ab329590d9ca
6985193 installadm incorrectly pads ip addresses with zeros
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
862
diff
changeset
|
266 |
|
ab329590d9ca
6985193 installadm incorrectly pads ip addresses with zeros
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
862
diff
changeset
|
267 |
def test_other_formatValue(self): |
ab329590d9ca
6985193 installadm incorrectly pads ip addresses with zeros
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
862
diff
changeset
|
268 |
'''Ensure that formatValue does nothing with all other criteria''' |
ab329590d9ca
6985193 installadm incorrectly pads ip addresses with zeros
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
862
diff
changeset
|
269 |
fmt = AIdb.formatValue('network', self.network) |
ab329590d9ca
6985193 installadm incorrectly pads ip addresses with zeros
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
862
diff
changeset
|
270 |
self.assertEqual(fmt, self.network) |
ab329590d9ca
6985193 installadm incorrectly pads ip addresses with zeros
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
862
diff
changeset
|
271 |
fmt = AIdb.formatValue('arch', self.arch) |
ab329590d9ca
6985193 installadm incorrectly pads ip addresses with zeros
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
862
diff
changeset
|
272 |
self.assertEqual(fmt, self.arch) |
ab329590d9ca
6985193 installadm incorrectly pads ip addresses with zeros
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
862
diff
changeset
|
273 |
fmt = AIdb.formatValue('platform', self.platform) |
ab329590d9ca
6985193 installadm incorrectly pads ip addresses with zeros
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
862
diff
changeset
|
274 |
self.assertEqual(fmt, self.platform) |
ab329590d9ca
6985193 installadm incorrectly pads ip addresses with zeros
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
862
diff
changeset
|
275 |
fmt = AIdb.formatValue('cpu', self.cpu) |
ab329590d9ca
6985193 installadm incorrectly pads ip addresses with zeros
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
862
diff
changeset
|
276 |
self.assertEqual(fmt, self.cpu) |
ab329590d9ca
6985193 installadm incorrectly pads ip addresses with zeros
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
862
diff
changeset
|
277 |
|
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
278 |
|
966
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
279 |
class build_query_str(unittest.TestCase): |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
280 |
'''Tests for build_query_str''' |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
281 |
|
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
282 |
def test_building_query_str(self): |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
283 |
''' test that we get reasonable query str ''' |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
284 |
cri_list = ['MINipv4', 'MAXipv4', 'arch', 'cpu', 'platform', |
966
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
285 |
'MINmac', 'MAXmac', 'MINmem', 'MAXmem', |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
286 |
'MINnetwork', 'MAXnetwork'] |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
287 |
# Artificially small list to test filter functionality. |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
288 |
all_cri_list = ['arch'] |
966
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
289 |
my_crit_dict = { |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
290 |
'ipv4': '020025224125', |
966
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
291 |
'arch': 'i86pc', |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
292 |
'platform': 'myplatform', |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
293 |
'cpu': 'i386', |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
294 |
'network': '010000002000', |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
295 |
'mem': '2048', |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
296 |
'mac': 'aabbccddeeff' |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
297 |
} |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
298 |
query_str = AIdb.build_query_str(my_crit_dict, cri_list, all_cri_list) |
966
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
299 |
self.assertTrue(query_str.startswith("SELECT name")) |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
300 |
self.assertTrue("FROM manifests WHERE " in query_str) |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
301 |
self.assertTrue("MAXmem >= 2048 OR MAXmem IS NULL" in query_str) |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
302 |
self.assertTrue("MINmem <= 2048 OR MINmem IS NULL" in query_str) |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
303 |
self.assertTrue("MAXipv4 >= 020025224125" in query_str) |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
304 |
self.assertTrue("MINipv4 <= 020025224125" in query_str) |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
305 |
self.assertTrue("MAXnetwork >= 010000002000" in query_str) |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
306 |
self.assertTrue("MINnetwork <= 010000002000" in query_str) |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
307 |
self.assertTrue("HEX(MINmac) <= HEX(x'aabbccddeeff'" in query_str) |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
308 |
self.assertTrue("HEX(MAXmac) >= HEX(x'aabbccddeeff'" in query_str) |
1160
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1116
diff
changeset
|
309 |
self.assertTrue("is_in_list('arch', 'i86pc', arch, 'None')" \ |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1116
diff
changeset
|
310 |
in query_str) |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1116
diff
changeset
|
311 |
self.assertTrue("is_in_list('platform', 'myplatform', platform, " + |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1116
diff
changeset
|
312 |
"'None')" in query_str) |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
313 |
self.assertTrue("NOT ((arch IS NULL)" in query_str) |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
314 |
self.assertFalse("(cpu IS NULL)" in query_str) |
966
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
315 |
self.assertTrue(query_str.endswith("LIMIT 1")) |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
316 |
|
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
317 |
|
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
318 |
class findManifest(unittest.TestCase): |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
319 |
'''Tests for findManifest''' |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
320 |
|
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
321 |
@classmethod |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
322 |
def setUpClass(cls): |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
323 |
'''unit test set up''' |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
324 |
dbname = tempfile.NamedTemporaryFile(dir="/tmp", delete=False) |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
325 |
cls.dbname = dbname.name |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
326 |
cls.db = sqlite3.connect(dbname.name, isolation_level=None) |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
327 |
|
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
328 |
# create db |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
329 |
cls.db.execute("CREATE TABLE manifests(" |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
330 |
"name TEXT, instance INTEGER, arch TEXT," |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
331 |
"MINmac INTEGER, MAXmac INTEGER, MINipv4 INTEGER," |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
332 |
"MAXipv4 INTEGER, cpu TEXT, platform TEXT, " |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
333 |
"MINnetwork INTEGER, MAXnetwork INTEGER," |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
334 |
"MINmem INTEGER, MAXmem INTEGER)") |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
335 |
|
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
336 |
# add manifests to db |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
337 |
cls.db.execute("INSERT INTO manifests VALUES" |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
338 |
"('mac_ipv4_man',0,NULL,x'AABBCCDDEEFF',x'AABBCCDDEEFF'," |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
339 |
"020000000025,020000000025,NULL,NULL,NULL,NULL,NULL,NULL)") |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
340 |
cls.db.execute("INSERT INTO manifests VALUES" |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
341 |
"('mac_min_unbound',0,NULL,x'AABBCCDDEEFF',x'AABBCCDDEEFF'," |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
342 |
"NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL)") |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
343 |
cls.db.execute("INSERT INTO manifests VALUES" |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
344 |
"('ipv4_max_unbound',0,NULL,NULL,NULL," |
966
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
345 |
"020000000025,NULL,NULL,NULL,NULL,NULL,NULL,NULL)") |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
346 |
cls.db.execute("INSERT INTO manifests VALUES" |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
347 |
"('platform_man',0,NULL,NULL,NULL," |
966
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
348 |
"NULL,NULL,NULL,'myplatform',NULL,NULL,NULL,NULL)") |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
349 |
cls.db.execute("INSERT INTO manifests VALUES" |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
350 |
"('arch_man',0,'i86pc',NULL,NULL," |
966
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
351 |
"NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL)") |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
352 |
cls.db.execute("INSERT INTO manifests VALUES" |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
353 |
"('cpu_man',0,NULL,NULL,NULL," |
966
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
354 |
"NULL,NULL,'i386',NULL,NULL,NULL,NULL,NULL)") |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
355 |
cls.db.execute("INSERT INTO manifests VALUES" |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
356 |
"('network_man',0,NULL,NULL,NULL,NULL,NULL,NULL,NULL," |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
357 |
"010000002000,010000002000,NULL,NULL)") |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
358 |
cls.db.execute("INSERT INTO manifests VALUES" |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
359 |
"('mem_min_unbound',0,NULL,NULL,NULL," |
966
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
360 |
"NULL,NULL,NULL,NULL,NULL,NULL,NULL,2048)") |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
361 |
cls.aidb = AIdb.DB(cls.dbname, commit=True) |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
362 |
|
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
363 |
@classmethod |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
364 |
def tearDownClass(cls): |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
365 |
'''Class-level variable teardown''' |
966
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
366 |
cls.db.close() |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
367 |
os.remove(cls.dbname) |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
368 |
|
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
369 |
def test_unique_criteria_match(self): |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
370 |
''' test manifest match on mac and ipv4 value ''' |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
371 |
my_crit_dict = { |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
372 |
'ipv4': '020000000025', |
966
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
373 |
'arch': 'i86pc', |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
374 |
'platform': 'myplatform', |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
375 |
'cpu': 'i386', |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
376 |
'network': '010000002000', |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
377 |
'mem': '2048', |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
378 |
'mac': 'aabbccddeeff' |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
379 |
} |
966
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
380 |
manifest = AIdb.findManifest(my_crit_dict, self.aidb) |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
381 |
self.assertEqual(manifest, "mac_ipv4_man") |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
382 |
|
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
383 |
def test_mac_match(self): |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
384 |
''' test manifest match on mac ''' |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
385 |
my_crit_dict = { |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
386 |
'ipv4': '022000000225', |
966
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
387 |
'arch': 'i86pc', |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
388 |
'platform': 'myplatform', |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
389 |
'cpu': 'i386', |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
390 |
'network': '010000002000', |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
391 |
'mem': '2048', |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
392 |
'mac': 'aabbccddeeff' |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
393 |
} |
966
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
394 |
manifest = AIdb.findManifest(my_crit_dict, self.aidb) |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
395 |
self.assertEqual(manifest, "mac_min_unbound") |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
396 |
|
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
397 |
def test_ipv4_match(self): |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
398 |
''' test manifest match on ipv4 ''' |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
399 |
my_crit_dict = { |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
400 |
'ipv4': '020000000025', |
966
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
401 |
'arch': 'i86pc', |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
402 |
'platform': 'myplatform', |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
403 |
'cpu': 'i386', |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
404 |
'network': '010000002000', |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
405 |
'mem': '2048', |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
406 |
'mac': 'aabbccddeef0' |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
407 |
} |
966
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
408 |
manifest = AIdb.findManifest(my_crit_dict, self.aidb) |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
409 |
self.assertEqual(manifest, "ipv4_max_unbound") |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
410 |
|
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
411 |
def test_platform_match(self): |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
412 |
''' test manifest match on platform ''' |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
413 |
my_crit_dict = { |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
414 |
'ipv4': '010000000225', |
966
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
415 |
'arch': 'i86pc', |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
416 |
'platform': 'myplatform', |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
417 |
'cpu': 'i386', |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
418 |
'network': '010000002000', |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
419 |
'mem': '2048', |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
420 |
'mac': 'aabbccddeef0' |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
421 |
} |
966
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
422 |
manifest = AIdb.findManifest(my_crit_dict, self.aidb) |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
423 |
self.assertEqual(manifest, "platform_man") |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
424 |
|
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
425 |
def test_arch_match(self): |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
426 |
''' test manifest match on arch ''' |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
427 |
my_crit_dict = { |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
428 |
'ipv4': '010000000225', |
966
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
429 |
'arch': 'i86pc', |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
430 |
'platform': 'otherplatform', |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
431 |
'cpu': 'i386', |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
432 |
'network': '010000002000', |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
433 |
'mem': '2048', |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
434 |
'mac': 'aabbccddeef0' |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
435 |
} |
966
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
436 |
manifest = AIdb.findManifest(my_crit_dict, self.aidb) |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
437 |
self.assertEqual(manifest, "arch_man") |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
438 |
|
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
439 |
def test_cpu_match(self): |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
440 |
''' test manifest match on cpu ''' |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
441 |
my_crit_dict = { |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
442 |
'ipv4': '010000000225', |
966
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
443 |
'arch': 'sparc', |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
444 |
'platform': 'otherplatform', |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
445 |
'cpu': 'i386', |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
446 |
'network': '010000002000', |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
447 |
'mem': '2048', |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
448 |
'mac': 'aabbccddeef0' |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
449 |
} |
966
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
450 |
manifest = AIdb.findManifest(my_crit_dict, self.aidb) |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
451 |
self.assertEqual(manifest, "cpu_man") |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
452 |
|
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
453 |
def test_network_match(self): |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
454 |
''' test manifest match on network ''' |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
455 |
my_crit_dict = { |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
456 |
'ipv4': '010000000225', |
966
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
457 |
'arch': 'sparc', |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
458 |
'platform': 'otherplatform', |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
459 |
'cpu': 'sun4v', |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
460 |
'network': '010000002000', |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
461 |
'mem': '2048', |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
462 |
'mac': 'aabbccddeef0' |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
463 |
} |
966
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
464 |
manifest = AIdb.findManifest(my_crit_dict, self.aidb) |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
465 |
self.assertEqual(manifest, "network_man") |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
466 |
|
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
467 |
def test_mem_match(self): |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
468 |
''' test manifest match on mem ''' |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
469 |
my_crit_dict = { |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
470 |
'ipv4': '010000000225', |
966
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
471 |
'arch': 'sparc', |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
472 |
'platform': 'otherplatform', |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
473 |
'cpu': 'sun4v', |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
474 |
'network': '010000002100', |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
475 |
'mem': '2048', |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
476 |
'mac': 'bbbbccddeef0' |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
477 |
} |
966
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
478 |
manifest = AIdb.findManifest(my_crit_dict, self.aidb) |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
479 |
self.assertEqual(manifest, "mem_min_unbound") |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
480 |
|
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
481 |
def test_manifest_nomatch(self): |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
482 |
''' test that findManifest returns 0 for no matching manifest ''' |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
483 |
my_crit_dict = { |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
484 |
'ipv4': '010000000225', |
966
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
485 |
'arch': 'sparc', |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
486 |
'platform': 'otherplatform', |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
487 |
'cpu': 'sun4v', |
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
488 |
'network': '010000002100', |
1087
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
489 |
'mem': '3000', |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
490 |
'mac': 'bbbbccddeef0' |
96b6cc8130c5
6994260 Implement Auto-Installer Derived Manifests
Jack Schwartz <Jack.Schwartz@Oracle.COM>
parents:
966
diff
changeset
|
491 |
} |
966
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
492 |
manifest = AIdb.findManifest(my_crit_dict, self.aidb) |
1160
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1116
diff
changeset
|
493 |
self.assertEquals(manifest, None) |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1116
diff
changeset
|
494 |
|
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1116
diff
changeset
|
495 |
class is_in_list(unittest.TestCase): |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1116
diff
changeset
|
496 |
'''Tests for is_in_list''' |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1116
diff
changeset
|
497 |
|
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1116
diff
changeset
|
498 |
def test_match_list_first_value(self): |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1116
diff
changeset
|
499 |
''' Test that we match a value that is the first in the list ''' |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1116
diff
changeset
|
500 |
value = "foo" |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1116
diff
changeset
|
501 |
value_list = "foo bar bum" |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1116
diff
changeset
|
502 |
self.assertTrue(AIdb.is_in_list('dummy_crit', value, value_list, None)) |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1116
diff
changeset
|
503 |
|
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1116
diff
changeset
|
504 |
def test_match_list_not_first_value(self): |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1116
diff
changeset
|
505 |
''' Test that we match a value in the middle of the list ''' |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1116
diff
changeset
|
506 |
value = "foo" |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1116
diff
changeset
|
507 |
value_list = "bar foo bum" |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1116
diff
changeset
|
508 |
self.assertTrue(AIdb.is_in_list('dummy_crit', value, value_list, None)) |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1116
diff
changeset
|
509 |
|
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1116
diff
changeset
|
510 |
def test_match_case_sensitive(self): |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1116
diff
changeset
|
511 |
''' Test that we match a value based on a case senstive criteria ''' |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1116
diff
changeset
|
512 |
value = "FoO" |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1116
diff
changeset
|
513 |
value_list = "bar FoO blah" |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1116
diff
changeset
|
514 |
self.assertTrue(AIdb.is_in_list('zonename', value, value_list, None)) |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1116
diff
changeset
|
515 |
|
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1116
diff
changeset
|
516 |
def test_no_match_case_sensitive(self): |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1116
diff
changeset
|
517 |
''' Test that we don't match a value on the wrong case.''' |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1116
diff
changeset
|
518 |
value = "FoO" |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1116
diff
changeset
|
519 |
value_list = "bar foo blah" |
6f7e708c38ec
16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents:
1116
diff
changeset
|
520 |
self.assertFalse(AIdb.is_in_list('zonename', value, value_list, None)) |
966
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
521 |
|
8c40f979a2a0
6973601 problem on the criteria matching algorithm in AI install service
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
878
diff
changeset
|
522 |
|
862
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
523 |
if __name__ == '__main__': |
e9f31f2f2f2d
16423 Updates to AI schema should be made
Sue Sohn <Susan.Sohn@Oracle.COM>
parents:
diff
changeset
|
524 |
unittest.main() |