Example #1
0
    def process_local_test_settings_closure(logger):
        logger.info('Preparing local test settings for your new instance...')
        template = os.sep.join([
            'jira-func-tests', 'src', 'main', 'resources', 'localtest.template'
        ])

        template_renderings = {
            'jira-func-tests':
            'jira-func-tests',
            'jira-webdriver-tests':
            'jira-webdriver-tests',
            os.sep.join(['jira-distribution', 'jira-integration-tests']):
            'jira-func-tests'
        }

        for project, xml_location in template_renderings.items():
            dir = fileutils.existing_dir(
                os.sep.join(['.', project, 'src', 'main', 'resources']))
            dest = os.sep.join([dir, 'localtest.properties'])

            # just for unit tests this settings dict is not reused:
            settings = {
                '${jira.port}': str(args.port),
                '${jira.context}': args.jira_context,
                '${test.xml.location}': PathUtils.abspath(xml_location)
            }

            logger.debug('Processing ' + template + ' to ' + dest)
            fileutils.filter_file(template, dest, settings)
        return Callable.success
Example #2
0
 def jrebel_options(self, log):
     jrebel_lib_location = self.jrebel_lib_location(log)
     if jrebel_lib_location is None:
         log.error(
             'Cannot find jrebel.jar in idea configuration. Please ensure that you have jrebel plugin installed')
         return None
     else:
         log.info('Using jrebel library from ' + jrebel_lib_location)
         return ' -Djira.rebel.root="%s" -javaagent:"%s"' % (PathUtils.abspath('.'), jrebel_lib_location)
Example #3
0
 def jrebel_options(self, log):
     jrebel_lib_location = self.jrebel_lib_location(log)
     if jrebel_lib_location is None:
         log.error(
             'Cannot find jrebel.jar in idea configuration. Please ensure that you have jrebel plugin installed'
         )
         return None
     else:
         log.info('Using jrebel library from ' + jrebel_lib_location)
         return ' -Djira.rebel.root="%s" -javaagent:"%s"' % (
             PathUtils.abspath('.'), jrebel_lib_location)
Example #4
0
    def plugin_resources(self, fileutils=FileUtils(),workspace_utils=WorkspaceUtils()):
        if self.args.disable_plugin_resources:
            return ''
        resources_marker = os.sep.join(['src', 'main', 'resources'])
        resources_marker_exclude = '.hg'
        plugins_roots = [os.sep.join(['jira-components', 'jira-plugins'])]
        if self.args.plugin_resources:
            plugins_roots.append(fileutils.abs_path(self.args.plugin_resources))
        plugins_roots.extend(os.sep.join([workspace_utils.get_jira_workspace_dir(), project])
                             for project in workspace_utils.get_workspace_projects_without_jira(self.args))

        return '-Dplugin.resource.directories=%s' % ','.join(
            PathUtils.abspath(path) for plugins_root in plugins_roots
            for (path, dirs, files) in fileutils.walk(plugins_root) if path.endswith(resources_marker)
            and not resources_marker_exclude in path)
    def test_jrebel_is_discovered_and_java_opts_are_set(self):
        #having
        self.args.jrebel = True
        file_utils = MockFileUtils()
        file_utils.expect_possible_idea_plugin_dirs(toReturn=['idea12', 'idea13', 'idea129'])
        jrebel_path = os.path.join('idea13', 'config', 'plugins', 'jr-ide-idea', 'lib', 'jrebel', 'jrebel.jar')
        file_utils.expect_file_exists(jrebel_path, toReturn=True)
        tomcat_starter = MockTomcatStarter(self.args, False, file_utils)

        #when
        return_code = tomcat_starter(Mock())

        #then
        self.assertEqual(return_code, Callable.success, 'Expected successful return code')
        opts = self.__get_opts_dict(tomcat_starter)
        self.__assertParameter(opts, '-javaagent:"' + jrebel_path + '"')
        self.__assertParameter(opts, '-Djira.rebel.root', '"' + PathUtils.abspath('.') + '"')
        self.assertNotIn('-agentlib:jdwp:', opts)
Example #6
0
    def __get_opts_for_jira(self, dev_mode, layout: WorkspaceLayout):
        args = ' -Xms128m'\
               ' -Xmx' + self.args.xmx + ''\
               ' -XX:MaxPermSize=' + self.args.max_perm_size + ''\
               ' -XX:+HeapDumpOnOutOfMemoryError'\
               ' -Djira.i18n.texthighlight=false'\
               ' -Dmail.debug=false'\
               ' -Dorg.apache.jasper.runtime.BodyContentImpl.LIMIT_BUFFER=true'\
               ' -Dmail.mime.decodeparameters=true'\
               ' -Djira.dev.mode=' + str(dev_mode).lower() +\
               ' -Djira.plugins.bundled.disable=false' \
               ' -Datlassian.plugins.tenant.smart.patterns=' + \
                                PathUtils.abspath('jira-components/jira-core/src/main/resources/tenant-smart-patterns.txt') +\
               ' -Djira.paths.set.allowed=true'\
               ' -Duser.language=en'\
               ' -Duser.region=AU'\
               ' -Duser.timezone=Australia/Sydney'\
               ' -Dplugin.webresource.batching.off=' + str(dev_mode).lower() +\
               ' -Djava.awt.headless=true'\
               ' -Djira.home=' + layout.jira_home()
        if not (self.args.bundled_plugins or layout.ondemand):
            args += ' -Djira.dev.bundledplugins.url=file://' + BundledPluginsUtility.BUNDLED_PLUGINS_LIST
        if layout.ondemand:
            args += ' -Dstudio.initial.data.xml=' + layout.studio_initial_data() +\
                    ' -Dstudio.home=' + layout.jira_home() +\
                    ' -Datlassian.darkfeature.com.atlassian.jira.config.CoreFeatures.ON_DEMAND=true'\
                    ' -Dcrowd.property.application.login.url=' + self.args.horde_layout.horde_application_login_url() +\
                    ' -Dcrowd.property.crowd.server.url=' + self.args.horde_layout.horde_server_url() +\
                    ' -Dstudio.webdav.directory=' + layout.webdav_dir()
            if self.args.manifesto_psd is not None:
                args += ' -Datlassian.jira.plugin.scan.directory=' + self.args.manifesto_psd

        if hasattr(self.args, 'clustered') and self.args.clustered:
            args += ' -Datlassian.cluster.scale=true' +\
                    ' -DjvmRoute=' + self.args.instance_name + \
                    ' -Datlassian.cache.ehcache=true'

        if self.args.enable_mail:
             args += ' -Datlassian.mail.senddisabled=false'\
                    ' -Datlassian.mail.fetchdisabled=false'

        return args + ' ' + self.plugin_resources()
Example #7
0
    def __get_opts_for_jira(self, dev_mode, layout: WorkspaceLayout):
        args = ' -Xms128m'\
               ' -Xmx' + self.args.xmx + ''\
               ' -XX:MaxPermSize=' + self.args.max_perm_size + ''\
               ' -XX:+HeapDumpOnOutOfMemoryError'\
               ' -Djira.i18n.texthighlight=false'\
               ' -Dmail.debug=false'\
               ' -Dorg.apache.jasper.runtime.BodyContentImpl.LIMIT_BUFFER=true'\
               ' -Dmail.mime.decodeparameters=true'\
               ' -Djira.dev.mode=' + str(dev_mode).lower() +\
               ' -Djira.plugins.bundled.disable=false' \
               ' -Datlassian.plugins.tenant.smart.patterns=' + \
                                PathUtils.abspath('jira-components/jira-core/src/main/resources/tenant-smart-patterns.txt') +\
               ' -Djira.paths.set.allowed=true'\
               ' -Duser.language=en'\
               ' -Duser.region=AU'\
               ' -Duser.timezone=Australia/Sydney'\
               ' -Dplugin.webresource.batching.off=' + str(dev_mode).lower() +\
               ' -Djava.awt.headless=true'\
               ' -Djira.home=' + layout.jira_home()
        if not (self.args.bundled_plugins or layout.ondemand):
            args += ' -Djira.dev.bundledplugins.url=file://' + BundledPluginsUtility.BUNDLED_PLUGINS_LIST
        if layout.ondemand:
            args += ' -Dstudio.initial.data.xml=' + layout.studio_initial_data() +\
                    ' -Dstudio.home=' + layout.jira_home() +\
                    ' -Datlassian.darkfeature.com.atlassian.jira.config.CoreFeatures.ON_DEMAND=true'\
                    ' -Dcrowd.property.application.login.url=' + self.args.horde_layout.horde_application_login_url() +\
                    ' -Dcrowd.property.crowd.server.url=' + self.args.horde_layout.horde_server_url() +\
                    ' -Dstudio.webdav.directory=' + layout.webdav_dir()
            if self.args.manifesto_psd is not None:
                args += ' -Datlassian.jira.plugin.scan.directory=' + self.args.manifesto_psd

        if hasattr(self.args, 'clustered') and self.args.clustered:
            args += ' -Datlassian.cluster.scale=true' +\
                    ' -DjvmRoute=' + self.args.instance_name + \
                    ' -Datlassian.cache.ehcache=true'

        if self.args.enable_mail:
            args += ' -Datlassian.mail.senddisabled=false'\
                   ' -Datlassian.mail.fetchdisabled=false'

        return args + ' ' + self.plugin_resources()
Example #8
0
    def process_local_test_settings_closure(logger):
        logger.info('Preparing local test settings for your new instance...')
        template = os.sep.join(['jira-func-tests', 'src', 'main', 'resources', 'localtest.template'])

        template_renderings = {'jira-func-tests': 'jira-func-tests',
                               'jira-webdriver-tests': 'jira-webdriver-tests',
                               os.sep.join(['jira-distribution', 'jira-integration-tests']): 'jira-func-tests'}

        for project, xml_location in template_renderings.items():
            dir = fileutils.existing_dir(os.sep.join(['.', project, 'src', 'main', 'resources']))
            dest = os.sep.join([dir, 'localtest.properties'])

            # just for unit tests this settings dict is not reused:
            settings = {'${jira.port}': str(args.port),
                        '${jira.context}': args.jira_context,
                        '${test.xml.location}': PathUtils.abspath(xml_location)}

            logger.debug('Processing ' + template + ' to ' + dest)
            fileutils.filter_file(template, dest, settings)
        return Callable.success
Example #9
0
    def plugin_resources(self,
                         fileutils=FileUtils(),
                         workspace_utils=WorkspaceUtils()):
        if self.args.disable_plugin_resources:
            return ''
        resources_marker = os.sep.join(['src', 'main', 'resources'])
        resources_marker_exclude = '.hg'
        plugins_roots = [os.sep.join(['jira-components', 'jira-plugins'])]
        if self.args.plugin_resources:
            plugins_roots.append(fileutils.abs_path(
                self.args.plugin_resources))
        plugins_roots.extend(
            os.sep.join([workspace_utils.get_jira_workspace_dir(), project])
            for project in workspace_utils.get_workspace_projects_without_jira(
                self.args))

        return '-Dplugin.resource.directories=%s' % ','.join(
            PathUtils.abspath(path) for plugins_root in plugins_roots
            for (path, dirs, files) in fileutils.walk(plugins_root)
            if path.endswith(resources_marker)
            and not resources_marker_exclude in path)
Example #10
0
    def test_jrebel_is_discovered_and_java_opts_are_set(self):
        #having
        self.args.jrebel = True
        file_utils = MockFileUtils()
        file_utils.expect_possible_idea_plugin_dirs(
            toReturn=['idea12', 'idea13', 'idea129'])
        jrebel_path = os.path.join('idea13', 'config', 'plugins',
                                   'jr-ide-idea', 'lib', 'jrebel',
                                   'jrebel.jar')
        file_utils.expect_file_exists(jrebel_path, toReturn=True)
        tomcat_starter = MockTomcatStarter(self.args, False, file_utils)

        #when
        return_code = tomcat_starter(Mock())

        #then
        self.assertEqual(return_code, Callable.success,
                         'Expected successful return code')
        opts = self.__get_opts_dict(tomcat_starter)
        self.__assertParameter(opts, '-javaagent:"' + jrebel_path + '"')
        self.__assertParameter(opts, '-Djira.rebel.root',
                               '"' + PathUtils.abspath('.') + '"')
        self.assertNotIn('-agentlib:jdwp:', opts)
Example #11
0
 def studio_initial_data(self):
     return PathUtils.abspath(
         os.sep.join(
             [self.jira_home_dir, WorkspaceLayout.STUDIO_INIT_DATA_FILE]))
Example #12
0
 def jira_home(self):
     return PathUtils.abspath(self.jira_home_dir)
Example #13
0
    def jira_webapp_dir(self):

        return PathUtils.abspath(WorkspaceLayout.JIRA_OD_WEBAPP) if self.ondemand \
            else PathUtils.abspath(WorkspaceLayout.JIRA_WEBAPP)
Example #14
0
 def existing_dir(self, path):
     result = PathUtils.abspath(path)
     if not os.path.lexists(result): os.makedirs(result)
     return result
Example #15
0
 def abs_path(self, path):
     return PathUtils.abspath(path)
Example #16
0
 def studio_initial_data(self):
     return PathUtils.abspath(os.sep.join([self.jira_home_dir, WorkspaceLayout.STUDIO_INIT_DATA_FILE]))
from Logger import LOG
from utils import PathUtils
from utils.FileUtils import FileUtils

JIRA_PLUGINS_DIR = os.sep.join(['jira-components', 'jira-plugins'])
JIRA_PLUGINS_DIR_ABS = os.path.abspath(
    os.sep.join(['jira-components', 'jira-plugins']))
JIRA_PLUGINS_POM_XML = os.sep.join([JIRA_PLUGINS_DIR, 'pom.xml'])
JIRA_PLUGIN_DIR = os.sep.join([JIRA_PLUGINS_DIR, '{0}'])
PLUGIN_TARGET_DIR = os.sep.join([JIRA_PLUGINS_DIR, '{}', 'target'])
PLUGIN_SRC_DIR = os.sep.join([JIRA_PLUGINS_DIR, '{}', 'src'])
PLUGIN_POM_DIR = os.sep.join([JIRA_PLUGINS_DIR, '{}', 'pom.xml'])
PLUGIN_JAR_FILE = os.sep.join([PLUGIN_TARGET_DIR, '{0}-{1}.jar'])
BUNDLED_PLUGINS_LIST = PathUtils.abspath(
    os.sep.join([
        PLUGIN_TARGET_DIR.format('jira-bundled-plugins'),
        'atlassian-bundled-plugins.list'
    ]))
JMAKE_PROFILES_PLUGINS_LIST = os.path.abspath(
    os.sep.join([
        PLUGIN_TARGET_DIR.format('jira-bundled-plugins'),
        'jmake-bundled-plugins-profiles.list'
    ]))
BUNDLED_PLUGINS_MODULE = JIRA_PLUGIN_DIR.format('jira-bundled-plugins')
BUNDLED_PLUGINS_POM = PLUGIN_POM_DIR.format('jira-bundled-plugins')
PLUGIN_FROM_PATH_EXTRACTOR = r'.+' + JIRA_PLUGINS_DIR + os.sep + '(.+)' + os.sep + "target.+"


class BundledPluginsUtility:
    def __init__(self, file_utils=FileUtils()):
        super().__init__()
Example #18
0
    def jira_webapp_dir(self):

        return PathUtils.abspath(WorkspaceLayout.JIRA_OD_WEBAPP) if self.ondemand \
            else PathUtils.abspath(WorkspaceLayout.JIRA_WEBAPP)
Example #19
0
 def jira_home(self):
     return PathUtils.abspath(self.jira_home_dir)
Example #20
0
 def webdav_dir(self):
     return PathUtils.abspath(
         os.sep.join([self.jira_home_dir,
                      WorkspaceLayout.WEBDAV_DIRECTORY]))
import os
import re
from Logger import LOG
from utils import PathUtils
from utils.FileUtils import FileUtils


JIRA_PLUGINS_DIR = os.sep.join(['jira-components', 'jira-plugins'])
JIRA_PLUGINS_DIR_ABS = os.path.abspath(os.sep.join(['jira-components', 'jira-plugins']))
JIRA_PLUGINS_POM_XML = os.sep.join([JIRA_PLUGINS_DIR, 'pom.xml'])
JIRA_PLUGIN_DIR = os.sep.join([JIRA_PLUGINS_DIR, '{0}'])
PLUGIN_TARGET_DIR = os.sep.join([JIRA_PLUGINS_DIR, '{}', 'target'])
PLUGIN_SRC_DIR = os.sep.join([JIRA_PLUGINS_DIR, '{}', 'src'])
PLUGIN_POM_DIR = os.sep.join([JIRA_PLUGINS_DIR, '{}', 'pom.xml'])
PLUGIN_JAR_FILE = os.sep.join([PLUGIN_TARGET_DIR, '{0}-{1}.jar'])
BUNDLED_PLUGINS_LIST = PathUtils.abspath(
    os.sep.join([PLUGIN_TARGET_DIR.format('jira-bundled-plugins'), 'atlassian-bundled-plugins.list']))
JMAKE_PROFILES_PLUGINS_LIST = os.path.abspath(
    os.sep.join([PLUGIN_TARGET_DIR.format('jira-bundled-plugins'), 'jmake-bundled-plugins-profiles.list']))
BUNDLED_PLUGINS_MODULE = JIRA_PLUGIN_DIR.format('jira-bundled-plugins')
BUNDLED_PLUGINS_POM = PLUGIN_POM_DIR.format('jira-bundled-plugins')
PLUGIN_FROM_PATH_EXTRACTOR = r'.+' + JIRA_PLUGINS_DIR + os.sep + '(.+)' + os.sep + "target.+"

class BundledPluginsUtility:
    def __init__(self, file_utils=FileUtils()):
        super().__init__()
        self.file_utils = file_utils


    def get_bundled_plugins_module(self):
        return [BUNDLED_PLUGINS_MODULE]
Example #22
0
 def abs_path(self, path):
     return PathUtils.abspath(path)
Example #23
0
 def existing_dir(self, path):
     result = PathUtils.abspath(path)
     if not os.path.lexists(result): os.makedirs(result)
     return result
Example #24
0
 def webdav_dir(self):
     return PathUtils.abspath(os.sep.join([self.jira_home_dir, WorkspaceLayout.WEBDAV_DIRECTORY]))