Skip to content

Commit

Permalink
Merge pull request buildbot#8256 from p12tic/fakedb-cleanup
Browse files Browse the repository at this point in the history
Fakedb cleanup
  • Loading branch information
p12tic authored Dec 8, 2024
2 parents b1b830c + f1c583d commit 6b1ccea
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 45 deletions.
26 changes: 0 additions & 26 deletions master/buildbot/test/util/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,6 @@ def validate(self, name, arg_object):
# Type definitions

message = {}
dbdict = {}

# parse and use a ResourceType class's dataFields into a validator

Expand All @@ -312,13 +311,6 @@ def validate(self, name, arg_object):
),
)

dbdict['masterdict'] = DictValidator(
id=IntValidator(),
name=StringValidator(),
active=BooleanValidator(),
last_active=DateTimeValidator(),
)

# sourcestamp

_sourcestamp = {
Expand Down Expand Up @@ -463,20 +455,6 @@ def validate(self, name, arg_object):
)

# Validates DATA API layer
dbdict['builddict'] = DictValidator(
id=IntValidator(),
number=IntValidator(),
builderid=IntValidator(),
buildrequestid=IntValidator(),
workerid=IntValidator(),
masterid=IntValidator(),
started_at=DateTimeValidator(),
complete_at=NoneOk(DateTimeValidator()),
locks_duration_s=IntValidator(),
state_string=StringValidator(),
results=NoneOk(IntValidator()),
properties=NoneOk(SourcedPropertiesValidator()),
)

# build data

Expand Down Expand Up @@ -585,10 +563,6 @@ def verifyMessage(testcase, routingKey, message_):
_verify(testcase, validator, '', (routingKey, (routingKey, message_)))


def verifyDbDict(testcase, type, value):
_verify(testcase, dbdict[type], type, value)


def verifyData(testcase, entityType, options, value):
_verify(testcase, entityType, entityType.name, value)

Expand Down
18 changes: 0 additions & 18 deletions master/docs/developer/database.rst
Original file line number Diff line number Diff line change
Expand Up @@ -291,24 +291,6 @@ this::
return thdict
return self.db.pool.do(thd)

Tests
~~~~~

It goes without saying that any new connector methods must be fully tested!

You will also want to add an in-memory implementation of the methods to the
fake classes in ``master/buildbot/test/fake/fakedb.py``. Non-DB Buildbot code
is tested using these fake implementations in order to isolate that code from
the database code, and to speed-up tests.

The keys and types used in the return value from a connector's ``get`` methods are described in :src:`master/buildbot/test/util/validation.py`, via the ``dbdict`` module-level value.
This is a dictionary of ``DictValidator`` objects, one for each return value.

These values are used within test methods like this::

rv = yield self.db.masters.getMaster(7)
validation.verifyDbDict(self, 'masterdict', rv)

.. _Modifying-the-Database-Schema:

Modifying the Database Schema
Expand Down
1 change: 0 additions & 1 deletion master/docs/developer/tests.rst
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,6 @@ It supports four types of data:

These are validated from elsewhere in the codebase with calls to

* ``verifyDbDict(testcase, type, value)``,
* ``verifyData(testcase, type, options, value)``,
* ``verifyMessage(testcase, routingKey, message)``, and
* ``verifyType(testcase, name, value, validator)``,
Expand Down

0 comments on commit 6b1ccea

Please sign in to comment.