コード例 #1
0
    def test_game_stats_it(self):
        state_verifier = PipelineStateMatcher(PipelineState.RUNNING)

        success_condition = 'mean_duration=300 LIMIT 1'
        sessions_query = ('SELECT mean_duration FROM [%s:%s.%s] '
                          'WHERE %s' %
                          (self.project, self.dataset.name,
                           self.OUTPUT_TABLE_SESSIONS, success_condition))
        bq_sessions_verifier = BigqueryMatcher(self.project, sessions_query,
                                               self.DEFAULT_EXPECTED_CHECKSUM)

        # TODO(mariagh): Add teams table verifier once game_stats.py is fixed.

        extra_opts = {
            'subscription': self.input_sub.full_name,
            'dataset': self.dataset.name,
            'topic': self.input_topic.full_name,
            'fixed_window_duration': 1,
            'user_activity_window_duration': 1,
            'wait_until_finish_duration': self.WAIT_UNTIL_FINISH_DURATION,
            'on_success_matcher': all_of(state_verifier, bq_sessions_verifier)
        }

        # Register cleanup before pipeline execution.
        # Note that actual execution happens in reverse order.
        self.addCleanup(self._cleanup_pubsub)
        self.addCleanup(self._cleanup_dataset)
        self.addCleanup(utils.delete_bq_table, self.project, self.dataset.name,
                        self.OUTPUT_TABLE_SESSIONS)
        self.addCleanup(utils.delete_bq_table, self.project, self.dataset.name,
                        self.OUTPUT_TABLE_TEAMS)

        # Generate input data and inject to PubSub.
        test_utils.wait_for_subscriptions_created(
            [self.input_topic, self.input_sub])
        self._inject_pubsub_game_events(self.input_topic,
                                        self.DEFAULT_INPUT_COUNT)

        # Get pipeline options from command argument: --test-pipeline-options,
        # and start pipeline job by calling pipeline main function.
        game_stats.run(
            self.test_pipeline.get_full_options_as_args(**extra_opts))
コード例 #2
0
  def test_game_stats_it(self):
    state_verifier = PipelineStateMatcher(PipelineState.RUNNING)

    success_condition = 'mean_duration=300 LIMIT 1'
    sessions_query = ('SELECT mean_duration FROM [%s:%s.%s] '
                      'WHERE %s' % (self.project,
                                    self.dataset.name,
                                    self.OUTPUT_TABLE_SESSIONS,
                                    success_condition))
    bq_sessions_verifier = BigqueryMatcher(self.project,
                                           sessions_query,
                                           self.DEFAULT_EXPECTED_CHECKSUM)

    # TODO(mariagh): Add teams table verifier once game_stats.py is fixed.

    extra_opts = {'subscription': self.input_sub.name,
                  'dataset': self.dataset.name,
                  'topic': self.input_topic.name,
                  'fixed_window_duration': 1,
                  'user_activity_window_duration': 1,
                  'wait_until_finish_duration':
                      self.WAIT_UNTIL_FINISH_DURATION,
                  'on_success_matcher': all_of(state_verifier,
                                               bq_sessions_verifier)}

    # Register cleanup before pipeline execution.
    # Note that actual execution happens in reverse order.
    self.addCleanup(self._cleanup_pubsub)
    self.addCleanup(self._cleanup_dataset)
    self.addCleanup(utils.delete_bq_table, self.project,
                    self.dataset.name, self.OUTPUT_TABLE_SESSIONS)
    self.addCleanup(utils.delete_bq_table, self.project,
                    self.dataset.name, self.OUTPUT_TABLE_TEAMS)

    # Generate input data and inject to PubSub.
    self._inject_pubsub_game_events(self.input_topic, self.DEFAULT_INPUT_COUNT)

    # Get pipeline options from command argument: --test-pipeline-options,
    # and start pipeline job by calling pipeline main function.
    game_stats.run(
        self.test_pipeline.get_full_options_as_args(**extra_opts))