import time import pytest import dbconnection.db as dbconnection @pytest.fixture def db(): database = dbconnection.DB() database.connect() return database def test_tiflash(db: dbconnection.DB): create_sql = """ /* Table t1: Clustered */ DROP TABLE IF EXISTS test.p; DROP TABLE IF EXISTS test.c; /* Table p will contain 524288 rows */ CREATE TABLE test.p ( pid INT PRIMARY KEY AUTO_INCREMENT, insert_batch_id INT NOT NULL, charname CHAR(100) NOT NULL, varname VARCHAR(30) NOT NULL ); /* Table c will contain 8388608 rows */ CREATE TABLE test.c ( cid INT PRIMARY KEY AUTO_INCREMENT, pid INT NOT NULL, insert_batch_id INT NOT NULL, charname CHAR(100) NOT NULL, varname VARCHAR(30) NOT NULL );""" db.query(create_sql) db.query("ALTER TABLE test.p SET TIFLASH REPLICA 1") # wait max 50s and every 5 second check if the tiflash is available for i in range(10): result = db.query("SELECT available FROM information_schema.tiflash_replica WHERE table_schema='test' AND table_name in ('p')") print(result) if result[0][0] == 1: assert True return time.sleep(5) # fail if tiflash is not available assert False