#
# 11-April-2023
#
#-------------------------------------------------------------------------
#
source [file join [file dirname [info script]] test_common.tcl]
set testprefix bcvfs_vtab2
bcv_mkdir testdir
bcv_create_container cont1
bcv_upload_new_db cont1 test.db {
CREATE TABLE t1(x, y);
INSERT INTO t1 VALUES('one', 'two');
}
bcv_upload_new_db cont1 test.db2 {
CREATE TABLE t2(x, y);
INSERT INTO t2 VALUES('three', 'four');
}
set cmd [bcvfs_create testdir "bcvfs"]
bcvfs_attach $cmd cont1
#$cmd log http logcb
proc logcb {args} { puts $args }
sqlite3 db /cont1/test.db -vfs bcvfs
sqlite3_bcvfs_register_vtab db
do_execsql_test 1.1 {
PRAGMA table_info = bcv_http_log
} {
0 id INTEGER 0 {} 0
1 start_time TEXT 0 {} 0
2 end_time TEXT 0 {} 0
3 method TEXT 0 {} 0
4 client TEXT 0 {} 0
5 logmsg TEXT 0 {} 0
6 uri TEXT 0 {} 0
7 httpcode INTEGER 0 {} 0
}
do_execsql_test 1.2 {
SELECT method, uri LIKE '%manifest%', client, httpcode
FROM bcv_http_log
} {
GET 1 "" 200
GET 0 "" 200
}
# execsql_pp { SELECT * FROM bcv_http_log }
do_execsql_test 1.3 { PRAGMA bcv_client } {}
do_execsql_test 1.4 { PRAGMA bcv_client = 'myclient' } {myclient}
do_execsql_test 1.5 { PRAGMA bcv_client } {myclient}
sqlite3 db2 /cont1/test.db2 -vfs bcvfs
do_execsql_test 1.6 {
SELECT method, uri LIKE '%manifest%', client, httpcode
FROM bcv_http_log
} {
GET 1 "" 200
GET 0 "" 200
}
do_test 1.7 {
db2 eval {
PRAGMA bcv_client = 'myclient2';
SELECT * FROM t2;
}
} {myclient2 three four}
do_execsql_test 1.8 {
SELECT method, uri LIKE '%manifest%', client, httpcode
FROM bcv_http_log
} {
GET 1 "" 200
GET 0 "" 200
GET 0 myclient2 200
}
db close
db2 close
$cmd destroy
#-------------------------------------------------------------------------
bcv_mkdir testdir
bcv_create_container cont1
bcv_upload_new_db cont1 test.db {
CREATE TABLE t1(x, y);
WITH s(i) AS (
SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<2000
)
INSERT INTO t1 SELECT randomblob(300), randomblob(300) FROM s;
}
set cmd [bcvfs_create testdir "bcvfs"]
bcvfs_attach $cmd cont1
sqlite3 db /cont1/test.db -vfs bcvfs
sqlite3_bcvfs_register_vtab db
do_execsql_test 2.0 {
SELECT method, uri LIKE '%manifest%', client, logmsg FROM bcv_http_log
} {
GET 1 "" ""
GET 0 "" "demand 0 of test.db"
}
do_execsql_test 2.1 {
SELECT * FROM t1 WHERE y IS NULL;
SELECT method, uri LIKE '%manifest%', client, logmsg FROM bcv_http_log
} {
GET 1 "" ""
GET 0 "" "demand 0 of test.db"
GET 0 "" "demand 1 of test.db"
GET 0 "" "demand 2 of test.db"
GET 0 "" "demand 3 of test.db"
GET 0 "" "demand 4 of test.db"
GET 0 "" "demand 5 of test.db"
GET 0 "" "demand 6 of test.db"
GET 0 "" "demand 7 of test.db"
GET 0 "" "demand 8 of test.db"
GET 0 "" "demand 9 of test.db"
GET 0 "" "demand 10 of test.db"
}
$cmd config httplog_nentry 8
do_execsql_test 2.2 {
SELECT method, uri LIKE '%manifest%', client, logmsg FROM bcv_http_log
} {
GET 0 "" "demand 3 of test.db"
GET 0 "" "demand 4 of test.db"
GET 0 "" "demand 5 of test.db"
GET 0 "" "demand 6 of test.db"
GET 0 "" "demand 7 of test.db"
GET 0 "" "demand 8 of test.db"
GET 0 "" "demand 9 of test.db"
GET 0 "" "demand 10 of test.db"
}
$cmd config httplog_nentry 8
bcv_upload_new_db cont1 test.db2 {
CREATE TABLE t1(x, y);
WITH s(i) AS (
SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<2000
)
INSERT INTO t1 SELECT randomblob(300), randomblob(300) FROM s;
}
$cmd poll cont1
do_execsql_test 2.2 {
SELECT method, uri LIKE '%manifest%', client, logmsg FROM bcv_http_log
} {
GET 0 "" "demand 4 of test.db"
GET 0 "" "demand 5 of test.db"
GET 0 "" "demand 6 of test.db"
GET 0 "" "demand 7 of test.db"
GET 0 "" "demand 8 of test.db"
GET 0 "" "demand 9 of test.db"
GET 0 "" "demand 10 of test.db"
GET 1 "" ""
}
sqlite3 db2 /cont1/test.db2 -vfs bcvfs
$cmd config httplog_timeout 4
do_test 2.3 {
db2 eval { SELECT count(*) FROM sqlite_schema; }
} {1}
do_execsql_test 2.4 {
SELECT method, uri LIKE '%manifest%', client, logmsg FROM bcv_http_log;
} {
GET 0 "" "demand 5 of test.db"
GET 0 "" "demand 6 of test.db"
GET 0 "" "demand 7 of test.db"
GET 0 "" "demand 8 of test.db"
GET 0 "" "demand 9 of test.db"
GET 0 "" "demand 10 of test.db"
GET 1 "" ""
GET 0 "" "demand 0 of test.db2"
}
wait_ms 4500
do_execsql_test 2.5 {
SELECT method, uri LIKE '%manifest%', client, logmsg FROM bcv_http_log;
} {
}
$cmd poll cont1
do_execsql_test 2.6 {
SELECT method, uri LIKE '%manifest%', client, logmsg FROM bcv_http_log;
} {
GET 1 "" ""
}
db close
db2 close
$cmd destroy
finish_test