Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# limitations under the License.
"""Module for testing the add personality --copy_from command."""
import unittest
if __name__ == "__main__":
from broker import utils
utils.import_depends()
from broker.brokertest import TestBrokerCommand
from broker.grntest import VerifyGrnsMixin
GRN = "grn:/ms/ei/aquilon/aqd"
class TestCopyPersonality(VerifyGrnsMixin, TestBrokerCommand):
def test_100_restore_utunused_comments(self):
self.noouttest(["update_personality", "--archetype", "aquilon",
"--personality", "utunused/dev",
"--comments", "New personality comments"])
def test_110_add_utunused_clone(self):
command = ["add_personality", "--personality", "utunused-clone/dev",
"--archetype", "aquilon", "--copy_from", "utunused/dev"]
out = self.statustest(command)
self.matchoutput(out, "Personality aquilon/utunused/dev has "
"config_override set", command)
def test_111_verify_utunused_clone(self):
command = ["show_personality", "--personality", "utunused-clone/dev",
"--archetype", "aquilon"]
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Module for testing the update personality command."""
if __name__ == "__main__":
from broker import utils
utils.import_depends()
import unittest2 as unittest
from broker.brokertest import TestBrokerCommand
from broker.grntest import VerifyGrnsMixin
class TestUpdatePersonality(VerifyGrnsMixin, TestBrokerCommand):
def test_200_invalid_function(self):
""" Verify that the list of built-in functions is restricted """
command = ["update_personality", "--personality", "vulcan-1g-desktop-prod",
"--archetype", "esx_cluster",
"--vmhost_capacity_function", "locals()"]
out = self.badrequesttest(command)
self.matchoutput(out, "name 'locals' is not defined", command)
def test_200_invalid_type(self):
command = ["update_personality", "--personality", "vulcan-1g-desktop-prod",
"--archetype", "esx_cluster",
"--vmhost_capacity_function", "memory - 100"]
out = self.badrequesttest(command)
self.matchoutput(out, "The function should return a dictonary.", command)
from collections import defaultdict
import unittest
if __name__ == "__main__":
from broker import utils
utils.import_depends()
from broker.brokertest import TestBrokerCommand
from broker.grntest import VerifyGrnsMixin
from broker.personalitytest import PersonalityTestMixin
GRN = "grn:/ms/ei/aquilon/aqd"
class TestAddPersonality(VerifyGrnsMixin, PersonalityTestMixin,
TestBrokerCommand):
def test_100_add_utunused(self):
# Unused personality with basic settings
command = ["add_personality", "--personality=utunused/dev",
"--archetype=aquilon", "--grn=%s" % GRN, "--config_override",
"--host_environment=dev",
"--comments", "Some personality comments"]
self.noouttest(command)
self.verifycatpersonality("aquilon", "utunused/dev", True, "dev",
grn=GRN, stage="next")
self.check_plenary_exists("aquilon", "personality", "utunused/dev+next",
"config")
def test_105_verify_utunused(self):
command = ["show_personality", "--personality=utunused/dev",
"--archetype=aquilon", "--personality_stage=next"]
# limitations under the License.
"""Module for testing GRN mapping."""
import unittest
if __name__ == "__main__":
import utils
utils.import_depends()
from broker.brokertest import TestBrokerCommand
from broker.grntest import VerifyGrnsMixin
GRN = "grn:/ms/ei/aquilon/unittest"
class TestMapGrn(VerifyGrnsMixin, TestBrokerCommand):
grn_list = [ "grn:/ms/ei/aquilon/aqd", "grn:/ms/ei/aquilon/unittest"]
grn_maps = { "esp": grn_list, "atarget": [ "grn:/example/cards"] }
def test_100_add_personality(self):
command = ["add_personality", "--personality=utesppers/dev",
"--archetype=aquilon", "--grn=%s" % GRN,
"--host_environment=dev",
"--comments", "Personality target test"]
self.noouttest(command)
command = ["show_personality", "--personality=utesppers/dev",
"--archetype=aquilon"]
out = self.commandtest(command)
self.matchoutput(out, "Used by GRN: grn:/ms/ei/aquilon/unittest [esp]",
command)
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Module for testing GRN support."""
if __name__ == "__main__":
from broker import utils
utils.import_depends()
import unittest2 as unittest
from broker.brokertest import TestBrokerCommand
from broker.grntest import VerifyGrnsMixin
class TestGrns(VerifyGrnsMixin, TestBrokerCommand):
def test_100_add_test1(self):
self.assert_("grn:/ms/test1" not in self.grns)
self.assert_(1 in self.eon_ids)
command = ["add", "grn", "--grn", "grn:/ms/test1", "--eon_id", "1",
"--disabled"]
self.noouttest(command)
def test_101_verify_test1(self):
command = ["show", "grn", "--eon_id", "1"]
out = self.commandtest(command)
self.matchoutput(out, "GRN: grn:/ms/test1", command)
self.matchoutput(out, "EON ID: 1", command)
self.matchoutput(out, "Disabled: True", command)
def test_110_add_test2(self):
# limitations under the License.
"""Module for testing the search personality command."""
from collections import defaultdict
import unittest
if __name__ == "__main__":
from broker import utils
utils.import_depends()
from broker.brokertest import TestBrokerCommand
from broker.grntest import VerifyGrnsMixin
class TestSearchPersonality(VerifyGrnsMixin, TestBrokerCommand):
def test_100_by_grn(self):
command = ["search", "personality", "--grn", "grn:/ms/ei/aquilon/aqd"]
out = self.commandtest(command)
self.matchoutput(out, "aquilon/utpers-dev@current", command)
self.matchoutput(out, "aquilon/utunused/dev", command)
self.matchoutput(out, "esx_cluster/esx_server", command)
self.matchoutput(out, "esx_cluster/vulcan-10g-server-prod", command)
def test_100_by_environment(self):
command = ["search", "personality", "--host_environment", "prod"]
out = self.commandtest(command)
self.matchoutput(out, "aurora/generic", command)
self.matchoutput(out, "filer/generic", command)
self.matchoutput(out, "f5/generic", command)
self.matchoutput(out, "esx_cluster/vulcan-10g-server-prod", command)
self.matchoutput(out, "storagecluster/metrocluster", command)
'class': 'system.swapUsed',
'descr': 'Swap space used [%]',
'latestonly': False,
'name': 'SwapUsed',
'period': 300,
'smooth': {
'maxdiff': 3.0,
'maxtime': 3600,
'typeString': False
}
}
}
class TestAddParameter(VerifyGrnsMixin, PersonalityTestMixin,
TestBrokerCommand):
def check_match(self, out, expected, command):
out = ' '.join(out.split())
self.matchoutput(out, expected, command)
def test_100_no_params_yet(self):
command = ["show_parameter", "--personality", "utpers-dev",
"--archetype", "aquilon", "--personality_stage", "next"]
err = self.notfoundtest(command)
self.matchoutput(err,
"No parameters found for personality aquilon/utpers-dev@next.",
command)
command = ["show_parameter", "--personality", "utpers-dev",
"--archetype", "aquilon", "--personality_stage", "next",
import os
import re
from datetime import datetime
import unittest
if __name__ == "__main__":
from broker import utils
utils.import_depends()
from broker.brokertest import TestBrokerCommand
from broker.grntest import VerifyGrnsMixin
from broker.notificationtest import VerifyNotificationsMixin
class TestReconfigure(VerifyGrnsMixin, VerifyNotificationsMixin,
TestBrokerCommand):
linux_version_prev = None
linux_version_curr = None
# Note that some tests for reconfigure --list appear in
# test_make_aquilon.py.
@classmethod
def setUpClass(cls):
super(TestReconfigure, cls).setUpClass()
cls.linux_version_prev = cls.config.get("unittest",
"linux_version_prev")
cls.linux_version_curr = cls.config.get("unittest",
"linux_version_curr")
def test_1000_edit_machine_plenary(self):