Exemple #1
0
 def _update(self, distribution_version):
     try:
         if self.remote and not self.offline:
             branch = versions.best_match(git.branches(self.tracks_dir, remote=self.remote), distribution_version)
             if branch:
                 # Allow uncommitted changes iff we do not have to change the branch
                 logger.info(
                     "Checking out [%s] in [%s] for distribution version [%s]." % (branch, self.tracks_dir, distribution_version))
                 git.checkout(self.tracks_dir, branch=branch)
                 logger.info("Rebasing on [%s] in [%s] for distribution version [%s]." % (branch, self.tracks_dir, distribution_version))
                 try:
                     git.rebase(self.tracks_dir, branch=branch)
                 except exceptions.SupplyError:
                     logger.exception("Cannot rebase due to local changes in [%s]" % self.tracks_dir)
                     console.warn(
                         "Local changes in [%s] prevent track update from remote. Please commit your changes." % self.tracks_dir)
                 return
             else:
                 msg = "Could not find track data remotely for distribution version [%s]. " \
                       "Trying to find track data locally." % distribution_version
                 logger.warn(msg)
         branch = versions.best_match(git.branches(self.tracks_dir, remote=False), distribution_version)
         if branch:
             logger.info("Checking out [%s] in [%s] for distribution version [%s]." % (branch, self.tracks_dir, distribution_version))
             git.checkout(self.tracks_dir, branch=branch)
         else:
             raise exceptions.SystemSetupError("Cannot find track data for distribution version %s" % distribution_version)
     except exceptions.SupplyError:
         tb = sys.exc_info()[2]
         raise exceptions.DataError("Cannot update track data in [%s]." % self.tracks_dir).with_traceback(tb)
Exemple #2
0
 def update(self, distribution_version):
     try:
         if self.remote:
             branch = versions.best_match(
                 git.branches(self.repo_dir, remote=self.remote),
                 distribution_version)
             if branch:
                 # Allow uncommitted changes iff we do not have to change the branch
                 self.logger.info(
                     "Checking out [%s] in [%s] for distribution version [%s].",
                     branch, self.repo_dir, distribution_version)
                 git.checkout(self.repo_dir, branch=branch)
                 self.logger.info(
                     "Rebasing on [%s] in [%s] for distribution version [%s].",
                     branch, self.repo_dir, distribution_version)
                 try:
                     git.rebase(self.repo_dir, branch=branch)
                     self.revision = git.head_revision(self.repo_dir)
                 except exceptions.SupplyError:
                     self.logger.exception(
                         "Cannot rebase due to local changes in [%s]",
                         self.repo_dir)
                     console.warn(
                         "Local changes in [%s] prevent %s update from remote. Please commit your changes."
                         % (self.repo_dir, self.resource_name))
                 return
             else:
                 msg = "Could not find %s remotely for distribution version [%s]. Trying to find %s locally." % \
                       (self.resource_name, distribution_version, self.resource_name)
                 self.logger.warning(msg)
         branch = versions.best_match(
             git.branches(self.repo_dir, remote=False),
             distribution_version)
         if branch:
             if git.current_branch(self.repo_dir) != branch:
                 self.logger.info(
                     "Checking out [%s] in [%s] for distribution version [%s].",
                     branch, self.repo_dir, distribution_version)
                 git.checkout(self.repo_dir, branch=branch)
                 self.revision = git.head_revision(self.repo_dir)
         else:
             self.logger.info(
                 "No local branch found for distribution version [%s] in [%s]. Checking tags.",
                 distribution_version, self.repo_dir)
             tag = self._find_matching_tag(distribution_version)
             if tag:
                 self.logger.info(
                     "Checking out tag [%s] in [%s] for distribution version [%s].",
                     tag, self.repo_dir, distribution_version)
                 git.checkout(self.repo_dir, branch=tag)
                 self.revision = git.head_revision(self.repo_dir)
             else:
                 raise exceptions.SystemSetupError(
                     "Cannot find %s for distribution version %s" %
                     (self.resource_name, distribution_version))
     except exceptions.SupplyError as e:
         tb = sys.exc_info()[2]
         raise exceptions.DataError("Cannot update %s in [%s] (%s)." %
                                    (self.resource_name, self.repo_dir,
                                     e.message)).with_traceback(tb)
Exemple #3
0
 def _update(self, distribution_version):
     try:
         if self.remote and not self.offline:
             branch = versions.best_match(git.branches(self.tracks_dir, remote=self.remote), distribution_version)
             if branch:
                 # Allow uncommitted changes iff we do not have to change the branch
                 logger.info(
                     "Checking out [%s] in [%s] for distribution version [%s]." % (branch, self.tracks_dir, distribution_version))
                 git.checkout(self.tracks_dir, branch=branch)
                 logger.info("Rebasing on [%s] in [%s] for distribution version [%s]." % (branch, self.tracks_dir, distribution_version))
                 try:
                     git.rebase(self.tracks_dir, branch=branch)
                 except exceptions.SupplyError:
                     logger.exception("Cannot rebase due to local changes in [%s]" % self.tracks_dir)
                     console.warn(
                         "Local changes in [%s] prevent track update from remote. Please commit your changes." % self.tracks_dir)
                 return
             else:
                 msg = "Could not find track data remotely for distribution version [%s]. " \
                       "Trying to find track data locally." % distribution_version
                 logger.warning(msg)
         branch = versions.best_match(git.branches(self.tracks_dir, remote=False), distribution_version)
         if branch:
             logger.info("Checking out [%s] in [%s] for distribution version [%s]." % (branch, self.tracks_dir, distribution_version))
             git.checkout(self.tracks_dir, branch=branch)
         else:
             raise exceptions.SystemSetupError("Cannot find track data for distribution version %s" % distribution_version)
     except exceptions.SupplyError:
         tb = sys.exc_info()[2]
         raise exceptions.DataError("Cannot update track data in [%s]." % self.tracks_dir).with_traceback(tb)
Exemple #4
0
 def _update(self, distribution_version):
     try:
         if self.remote and not self.offline:
             branch = versions.best_match(
                 git.branches(self.tracks_dir, remote=self.remote),
                 distribution_version)
             if branch:
                 logger.info(
                     "Rebasing on '%s' in '%s' for distribution version '%s'."
                     % (branch, self.tracks_dir, distribution_version))
                 git.rebase(self.tracks_dir, branch=branch)
                 return
             else:
                 msg = "Could not find track data remotely for distribution version %s. " \
                       "Trying to find track data locally." % distribution_version
                 logger.warn(msg)
         branch = versions.best_match(
             git.branches(self.tracks_dir, remote=False),
             distribution_version)
         if branch:
             logger.info(
                 "Checking out '%s' in '%s' for distribution version '%s'."
                 % (branch, self.tracks_dir, distribution_version))
             git.checkout(self.tracks_dir, branch=branch)
         else:
             raise exceptions.SystemSetupError(
                 "Cannot find track data for distribution version %s" %
                 distribution_version)
     except exceptions.SupplyError as e:
         raise exceptions.DataError("Cannot update track data in '%s': %s" %
                                    (self.tracks_dir, e))
 def test_find_best_match(self):
     self.assertEqual("master", versions.best_match(["1.7", "2", "5.0.0-alpha1", "5", "master"], "6.0.0-alpha1"),
                      "Assume master for versions newer than latest alternative available")
     self.assertEqual("5", versions.best_match(["1.7", "2", "5.0.0-alpha1", "5", "master"], "5.1.0-SNAPSHOT"),
                      "Best match for specific version")
     self.assertEqual("master", versions.best_match(["1.7", "2", "5.0.0-alpha1", "5", "master"], None),
                      "Assume master on unknown version")
     self.assertIsNone(versions.best_match(["1.7", "2", "5.0.0-alpha1", "5", "master"], "0.4"), "Reject versions that are too old")
Exemple #6
0
 def test_find_best_match(self):
     self.assertEqual("master", versions.best_match(["1.7", "2", "5.0.0-alpha1", "5", "master"], "6.0.0-alpha1"),
                      "Assume master for versions newer than latest alternative available")
     self.assertEqual("5", versions.best_match(["1.7", "2", "5.0.0-alpha1", "5", "master"], "5.1.0-SNAPSHOT"),
                      "Best match for specific version")
     self.assertEqual("master", versions.best_match(["1.7", "2", "5.0.0-alpha1", "5", "master"], None),
                      "Assume master on unknown version")
     self.assertIsNone(versions.best_match(["1.7", "2", "5.0.0-alpha1", "5", "master"], "0.4"), "Reject versions that are too old")
Exemple #7
0
 def cmd_line_opt(self, distribution_version, key):
     best_version = versions.best_match(InProcessLauncher.ES_CMD_LINE_OPTS_PER_VERSION.keys(), distribution_version)
     if best_version:
         return InProcessLauncher.ES_CMD_LINE_OPTS_PER_VERSION[best_version][key]
     else:
         raise exceptions.LaunchError("Cannot start cluster. Unsupported distribution version %s. "
                                      "Please raise a bug at %s." % (distribution_version, format.link("https://github.com/elastic/rally")))
Exemple #8
0
 def cmd_line_opt(self, distribution_version, key):
     best_version = versions.best_match(InProcessLauncher.ES_CMD_LINE_OPTS_PER_VERSION.keys(), distribution_version)
     if best_version:
         return InProcessLauncher.ES_CMD_LINE_OPTS_PER_VERSION[best_version][key]
     else:
         raise exceptions.LaunchError("Cannot start cluster. Unsupported distribution version %s. "
                                      "Please raise a bug at %s." %
                                      (distribution_version, console.format.link("https://github.com/elastic/rally")))
Exemple #9
0
 def _update(self, distribution_version):
     try:
         if self.remote:
             branch = versions.best_match(git.branches(self.tracks_dir, remote=self.remote), distribution_version)
             if branch:
                 logger.info("Rebasing on '%s' in '%s' for distribution version '%s'." % (branch, self.tracks_dir, distribution_version))
                 git.rebase(self.tracks_dir, branch=branch)
                 return
             else:
                 msg = "Could not find track data remotely for distribution version %s. " \
                       "Trying to find track data locally." % distribution_version
                 logger.warn(msg)
         branch = versions.best_match(git.branches(self.tracks_dir, remote=False), distribution_version)
         if branch:
             logger.info("Checking out '%s' in '%s' for distribution version '%s'." % (branch, self.tracks_dir, distribution_version))
             git.checkout(self.tracks_dir, branch=branch)
         else:
             raise exceptions.SystemSetupError("Cannot find track data for distribution version %s" % distribution_version)
     except exceptions.SupplyError as e:
         raise exceptions.DataError("Cannot update track data in '%s': %s" % (self.tracks_dir, e))
Exemple #10
0
    def test_find_best_match(self):
        assert (
            versions.best_match(["1.7", "2", "5.0.0-alpha1", "5", "master"], "6.0.0-alpha1") == "master"
        ), "Assume master for versions newer than latest alternative available"

        assert versions.best_match(["1.7", "2", "5.0.0-alpha1", "5", "master"], "5.1.0-SNAPSHOT") == "5", "Best match for specific version"

        assert versions.best_match(["1.7", "2", "5.0.0-alpha1", "5", "master"], None) == "master", "Assume master on unknown version"

        assert versions.best_match(["1.7", "2", "5.0.0-alpha1", "5", "master"], "0.4") is None, "Reject versions that are too old"

        assert versions.best_match(["7", "7.10.2", "7.11", "7.2", "5", "6", "master"], "7.10.2") == "7.10.2", "Exact match"

        assert versions.best_match(["7", "7.10", "master"], "7.1.0") == "7", "Best match is major version"

        assert versions.best_match(["7", "7.11", "7.2", "5", "6", "master"], "7.11.0") == "7.11", "Best match for specific minor version"

        assert (
            versions.best_match(["7", "7.11", "7.2", "5", "6", "master"], "7.12.0") == "7.11"
        ), "If no exact match, best match is the nearest prior minor"

        assert (
            versions.best_match(["7", "7.11", "7.2", "5", "6", "master"], "7.3.0") == "7.2"
        ), "If no exact match, best match is the nearest prior minor"

        assert (
            versions.best_match(["7", "7.11", "7.2", "5", "6", "master"], "7.10.0") == "7.2"
        ), "If no exact match, best match is the nearest prior minor"

        assert (
            versions.best_match(["7", "7.1", "7.11.1", "7.11.0", "7.2", "5", "6", "master"], "7.12.0") == "7.2"
        ), "Patch or patch-suffix branches are not supported and ignored, best match is nearest prior minor"

        assert (
            versions.best_match(["7", "7.11", "7.2", "5", "6", "master"], "7.1.0") == "7"
        ), "If no exact match and no minor match, next best match is major version"