Exemplo n.º 1
0
def test_migrate_couchdb_not_found(m_utils, m_sh):
    m_utils.ctx_opts.return_value.dry_run = False
    m_utils.path_exists.return_value = False

    migration.migrate_couchdb()

    assert m_sh.call_count == 0
Exemplo n.º 2
0
def test_migrate_couchdb_empty(m_utils, m_sh, mocker):
    m_utils.ctx_opts.return_value.dry_run = False
    httpretty.register_uri(
        httpretty.GET,
        'http://localhost:5984/_all_dbs',
        body=json.dumps(['unused'
                         ]),  # no known databases found -> nothing migrated
        adding_headers={'ContentType': 'application/json'},
    )
    migration.migrate_couchdb()
    assert len(httpretty.latest_requests()) == 1
Exemplo n.º 3
0
def from_couchdb():
    """Migrate configuration data from CouchDB to Redis.

    In the 2020/09/22 release (config version 0.6.0)
    Redis replaced CouchDB as configuration database.

    This command copies the configuration data from CouchDB to Redis.

    \b
    Steps:
        - Create CouchdDB container.
        - Fetch data from CouchDB.
        - Write data to Redis.
    """
    utils.check_config()
    utils.confirm_mode()
    migration.migrate_couchdb()
Exemplo n.º 4
0
def test_migrate_couchdb(m_utils, m_sh, mocker):
    m_utils.ctx_opts.return_value.dry_run = False
    httpretty.register_uri(
        httpretty.GET,
        'http://localhost:5984/_all_dbs',
        body=json.dumps(['brewblox-ui-store', 'spark-service']),
        adding_headers={'ContentType': 'application/json'},
    )
    httpretty.register_uri(
        httpretty.GET,
        'http://localhost:5984/brewblox-ui-store/_all_docs',
        body=json.dumps({
            'rows': [
                {
                    'doc': {
                        '_id': 'module__obj',
                        '_rev': '1234',
                        'k': 'v'
                    }
                },
                {
                    'doc': {
                        '_id': 'invalid',
                        '_rev': '1234',
                        'k': 'v'
                    }
                },
            ]
        }),
        adding_headers={'ContentType': 'application/json'},
    )
    httpretty.register_uri(
        httpretty.GET,
        'http://localhost:5984/spark-service/_all_docs',
        body=json.dumps({
            'rows': [
                {
                    'doc': {
                        '_id': 'spaced__id',
                        '_rev': '1234',
                        'k': 'v'
                    }
                },
                {
                    'doc': {
                        '_id': 'valid',
                        '_rev': '1234',
                        'k': 'v'
                    }
                },
            ]
        }),
        adding_headers={'ContentType': 'application/json'},
    )
    httpretty.register_uri(
        httpretty.POST,
        STORE_URL + '/mset',
        body='{"values":[]}',
        adding_headers={'ContentType': 'application/json'},
    )

    migration.migrate_couchdb()
    assert len(httpretty.latest_requests()) == 5
Exemplo n.º 5
0
def test_migrate_couchdb_dry(m_utils, m_sh):
    m_utils.ctx_opts.return_value.dry_run = True

    migration.migrate_couchdb()

    assert m_sh.call_count == 0