def test_build_urls_for_cli(self):
     self.assertEqual(
         'https://dist.xebialabs.com/xl-deploy/4.0.0/xl-deploy-4.0.0-cli.zip',
         Utils.build_url('4.0.0', 'cli'))
     self.assertEqual(
         'https://dist.xebialabs.com/deployit/3.9.4/deployit-3.9.4-cli.zip',
         Utils.build_url('3.9.4', 'cli'))
 def test_server(self):
     server_version = '4.0.0'
     full_server_path = os.path.join(self.server_dir, Utils.build_server_dir_name(server_version))
     full_server_zip_path = os.path.join(self.server_dir, Utils.build_server_zip_name(server_version))
     os.makedirs(full_server_path)
     open(full_server_zip_path, 'w+')
     assert os.path.isdir(full_server_path)
     self.uninstaller.server(server_version, self.server_dir)
     assert not os.path.isdir(full_server_path)
    def test_build_url_for_plugins(self):
        expected_path = 'https://dist.xebialabs.com/plugins/tomcat-plugin/3.9.2/tomcat-plugin-3.9.2.jar'
        assert expected_path == Utils.build_url('3.9.2', 'plugin', 'tomcat')

        expected_path = 'https://dist.xebialabs.com/plugins/ec2-plugin/4.0.0-beta-3/ec2-plugin-4.0.0-beta-3.jar'
        assert expected_path == Utils.build_url('4.0.0-beta-3', 'plugin',
                                                'ec2')

        expected_path = 'https://dist.xebialabs.com/plugins/xl-scale-plugin/4.0.0/xl-scale-plugin-4.0.0.jar'
        assert expected_path == Utils.build_url('4.0.0', 'plugin', 'xl-scale')
 def test_plugin(self):
     short_plugin_name = 'tomcat'
     plugin_version = '3.9.0'
     full_server_path = os.path.join(self.server_dir, Utils.build_server_dir_name(plugin_version))
     plugin_dir = os.path.join(full_server_path, 'plugins')
     full_plugin_path = os.path.join(plugin_dir, Utils.build_plugin_name(plugin_version, short_plugin_name))
     os.makedirs(plugin_dir)
     open(full_plugin_path, 'w+')
     self.uninstaller.plugin(short_plugin_name, plugin_version, self.server_dir)
     assert not os.makedirs(full_plugin_path)
    def download(self, target):
        print "Downloading CLI distribution %s" % self.version

        Utils().download(
            url=Utils.build_url(_version=self.version, _xltype="cli"),
            target=target,
            username=self._downloadsUsername,
            password=self._downloadsPassword
        )

        return self
Example #6
0
 def test_server(self):
     server_version = '4.0.0'
     full_server_path = os.path.join(
         self.server_dir, Utils.build_server_dir_name(server_version))
     full_server_zip_path = os.path.join(
         self.server_dir, Utils.build_server_zip_name(server_version))
     os.makedirs(full_server_path)
     open(full_server_zip_path, 'w+')
     assert os.path.isdir(full_server_path)
     self.uninstaller.server(server_version, self.server_dir)
     assert not os.path.isdir(full_server_path)
Example #7
0
    def plugin(self, name, version, location):
        server_dir = os.path.join(location,
                                  Utils.build_server_dir_name(version))
        plugin_path = "{path}/plugins/{name}".format(
            path=server_dir, name=Utils.build_plugin_name(version, name))

        if os.path.isfile(plugin_path):
            os.remove(plugin_path)
        else:
            print "Plugin {} hasn\'t been removed as it doesn\'t exist".format(
                plugin_path)
Example #8
0
 def test_plugin(self):
     short_plugin_name = 'tomcat'
     plugin_version = '3.9.0'
     full_server_path = os.path.join(
         self.server_dir, Utils.build_server_dir_name(plugin_version))
     plugin_dir = os.path.join(full_server_path, 'plugins')
     full_plugin_path = os.path.join(
         plugin_dir,
         Utils.build_plugin_name(plugin_version, short_plugin_name))
     os.makedirs(plugin_dir)
     open(full_plugin_path, 'w+')
     self.uninstaller.plugin(short_plugin_name, plugin_version,
                             self.server_dir)
     assert not os.makedirs(full_plugin_path)
Example #9
0
    def server(self, version, location):
        server_dir = os.path.join(location,
                                  Utils.build_server_dir_name(version))
        if os.path.isdir(server_dir):
            shutil.rmtree(server_dir)
        else:
            print "The server {} hasn\'t been removed as it doesn\'t exist".format(
                server_dir)

        zip_path = os.path.join(location, Utils.build_server_zip_name(version))
        if os.path.isfile(zip_path):
            os.remove(zip_path)
        else:
            print "Zip file {} hasn\'t been removed as it doesn\'t exist".format(
                zip_path)
Example #10
0
 def _ping(self):
     try:
         ping_url = self.url + 'server/info'
         print "Pinging %s " % ping_url
         opener = Utils.auth_and_open_url(ping_url, 'GET', self.username, self.password)
         urllib2.install_opener(opener)
         return True
     except urllib2.URLError:
         return False
    def _get_url(self):

        if self.version == 'SNAPSHOT':
            job = self._jenkins.get_job(self._jobName)
            artifacts = job.get_last_good_build().get_artifact_dict().values()
            server_artifact = [a for a in artifacts if a.filename.endswith('-server.zip')].pop()
            return server_artifact.url
        else:
            return Utils.build_url(_version=self.version, _xltype="server")
Example #12
0
 def _ping(self):
     try:
         ping_url = self.url + 'server/info'
         print "Pinging %s " % ping_url
         opener = Utils.auth_and_open_url(ping_url, 'GET', self.username, self.password)
         urllib2.install_opener(opener)
         return True
     except urllib2.URLError:
         return False
    def _get_url(self):

        if self.version == 'SNAPSHOT':
            job = self._jenkins.get_job(self._jobName)
            artifacts = job.get_last_good_build().get_artifact_dict().values()
            server_artifact = [a for a in artifacts if a.filename.endswith('-server.zip')].pop()
            return server_artifact.url
        else:
            return Utils.build_url(_version=self.version, _xltype="server")
Example #14
0
    def plugin(self, name, version, server_location):
        plugins_path = os.path.join(server_location, 'plugins')

        print "Installing plugin %s into " % plugins_path

        u = Utils.build_url(_version=version,
                            _xltype="plugin",
                            _plugin_short_name=name)

        Utils().download(url=u,
                         target=plugins_path,
                         username=self.config.get('downloads', 'username'),
                         password=self.config.get('downloads', 'password'))

        server = Server.from_config(config=self.config, home=server_location)

        if server.is_running():
            server.restart()
Example #15
0
    def test_download_file(self):
        file_name = 'bring-your-own-cloud-plugin-3.9.4.jar'
        url = 'https://dist.xebialabs.com/community/bring-your-own-cloud-plugin/3.9.4/%s' % file_name
        target = '/tmp/'

        target_file = Utils.download(url, target, self.downloads_username,
                                     self.downloads_password)
        assert os.path.isfile(
            target_file), 'file %s hasn\'t been found' % target_file
        os.remove(target_file)
    def download(self, target):
        print "Downloading CLI distribution %s" % self.version

        Utils().download(
            url=Utils.build_url(_version=self.version, _xltype="cli"),
            target=target,
            username=self._downloadsUsername,
            password=self._downloadsPassword
        )

        return self
Example #17
0
    def test_operations(self):
        assert not self.server.is_running()
        assert self.server.is_stopped()

        thread.start_new_thread(self.server.start, ())
        assert not self.server.is_running()  # still starting
        Utils.wait_until(self.server.is_running, tick=True)
        assert not self.server.is_stopped()  # has started starting

        thread.start_new_thread(self.server.restart, ())
        Utils.wait_until(self.server.is_stopped, tick=True)  # first should stop
        Utils.wait_until(self.server.is_running, tick=True)  # then should start

        self.server.stop()
        Utils.wait_until(self.server.is_stopped, tick=True)  # also takes some time
        assert not self.server.is_running()
    def plugin(self, name, version, server_location):
        plugins_path = os.path.join(server_location, 'plugins')

        print "Installing plugin %s into " % plugins_path

        u = Utils.build_url(_version=version, _xltype="plugin", _plugin_short_name=name)

        Utils().download(
            url=u,
            target=plugins_path,
            username=self.config.get('downloads', 'username'),
            password=self.config.get('downloads', 'password')
        )

        server = Server.from_config(config=self.config, home=server_location)

        if server.is_running():
            server.restart()
Example #19
0
    def test_operations(self):
        assert not self.server.is_running()
        assert self.server.is_stopped()

        self.server.start()
        assert not self.server.is_running()  # still starting
        Utils.wait_until(self.server.is_running, tick=True)
        assert not self.server.is_stopped()  # has started starting

        thread.start_new_thread(self.server.restart, ())
        Utils.wait_until(self.server.is_stopped,
                         tick=True)  # first should stop
        Utils.wait_until(self.server.is_running, tick=True)  # then should run

        self.server.stop_and_wait()
        assert not self.server.is_running()
Example #20
0
 def stop_and_wait(self):
     self.stop()
     Utils.wait_until(self.is_stopped, tick=True)
 def get_filename(self):
     return Utils.build_cli_zip_name(self.version)
 def cli(self, version, path):
     ZipFile(self.cache.get(DownloadsCliDist(version, self.config)), 'r').extractall(path)
     return os.path.join(path, Utils.build_cli_dir_name(version))
Example #23
0
 def tearDown(self):
     self.server.stop()
     Utils.wait_until(self.server.is_stopped)
 def download(self, target):
     print "Downloading: %s" % self.get_filename()
     username = self._jenkins.username if self.version == 'SNAPSHOT' else self._downloadsUsername
     password = self._jenkins.password if self.version == 'SNAPSHOT' else self._downloadsPassword
     return Utils().download(url=self._get_url(), target=target, username=username, password=password)
 def get_filename(self):
     return Utils.build_cli_zip_name(self.version)
Example #26
0
 def test_download_plugin(self):
     tomcat_url = Utils.build_url('4.0.0-beta-3', 'plugin', 'ec2')
     target_file = Utils.download(tomcat_url, os.getcwd(),
                                  self.downloads_username,
                                  self.downloads_password)
     os.remove(target_file)
Example #27
0
 def stop(self):
     if self.is_running():
         stop_url = self.url + 'server/shutdown'
         opener = Utils.auth_and_open_url(stop_url, 'POST', self.username, self.password)
         print "Stopping the server"
         urllib2.install_opener(opener)
Example #28
0
    def test_build_url_for_servers(self):
        expected_path = 'https://dist.xebialabs.com/xl-deploy/4.0.0/xl-deploy-4.0.0-server.zip'
        assert expected_path == Utils.build_url('4.0.0', 'server')

        expected_path = 'https://dist.xebialabs.com/deployit/3.9.4/deployit-3.9.4-server.zip'
        assert expected_path == Utils.build_url('3.9.4', 'server')
Example #29
0
 def cli(self, version, path):
     ZipFile(self.cache.get(DownloadsCliDist(version, self.config)),
             'r').extractall(path)
     return os.path.join(path, Utils.build_cli_dir_name(version))
Example #30
0
 def stop(self):
     if self.is_running():
         stop_url = self.url + 'server/shutdown'
         opener = Utils.auth_and_open_url(stop_url, 'POST', self.username, self.password)
         print "Stopping the server"
         urllib2.install_opener(opener)
Example #31
0
 def start_and_wait(self):
     self.start()
     Utils.wait_until(self.is_running, tick=True)