Ejemplo n.º 1
0
    def __init__(self, redis, cassandra, repositories=[], default_ttl_seconds=TTL_YEAR * 5, archive_ttl_seconds=TTL_WEEK * 8, async_processing=False, s3_credentials=None):
        if default_ttl_seconds is not None and default_ttl_seconds < 4 * self.TTL_WEEK:
            raise ValueError('TTL must be at least 4 weeks')
        if archive_ttl_seconds is not None and archive_ttl_seconds < 2 * self.TTL_WEEK:
            raise ValueError('Archive TTL must be at least 2 weeks')
        self.default_ttl_seconds = default_ttl_seconds
        self.archive_ttl_seconds = archive_ttl_seconds or default_ttl_seconds
        self._async_processing = async_processing

        self.redis = redis
        self.cassandra = cassandra

        with self.cassandra:
            self.cassandra.create_table(self.HealthTable)

        self.commit_context = CommitContext(redis, cassandra)
        for repository in repositories:
            self.commit_context.register_repository(repository)
        self.configuration_context = ConfigurationContext(redis, cassandra)
        self.upload_context = UploadContext(
            configuration_context=self.configuration_context,
            commit_context=self.commit_context,
            ttl_seconds=self.default_ttl_seconds,
            async_processing=async_processing,
        )

        self.suite_context = SuiteContext(
            configuration_context=self.configuration_context,
            commit_context=self.commit_context,
            ttl_seconds=self.default_ttl_seconds,
        )
        self.test_context = TestContext(
            configuration_context=self.configuration_context,
            commit_context=self.commit_context,
            ttl_seconds=self.default_ttl_seconds,
        )
        self.failure_context = FailureContext(
            configuration_context=self.configuration_context,
            commit_context=self.commit_context,
            ttl_seconds=self.default_ttl_seconds,
        )
        self.ci_context = CIContext(
            configuration_context=self.configuration_context,
            commit_context=self.commit_context,
            ttl_seconds=self.default_ttl_seconds,
        )

        for context in [self.ci_context, self.failure_context, self.suite_context, self.test_context]:
            self.upload_context.register_upload_callback(context.name, context.register)

        self.archive_context = ArchiveContext(
            configuration_context=self.configuration_context,
            commit_context=self.commit_context,
            ttl_seconds=self.archive_ttl_seconds,
            s3_credentials=s3_credentials,
        )
Ejemplo n.º 2
0
    def init_database(self, redis=StrictRedis, cassandra=CassandraContext):
        redis_instance = redis()

        self.stash_repository = MockStashRepository.safari(redis_instance)
        self.svn_repository = MockSVNRepository.webkit(redis_instance)

        cassandra.drop_keyspace(keyspace=self.KEYSPACE)
        self.database = CommitContext(
            redis=redis_instance,
            cassandra=cassandra(keyspace=self.KEYSPACE, create_keyspace=True),
        )
        self.database.register_repository(self.stash_repository)
        self.database.register_repository(self.svn_repository)
Ejemplo n.º 3
0
    def __init__(self,
                 redis,
                 cassandra,
                 repositories=[],
                 default_ttl_seconds=TTL_YEAR * 5,
                 async_processing=False):
        if default_ttl_seconds is not None and default_ttl_seconds < 4 * self.TTL_WEEK:
            raise ValueError('TTL must be at least 4 weeks')
        self.default_ttl_seconds = default_ttl_seconds
        self._async_processing = async_processing

        self.redis = redis
        self.cassandra = cassandra
        self.commit_context = CommitContext(redis, cassandra)
        for repository in repositories:
            self.commit_context.register_repository(repository)
        self.configuration_context = ConfigurationContext(redis, cassandra)
        self.upload_context = UploadContext(
            configuration_context=self.configuration_context,
            commit_context=self.commit_context,
            ttl_seconds=self.default_ttl_seconds,
            async_processing=async_processing,
        )

        self.suite_context = SuiteContext(
            configuration_context=self.configuration_context,
            commit_context=self.commit_context,
            ttl_seconds=self.default_ttl_seconds,
        )
        self.test_context = TestContext(
            configuration_context=self.configuration_context,
            commit_context=self.commit_context,
            ttl_seconds=self.default_ttl_seconds,
        )
        self.ci_context = CIContext(
            configuration_context=self.configuration_context,
            commit_context=self.commit_context,
            ttl_seconds=self.default_ttl_seconds,
        )

        for context in [
                self.suite_context, self.test_context, self.ci_context
        ]:
            self.upload_context.register_upload_callback(
                context.name, context.register)

        self.archive_context = ArchiveContext(
            configuration_context=self.configuration_context,
            commit_context=self.commit_context,
            ttl_seconds=self.default_ttl_seconds,
        )
Ejemplo n.º 4
0
    def init_database(self, redis=StrictRedis, cassandra=CassandraContext):
        redis_instance = redis()

        self.stash_repository = StashRepository(
            'https://bitbucket.example.com/projects/SAFARI/repos/safari')
        self.svn_repository = WebKitRepository()

        cassandra.drop_keyspace(keyspace=self.KEYSPACE)
        self.database = CommitContext(
            redis=redis_instance,
            cassandra=cassandra(keyspace=self.KEYSPACE, create_keyspace=True),
        )
        self.database.register_repository(self.stash_repository)
        self.database.register_repository(self.svn_repository)
Ejemplo n.º 5
0
 def test_verify_table(self, redis=StrictRedis, cassandra=CassandraContext):
     with MockModelFactory.safari(), MockModelFactory.webkit():
         self.init_database(redis=redis, cassandra=cassandra)
         CommitContext(redis=redis(),
                       cassandra=cassandra(keyspace=self.KEYSPACE))
Ejemplo n.º 6
0
 def test_verify_table(self, redis=StrictRedis, cassandra=CassandraContext):
     self.init_database(redis=redis, cassandra=cassandra)
     CommitContext(redis=redis(),
                   cassandra=cassandra(keyspace=self.KEYSPACE))