forked from pgmoneta/pgmoneta_ext
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
671 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
--- | ||
name: Bug report | ||
about: Create a report to help us improve | ||
title: '' | ||
labels: bug | ||
assignees: '' | ||
|
||
--- | ||
|
||
**Describe the bug** | ||
|
||
A clear and concise description of what the bug is. | ||
|
||
**To Reproduce** | ||
|
||
Steps to reproduce the behavior. | ||
|
||
**Version** | ||
|
||
What is the version of pgmoneta_ext ? | ||
|
||
**PostgreSQL** | ||
|
||
What is the version of PostgreSQL ? | ||
|
||
**Debug logs** | ||
|
||
Can you provide any debug logs (`log_level = debug5`) of the issue ? | ||
|
||
**Tip** | ||
|
||
Use \`\`\` before and after the text to keep the output as is. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
name: Feature request | ||
about: Suggest an idea for this project | ||
title: '' | ||
labels: feature | ||
assignees: '' | ||
|
||
--- | ||
|
||
**Is your feature request related to a problem? Please describe.** | ||
|
||
A clear and concise description of what the problem is. | ||
|
||
**Describe the solution you'd like** | ||
|
||
A clear and concise description of what you want to happen. | ||
|
||
**Additional information** | ||
|
||
Any additional information you can provide, like an overall design description |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# Test | ||
|
||
## Installation | ||
|
||
Since we are using source code to install, please first create a new user `postgres` for a normal installation. | ||
|
||
``` sh | ||
sudo adduser postgres | ||
``` | ||
|
||
Enter into the `/test` directory. | ||
|
||
``` sh | ||
chmod +x installation.sh | ||
``` | ||
|
||
Run `installation.sh` to install any necessary dependencies and configuration. | ||
|
||
``` sh | ||
./installation.sh | ||
``` | ||
|
||
The script will install PostgreSQL 13 by default. If you prefer to install a specific version, please input the version as shown below. It will automatically download and use the latest patch release number. You can find the source versions at [PostgreSQL GIT repository](https://github.com/postgres/postgres). | ||
|
||
``` sh | ||
./installation.sh 14 | ||
``` | ||
|
||
> IMPORTANT: | ||
> If you want to test different versions, please make sure you have deleted all previous version data, removed the role 'repl', and stopped the PostgreSQL server. Otherwise, it will raise some compatibility errors when you install and configure a new version. It is better to kill all current PostgreSQL processes. | ||
If you encounter the following error when creating the extension, you may need to inform the system where to find the `libpq.so.5` library. Use the command `echo "/usr/local/pgsql/lib" | sudo tee -a /etc/ld.so.conf` and then update the cache using `sudo ldconfig`. After this, you need to create the extension manually. | ||
|
||
``` console | ||
ERROR: could not load library "/usr/local/pgsql/lib/pgmoneta_ext.so": libpq.so.5: cannot open shared object file: No such file or directory | ||
``` | ||
|
||
If you see the error `could not change directory to "/home/pgmoneta/pgmoneta_ext/test/build": Permission denied`, it doesn't matter. This will not affect the execution of the command; it is just because you used `sudo`, which tries to change the current working directory. | ||
|
||
## Test functions | ||
|
||
If you have already installed `pgmoneta_ext` successfully and completed all configurations described in [DEVELOPERS.md](https://github.com/pgmoneta/pgmoneta_ext/blob/main/doc/DEVELOPERS.md#developer-guide), you can skip the **Installation** step above and directly follow the steps below to test the functions in the API extension. | ||
|
||
download dependencies | ||
|
||
``` sh | ||
dnf install check check-devel | ||
``` | ||
|
||
Enter into the `/test` directory. | ||
|
||
``` sh | ||
mkdir build | ||
cd build | ||
cmake .. | ||
make | ||
``` | ||
|
||
Before running the `pgmoneta_ext_test` executable, you need to set the `PGPASSWORD` environment variable for the `repl` role. For our setup, the password is `secretpassword`. Follow these steps: | ||
|
||
Set the `PGPASSWORD` environment variable: | ||
|
||
``` sh | ||
export PGPASSWORD='secretpassword' | ||
``` | ||
|
||
Run the `pgmoneta_ext_test` executable. | ||
|
||
``` sh | ||
./pgmoneta_ext_test | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
\newpage | ||
|
||
# Test suite | ||
|
||
## Installation | ||
|
||
Since we are using source code to install, please first create a new user `postgres` for a normal installation. | ||
|
||
``` sh | ||
sudo adduser postgres | ||
``` | ||
|
||
Enter into the `/test` directory. | ||
|
||
``` sh | ||
chmod +x installation.sh | ||
``` | ||
|
||
Run `installation.sh` to install any necessary dependencies and configuration. | ||
|
||
``` sh | ||
./installation.sh | ||
``` | ||
|
||
The script will install PostgreSQL 13 by default. If you prefer to install a specific version, please input the version as shown below. It will automatically download and use the latest patch release number. You can find the source versions at [PostgreSQL GIT repository][postgresqlrepo]. | ||
|
||
``` sh | ||
./installation.sh 14 | ||
``` | ||
|
||
> IMPORTANT: | ||
> If you want to test different versions, please make sure you have deleted all previous version data, removed the role 'repl', and stopped the PostgreSQL server. Otherwise, it will raise some compatibility errors when you install and configure a new version. It is better to kill all current PostgreSQL processes. | ||
If you encounter the following error when creating the extension, you may need to inform the system where to find the `libpq.so.5` library. Use the command `echo "/usr/local/pgsql/lib" | sudo tee -a /etc/ld.so.conf` and then update the cache using `sudo ldconfig`. After this, you need to create the extension manually. | ||
|
||
``` console | ||
ERROR: could not load library "/usr/local/pgsql/lib/pgmoneta_ext.so": libpq.so.5: cannot open shared object file: No such file or directory | ||
``` | ||
|
||
If you see the error `could not change directory to "/home/pgmoneta/pgmoneta_ext/test/build": Permission denied`, it doesn't matter. This will not affect the execution of the command; it is just because you used `sudo`, which tries to change the current working directory. | ||
|
||
## Test functions | ||
|
||
If you have already installed `pgmoneta_ext` successfully and completed all configurations described in [DEVELOPERS.md][developers], you can skip the **Installation** step above and directly follow the steps below to test the functions in the API extension. | ||
|
||
download dependencies | ||
|
||
``` sh | ||
dnf install check check-devel | ||
``` | ||
|
||
Enter into the `/test` directory. | ||
|
||
``` sh | ||
mkdir build | ||
cd build | ||
cmake .. | ||
make | ||
``` | ||
|
||
Before running the `pgmoneta_ext_test` executable, you need to set the `PGPASSWORD` environment variable for the `repl` role. For our setup, the password is `secretpassword`. Follow these steps: | ||
|
||
Set the `PGPASSWORD` environment variable: | ||
|
||
``` sh | ||
export PGPASSWORD='secretpassword' | ||
``` | ||
|
||
Run the `pgmoneta_ext_test` executable. | ||
|
||
``` sh | ||
./pgmoneta_ext_test | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# | ||
# Copyright (C) 2024 The pgmoneta community | ||
# | ||
# Redistribution and use in source and binary forms, with or without modification, | ||
# are permitted provided that the following conditions are met: | ||
# | ||
# 1. Redistributions of source code must retain the above copyright notice, this list | ||
# of conditions and the following disclaimer. | ||
# | ||
# 2. Redistributions in binary form must reproduce the above copyright notice, this | ||
# list of conditions and the following disclaimer in the documentation and/or other | ||
# materials provided with the distribution. | ||
# | ||
# 3. Neither the name of the copyright holder nor the names of its contributors may | ||
# be used to endorse or promote products derived from this software without specific | ||
# prior written permission. | ||
# | ||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY | ||
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | ||
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL | ||
# THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT | ||
# OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR | ||
# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
# | ||
|
||
cmake_minimum_required(VERSION 3.14) | ||
|
||
project(pgmoneta_ext_test C) | ||
|
||
set(CMAKE_C_STANDARD 11) | ||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra") | ||
|
||
find_library(CHECK_LIBRARY check PATHS /usr/lib64) | ||
find_path(CHECK_INCLUDE_DIR check.h PATHS /usr/include) | ||
|
||
if(CHECK_LIBRARY AND CHECK_INCLUDE_DIR) | ||
add_library(Check::check SHARED IMPORTED) | ||
set_target_properties(Check::check PROPERTIES | ||
IMPORTED_LOCATION ${CHECK_LIBRARY} | ||
INTERFACE_INCLUDE_DIRECTORIES ${CHECK_INCLUDE_DIR}) | ||
else() | ||
message(FATAL_ERROR "Check library not found") | ||
endif() | ||
|
||
if(EXISTS "/etc/debian_version") | ||
include_directories(/usr/include/subunit) | ||
endif() | ||
|
||
set(SOURCES | ||
pgmoneta_ext_test.c | ||
runner.c | ||
) | ||
|
||
add_executable(pgmoneta_ext_test ${SOURCES}) | ||
|
||
if(EXISTS "/etc/debian_version") | ||
target_link_libraries(pgmoneta_ext_test Check::check subunit pthread rt m) | ||
else() | ||
target_link_libraries(pgmoneta_ext_test Check::check pthread rt m) | ||
endif() | ||
|
||
|
||
add_custom_target(custom_clean | ||
COMMAND ${CMAKE_COMMAND} -E remove -f *.o pgmoneta_ext_test | ||
COMMENT "Cleaning up..." | ||
) |
Oops, something went wrong.