Beispiel #1
0
class ListenerTests(unittest.TestCase):

    def setUp(self):
        self.platform = PlatformWrapper()
        self.platform.startup_platform("base-platform-test.json", use_twistd=False)

    def tearDown(self):
        self.platform.cleanup()

    def test_direct_install_start_stop_start(self):
        uuid = self.platform.direct_build_install_run_agent(AGENT_DIR, CONFIG_FILE)
        time.sleep(5)
        self.platform.direct_stop_agent(uuid)
        time.sleep(5)
        self.platform.direct_start_agent(uuid)
Beispiel #2
0
 def setUp(self):
     self.platform_wrapper = PlatformWrapper()
Beispiel #3
0
class BasePlatformTest(unittest.TestCase):

    cleanup_tempdir = True

    def env(self):
        return self.platform_wrapper.env

    def setUp(self):
        self.platform_wrapper = PlatformWrapper()

    def startup_platform(self,
                         platform_config,
                         volttron_home=None,
                         use_twistd=True,
                         mode=UNRESTRICTED):

        if volttron_home != None:
            self.platform_wrapper.initialize_volttron_home(volttron_home)
        self.platform_wrapper.startup_platform(platform_config,
                                               use_twistd=use_twistd,
                                               mode=mode)

    def fillout_file(self, filename, template, config_file):
        return self.platform_wrapper.fillout_file(filename, template,
                                                  config_file)

    def build_agentpackage(self, distdir):
        pwd = os.getcwd()
        try:
            basepackage = os.path.join(self.platform_wrapper.tmpdir, distdir)
            shutil.copytree(os.path.abspath(distdir), basepackage)

            os.chdir(basepackage)
            sys.argv = ['', 'bdist_wheel']
            exec(compile(open('setup.py').read(), 'setup.py', 'exec'))

            wheel_name = os.listdir('./dist')[0]

            wheel_file_and_path = os.path.join(os.path.abspath('./dist'),
                                               wheel_name)
        finally:
            os.chdir(pwd)

        return wheel_file_and_path

    def direct_build_agentpackage(self, agent_dir):
        uuid = self.platform_wrapper.direct_build_agentpackage(agent_dir)
        self.assertTrue(uuid, "Invalid uuid returned")
        return uuid

    def direct_configure_agentpackage(self, agent_wheel, config_file):
        packaging.add_files_to_package(
            agent_wheel, {'config_file': os.path.join(rel_path, config_file)})

    def direct_buid_install_agent(self, agent_dir, config_file):
        uuid = self.platform_wrapper.direct_buid_install_agent(
            agent_dir, config_file)
        self.assertTrue(uuid, "Invalid uuid returned")
        return uuid

    def direct_remove_agent(self, uuid):
        uuid = self.direct_remove_agent(uuid)
        self.assertTrue(uuid, "Invalid uuid returned")
        return uuid

    def direct_build_install_run_agent(self, agent_dir, config_file):
        uuid = self.platform_wrapper.direct_build_install_run_agent(
            agent_dir, config_file)
        self.assertTrue(uuid, "Invalid uuid returned")
        return uuid

    def direct_start_agent(self, agent_uuid):
        self.platform_wrapper.direct_start_agent(agent_uuid)

    def direct_stop_agent(self, agent_uuid):
        self.platform_wrapper.direct_stop_agent(agent_uuid)

    def shutdown_platform(self):
        '''Stop platform here'''
        self.platform_wrapper.shutdown_platform(self.cleanup_tempdir)

    def tearDown(self):
        self.platform_wrapper.shutdown_platform(self.cleanup_tempdir)
Beispiel #4
0
 def setUp(self):
     self.platform = PlatformWrapper()
     self.platform.startup_platform("base-platform-test.json", use_twistd=False)
Beispiel #5
0
 def setUp(self):
     self.platform_wrapper = PlatformWrapper()
Beispiel #6
0
class BasePlatformTest(unittest.TestCase):

    cleanup_tempdir = True

    def env(self):
        return self.platform_wrapper.env

    def setUp(self):
        self.platform_wrapper = PlatformWrapper()

    def startup_platform(self, platform_config, volttron_home=None,
                         use_twistd=True, mode=UNRESTRICTED):

        if volttron_home != None:
            self.platform_wrapper.initialize_volttron_home(volttron_home)
        self.platform_wrapper.startup_platform(platform_config,
                                               use_twistd=use_twistd,
                                               mode=mode)

    def fillout_file(self, filename, template, config_file):
        return self.platform_wrapper.fillout_file(filename, template, config_file)

    def build_agentpackage(self, distdir):
        pwd = os.getcwd()
        try:
            basepackage = os.path.join(self.platform_wrapper.tmpdir,distdir)
            shutil.copytree(os.path.abspath(distdir), basepackage)

            os.chdir(basepackage)
            sys.argv = ['', 'bdist_wheel']
            exec(compile(open('setup.py').read(), 'setup.py', 'exec'))

            wheel_name = os.listdir('./dist')[0]

            wheel_file_and_path = os.path.join(os.path.abspath('./dist'), wheel_name)
        finally:
            os.chdir(pwd)

        return wheel_file_and_path

    def direct_build_agentpackage(self, agent_dir):
        uuid = self.platform_wrapper.direct_build_agentpackage(agent_dir)
        self.assertTrue(uuid, "Invalid uuid returned")
        return uuid

    def direct_configure_agentpackage(self, agent_wheel, config_file):
        packaging.add_files_to_package(agent_wheel, {'config_file':os.path.join(rel_path, config_file)})

    def direct_buid_install_agent(self, agent_dir, config_file):
        uuid = self.platform_wrapper.direct_buid_install_agent(agent_dir,
                                                               config_file)
        self.assertTrue(uuid, "Invalid uuid returned")
        return uuid


    def direct_remove_agent(self, uuid):
        uuid = self.direct_remove_agent(uuid)
        self.assertTrue(uuid, "Invalid uuid returned")
        return uuid

    def direct_build_install_run_agent(self, agent_dir, config_file):
        uuid = self.platform_wrapper.direct_build_install_run_agent(agent_dir,
                                                                    config_file)
        self.assertTrue(uuid, "Invalid uuid returned")
        return uuid

    def direct_start_agent(self, agent_uuid):
        self.platform_wrapper.direct_start_agent(agent_uuid)

    def direct_stop_agent(self, agent_uuid):
        self.platform_wrapper.direct_stop_agent(agent_uuid)

    def shutdown_platform(self):
        '''Stop platform here'''
        self.platform_wrapper.shutdown_platform(self.cleanup_tempdir)

    def tearDown(self):
        self.platform_wrapper.shutdown_platform(self.cleanup_tempdir)