Skip to content

Commit

Permalink
Merge #664
Browse files Browse the repository at this point in the history
664: Support running on PostgreSQL 15 r=Smittyvb a=Smittyvb

Fixes #648.

- [x] Fix all doctests that call `setseed`
- [x] Fix TimescaleDB crash in CI
- [x] Fix `random` function on pg12/pg13
- [x] Don't try to run upgrade tester on releases without PG15 binaries (currently this is all releases)

Things to fix in release-build-scripts (these don't block this PR):
- Drop Ubuntu 18.04 support (since TimescaleDB has also dropped support) (https://github.com/timescale/release-build-scripts/pull/94)
- Fix rockylinux 9 error in build scripts (`package curl-minimal-7.76.1-19.el9.x86_64 conflicts with curl provided by curl-7.76.1-19.el9.x86_64`)

This reverts commit ff66df6.

Co-authored-by: Smitty <smitty@timescale.com>
  • Loading branch information
bors[bot] and syvb committed Jan 3, 2023
2 parents c2b7f75 + ea55811 commit 4df0b89
Show file tree
Hide file tree
Showing 9 changed files with 149 additions and 158 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,9 @@ jobs:
run: su postgres -c 'sh tools/build -pg${{ matrix.pgversion }} test-extension 2>&1'

- name: Run doc tests
# TODO: remove this once TimescaleDB supports PostgreSQL 15: issue #648
if: ${{ matrix.pgversion != 15 }}
run: su postgres -c 'sh tools/build -pg${{ matrix.pgversion }} test-doc 2>&1'

- name: Run binary update tests
# TODO: remove this once TimescaleDB supports PostgreSQL 15: issue #648
if: ${{ matrix.pgversion != 15 }}
run: |
su postgres -c 'OS_NAME=debian OS_VERSION=11 tools/testbin -version no -bindir / -pgversions ${{ matrix.pgversion }} ci 2>&1'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/patch_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
- name: Run Doc Tests
run: |
docker run -d --name toolkit_test -e POSTGRES_HOST_AUTH_METHOD=trust -p 5432:5432 timescaledev/timescale-analytics:nightly
cargo run --manifest-path ./tools/sql-doctester/Cargo.toml -- -h localhost -s "CREATE EXTENSION timescaledb_toolkit; SET SESSION TIMEZONE TO 'UTC'" -p 5432 docs
cargo run --manifest-path ./tools/sql-doctester/Cargo.toml -- -h localhost -p 5432 docs
#TODO can/should we run our other tests also?

- name: Push
Expand Down
237 changes: 117 additions & 120 deletions docs/percentile_approximation.md

Large diffs are not rendered by default.

11 changes: 5 additions & 6 deletions docs/timeseries_pipeline_elements.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,11 @@ CREATE TABLE test_data(time TIMESTAMPTZ, device INTEGER, temperature DOUBLE PREC
In order to have some nominally interesting data to look at, let's populate this table with random data covering 30 days of readings over 10 devices.

```SQL ,non-transactional,ignore-output
SELECT setseed(0.456);
INSERT INTO test_data
SELECT
'2020-01-01 00:00:00+00'::timestamptz + ((random() * 2592000)::int * '1 second'::interval),
floor(random() * 10 + 1),
50 + random() * 20
'2020-01-01 00:00:00+00'::timestamptz + ((test_random() * 2592000)::int * '1 second'::interval),
floor(test_random() * 10 + 1),
50 + test_random() * 20
FROM generate_series(1,10000);
```

Expand Down Expand Up @@ -101,8 +100,8 @@ SELECT (deltas -> toolkit_experimental.lttb(10))::TEXT FROM daily_delta where de
```
```output
text
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
(version:1,num_points:10,flags:1,internal_padding:(0,0,0),points:[(ts:"2020-01-01 01:25:10+00",val:6.071850341376361),(ts:"2020-01-01 06:42:42+00",val:-19.012231731606803),(ts:"2020-01-05 07:18:48+00",val:15.050657902599482),(ts:"2020-01-10 09:35:14+00",val:-17.350077317333685),(ts:"2020-01-13 05:26:49+00",val:17.4527246179904),(ts:"2020-01-17 06:52:46+00",val:-19.59155342245161),(ts:"2020-01-21 12:43:25+00",val:18.586476656935602),(ts:"2020-01-24 09:45:35+00",val:-17.787766631363837),(ts:"2020-01-30 14:00:56+00",val:-15.147139203422384),(ts:"2020-01-30 23:50:41+00",val:10.993553071510647)],null_val:[0,0])
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
(version:1,num_points:10,flags:1,internal_padding:(0,0,0),points:[(ts:"2020-01-01 23:45:36+00",val:0),(ts:"2020-01-02 00:28:48+00",val:0.01999999999999602),(ts:"2020-01-02 17:45:36+00",val:0.020000000000003126),(ts:"2020-01-02 17:45:36+00",val:0),(ts:"2020-01-03 03:07:12+00",val:0.020000000000003126),(ts:"2020-01-03 20:24:00+00",val:0.01999999999999602),(ts:"2020-01-03 20:24:00+00",val:0),(ts:"2020-01-04 05:45:36+00",val:0.020000000000003126),(ts:"2020-01-04 23:02:24+00",val:0.020000000000003126),(ts:"2020-01-04 23:02:24+00",val:0)],null_val:[0,0])
```

## Current Pipeline Elements(A-Z) <a id="timevector-pipeline-elements"></a>
Expand Down
1 change: 0 additions & 1 deletion tools/build
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ while [ $# -gt 0 ]; do
$nop cargo run --profile $profile -p sql-doctester -- \
-h localhost \
-p $pg_port \
-s "CREATE EXTENSION timescaledb; CREATE EXTENSION timescaledb_toolkit; SET SESSION TIMEZONE TO 'UTC'" \
docs
$nop cargo pgx stop $pg
;;
Expand Down
23 changes: 1 addition & 22 deletions tools/sql-doctester/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use std::{
borrow::Cow,
collections::HashMap,
ffi::OsStr,
fs,
Expand Down Expand Up @@ -28,20 +27,6 @@ fn main() {
.takes_value(true),
)
.arg(Arg::new("DB").short('d').long("database").takes_value(true))
.arg(
Arg::new("START_SCRIPT")
.short('s')
.long("startup-script")
.takes_value(true)
.conflicts_with("START_FILE"),
)
.arg(
Arg::new("START_FILE")
.short('f')
.long("startup-file")
.takes_value(true)
.conflicts_with("START_SCRIPT"),
)
.arg(Arg::new("INPUT").takes_value(true))
.mut_arg("help", |_h| Arg::new("help").long("help"))
.get_matches();
Expand All @@ -56,13 +41,7 @@ fn main() {
database: matches.value_of("DB"),
};

let startup_script = match matches.value_of("START_SCRIPT") {
Some(script) => Some(Cow::Borrowed(script)),
None => matches.value_of("START_FILE").map(|file| {
let contents = fs::read_to_string(file).expect("cannot read script file");
Cow::Owned(contents)
}),
};
let startup_script = include_str!("startup.sql");

let all_tests = extract_tests(dirname);

Expand Down
7 changes: 3 additions & 4 deletions tools/sql-doctester/src/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,10 @@ impl<'s> ConnectionConfig<'s> {

pub fn run_tests<OnErr: FnMut(Test, TestError)>(
connection_config: ConnectionConfig<'_>,
startup_script: Option<Cow<'_, str>>,
startup_script: &str,
all_tests: Vec<TestFile>,
mut on_error: OnErr,
) {
let startup_script = startup_script.as_deref();
let root_connection_config = connection_config.config_string();
let root_connection_config = &*root_connection_config;
eprintln!("running {} test files", all_tests.len());
Expand Down Expand Up @@ -92,7 +91,7 @@ pub fn run_tests<OnErr: FnMut(Test, TestError)>(
}
};

if let (Some(db), Some(startup_script)) = (stateless_db.as_ref(), startup_script) {
if let Some(db) = stateless_db.as_ref() {
let stateless_connection_config = ConnectionConfig {
database: Some(db),
..connection_config
Expand Down Expand Up @@ -127,7 +126,7 @@ pub fn run_tests<OnErr: FnMut(Test, TestError)>(
let mut client = Client::connect(&test_connection_config.config_string(), NoTls)
.expect("could not connect to test DB");

if let (false, Some(startup_script)) = (tests.stateless, startup_script) {
if !tests.stateless {
let _ = client
.simple_query(startup_script)
.expect("could not run init script");
Expand Down
9 changes: 9 additions & 0 deletions tools/sql-doctester/src/startup.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CREATE EXTENSION timescaledb;
CREATE EXTENSION timescaledb_toolkit;
SET SESSION TIMEZONE TO 'UTC';

-- utility for generating random numbers
CREATE SEQUENCE rand START 567;
CREATE FUNCTION test_random() RETURNS float AS
'SELECT ((nextval(''rand'')*34567)%1000)::float/1000'
LANGUAGE SQL;
13 changes: 13 additions & 0 deletions tools/testbin
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,14 @@ skip_from_version() {
[ $FROM_VERSION = 1.10.0-dev ] && return
}

# Requires:
# - FROM_VERSION
# - PG_VERSION
skip_from_version_pg_version() {
# skip versions without PG15 binaries
[ $PG_VERSION -gt 14 ] && [ `cmp_version $FROM_VERSION` -lt 011301 ] && return
}

# Requires:
# - FROM_VERSION
deb_start_test() {
Expand All @@ -105,6 +113,7 @@ deb_start_test() {

[ $cmp_version -ge $MIN_DEB_EPOCH ] && EPOCH=1:
for PG_VERSION in $PG_VERSIONS; do
skip_from_version_pg_version && continue
select_pg $PG_VERSION
deb=timescaledb-toolkit-postgresql-${PG_VERSION}=${EPOCH}${FROM_VERSION}~${OS_NAME}${OS_VERSION}
$nop sudo apt-get -qq install $deb || die
Expand All @@ -118,6 +127,7 @@ test_deb() {
for FROM_VERSION; do
deb_start_test || continue
for PG_VERSION in $PG_VERSIONS; do
skip_from_version_pg_version && continue
select_pg $PG_VERSION
deb=timescaledb-toolkit-postgresql-${PG_VERSION}_${TOOLKIT_VERSION}~${OS_NAME}${OS_VERSION}_${ARCH}.deb
$nop sudo dpkg -i "$BINDIR/$deb"
Expand All @@ -139,6 +149,7 @@ test_ci() {
for FROM_VERSION; do
deb_start_test || continue
for PG_VERSION in $PG_VERSIONS; do
skip_from_version_pg_version && continue
select_pg $PG_VERSION
$nop sudo dpkg -P timescaledb-toolkit-postgresql-$PG_VERSION
# Installing (and possibly uninstalling) toolkit binary gives this back to root but we need to write to it.
Expand All @@ -155,6 +166,7 @@ test_rpm() {
for FROM_VERSION; do
skip_from_version && continue
for PG_VERSION in $PG_VERSIONS; do
skip_from_version_pg_version && continue
select_pg $PG_VERSION
rpm=timescaledb-toolkit-postgresql-$PG_VERSION
# yum doesn't seem to allow force-install of a specific version.
Expand All @@ -167,6 +179,7 @@ test_rpm() {
start_test
done
for PG_VERSION in $PG_VERSIONS; do
skip_from_version_pg_version && continue
select_pg $PG_VERSION
rpm=timescaledb-toolkit-postgresql-$PG_VERSION-$TOOLKIT_VERSION-0.el$OS_VERSION.$ARCH.rpm
$nop sudo rpm -U "$BINDIR/$rpm"
Expand Down

0 comments on commit 4df0b89

Please sign in to comment.