コード例 #1
0
def testDropTableBootConfiguration(mysqlBackendConfig, mySQLBackendConfigFile):
    """
    Test if the BOOT_CONFIGURATION table gets dropped with an update.
    """
    with cleanDatabase(MySQL(**mysqlBackendConfig)) as db:
        createRequiredTables(db)

        updateMySQLBackend(backendConfigFile=mySQLBackendConfigFile)

        assert 'BOOT_CONFIGURATION' not in getTableNames(db)
コード例 #2
0
def testAddingIndexToProductPropertyValues(mysqlBackendConfig,
                                           mySQLBackendConfigFile):
    with cleanDatabase(MySQL(**mysqlBackendConfig)) as db:
        createRequiredTables(db)

        updateMySQLBackend(backendConfigFile=mySQLBackendConfigFile)
        # Just making sure nothing breaks because checking if the right
        # index exists in mysql comes near totally senseless torture.

        # Calling the update procedure a second time must not fail.
        updateMySQLBackend(backendConfigFile=mySQLBackendConfigFile)
コード例 #3
0
def testCorrectingObjectToGroupGroupIdFieldLength(mysqlBackendConfig,
                                                  mySQLBackendConfigFile):
    with cleanDatabase(MySQL(**mysqlBackendConfig)) as db:
        createRequiredTables(db)

        updateMySQLBackend(backendConfigFile=mySQLBackendConfigFile)

        for column in getTableColumns(db, 'OBJECT_TO_GROUP'):
            if column.name == 'groupId':
                assert column.type.lower().startswith('varchar(')
                assert getColumnLength(column.type) == 255
                break
コード例 #4
0
def testIncreasingInventoryNumberFieldLength(mysqlBackendConfig,
                                             mySQLBackendConfigFile):
    with cleanDatabase(MySQL(**mysqlBackendConfig)) as db:
        createRequiredTables(db)

        updateMySQLBackend(backendConfigFile=mySQLBackendConfigFile)

        for column in getTableColumns(db, 'HOST'):
            if column.name == 'inventoryNumber':
                assert column.type.lower().startswith('varchar(')
                assert getColumnLength(column.type) == 64
                break
        else:
            raise RuntimeError("Expected to find matching column.")
コード例 #5
0
def testUpdatingCurrentBackendDoesBreakNothing(mysqlBackendConfig,
                                               mySQLBackendConfigFile):
    with cleanDatabase(MySQL(**mysqlBackendConfig)):
        with MySQLBackend(**mysqlBackendConfig) as freshBackend:
            freshBackend.backend_createBase()

        updateMySQLBackend(backendConfigFile=mySQLBackendConfigFile)
        # Updating again. Should break nothing.
        updateMySQLBackend(backendConfigFile=mySQLBackendConfigFile)

        with MySQLBackend(**mysqlBackendConfig) as anotherBackend:
            # We want to have the latest schema version
            assert DATABASE_SCHEMA_VERSION == readSchemaVersion(
                anotherBackend._sql)
コード例 #6
0
def testCorrectingProductIdLength(mysqlBackendConfig, mySQLBackendConfigFile):
    """
    Test if the product id length is correctly set.
    """
    with cleanDatabase(MySQL(**mysqlBackendConfig)) as db:
        createRequiredTables(db)

        updateMySQLBackend(backendConfigFile=mySQLBackendConfigFile)

        for tableName in ('PRODUCT_PROPERTY', ):
            print("Checking {0}...".format(tableName))

            assert tableName in getTableNames(db)

            assertColumnIsVarchar(db, tableName, 'productId', 255)
コード例 #7
0
def testInsertingSchemaNumber(mysqlBackendConfig, mySQLBackendConfigFile):
    with cleanDatabase(MySQL(**mysqlBackendConfig)) as db:
        createRequiredTables(db)

        updateMySQLBackend(backendConfigFile=mySQLBackendConfigFile)

        assert 'OPSI_SCHEMA' in getTableNames(db)

        for column in getTableColumns(db, 'OPSI_SCHEMA'):
            name = column.name
            if name == 'version':
                assert column.type.lower().startswith('int')
            elif name == 'updateStarted':
                assert column.type.lower().startswith('timestamp')
            elif name == 'updateEnded':
                assert column.type.lower().startswith('timestamp')
            else:
                raise Exception("Unexpected column!")
コード例 #8
0
def testCorrectingLicenseOnClientLicenseKeyLength(mysqlBackendConfig,
                                                  mySQLBackendConfigFile):
    """
    Test if the license key length is correctly set.

    An backend updated from an older version has the field 'licenseKey'
    on the LICENSE_ON_CLIENT table as VARCHAR(100).
    A fresh backend has the length of 1024.
    The size should be the same.
    """
    with cleanDatabase(MySQL(**mysqlBackendConfig)) as db:
        createRequiredTables(db)

        updateMySQLBackend(backendConfigFile=mySQLBackendConfigFile)

        for tableName in ('LICENSE_ON_CLIENT', 'SOFTWARE_CONFIG',
                          'SOFTWARE_LICENSE_TO_LICENSE_POOL'):
            print("Checking {0}...".format(tableName))

            assert tableName in getTableNames(db)

            assertColumnIsVarchar(db, tableName, 'licenseKey', 1024)
コード例 #9
0
def testAddingWorkbenchAttributesToHost(mysqlBackendConfig,
                                        mySQLBackendConfigFile):
    with cleanDatabase(MySQL(**mysqlBackendConfig)) as db:
        createRequiredTables(db)

        updateMySQLBackend(backendConfigFile=mySQLBackendConfigFile)

        changesFound = 0
        for column in getTableColumns(db, 'HOST'):
            if column.name == 'workbenchLocalUrl':
                assert column.type.lower().startswith('varchar(')
                assert getColumnLength(column.type) == 128
                changesFound += 1
            elif column.name == 'workbenchRemoteUrl':
                assert column.type.lower().startswith('varchar(')
                assert getColumnLength(column.type) == 255
                changesFound += 1

            if changesFound == 2:
                break

        assert changesFound == 2