Skip to content

Commit

Permalink
Merge f30319b into 777b95a
Browse files Browse the repository at this point in the history
  • Loading branch information
dianaclarke committed Apr 29, 2021
2 parents 777b95a + f30319b commit 2054acf
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 2 deletions.
10 changes: 10 additions & 0 deletions conbench/tests/migrations/test_4a5177dc4e44_migrate_contexts.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from ...db import Session
from ...entities.summary import Summary
from ...entities.context import Context


this_dir = os.path.abspath(os.path.dirname(__file__))
Expand Down Expand Up @@ -259,8 +260,14 @@ def test_upgrade():
summary_1 = Summary.create(VALID_PAYLOAD_1)
summary_2 = Summary.create(VALID_PAYLOAD_2)
summary_3 = Summary.create(VALID_PAYLOAD_3)
before_context_id_1 = summary_1.context_id
before_context_id_2 = summary_2.context_id
before_context_id_3 = summary_3.context_id

# assert before migration
assert Context.get(before_context_id_1) is not None
assert Context.get(before_context_id_2) is not None
assert Context.get(before_context_id_3) is not None
assert "arrow_git_revision" in summary_1.context.tags
assert "arrow_git_revision" not in summary_2.context.tags
assert "arrow_git_revision" in summary_3.context.tags
Expand All @@ -278,6 +285,9 @@ def test_upgrade():
Session.refresh(summary_3)

# assert after migration
assert Context.get(before_context_id_1) is None # deleted
assert Context.get(before_context_id_2) is not None
assert Context.get(before_context_id_3) is not None
assert "arrow_git_revision" not in summary_1.context.tags
assert "arrow_git_revision" not in summary_2.context.tags
assert "arrow_git_revision" not in summary_3.context.tags
Expand Down
18 changes: 18 additions & 0 deletions conbench/tests/migrations/test_854c3ba5abd6_migrate_cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from alembic.config import Config

from ...db import Session
from ...entities.case import Case
from ...entities.summary import Summary


Expand Down Expand Up @@ -424,6 +425,11 @@ def test_upgrade():
summary_3 = Summary.create(VALID_PAYLOAD_3)
summary_4 = Summary.create(VALID_PAYLOAD_4)
summary_5 = Summary.create(VALID_PAYLOAD_5)
before_case_id_1 = summary_1.case_id
before_case_id_2 = summary_2.case_id
before_case_id_3 = summary_3.case_id
before_case_id_4 = summary_4.case_id
before_case_id_5 = summary_5.case_id

expected = {
"dataset": "nyctaxi_sample",
Expand All @@ -443,6 +449,12 @@ def test_upgrade():
}

# assert before migration
assert Case.get(before_case_id_1) is not None
assert Case.get(before_case_id_2) is not None
assert Case.get(before_case_id_3) is not None
assert Case.get(before_case_id_4) is not None
assert Case.get(before_case_id_5) is not None

assert summary_1.case.name == "file-write"
assert summary_1.case.tags == expected
assert summary_2.case.name == "file-write"
Expand All @@ -469,6 +481,12 @@ def test_upgrade():
Session.refresh(summary_5)

# assert after migration
assert Case.get(before_case_id_1) is not None
assert Case.get(before_case_id_2) is None # deleted
assert Case.get(before_case_id_3) is not None
assert Case.get(before_case_id_4) is None # deleted
assert Case.get(before_case_id_5) is not None

assert summary_1.case.name == "file-write"
assert summary_1.case.tags == expected
assert summary_2.case.name == "file-write"
Expand Down
4 changes: 3 additions & 1 deletion migrations/versions/4a5177dc4e44_migrate_contexts.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ def upgrade():
.where(summary_table.c.context_id == context.id)
.values(context_id=other.id)
)
context_table.delete().where(context_table.c.id == context.id)
connection.execute(
context_table.delete().where(context_table.c.id == context.id)
)
else:
connection.execute(
context_table.update()
Expand Down
4 changes: 3 additions & 1 deletion migrations/versions/854c3ba5abd6_migrate_cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ def upgrade():
.where(summary_table.c.case_id == case.id)
.values(case_id=other.id)
)
case_table.delete().where(case_table.c.id == case.id)
connection.execute(
case_table.delete().where(case_table.c.id == case.id)
)
else:
connection.execute(
case_table.update()
Expand Down

0 comments on commit 2054acf

Please sign in to comment.