#
# 11-April-2023
#
#-------------------------------------------------------------------------
#
source [file join [file dirname [info script]] test_common.tcl]
set testprefix dmn_vtab2
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');
}
start_new_daemon 0
set cmd [bcvfs_create testdir.0 "bcvfs"]
bcvfs_attach $cmd cont1
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
}
db2 close
db close
$cmd destroy
wait_daemon 0
#-------------------------------------------------------------------------
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;
}
start_new_daemon 0 -httplognentry 8 -httplogtimeout 4
set cmd [bcvfs_create testdir.0 "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 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"
}
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.3 {
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
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
breakpoint
$cmd poll cont1
do_execsql_test 2.5 {
SELECT method, uri LIKE '%manifest%', client, logmsg FROM bcv_http_log;
} {
GET 1 "" ""
}
db close
db2 close
$cmd destroy
wait_daemon 0
finish_test