Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PG-1289: Add testcase to cover PGMajor.PGMinor.PerconaVersion #150

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ci_scripts/configure-tde-server.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#!/bin/bash

set -e

# This script is used to configure a TDE server for testing purposes.
export TDE_MODE=1
export PERCONA_SERVER_VERSION=17.4.1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need the variable for the configure command? It is only used by test commands


SCRIPT_DIR="$(cd -- "$(dirname "$0")" >/dev/null 2>&1; pwd -P)"
INSTALL_DIR="$SCRIPT_DIR/../../pginst"
Expand Down
5 changes: 3 additions & 2 deletions ci_scripts/make-build.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/bash

export TDE_MODE=1
export PERCONA_SERVER_VERSION=17.4.1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need the variable for the build command?


SCRIPT_DIR="$(cd -- "$(dirname "$0")" >/dev/null 2>&1; pwd -P)"
INSTALL_DIR="$SCRIPT_DIR/../../pginst"
Expand All @@ -12,5 +13,5 @@ if [ "$1" = "debugoptimized" ]; then
export CXXFLAGS="-O2"
fi

./configure --enable-debug --enable-cassert --enable-tap-tests --prefix=$INSTALL_DIR
make install-world -j
./configure --enable-debug --enable-cassert --enable-tap-tests --enable-coverage --prefix=$INSTALL_DIR
make install-world
19 changes: 19 additions & 0 deletions ci_scripts/make-test-tde-only.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name of this script is misleading, it's not tde-only but "only main regression suite with tde, without contrib".

Also it's a duplication of the other script, can't we make this an option to the existing make-test-tde script?


set -e

export TDE_MODE=1
export PERCONA_SERVER_VERSION=17.4.1

SCRIPT_DIR="$(cd -- "$(dirname "$0")" >/dev/null 2>&1; pwd -P)"
source $SCRIPT_DIR/configure-tde-server.sh

ADD_FLAGS=

if [ "$1" = "--continue" ]; then
ADD_FLAGS="-k"
fi

cd $SCRIPT_DIR/../contrib/pg_tde
pwd
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debug leftover?

EXTRA_REGRESS_OPTS="--extra-setup=$SCRIPT_DIR/tde_setup.sql" make installcheck $ADD_FLAGS
1 change: 1 addition & 0 deletions ci_scripts/make-test-tde.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
set -e

export TDE_MODE=1
export PERCONA_SERVER_VERSION=17.4.1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like this repeating.. With this, every time we update the version, we have to replace it at many places.

Can't we add it as a file called PERCONA_SERVER_VERSION, if we really want to do this?

Also, only the make scripts are updated, the meson scripts are left as-is.


SCRIPT_DIR="$(cd -- "$(dirname "$0")" >/dev/null 2>&1; pwd -P)"
source $SCRIPT_DIR/configure-tde-server.sh
Expand Down
1 change: 1 addition & 0 deletions ci_scripts/make-test.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/bash

export TDE_MODE=1
export PERCONA_SERVER_VERSION=17.4.1

SCRIPT_DIR="$(cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P)"
INSTALL_DIR="$SCRIPT_DIR/../../pginst"
Expand Down
1 change: 1 addition & 0 deletions ci_scripts/ubuntu-deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ DEPS=(
# Test pg_tde
python3-pykmip
libhttp-server-simple-perl
lcov
)

sudo apt-get update
Expand Down
85 changes: 85 additions & 0 deletions contrib/pg_tde/t/011_percona_server_version.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#!/usr/bin/perl
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file isn't executed at all, no related makefile or meson.build changes.

use strict;
use warnings;
use File::Basename;
use File::Compare;
use File::Copy;
use Test::More;
use lib 't';
use Env;
use pgtde;

# Get file name and CREATE out file name and dirs WHERE requried
PGTDE::setup_files_dir(basename($0));

# CREATE new PostgreSQL node and do initdb
my $node = PGTDE->pgtde_init_pg();
my $pgdata = $node->data_dir;

if (!defined($ENV{PERCONA_SERVER_VERSION}))
{
plan skip_all => "PERCONA_SERVER_VERSION variable not define in the environment.";
}

my $percona_expected_server_version = $ENV{PERCONA_SERVER_VERSION};

# UPDATE postgresql.conf to include/load pg_tde library
open my $conf, '>>', "$pgdata/postgresql.conf";
print $conf "shared_preload_libraries = 'pg_tde'\n";
close $conf;

# Start server
my $rt_value = $node->start;
ok($rt_value == 1, "Start Server");

# CREATE EXTENSION and change out file permissions
my ($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE EXTENSION pg_tde;', extra_params => ['-a']);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need the extension for this test? Why is this test in the extension folder?

ok($cmdret == 0, "CREATE PGTDE EXTENSION");
PGTDE::append_to_debug_file($stdout);

# Get PG Server version ( e.g 17.4) from pg_config
my $pg_server_version = `pg_config --version | awk {'print \$2'}`;
$pg_server_version=~ s/^\s+|\s+$//g;

PGTDE::append_to_debug_file($pg_server_version + "df");
PGTDE::append_to_debug_file($percona_expected_server_version);

# Check pg_config output.
my $pg_config_output = `pg_config --version`;
$pg_config_output=~ s/^\s+|\s+$//g;
cmp_ok($pg_config_output,'eq',"PostgreSQL $pg_server_version - Percona Server for PostgreSQL $percona_expected_server_version", "Test pg_config --version output");
PGTDE::append_to_debug_file("# Test pg_config --version output");
PGTDE::append_to_debug_file($pg_config_output);

# Check psql --version output.
my $psql_version_output = `psql --version`;
$psql_version_output=~ s/^\s+|\s+$//g;
cmp_ok($psql_version_output,'eq',"psql (PostgreSQL) $pg_server_version - Percona Server for PostgreSQL $percona_expected_server_version", "Test psql --version output");
PGTDE::append_to_debug_file("# Test psql --version output");
PGTDE::append_to_debug_file($psql_version_output);

# Check postgres --version output.
my $postgres_output = `postgres --version`;
$postgres_output=~ s/^\s+|\s+$//g;
cmp_ok($postgres_output,'eq',"postgres (PostgreSQL) $pg_server_version - Percona Server for PostgreSQL $percona_expected_server_version", "Test postgres --version output");
PGTDE::append_to_debug_file("# Test postgres --version output");
PGTDE::append_to_debug_file($postgres_output);

# Check select version() output.
($cmdret, $stdout, $stderr) = $node->psql('postgres', "select version();", extra_params => ['-a', '-Pformat=aligned','-Ptuples_only=on']);
ok($cmdret == 0, "# Get output of select version();");
$stdout=~ s/^\s+|\s+$//g;
like($stdout, "/PostgreSQL $pg_server_version - Percona Server for PostgreSQL $percona_expected_server_version/", "# Test select version() output");
PGTDE::append_to_debug_file("# Test select version() output");
PGTDE::append_to_debug_file($stdout);

# DROP EXTENSION
$stdout = $node->safe_psql('postgres', 'DROP EXTENSION pg_tde;', extra_params => ['-a']);
ok($cmdret == 0, "DROP PGTDE EXTENSION");
PGTDE::append_to_debug_file($stdout);

# Stop the server
$node->stop;

# Done testing for this testcase file.
done_testing();