Skip to content

Commit

Permalink
Add dummy support for I/O schema v4.4
Browse files Browse the repository at this point in the history
  • Loading branch information
spbnick committed Jun 6, 2024
1 parent 5a990dc commit f07813d
Show file tree
Hide file tree
Showing 8 changed files with 133 additions and 2 deletions.
14 changes: 14 additions & 0 deletions kcidb/db/bigquery/v04_00.py
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,7 @@ class Schema(AbstractSchema):
checkout="SELECT\n"
" id,\n"
" git_commit_hash,\n"
" NULL AS git_commit_generation,\n"
" patchset_hash,\n"
" origin,\n"
" git_repository_url,\n"
Expand Down Expand Up @@ -584,6 +585,19 @@ class Schema(AbstractSchema):
' "" AS comment,\n'
' "" AS misc\n'
'FROM UNNEST([])',
transition='SELECT\n'
' "" AS id,\n'
' 0 AS version,\n'
' "" AS origin,\n'
' "" AS issue_id,\n'
' 0 AS issue_version,\n'
' "" AS revision_before_git_commit_hash,\n'
' "" AS revision_before_patchset_hash,\n'
' "" AS revision_after_git_commit_hash,\n'
' "" AS revision_after_patchset_hash,\n'
' "" AS comment,\n'
' "" AS misc\n'
'FROM UNNEST([])',
)

@classmethod
Expand Down
32 changes: 32 additions & 0 deletions kcidb/db/postgresql/v04_00.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ class Schema(AbstractSchema):
statement="SELECT\n"
" id,\n"
" git_commit_hash,\n"
" NULL AS git_commit_generation,\n"
" patchset_hash,\n"
" origin,\n"
" git_repository_url,\n"
Expand All @@ -320,6 +321,7 @@ class Schema(AbstractSchema):
schema=Table(dict(
id=TextColumn(),
git_commit_hash=TextColumn(),
git_commit_generation=IntegerColumn(),
patchset_hash=TextColumn(),
origin=TextColumn(),
git_repository_url=TextColumn(),
Expand Down Expand Up @@ -478,6 +480,36 @@ class Schema(AbstractSchema):
misc=JSONColumn(),
)),
),
transition=dict(
statement="SELECT\n"
" NULL AS id,\n"
" NULL AS version,\n"
" NULL AS origin,\n"
" NULL AS issue_id,\n"
" NULL AS issue_version,\n"
" NULL AS appearance,\n"
" NULL AS revision_before_git_commit_hash,\n"
" NULL AS revision_before_patchset_hash,\n"
" NULL AS revision_after_git_commit_hash,\n"
" NULL AS revision_after_patchset_hash,\n"
" NULL AS comment,\n"
" NULL AS misc\n"
"WHERE FALSE",
schema=Table(dict(
id=TextColumn(),
version=IntegerColumn(),
origin=TextColumn(),
issue_id=TextColumn(),
issue_version=IntegerColumn(),
appearance=BoolColumn(),
revision_before_git_commit_hash=TextColumn(),
revision_before_patchset_hash=TextColumn(),
revision_after_git_commit_hash=TextColumn(),
revision_after_patchset_hash=TextColumn(),
comment=TextColumn(),
misc=JSONColumn(),
)),
),
)

def init(self):
Expand Down
32 changes: 32 additions & 0 deletions kcidb/db/sqlite/v04_00.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ class Schema(AbstractSchema):
statement="SELECT\n"
" id,\n"
" git_commit_hash,\n"
" NULL AS git_commit_generation,\n"
" patchset_hash,\n"
" origin,\n"
" git_repository_url,\n"
Expand All @@ -282,6 +283,7 @@ class Schema(AbstractSchema):
schema=Table(dict(
id=TextColumn(),
git_commit_hash=TextColumn(),
git_commit_generation=IntegerColumn(),
patchset_hash=TextColumn(),
origin=TextColumn(),
git_repository_url=TextColumn(),
Expand Down Expand Up @@ -440,6 +442,36 @@ class Schema(AbstractSchema):
misc=JSONColumn(),
)),
),
transition=dict(
statement="SELECT\n"
" NULL AS id,\n"
" NULL AS version,\n"
" NULL AS origin,\n"
" NULL AS issue_id,\n"
" NULL AS issue_version,\n"
" NULL AS appearance,\n"
" NULL AS revision_before_git_commit_hash,\n"
" NULL AS revision_before_patchset_hash,\n"
" NULL AS revision_after_git_commit_hash,\n"
" NULL AS revision_after_patchset_hash,\n"
" NULL AS comment,\n"
" NULL AS misc\n"
"WHERE 0",
schema=Table(dict(
id=TextColumn(),
version=IntegerColumn(),
origin=TextColumn(),
issue_id=TextColumn(),
issue_version=IntegerColumn(),
appearance=BoolColumn(),
revision_before_git_commit_hash=TextColumn(),
revision_before_patchset_hash=TextColumn(),
revision_after_git_commit_hash=TextColumn(),
revision_after_patchset_hash=TextColumn(),
comment=TextColumn(),
misc=JSONColumn(),
)),
),
)

def init(self):
Expand Down
2 changes: 1 addition & 1 deletion kcidb/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
from kcidb_io import * # noqa: F403

# The I/O schema version used by KCIDB
SCHEMA = schema.V4_3 # noqa: F405
SCHEMA = schema.V4_4 # noqa: F405
5 changes: 5 additions & 0 deletions kcidb/oo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,10 @@ class Incident(Object):
"""An OO-representation of an incident"""


class Transition(Object):
"""An OO-representation of a transition"""


# A map of object type names and Object-derived classes handling their data
CLASSES = dict(
revision=Revision,
Expand All @@ -707,6 +711,7 @@ class Incident(Object):
bug=Bug,
issue=Issue,
incident=Incident,
transition=Transition,
)

assert set(CLASSES) == set(SCHEMA.types)
Expand Down
28 changes: 28 additions & 0 deletions kcidb/orm/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,8 @@ def format_dot(self):

# Latest I/O schema shared definitions
_DEFS = io.SCHEMA.json['$defs']
# Revision ID properties from the current I/O schema
_REVISION_ID = _DEFS['revision_id']['properties']
# Checkout properties from the current I/O schema
_CHECKOUT = _DEFS['checkout']['properties']
# Build properties from the current I/O schema
Expand All @@ -317,6 +319,8 @@ def format_dot(self):
_ISSUE_CULPRIT = _ISSUE['culprit']['properties']
# Incident properties from the current I/O schema
_INCIDENT = _DEFS['incident']['properties']
# Transition properties from the current I/O schema
_TRANSITION = _DEFS['transition']['properties']
# Test environment properties from the current I/O schema
_TEST_ENVIRONMENT = _TEST['environment']['properties']

Expand All @@ -342,6 +346,7 @@ def format_dot(self):
field_json_schemas=dict(
id=_CHECKOUT['id'],
git_commit_hash=_CHECKOUT['git_commit_hash'],
git_commit_generation=_CHECKOUT['git_commit_generation'],
patchset_hash=_CHECKOUT['patchset_hash'],
origin=_CHECKOUT['origin'],
git_repository_url=_CHECKOUT['git_repository_url'],
Expand Down Expand Up @@ -445,6 +450,7 @@ def format_dot(self):
id_fields=("id",),
children=dict(
incident=("issue_id",),
transition=("issue_id",),
),
),
incident=dict(
Expand All @@ -461,6 +467,28 @@ def format_dot(self):
required_fields={'id', 'origin', 'issue_id', 'issue_version'},
id_fields=("id",),
),
transition=dict(
field_json_schemas=dict(
id=_TRANSITION['id'],
version=_TRANSITION['version'],
origin=_TRANSITION['origin'],
issue_id=_TRANSITION['issue_id'],
issue_version=_TRANSITION['issue_version'],
appearance=_TRANSITION['appearance'],
revision_before_git_commit_hash=_REVISION_ID[
'git_commit_hash'
],
revision_before_patchset_hash=_REVISION_ID['patchset_hash'],
revision_after_git_commit_hash=_REVISION_ID[
'git_commit_hash'
],
revision_after_patchset_hash=_REVISION_ID['patchset_hash'],
comment=_TRANSITION['comment'],
misc=_TRANSITION['misc'],
),
required_fields={'id', 'origin', 'issue_id', 'issue_version'},
id_fields=("id",),
),
)
)

Expand Down
10 changes: 9 additions & 1 deletion kcidb/test_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ def test_load_main():

# I/O data containing all possible fields
COMPREHENSIVE_IO_DATA = {
**kcidb.io.SCHEMA.new(),
**kcidb.io.schema.V4_3.new(),
"checkouts": [
dict(
id="origin:1",
Expand Down Expand Up @@ -742,6 +742,7 @@ def test_upgrade(clean_database):
'comment': None,
'git_commit_hash':
'f00af9d68ed146b47fdbfe91134fcf04c36e6d78',
'git_commit_generation': None,
'git_repository_branch': 'android-mainline',
'git_repository_url':
'https://android.googlesource.com/kernel/common.git',
Expand Down Expand Up @@ -828,6 +829,7 @@ def test_upgrade(clean_database):
'bug': [],
'issue': [],
'incident': [],
'transition': [],
}
),
kcidb.io.schema.V4_0: dict(
Expand Down Expand Up @@ -869,6 +871,7 @@ def test_upgrade(clean_database):
"comment": None,
"git_commit_hash":
"5acb9c2a7bc836e9e5172bbcd2311499c5b4e5f1",
'git_commit_generation': None,
"git_repository_branch": None,
"git_repository_url": None,
"id":
Expand Down Expand Up @@ -927,6 +930,7 @@ def test_upgrade(clean_database):
"bug": [],
"issue": [],
"incident": [],
'transition': [],
}
),
kcidb.io.schema.V4_2: dict(
Expand Down Expand Up @@ -995,6 +999,7 @@ def test_upgrade(clean_database):
"comment": None,
"git_commit_hash":
"5acb9c2a7bc836e9e5172bbcd2311499c5b4e5f1",
'git_commit_generation': None,
"git_repository_branch": None,
"git_repository_url": None,
"id":
Expand Down Expand Up @@ -1090,6 +1095,7 @@ def test_upgrade(clean_database):
"test_id":
"google:google.org:a19di3j5h67f8d9475f26v11",
}],
'transition': [],
}
),
kcidb.io.schema.V4_3: dict(
Expand Down Expand Up @@ -1158,6 +1164,7 @@ def test_upgrade(clean_database):
"comment": None,
"git_commit_hash":
"5acb9c2a7bc836e9e5172bbcd2311499c5b4e5f1",
'git_commit_generation': None,
"git_repository_branch": None,
"git_repository_url": None,
"id":
Expand Down Expand Up @@ -1253,6 +1260,7 @@ def test_upgrade(clean_database):
"test_id":
"google:google.org:a19di3j5h67f8d9475f26v11",
}],
'transition': [],
}
),
}
Expand Down
12 changes: 12 additions & 0 deletions kcidb/test_orm.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,18 @@
required_fields={'id', 'origin', 'issue_id', 'issue_version'},
id_fields=("id",),
),
transition=dict(
field_json_schemas=dict(
id=dict(type="string"),
version=dict(type="integer"),
origin=dict(type="string"),
issue_id=dict(type="string"),
issue_version=dict(type="integer"),
appearance=dict(type="boolean"),
),
required_fields={'id', 'origin', 'issue_id', 'issue_version'},
id_fields=("id",),
),
)
)

Expand Down

0 comments on commit f07813d

Please sign in to comment.