#1573 Add indexes to ModuleBuild and ComponentBuild
Merged 4 years ago by cqi. Opened 4 years ago by cqi.
cqi/fm-orchestrator add-indexes  into  v3

@@ -16,6 +16,8 @@ 

  from sqlalchemy import func, and_

  from sqlalchemy.orm import lazyload

  from sqlalchemy.orm import validates, load_only

+ from sqlalchemy.schema import Index

+ 

  

  from module_build_service import db, log, get_url_for, conf

  from module_build_service.common.errors import UnprocessableEntity
@@ -121,17 +123,17 @@ 

  class ModuleBuild(MBSBase):

      __tablename__ = "module_builds"

      id = db.Column(db.Integer, primary_key=True)

-     name = db.Column(db.String, nullable=False)

+     name = db.Column(db.String, nullable=False, index=True)

      stream = db.Column(db.String, nullable=False)

      version = db.Column(db.String, nullable=False)

      build_context = db.Column(db.String)

      build_context_no_bms = db.Column(db.String)

      runtime_context = db.Column(db.String)

      context = db.Column(db.String, nullable=False, server_default=DEFAULT_MODULE_CONTEXT)

-     state = db.Column(db.Integer, nullable=False)

+     state = db.Column(db.Integer, nullable=False, index=True)

      state_reason = db.Column(db.String)

      modulemd = db.Column(db.String, nullable=False)

-     koji_tag = db.Column(db.String)  # This gets set after 'wait'

+     koji_tag = db.Column(db.String, index=True)  # This gets set after 'wait'

      # Koji tag to which tag the Content Generator Koji build.

      cg_build_koji_tag = db.Column(db.String)  # This gets set after wait

      scmurl = db.Column(db.String)
@@ -172,6 +174,13 @@ 

          backref="buildrequire_for",

      )

  

+     __table_args__ = (

+         Index(

+             "idx_module_builds_name_stream_version_context",

+             "name", "stream", "version", "context", unique=True

+         ),

+     )

+ 

      rebuild_strategies = {

          "all": "All components will be rebuilt",

          "changed-and-after": (
@@ -1079,7 +1088,7 @@ 

      # iteration this *component* is currently in.  This relates to the owning

      # module's batch.  This one defaults to None, which means that this

      # component is not currently part of a batch.

-     batch = db.Column(db.Integer, default=0)

+     batch = db.Column(db.Integer, default=0, index=True)

  

      module_id = db.Column(db.Integer, db.ForeignKey("module_builds.id"), nullable=False)

      module_build = db.relationship("ModuleBuild", backref="component_builds", lazy=False)
@@ -1090,6 +1099,11 @@ 

      # get_build_weights function

      weight = db.Column(db.Float, default=0)

  

+     __table_args__ = (

+         Index("idx_component_builds_build_id_task_id", "module_id", "task_id", unique=True),

+         Index("idx_component_builds_build_id_nvr", "module_id", "nvr", unique=True),

+     )

+ 

      @classmethod

      def from_component_event(cls, db_session, task_id, module_id=None):

          _filter = db_session.query(cls).filter

@@ -0,0 +1,60 @@ 

+ """Add indexes to models

+ 

+ Revision ID: 440a8a3c0d96

+ Revises: 4d1e2e13e514

+ Create Date: 2020-02-04 17:15:37.150756

+ 

+ """

+ 

+ from alembic import op

+ 

+ # revision identifiers, used by Alembic.

+ revision = "440a8a3c0d96"

+ down_revision = "4d1e2e13e514"

+ 

+ 

+ def upgrade():

+     op.create_index(

+         "idx_component_builds_build_id_nvr",

+         "component_builds",

+         ["module_id", "nvr"],

+         unique=True,

+     )

+     op.create_index(

+         "idx_component_builds_build_id_task_id",

+         "component_builds",

+         ["module_id", "task_id"],

+         unique=True,

+     )

+     op.create_index(

+         op.f("ix_component_builds_batch"), "component_builds", ["batch"], unique=False

+     )

+     op.create_index(

+         "idx_module_builds_name_stream_version_context",

+         "module_builds",

+         ["name", "stream", "version", "context"],

+         unique=True,

+     )

+     op.create_index(

+         op.f("ix_module_builds_name"), "module_builds", ["name"], unique=False

+     )

+     op.create_index(

+         op.f("ix_module_builds_state"), "module_builds", ["state"], unique=False

+     )

+     op.create_index(

+         op.f("ix_module_builds_koji_tag"), "module_builds", ["koji_tag"], unique=False

+     )

+ 

+ 

+ def downgrade():

+     op.drop_index(op.f("ix_module_builds_koji_tag"), table_name="module_builds")

+     op.drop_index(op.f("ix_module_builds_state"), table_name="module_builds")

+     op.drop_index(op.f("ix_module_builds_name"), table_name="module_builds")

+     op.drop_index(

+         "idx_module_builds_name_stream_version_context", table_name="module_builds"

+     )

+     op.drop_index(op.f("ix_component_builds_batch"), table_name="component_builds")

+     op.drop_index(

+         "idx_component_builds_build_id_task_id", table_name="component_builds"

+     )

+     op.drop_index("idx_component_builds_build_id_nvr", table_name="component_builds")

file modified
+5 -2
@@ -4,8 +4,10 @@ 

  from datetime import datetime, timedelta

  import functools

  import hashlib

+ import itertools

  import os

  import re

+ import six

  import time

  from traceback import extract_stack

  
@@ -165,6 +167,7 @@ 

      # like "Object '<ModuleBuild at 0x7f4ccc805c50>' is already attached to

      # session '275' (this is '276')" when add new module build object to passed

      # session.

+     task_id_counter = itertools.count(1)

      arch = db_session.query(module_build_service.common.models.ModuleArch).get(1)

      num_contexts = 2 if contexts else 1

      for index in range(data_size):
@@ -214,7 +217,7 @@ 

                      scmurl="git://pkgs.domain.local/rpms/nginx?"

                             "#ga95886c8a443b36a9ce31abda1f9bed22f2f8c3",

                      format="rpms",

-                     task_id=12312345 + index,

+                     task_id=six.next(task_id_counter),

                      state=koji.BUILD_STATES["COMPLETE"],

                      nvr="nginx-1.10.1-2.{0}".format(build_one_component_release),

                      batch=1,
@@ -226,7 +229,7 @@ 

                      scmurl="/tmp/module_build_service-build-macrosWZUPeK/SRPMS/"

                             "module-build-macros-0.1-1.module_nginx_1_2.src.rpm",

                      format="rpms",

-                     task_id=12312321 + index,

+                     task_id=six.next(task_id_counter),

                      state=koji.BUILD_STATES["COMPLETE"],

                      nvr="module-build-macros-01-1.{0}".format(build_one_component_release),

                      batch=2,

@@ -8,7 +8,7 @@ 

            dependency of mksh., ref: master, repository: 'https://src.fedoraproject.org/rpms/ed'}

    dependencies:

      buildrequires: {testmodule: master}

-     requires: {platform: f28}

+     requires: {platform: f30}

    description: This module demonstrates how to write simple modulemd files And can

      be used for testing the build and release pipeline.

    license:
@@ -28,7 +28,7 @@ 

          testmodule: {ref: 147dca4ca65aa9a1ac51f71b7e687f9178ffa5df, stream: master,

            version: '20170616125652', context: '321'}

        requires:

-         platform: {ref: virtual, stream: f28, version: '3', context: '00000000'}

+         platform: {ref: virtual, stream: f30, version: '3', context: '00000000'}

        commit: 722fd739fd6cf66faf29f6fb95dd64f60ba3e39a

        rpms:

          ed: {ref: 01bf8330812fea798671925cc537f2f29b0bd216}

@@ -18,7 +18,7 @@ 

    dependencies:

      buildrequires: {}

      requires: {}

-   description: Fedora 28 traditional base

+   description: Fedora 30 traditional base

    license:

      module: [MIT]

    name: platform
@@ -35,6 +35,7 @@ 

    stream: f28

    summary: A test module in all its beautiful beauty

    version: 3

+   context: 00000000

    xmd:

      mbs:

        buildrequires:

@@ -0,0 +1,26 @@ 

+ ---

+ document: modulemd

+ version: 1

+ data:

+   description: Fedora 30 traditional base

+   name: platform

+   license:

+     module: [MIT]

+   profiles:

+     default:

+       rpms: [mksh]

+     buildroot:

+         rpms: foo

+     srpm-buildroot:

+         rpms: bar

+   stream: f30

+   summary: A test module in all its beautiful beauty

+   version: 3

+   context: 00000000

+   xmd:

+     mbs:

+       buildrequires: {}

+       commit: virtual

+       requires: {}

+       mse: true

+       koji_tag: module-f30-build

@@ -7,8 +7,8 @@ 

        ed: {cache: 'http://pkgs.fedoraproject.org/repo/pkgs/ed', rationale: A build

            dependency of mksh., ref: master, repository: 'https://src.fedoraproject.org/rpms/ed'}

    dependencies:

-     buildrequires: {platform: f28}

-     requires: {platform: f28}

+     buildrequires: {platform: f30}

+     requires: {platform: f30}

    description: This module demonstrates how to write simple modulemd files And can

      be used for testing the build and release pipeline.

    license:
@@ -25,7 +25,7 @@ 

    xmd:

      mbs:

        buildrequires:

-         platform: {ref: virtual, stream: f28, version: '3', context: '00000000'}

+         platform: {ref: virtual, stream: f30, version: '3', context: '00000000'}

        commit: 722fd739fd6cf66faf29f6fb95dd64f60ba3e39a

        rpms:

          ed: {ref: 01bf8330812fea798671925cc537f2f29b0bd216}

@@ -7,8 +7,8 @@ 

        ed: {cache: 'http://pkgs.fedoraproject.org/repo/pkgs/ed', rationale: A build

            dependency of mksh., ref: master, repository: 'https://src.fedoraproject.org/rpms/ed'}

    dependencies:

-     buildrequires: {platform: f28}

-     requires: {platform: f28}

+     buildrequires: {platform: f30}

+     requires: {platform: f30}

    description: This module demonstrates how to write simple modulemd files And can

      be used for testing the build and release pipeline.

    license:
@@ -25,7 +25,7 @@ 

    xmd:

      mbs:

        buildrequires:

-         platform: {ref: virtual, stream: f28, version: '3', context: '00000000'}

+         platform: {ref: virtual, stream: f30, version: '3', context: '00000000'}

        commit: 722fd739fd6cf66faf29f6fb95dd64f60ba3e39a

        rpms:

          ed: {ref: 01bf8330812fea798671925cc537f2f29b0bd216}

@@ -14,8 +14,8 @@ 

        mksh: {cache: 'http://pkgs.fedoraproject.org/repo/pkgs/mksh', rationale: A build

            dependency of mksh., ref: master, repository: 'https://src.fedoraproject.org/rpms/mksh'}

    dependencies:

-     buildrequires: {platform: f28, testmodule: master}

-     requires: {platform: f28}

+     buildrequires: {platform: f30, testmodule: master}

+     requires: {platform: f30}

    description: This module demonstrates how to write simple modulemd files And can

      be used for testing the build and release pipeline.

    license:
@@ -31,7 +31,7 @@ 

    xmd:

      mbs:

        buildrequires:

-         platform: {ref: virtual, stream: f28, version: '3'}

+         platform: {ref: virtual, stream: f30, version: '3'}

          testmodule: {stream: master, version: '20170816080815'}

        commit: null

        rpms:

@@ -0,0 +1,37 @@ 

+ document: modulemd

+ version: 1

+ data:

+     summary: A test module in all its beautiful beauty

+     description: >-

+         This module demonstrates how to write simple modulemd files And

+         can be used for testing the build and release pipeline. ’

+     license:

+         module: [ MIT ]

+     dependencies:

+         buildrequires:

+             platform: f30

+         requires:

+             platform: f30

+     references:

+         community: https://docs.pagure.org/modularity/

+         documentation: https://fedoraproject.org/wiki/Fedora_Packaging_Guidelines_for_Modules

+     profiles:

+         default:

+             rpms:

+             - tangerine

+     api:

+         rpms:

+         - perl-Tangerine

+         - tangerine

+     components:

+         rpms:

+             perl-List-Compare:

+                 rationale: A dependency of tangerine.

+                 ref: master

+             perl-Tangerine:

+                 rationale: Provides API for this module and is a dependency of tangerine.

+                 ref: master

+             tangerine:

+                 rationale: Provides API for this module.

+                 buildorder: 10

+                 ref: master

@@ -1909,11 +1909,11 @@ 

          """

          Tests local module build dependency.

          """

-         load_local_builds(["platform"])

+         load_local_builds(["platform:f30"])

          FakeSCM(

              mocked_scm,

              "testmodule",

-             "testmodule.yaml",

+             "testmodule-buildrequires-f30.yaml",

              "620ec77321b2ea7b0d67d82992dda3e1d67055b4",

          )

  

@@ -140,6 +140,7 @@ 

          dest_tagged = [{"nvr": "foo-1.0-1.module+e0095747", "task_id": 12345, "build_id": 91}]

          builder.koji_session.listTagged.side_effect = [build_tagged, dest_tagged]

          module_build = module_build_service.common.models.ModuleBuild.get_by_id(db_session, 4)

+         module_build.component_builds.sort(key=lambda item: item.id)

          component_build = module_build.component_builds[0]

          component_build.task_id = None

          component_build.state = None
@@ -195,6 +196,7 @@ 

          build_info = {"nvr": "foo-1.0-1.{0}".format(dist_tag), "task_id": 12345, "build_id": 91}

          builder.koji_session.getBuild.return_value = build_info

          module_build = module_build_service.common.models.ModuleBuild.get_by_id(db_session, 4)

+         module_build.component_builds.sort(key=lambda item: item.id)

          component_build = module_build.component_builds[0]

          component_build.task_id = None

          component_build.nvr = None
@@ -245,6 +247,7 @@ 

                        "build_id": 91}

          builder.koji_session.getBuild.return_value = build_info

          module_build = module_build_service.common.models.ModuleBuild.get_by_id(db_session, 4)

+         module_build.component_builds.sort(key=lambda item: item.id)

          component_build = module_build.component_builds[1]

          component_build.task_id = None

          component_build.nvr = None

@@ -367,15 +367,15 @@ 

              models.ModuleBuild.local_modules(db_session)

  

      def test_load_local_builds_platform(self, conf_system, conf_resultsdir):

-         load_local_builds("platform")

+         load_local_builds("platform:f30")

          local_modules = models.ModuleBuild.local_modules(db_session)

  

          assert len(local_modules) == 1

-         assert local_modules[0].koji_tag.endswith("/module-platform-f28-3/results")

+         assert local_modules[0].koji_tag.endswith("/module-platform-f30-3/results")

  

      def test_load_local_builds_platform_f28(self, conf_system, conf_resultsdir):

-         load_local_builds("platform:f28")

+         load_local_builds("platform:f30")

          local_modules = models.ModuleBuild.local_modules(db_session)

  

          assert len(local_modules) == 1

-         assert local_modules[0].koji_tag.endswith("/module-platform-f28-3/results")

+         assert local_modules[0].koji_tag.endswith("/module-platform-f30-3/results")

@@ -71,6 +71,7 @@ 

          mmd = load_mmd(read_staged_data("formatted_testmodule"))

          for i in range(3):

              build = module_build_from_modulemd(mmd_to_str(mmd))

+             build.context = "f6e2aec" + str(i)

              build.build_context = "f6e2aeec7576196241b9afa0b6b22acf2b6873d" + str(i)

              build.runtime_context = "bbc84c7b817ab3dd54916c0bcd6c6bdf512f7f9c" + str(i)

              db_session.add(build)
@@ -80,7 +81,7 @@ 

          sibling_ids = build_one.siblings(db_session)

          db_session.commit()

  

-         assert sibling_ids == [3, 4]

+         assert sorted(sibling_ids) == [3, 4]

  

      @pytest.mark.parametrize(

          "stream,right_pad,expected",
@@ -127,7 +128,7 @@ 

              for build in builds

          ]

          db_session.commit()

-         assert builds == ["nginx:1:3:d5a6c0fa", "nginx:1:3:795e97c1"]

+         assert sorted(builds) == ["nginx:1:3:795e97c1", "nginx:1:3:d5a6c0fa"]

  

      def test_get_last_builds_in_stream_version_lte(self):

          init_data_contexts(1, multiple_stream_versions=True)

@@ -12,7 +12,7 @@ 

  from module_build_service.common import models

  import module_build_service.common.monitor

  from module_build_service.scheduler.db_session import db_session

- from tests import init_data, make_module_in_db

+ from tests import clean_database, init_data, make_module_in_db

  

  num_of_metrics = 18

  
@@ -52,6 +52,7 @@ 

  @mock.patch("module_build_service.common.monitor.builder_failed_counter.labels")

  @mock.patch("module_build_service.common.monitor.builder_success_counter.inc")

  def test_monitor_state_changing_success(succ_cnt, failed_cnt):

+     clean_database(add_platform_module=False, add_default_arches=False)

      b = make_module_in_db(

          "pkg:0.1:1:c1",

          [
@@ -72,6 +73,7 @@ 

  @mock.patch("module_build_service.common.monitor.builder_failed_counter.labels")

  @mock.patch("module_build_service.common.monitor.builder_success_counter.inc")

  def test_monitor_state_changing_failure(succ_cnt, failed_cnt):

+     clean_database(add_platform_module=False, add_default_arches=False)

      failure_type = "user"

      b = make_module_in_db(

          "pkg:0.1:1:c1",

file modified
+12 -4
@@ -51,7 +51,12 @@ 

      def test_retire_build(self, prompt_bool, overrides, identifier, changed_count):

          prompt_bool.return_value = True

  

-         module_builds = db_session.query(ModuleBuild).filter_by(state=BUILD_STATES["ready"]).all()

+         module_builds = (

+             db_session.query(ModuleBuild)

+             .filter_by(state=BUILD_STATES["ready"])

+             .order_by(ModuleBuild.id.desc())

+             .all()

+         )

          # Verify our assumption of the amount of ModuleBuilds in database

          assert len(module_builds) == 3

  
@@ -68,7 +73,10 @@ 

  

          retire(identifier)

          retired_module_builds = (

-             db_session.query(ModuleBuild).filter_by(state=BUILD_STATES["garbage"]).all()

+             db_session.query(ModuleBuild)

+             .filter_by(state=BUILD_STATES["garbage"])

+             .order_by(ModuleBuild.id.desc())

+             .all()

          )

  

          assert len(retired_module_builds) == changed_count
@@ -96,7 +104,7 @@ 

          assert len(module_builds) == 3

  

          for x, build in enumerate(module_builds):

-             build.name = "spam"

+             build.name = "spam" + str(x) if x > 0 else "spam"

              build.stream = "eggs"

  

          db_session.commit()
@@ -106,7 +114,7 @@ 

              db_session.query(ModuleBuild).filter_by(state=BUILD_STATES["garbage"]).all()

          )

  

-         expected_changed_count = 3 if confirm_expected else 0

+         expected_changed_count = 1 if confirm_expected else 0

          assert len(retired_module_builds) == expected_changed_count

  

  

@@ -144,7 +144,7 @@ 

          """

          Tests that it returns the requires of the buildrequires recursively

          """

-         load_local_builds(["platform", "parent", "child", "testmodule"])

+         load_local_builds(["platform:f30", "parent", "child", "testmodule"])

  

          build = models.ModuleBuild.local_modules(db_session, "child", "master")

          resolver = mbs_resolver.GenericResolver.create(db_session, conf, backend="db")
@@ -186,6 +186,7 @@ 

          mmd = load_mmd(tests.read_staged_data("formatted_testmodule"))

          for i in range(3):

              build = tests.module_build_from_modulemd(mmd_to_str(mmd))

+             build.context = "f6e2ae" + str(i)

              build.build_context = "f6e2aeec7576196241b9afa0b6b22acf2b6873d" + str(i)

              build.runtime_context = "bbc84c7b817ab3dd54916c0bcd6c6bdf512f7f9c" + str(i)

              build.state = models.BUILD_STATES["ready"]
@@ -267,7 +268,15 @@ 

          """

          Test that profiles get resolved recursively on local builds

          """

-         load_local_builds(["platform"])

+         # This test requires a platform module loaded from local rather than

+         # the one added to database.

+         platform = db_session.query(models.ModuleBuild).filter(

+             models.ModuleBuild.name == "platform"

+         ).one()

+         db_session.delete(platform)

+         db_session.commit()

+ 

+         load_local_builds(["platform:f28"])

          mmd = models.ModuleBuild.get_by_id(db_session, 2).mmd()

          resolver = mbs_resolver.GenericResolver.create(db_session, conf, backend="mbs")

          result = resolver.resolve_profiles(mmd, ("buildroot", "srpm-buildroot"))

@@ -331,8 +331,8 @@ 

      def test_resolve_profiles_local_module(

          self, local_builds, conf_system, formatted_testmodule_mmd

      ):

-         tests.clean_database()

-         load_local_builds(["platform"])

+         tests.clean_database(add_platform_module=False)

+         load_local_builds(["platform:f28"])

  

          resolver = mbs_resolver.GenericResolver.create(db_session, conf, backend="mbs")

          result = resolver.resolve_profiles(

@@ -431,12 +431,15 @@ 

          # Make sure module_build_two stayed the same

          assert module_build_two.state == models.BUILD_STATES["failed"]

          # Make sure the builds were untagged

-         builder.untag_artifacts.assert_called_once_with([

-             "perl-Tangerine-0.23-1.module+0+d027b723",

+         builder.untag_artifacts.assert_called_once()

+         args, _ = builder.untag_artifacts.call_args

+         expected = [

+             "module-build-macros-0.1-1.module+0+d027b723",

              "perl-List-Compare-0.53-5.module+0+d027b723",

+             "perl-Tangerine-0.23-1.module+0+d027b723",

              "tangerine-0.22-3.module+0+d027b723",

-             "module-build-macros-0.1-1.module+0+d027b723",

-         ])

+         ]

+         assert expected == sorted(args[0])

  

      def test_cleanup_stale_failed_builds_no_components(self, create_builder, dbg):

          """ Test that a module build without any components built gets to the garbage state when

@@ -341,9 +341,11 @@ 

          xmd["mbs"]["buildrequires"]["platform"]["stream"] = "f29"

          mmd.set_xmd(xmd)

          latest_module.modulemd = mmd_to_str(mmd)

-         latest_module.build_context = models.ModuleBuild.contexts_from_mmd(

+         contexts = models.ModuleBuild.contexts_from_mmd(

              latest_module.modulemd

-         ).build_context

+         )

+         latest_module.build_context = contexts.build_context

+         latest_module.context = contexts.context

          latest_module.buildrequires = [platform_f29]

  

          # Set the `id` to None, so new one is generated by SQLAlchemy.
@@ -362,8 +364,12 @@ 

          if allow_ocbm:

              assert reusable_module.id == latest_module.id

          else:

+             # There are two testmodules in ready state, the first one with

+             # lower id is what we want.

              first_module = db_session.query(models.ModuleBuild).filter_by(

-                 name="testmodule", state=models.BUILD_STATES["ready"]).first()

+                 name="testmodule", state=models.BUILD_STATES["ready"]

+             ).order_by(models.ModuleBuild.id).first()

+ 

              assert reusable_module.id == first_module.id

  

      @pytest.mark.parametrize("allow_ocbm", (True, False))

file modified
+10 -8
@@ -143,13 +143,13 @@ 

          assert data["tasks"] == {

              "rpms": {

                  "module-build-macros": {

-                     "task_id": 12312321,

+                     "task_id": 2,

                      "state": 1,

                      "state_reason": None,

                      "nvr": "module-build-macros-01-1.module+2+b8661ee4",

                  },

                  "nginx": {

-                     "task_id": 12312345,

+                     "task_id": 1,

                      "state": 1,

                      "state_reason": None,

                      "nvr": "nginx-1.10.1-2.module+2+b8661ee4",
@@ -186,7 +186,7 @@ 

          rv = self.client.get("/module-build-service/1/module-builds/2?verbose=true")

          data = json.loads(rv.data)

          assert data["base_module_buildrequires"] == []

-         assert data["component_builds"] == [1, 2]

+         assert sorted(data["component_builds"]) == [1, 2]

          assert data["context"] == "00000000"

          # There is no xmd information on this module, so these values should be None

          assert data["build_context"] is None
@@ -214,13 +214,13 @@ 

          assert data["tasks"] == {

              "rpms": {

                  "module-build-macros": {

-                     "task_id": 12312321,

+                     "task_id": 2,

                      "state": 1,

                      "state_reason": None,

                      "nvr": "module-build-macros-01-1.module+2+b8661ee4",

                  },

                  "nginx": {

-                     "task_id": 12312345,

+                     "task_id": 1,

                      "state": 1,

                      "state_reason": None,

                      "nvr": "nginx-1.10.1-2.module+2+b8661ee4",
@@ -359,6 +359,8 @@ 

              },

          ]

  

+         for module_build in items:

+             module_build["component_builds"].sort()

          assert items == expected

  

      def test_query_builds_with_context(self):
@@ -528,7 +530,7 @@ 

          assert data["state"] == 1

          assert data["state_name"] == "COMPLETE"

          assert data["state_reason"] is None

-         assert data["task_id"] == 12312345

+         assert data["task_id"] == 1

  

      def test_query_component_build_short(self):

          rv = self.client.get("/module-build-service/1/component-builds/1?short=True")
@@ -541,7 +543,7 @@ 

          assert data["state"] == 1

          assert data["state_name"] == "COMPLETE"

          assert data["state_reason"] is None

-         assert data["task_id"] == 12312345

+         assert data["task_id"] == 1

  

      def test_query_component_build_verbose(self):

          rv = self.client.get("/module-build-service/1/component-builds/3?verbose=true")
@@ -622,7 +624,7 @@ 

          assert data["meta"]["total"] == 1

  

      def test_query_component_builds_filter_task_id(self):

-         rv = self.client.get("/module-build-service/1/component-builds/?task_id=12312346")

+         rv = self.client.get("/module-build-service/1/component-builds/?task_id=1")

          data = json.loads(rv.data)

          assert data["meta"]["total"] == 1

  

Signed-off-by: Chenxiong Qi cqi@redhat.com

Build #745 failed (commit: ab6edfe02cad6ffe08afff62eb749ddb4e971051).
Rebase or make new commits to rebuild.

rebased onto 19857a4cd1dbd8e4c242e706e1341892191a0499

4 years ago

Build #746 failed (commit: 19857a4cd1dbd8e4c242e706e1341892191a0499).
Rebase or make new commits to rebuild.

For the indexes on single columns, you can use the index=True keyword argument when defining the column.

I think it'd make sense to index the name column individually as well.

Could you please name the constraint? If a name isn't provided, one is auto-generated as part of the migration when it's performed on Postgres since it doesn't support unnamed constraints. If we rely on the auto-generated one, then future migrations can't drop the constraint without us having to find what it was named in Postgres and then adjusting this migration script to use that name for the constraint.

Optional: It'd be nice to format this file with "black" so that double quotes are used and line lengths are respected, but I realize that we haven't enforced formatting on the migrations in the past.

rebased onto 1dec226915c6047c9adac620bd1217abf6578da6

4 years ago

rebased onto ed5867fb82524000a08a8c347467baa561820b5b

4 years ago

@mprahl All comments are addressed. PTAL.

Build #784 failed (commit: ed5867fb82524000a08a8c347467baa561820b5b).
Rebase or make new commits to rebuild.

Build #783 failed (commit: ed5867fb82524000a08a8c347467baa561820b5b).
Rebase or make new commits to rebuild.

Build #785 failed (commit: ed5867fb82524000a08a8c347467baa561820b5b).
Rebase or make new commits to rebuild.

rebased onto 1adeafccafc92583724369afe93899f7203637e2

4 years ago

Rebased and fix conflicts.

@breilly Would you like to review as well?

Build #794 failed (commit: 1adeafccafc92583724369afe93899f7203637e2).
Rebase or make new commits to rebuild.

@cqi, instead of this style, could you declare them in __tableargs__? I think it'd be easier to read. Here's an example:
https://stackoverflow.com/a/6627154/9706416

rebased onto 6be4a0e56df79cfc2a74d0edbaa2d299e884d652

4 years ago

@mprahl Cool :thumbsup: PR is updated accordingly.

Build #796 failed (commit: 6be4a0e56df79cfc2a74d0edbaa2d299e884d652).
Rebase or make new commits to rebuild.

:thumbsup:

Thanks for doing this!

I'll rebase this pr and merge it.

rebased onto e8dc3666070e8e3274fe4a999f3a86270d1a39fd

4 years ago

Build #799 failed (commit: e8dc3666070e8e3274fe4a999f3a86270d1a39fd).
Rebase or make new commits to rebuild.

The merge should be postponed. Lots of tests fail due to the unique index of name, stream, vesion, context on ModuleBuild.

rebased onto 73477b6679a70493ef726d67426e142e8e8114ff

4 years ago

Build #806 failed (commit: 73477b6679a70493ef726d67426e142e8e8114ff).
Rebase or make new commits to rebuild.

rebased onto e5fc1e0b6cb4784a5a482c0e2648b94839a74bf8

4 years ago

Build #808 failed (commit: e5fc1e0b6cb4784a5a482c0e2648b94839a74bf8).
Rebase or make new commits to rebuild.

This PR has these updates:

  • Add index to ModuleBuild.koji_tag, but it is not unique.
  • Remove unique index on fields module_id and package on model ComponentBuild.
  • Tests are updated accordingly.

PTAL.

pretty please pagure-ci rebuild

4 years ago

rebased onto a49f686cc577af7534bea6ee09c8a4b714025e2e

4 years ago

Build #810 failed (commit: a49f686cc577af7534bea6ee09c8a4b714025e2e).
Rebase or make new commits to rebuild.

The tests pass, but job finishes as ABORTED in CI.

Could you make this modulemd look more like the following:
https://pagure.io/fm-orchestrator/blob/master/f/tests/staged_data/platform.yaml

I'd just like the platform module in the test data to look like a platform module and not a regular module.

@cqi once my comment is addressed and the tests pass, feel free to merge.

rebased onto 29d05a5

4 years ago

Build #811 failed (commit: 29d05a5).
Rebase or make new commits to rebuild.

@mprahl The yaml file is updated. I'm going to merge this PR. Thanks for reivew.

Pull-Request has been merged by cqi

4 years ago
Metadata