s3/test: use variable for inserted data
instead of repeating it, let's define it and reuse it later. Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
This commit is contained in:
@@ -70,12 +70,16 @@ storage_opts = format_tuples(type='S3',
|
||||
bucket=s3_public_bucket)
|
||||
ks = 'test_ks'
|
||||
cf = 'test_cf'
|
||||
rows = [('0', 'zero'),
|
||||
('1', 'one'),
|
||||
('2', 'two')]
|
||||
|
||||
conn.execute((f"CREATE KEYSPACE {ks} WITH"
|
||||
f" REPLICATION = {replication_opts} AND STORAGE = {storage_opts};"))
|
||||
conn.execute(f"CREATE TABLE {ks}.{cf} ( name text primary key, value text );")
|
||||
conn.execute(f"INSERT INTO {ks}.{cf} ( name, value ) VALUES ('0', 'zero');")
|
||||
conn.execute(f"INSERT INTO {ks}.{cf} ( name, value ) VALUES ('1', 'one');")
|
||||
conn.execute(f"INSERT INTO {ks}.{cf} ( name, value ) VALUES ('2', 'two');")
|
||||
for row in rows:
|
||||
cql_fmt = "INSERT INTO {}.{} ( name, value ) VALUES ('{}', '{}');"
|
||||
conn.execute(cql_fmt.format(ks, cf, *row))
|
||||
res = conn.execute(f"SELECT * FROM {ks}.{cf};")
|
||||
|
||||
r = requests.post(f'http://{ip}:10000/storage_service/keyspace_flush/{ks}', timeout=60)
|
||||
@@ -103,9 +107,8 @@ run.wait_for_services(pid, [ lambda: check_cql(ip) ])
|
||||
cluster = run.get_cql_cluster(ip)
|
||||
conn = cluster.connect()
|
||||
res = conn.execute(f"SELECT * FROM {ks}.{cf};")
|
||||
want_res = { '0': 'zero', '1': 'one', '2': 'two' }
|
||||
have_res = { x.name: x.value for x in res }
|
||||
if want_res != have_res:
|
||||
if have_res != dict(rows):
|
||||
print(f'Unexpected table content: {have_res}')
|
||||
success = False
|
||||
|
||||
|
||||
Reference in New Issue
Block a user