def test_existing_multiple(self, tmp_path, loader, registry, plugin_1, bg_instance): """This is mainly to test that Instance IDs are correct We save a system with 2 instances: - instance1, 58542eb571afd47ead90beef - instance2, 58542eb571afd47ead90beee Then we load a plugin that defines instances [instance2, instance3]. Correct behavior is: - instance1 removed from the database - instance3 created in the database - instance2 remains in the database, and the ID remains the same """ instance1 = Instance(name="instance1", id="58542eb571afd47ead90beef") instance2 = Instance(name="instance2", id="58542eb571afd47ead90beee") create_system( System(name="foo", version="1.0", instances=[instance1, instance2]) ) plugin = tmp_path / "plugin" plugin.mkdir() write_file( plugin, textwrap.dedent( """ NAME='foo' VERSION='1.0' PLUGIN_ENTRY='entry.py' INSTANCES=["instance2", "instance3"] """ ), ) plugin_runners = loader.load_plugin(plugin) assert len(plugin_runners) == 2 assert db.query_unique(Instance, name="instance1") is None assert db.query_unique(Instance, name="instance3") is not None instance2_db = db.query_unique(Instance, name="instance2") assert instance2_db is not None assert instance2_db.id == instance2.id
def test_existing(self, loader, registry, plugin_1): system_id = "58542eb571afd47ead90face" instance_id = "58542eb571afd47ead90beef" create_system( System( id=system_id, name="foo", version="1.0", instances=[Instance(id=instance_id)], ) ) plugin_runners = loader.load_plugin(plugin_1) assert len(plugin_runners) == 1 assert str(plugin_runners[0].system.id) == system_id assert str(plugin_runners[0].instance.id) == instance_id assert plugin_runners[0].name == "foo[default]-1.0" assert plugin_runners[0].entry_point == "entry.py"
def system(): yield create_system( BrewtilsSystem( name="original", version="v0.0.1", namespace="beer_garden", commands=[BrewtilsCommand(name="original")], )) System.drop_collection()
def remotegarden_system(): yield create_system( BrewtilsSystem(name="remotesystem", version="1.2.3", namespace="remotegarden", local=False))
def localgarden_system(): yield create_system( BrewtilsSystem(name="localsystem", version="1.2.3", namespace="localgarden", local=True))