Functional db migration tests broken and not running in gate

Bug #1766639 reported by Lucas Alvares Gomes
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
networking-ovn
Fix Released
High
Lucas Alvares Gomes

Bug Description

The functional db migration tests such as "TestModelsMigrationsMysql.test_models_sync" are not running in the gate due to miss configuration, for example:

2018-04-24 13:14:40.029396 | primary | 2018-04-24 13:14:40.028 | {4} networking_ovn.tests.functional.db.test_migrations.TestModelsMigrationsMysql.test_models_sync ... SKIPPED: backend 'mysql' unavailable

This is because we don't properly configure the databases for the functional tests in the networking-ovn gate. We need something similar to this script for Neutron [0].

Now, it's possible to configure things manually to verify the tests, to do this follow the steps below:

1. Stack DevStack as per our documentation

2. Configure Mysql:

  $ cat << EOF > /tmp/mysql.sql
  CREATE DATABASE openstack_citest;
  CREATE USER 'openstack_citest'@'localhost' IDENTIFIED BY
  'openstack_citest';
  CREATE USER 'openstack_citest' IDENTIFIED BY 'openstack_citest';
  GRANT ALL PRIVILEGES ON *.* TO 'openstack_citest'@'localhost';
  GRANT ALL PRIVILEGES ON *.* TO 'openstack_citest';
  FLUSH PRIVILEGES;
  EOF

  $ /usr/bin/mysql -u root < /tmp/mysql.sql

3. Change to the networking-ovn directory

  $ cd ~/networking-ovn

4. Run the test_models_sync() functional test:

  $ tox -edsvm-functional TestModelsMigrationsMysql.test_models_sync

And finally, the tests are broken:

networking_ovn.tests.functional.db.test_migrations.TestModelsMigrationsMysql.test_models_sync
---------------------------------------------------------------------------------------------

Captured traceback:
~~~~~~~~~~~~~~~~~~~
    Traceback (most recent call last):
      File "/opt/stack/networking-ovn/.tox/dsvm-functional/lib/python2.7/site-packages/neutron/tests/base.py", line 132, in func
        return f(self, *args, **kwargs)
      File "/opt/stack/networking-ovn/.tox/dsvm-functional/lib/python2.7/site-packages/oslo_db/sqlalchemy/test_migrations.py", line 621, in test_models_sync
        "Models and migration scripts aren't in sync:\n%s" % msg)
      File "/opt/stack/networking-ovn/.tox/dsvm-functional/lib/python2.7/site-packages/unittest2/case.py", line 690, in fail
        raise self.failureException(msg)
    AssertionError: Models and migration scripts aren't in sync:
    [ [ ( 'modify_nullable',
          None,
          'ovn_revision_numbers',
          'created_at',
          { 'existing_server_default': False,
            'existing_type': DATETIME()},
          False,
          True)],
      [ ( 'modify_default',
          None,
          'ovn_revision_numbers',
          'revision_number',
          { 'existing_nullable': False,
            'existing_type': BIGINT(display_width=20)},
          None,
          DefaultClause('0', for_update=False))],
      [ ( 'modify_default',
          None,
          'ovn_revision_numbers',
          'updated_at',
          { 'existing_nullable': True,
            'existing_type': TIMESTAMP()},
          DefaultClause(<sqlalchemy.sql.elements.TextClause object at 0x7d9f690>, for_update=False),
          DefaultClause(<sqlalchemy.sql.functions.now at 0x5f1ea10; now>, for_update=False))]]

[0] https://github.com/openstack/neutron/blob/ea89748b0e4e70dfd70b1435da23c8936497123e/tools/configure_for_func_testing.sh

Changed in networking-ovn:
status: New → Confirmed
importance: Undecided → High
assignee: nobody → Lucas Alvares Gomes (lucasagomes)
Changed in networking-ovn:
status: Confirmed → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to networking-ovn (master)

Reviewed: https://review.openstack.org/563994
Committed: https://git.openstack.org/cgit/openstack/networking-ovn/commit/?id=b892650a6e62ac71679409cac767b58d867021bf
Submitter: Zuul
Branch: master

commit b892650a6e62ac71679409cac767b58d867021bf
Author: Lucas Alvares Gomes <email address hidden>
Date: Tue Apr 24 15:31:09 2018 +0100

    Fix test_models_sync() functional test

    This patch is fixing the test_models_sync() test from oslo.db by removing
    the inconsistencies from the models.py module and the migration script
    for the ovn_revision_numbers table.

    Note that this test doesn't current run in our gate, it gets skipped
    because the databases are not properly configured when setting up the
    functional tests. For now, it's possible to configure mysql by hand to
    test this patch by doing the following:

    1. Stack DevStack as per our documentation

    2. Configure Mysql:

      $ cat << EOF > /tmp/mysql.sql
      CREATE DATABASE openstack_citest;
      CREATE USER 'openstack_citest'@'localhost' IDENTIFIED BY
      'openstack_citest';
      CREATE USER 'openstack_citest' IDENTIFIED BY 'openstack_citest';
      GRANT ALL PRIVILEGES ON *.* TO 'openstack_citest'@'localhost';
      GRANT ALL PRIVILEGES ON *.* TO 'openstack_citest';
      FLUSH PRIVILEGES;
      EOF

      $ /usr/bin/mysql -u root < /tmp/mysql.sql

    3. Change to the networking-ovn directory

      $ cd ~/networking-ovn

    4. Run the test_models_sync() functional test:

      $ tox -edsvm-functional TestModelsMigrationsMysql.test_models_sync

    Partial-Bug: #1766639
    Change-Id: Ie3b600d4f3d7a3d594685848f35868c438f20976

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Reviewed: https://review.openstack.org/564152
Committed: https://git.openstack.org/cgit/openstack/networking-ovn/commit/?id=77a38a1ce7d85e872ef1967831cb24863dbdfc0a
Submitter: Zuul
Branch: master

commit 77a38a1ce7d85e872ef1967831cb24863dbdfc0a
Author: Lucas Alvares Gomes <email address hidden>
Date: Wed Apr 25 10:40:23 2018 +0100

    Properly configure the environment for functional tests

    This patch is configuring the functional tests environment so we can
    also run the database migration tests.

    The patch includes a new script at tools/configure_for_func_testing.sh
    which runs as part of the gate_hook.sh for the dsvm-functional tests and
    is responsible for installing and configuring the environment.

    Closes-Bug: #1766639
    Change-Id: I0df72a17f78c011d68ae5662e8550ce7714c1680

Changed in networking-ovn:
status: In Progress → Fix Released
tags: added: networking-ovn-proactive-backport-potential
tags: added: networking-ovn-easy-proactive-backport-potential
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/networking-ovn 5.0.0.0b2

This issue was fixed in the openstack/networking-ovn 5.0.0.0b2 development milestone.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to networking-ovn (stable/queens)

Fix proposed to branch: stable/queens
Review: https://review.openstack.org/580366

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on networking-ovn (stable/queens)

Change abandoned by Lucas Alvares Gomes (<email address hidden>) on branch: stable/queens
Review: https://review.openstack.org/580366
Reason: doesn't seem to be needed for queens?

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to networking-ovn (stable/queens)

Fix proposed to branch: stable/queens
Review: https://review.openstack.org/611877

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on networking-ovn (stable/queens)

Change abandoned by Lucas Alvares Gomes (<email address hidden>) on branch: stable/queens
Review: https://review.openstack.org/580366

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Change abandoned by Lucas Alvares Gomes (<email address hidden>) on branch: stable/queens
Review: https://review.openstack.org/611877

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.