Ejemplo n.º 1
0
    def test_reindex(self):
        crate_v3 = CrateNode(crate_dir=get_crate('3.x.x'),
                             keep_data=True,
                             settings=self.crate_settings)
        self._to_stop.append(crate_v3)
        crate_v3.start()
        with client(crate_v3.http_url) as c:
            aio.run(c.execute, "create table t (x int)")
            args = (
                (1, ),
                (2, ),
                (3, ),
            )
            aio.run(c.execute_many, "insert into t (x) values (?)", args)
        crate_v3.stop()
        self._to_stop.remove(crate_v3)

        crate_v4 = CrateNode(crate_dir=get_crate('4.0.3'),
                             keep_data=True,
                             settings=self.crate_settings)
        self._to_stop.append(crate_v4)
        crate_v4.start()
        reindex(crate_v4.http_url)
        with client(crate_v4.http_url) as c:
            result = aio.run(
                c.execute,
                "SELECT version FROM information_schema.tables WHERE table_name = 't'"
            )
            version = result['rows'][0][0]
            self.assertEqual(version, {'upgraded': None, 'created': '4.0.3'})

            cnt = aio.run(c.execute, 'SELECT count(*) FROM t')['rows'][0][0]
            self.assertEqual(cnt, 3)
Ejemplo n.º 2
0
    def test_reindex(self):
        crate_v3 = CrateNode(crate_dir=get_crate('3.x.x'),
                             keep_data=True,
                             settings=self.crate_settings)
        self._to_stop.append(crate_v3)
        crate_v3.start()
        with connect(crate_v3.http_url) as conn:
            cur = conn.cursor()
            cur.execute("create table t (x int)")
            args = (
                (1, ),
                (2, ),
                (3, ),
            )
            cur.executemany("insert into t (x) values (?)", args)
        crate_v3.stop()
        self._to_stop.remove(crate_v3)

        crate_v4 = CrateNode(crate_dir=get_crate('4.0.3'),
                             keep_data=True,
                             settings=self.crate_settings)
        self._to_stop.append(crate_v4)
        crate_v4.start()
        reindex(crate_v4.http_url)
        with connect(crate_v4.http_url) as conn:
            cur = conn.cursor()
            cur.execute(
                "SELECT version FROM information_schema.tables WHERE table_name = 't'"
            )
            version, = cur.fetchone()
            self.assertEqual(version, {'upgraded': None, 'created': '4.0.3'})

            cur.execute('SELECT count(*) FROM t')
            cnt, = cur.fetchone()
            self.assertEqual(cnt, 3)