Exemplo n.º 1
0
    def get_project_lag_list(self, request):
        """Calculates per-project repository scanning lag.

    Per-project, returns:
      project:  the googlecode project
      total_active_repos:  all active repos under the project
      unscanned_repos:  the number of repositories which have not yet been
                        scanned.
      scanned_repos:  the number of repositories which have at least been
                      partially scanned.
      repos_without_root:  the number of repositories which have not yet been
                           fully scanned.
      repos_with_root:  the number of repositories which have been fully
                        scanned.
      generated:  when the statistic was generated.
      p50-99: 50th, 75th, 90th, 95th, and 99th percentile seconds since
              repositories were last scanned.
      min, max:  minimum/maximum seconds since a repository was last scanned.
      most_lagging_repo:  the project:repo that has the most scan lag.
    """
        return controller.calculate_lag_stats(generated=request.generated)
Exemplo n.º 2
0
  def get_project_lag_list(self, request):
    """Calculates per-project repository scanning lag.

    Per-project, returns:
      project:  the googlecode project
      total_active_repos:  all active repos under the project
      unscanned_repos:  the number of repositories which have not yet been
                        scanned.
      scanned_repos:  the number of repositories which have at least been
                      partially scanned.
      repos_without_root:  the number of repositories which have not yet been
                           fully scanned.
      repos_with_root:  the number of repositories which have been fully
                        scanned.
      generated:  when the statistic was generated.
      p50-99: 50th, 75th, 90th, 95th, and 99th percentile seconds since
              repositories were last scanned.
      min, max:  minimum/maximum seconds since a repository was last scanned.
      most_lagging_repo:  the project:repo that has the most scan lag.
    """
    return controller.calculate_lag_stats(generated=request.generated)
Exemplo n.º 3
0
    def test_empty_calculate_lag_stats(self):
        my_project = model_helpers.create_project()
        my_project.put()
        generated_time = datetime.datetime(1970, 01, 02)

        expected = models.ProjectLagList(
            generated=generated_time,
            projects=[
                models.ProjectLagStats(
                    project=my_project.name,
                    total_active_repos=0,
                    repos_without_root=0,
                    repos_with_root=0,
                    scanned_repos=0,
                    unscanned_repos=0,
                    generated=generated_time,
                ),
            ],
        )

        generated = controller.calculate_lag_stats(generated=generated_time)

        self.assertEqual(expected, generated)
Exemplo n.º 4
0
  def test_empty_calculate_lag_stats(self):
    my_project = model_helpers.create_project()
    my_project.put()
    generated_time = datetime.datetime(1970, 01, 02)

    expected = models.ProjectLagList(
        generated=generated_time,
        projects=[
          models.ProjectLagStats(
            project=my_project.name,
            total_active_repos=0,
            repos_without_root=0,
            repos_with_root=0,
            scanned_repos=0,
            unscanned_repos=0,
            generated=generated_time,
          ),
        ],
    )

    generated = controller.calculate_lag_stats(generated=generated_time)

    self.assertEqual(expected, generated)
Exemplo n.º 5
0
  def test_calculate_lag_stats(self):
    model_helpers.create_project().put()
    my_repo = model_helpers.create_repo()
    my_repo.put()
    second_repo = model_helpers.create_repo()
    second_repo.repo = 'cooler'
    second_repo.root_commit_scanned = True
    second_repo.last_scanned = None
    second_repo.put()

    generated_time = datetime.datetime(1970, 01, 02)
    expected = models.ProjectLagList(
        generated=generated_time,
        projects=[
          models.ProjectLagStats(
            project=my_repo.project,
            total_active_repos=2,
            repos_without_root=1,
            repos_with_root=1,
            scanned_repos=1,
            unscanned_repos=1,
            generated=generated_time,
            most_lagging_repo='%s:%s' % (my_repo.project, my_repo.repo),
            max=float(24 * 60 * 60),
            min=float(24 * 60 * 60),
            p50=float(24 * 60 * 60),
            p75=float(24 * 60 * 60),
            p90=float(24 * 60 * 60),
            p95=float(24 * 60 * 60),
            p99=float(24 * 60 * 60)
          ),
        ],
    )

    generated = controller.calculate_lag_stats(generated=generated_time)

    self.assertEqual(expected, generated)
Exemplo n.º 6
0
    def test_calculate_lag_stats(self):
        model_helpers.create_project().put()
        my_repo = model_helpers.create_repo()
        my_repo.put()
        second_repo = model_helpers.create_repo()
        second_repo.repo = 'cooler'
        second_repo.root_commit_scanned = True
        second_repo.last_scanned = None
        second_repo.put()

        generated_time = datetime.datetime(1970, 01, 02)
        expected = models.ProjectLagList(
            generated=generated_time,
            projects=[
                models.ProjectLagStats(project=my_repo.project,
                                       total_active_repos=2,
                                       repos_without_root=1,
                                       repos_with_root=1,
                                       scanned_repos=1,
                                       unscanned_repos=1,
                                       generated=generated_time,
                                       most_lagging_repo='%s:%s' %
                                       (my_repo.project, my_repo.repo),
                                       max=float(24 * 60 * 60),
                                       min=float(24 * 60 * 60),
                                       p50=float(24 * 60 * 60),
                                       p75=float(24 * 60 * 60),
                                       p90=float(24 * 60 * 60),
                                       p95=float(24 * 60 * 60),
                                       p99=float(24 * 60 * 60)),
            ],
        )

        generated = controller.calculate_lag_stats(generated=generated_time)

        self.assertEqual(expected, generated)