Skip to content

Commit 1f4607b

Browse files
- Rust test improvement.
1 parent 31bf2fb commit 1f4607b

3 files changed

Lines changed: 20 additions & 13 deletions

File tree

src/main.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ fn pq_query(conn: &libpq::Connection, query: &str, notices: SharedNotices) -> Re
104104
Ok(())
105105
}
106106

107-
fn pq_main(query_str: &str) -> Result<(), Box<dyn std::error::Error>> {
108-
let conninfo = "host=localhost port=5888";
107+
fn pq_main(query_str: &str, dsn: &str) -> Result<(), Box<dyn std::error::Error>> {
108+
let conninfo = dsn.to_string();
109109
// let query_str = "\
110110
// SELECT repo, count(*) as has_starred \
111111
// FROM github.activity.repo_stargazers \
@@ -136,12 +136,13 @@ fn pq_main(query_str: &str) -> Result<(), Box<dyn std::error::Error>> {
136136

137137
fn main() {
138138
let all_args = env::args().collect::<Vec<String>>();
139-
if all_args.len() < 2 {
140-
println!("Need to at least supply query argument.");
139+
if all_args.len() < 3 {
140+
println!("Need to at least supply query argument and dsn.");
141141
exit(1);
142142
}
143143
let query = &all_args[1];
144-
if let Err(e) = pq_main(&query) {
144+
let dsn = &all_args[2];
145+
if let Err(e) = pq_main(&query, &dsn) {
145146
eprintln!("Error: {}", e);
146147
exit(1);
147148
}

test/robot/functional/stackql.resource

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ Start StackQL PG Server unencrypted
148148
... \-\-pgsrv\.address\=0.0.0.0
149149
... \-\-pgsrv\.port\=${_SRV_PORT_UNENCRYPTED}
150150
... \-\-namespaces\=${_NAMESPACES_CFG}
151+
... \-\-pgsrv\.debug\.enable\=true
151152
... \-\-sqlBackend\=${_SQL_BACKEND_CFG}
152153
... \-\-dbInternal\=${DB_INTERNAL_CFG_LAX}
153154
... \-\-execution\.concurrency\.limit\=${CONCURRENCY_LIMIT}
@@ -161,7 +162,7 @@ Start StackQL PG Server unencrypted
161162
... stackqlsrv
162163
... bash
163164
... \-c
164-
... sleep 2 && stackql srv \-\-execution\.concurrency\.limit\=${CONCURRENCY_LIMIT} \-\-registry\='${REGISTRY_NO_VERIFY_CFG_STR.get_config_str('docker')}' \-\-auth\='${AUTH_CFG_STR}' \-\-namespaces\='${_NAMESPACES_CFG}' \-\-sqlBackend\='${_SQL_BACKEND_CFG}' \-\-dbInternal\='${DB_INTERNAL_CFG_LAX}' \-\-tls\.allowInsecure\=true \-\-pgsrv\.address\=0.0.0.0 \-\-pgsrv\.port\=${PG_SRV_PORT_DOCKER_UNENCRYPTED}
165+
... sleep 2 && stackql srv \-\-execution\.concurrency\.limit\=${CONCURRENCY_LIMIT} \-\-registry\='${REGISTRY_NO_VERIFY_CFG_STR.get_config_str('docker')}' \-\-pgsrv\.debug\.enable\=true \-\-auth\='${AUTH_CFG_STR}' \-\-namespaces\='${_NAMESPACES_CFG}' \-\-sqlBackend\='${_SQL_BACKEND_CFG}' \-\-dbInternal\='${DB_INTERNAL_CFG_LAX}' \-\-tls\.allowInsecure\=true \-\-pgsrv\.address\=0.0.0.0 \-\-pgsrv\.port\=${PG_SRV_PORT_DOCKER_UNENCRYPTED}
165166
... stderr=${CURDIR}/tmp/stdout-stackql-srv-unencrypted-${_SRV_PORT_UNENCRYPTED}.txt
166167
... stdout=${CURDIR}/tmp/stderr-stackql-srv-unencrypted-${_SRV_PORT_UNENCRYPTED}.txt
167168
END

test/robot/functional/stackql_sessions.robot

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ PG Session Debug Behaviour Canonical
4646
... AND Remove Environment Variable PGSSLKEY
4747
... AND Remove Environment Variable PGSSLROOTCERT
4848

49-
PG Session Debug Off Behaviour Canonical
50-
[Documentation] The unencrypted servers have debug off
49+
PG Session Debug On Unencryopted Server Behaviour Canonical
50+
[Documentation] The unencrypted servers also have debug on
5151
Set Environment Variable PGHOST ${PSQL_CLIENT_HOST}
5252
Set Environment Variable PGPORT ${PG_SRV_PORT_UNENCRYPTED}
5353
Set Environment Variable PGUSER stackql
@@ -61,6 +61,11 @@ PG Session Debug Off Behaviour Canonical
6161
... repo | has_starred
6262
... ------+-------------
6363
... (0 rows)
64+
${outputErrStr} = Catenate SEPARATOR=\n
65+
... NOTICE: a notice level event has occurred
66+
... DETAIL: http response status code: 403, response body: "{\\"message\\":\\"API rate limit exceeded for 111.1111.111.11. (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.) If you reach out to GitHub Support for help, please include the request ID AAAA:AAAA:BBBBBB:BBBBBB:BBBBBBBB and timestamp 2025-01-01 01:00:00 UTC.\\",\\"documentation_url\\":\\"https://docs.github.com/rest/overview/rate-limits-for-the-rest-api\\",\\"status\\":\\"403\\"}"
67+
...
68+
... http response status code: 403, response body: "{\\"message\\":\\"API rate limit exceeded for 111.1111.111.11. (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.) If you reach out to GitHub Support for help, please include the request ID AAAA:AAAA:BBBBBB:BBBBBB:BBBBBBBB and timestamp 2025-01-01 01:00:00 UTC.\\",\\"documentation_url\\":\\"https://docs.github.com/rest/overview/rate-limits-for-the-rest-api\\",\\"status\\":\\"403\\"}"
6469
${posixInput} = Catenate
6570
... "${PSQL_EXE}" -c "${inputStr}"
6671
${windowsInput} = Catenate
@@ -69,19 +74,19 @@ PG Session Debug Off Behaviour Canonical
6974
${shellExe} = Set Variable If "${IS_WINDOWS}" == "1" powershell sh
7075
${result} = Run Process
7176
... ${shellExe} \-c ${input}
72-
... stdout=${CURDIR}/tmp/PG-Session-Debug-Off-Behaviour-Canonical.tmp
73-
... stderr=${CURDIR}/tmp/PG-Session-Debug-Off-Behaviour-Canonical-stderr.tmp
77+
... stdout=${CURDIR}/tmp/PG-Session-Debug-On-Unencrypted-Server-Behaviour-Canonical.tmp
78+
... stderr=${CURDIR}/tmp/PG-Session-Debug-On-Unencrypted-Server-Behaviour-Canonical-stderr.tmp
7479
Log STDOUT = "${result.stdout}"
7580
Log STDERR = "${result.stderr}"
7681
# Should Contain ${result.stdout} ${outputStr} collapse_spaces=True
77-
Should Be Empty ${result.stderr}
82+
Should Contain ${result.stderr} ${outputErrStr} collapse_spaces=True
7883
[Teardown] Run Keywords Remove Environment Variable PGHOST
7984
... AND Remove Environment Variable PGPORT
8085
... AND Remove Environment Variable PGUSER
8186
... AND Remove Environment Variable PGPASSWORD
8287

8388
Rust Testing Client Positive Control Notice Messages from GitHub
84-
[Documentation] The unencrypted servers have debug off
89+
[Documentation] The unencrypted servers also have debug on
8590
Set Environment Variable PGHOST ${PSQL_CLIENT_HOST}
8691
Set Environment Variable PGPORT ${PG_SRV_PORT_UNENCRYPTED}
8792
Set Environment Variable PGUSER stackql
@@ -92,7 +97,7 @@ Rust Testing Client Positive Control Notice Messages from GitHub
9297
... WHERE owner = 'sillyorg' and repo in ('silly', 'silly-but-more') and login = 'sillylogin'
9398
... GROUP BY repo;
9499
${posixInput} = Catenate
95-
... "${RUST_TESTING_EXE}" "${inputStr}"
100+
... "${RUST_TESTING_EXE}" "${inputStr}" "localhost ${PG_SRV_PORT_UNENCRYPTED}"
96101
${windowsInput} = Catenate
97102
... & ${posixInput}
98103
${input} = Set Variable If "${IS_WINDOWS}" == "1" ${windowsInput} ${posixInput}

0 commit comments

Comments
 (0)