Skip to content

Commit

Permalink
Integration Test for PostgreSQL and Manticore using Docker (#93)
Browse files Browse the repository at this point in the history
* Created test-postgres-docker.rec

---------

Co-authored-by: Pavel_Shilin <work@pavelshilin.com>
  • Loading branch information
PavelShilin89 and Pavel_Shilin authored Sep 17, 2024
1 parent 5e6f6a9 commit 141f7d8
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 0 deletions.
11 changes: 11 additions & 0 deletions clt_tests/tests/base/init.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
\c api_db;

CREATE TABLE a_block_element (
id SERIAL PRIMARY KEY,
name VARCHAR NOT NULL,
text JSONB
);

INSERT INTO a_block_element (name, text) VALUES
('Element 1', '{"key1": "value1"}'),
('Element 2', '{"key2": "value2"}');
22 changes: 22 additions & 0 deletions clt_tests/tests/base/manticore-indexer-postgres.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
source text_src {
type = pgsql
sql_host = postgres
sql_user = postgres
sql_pass = qazQASD!
sql_db = api_db
sql_port = 5432
sql_query = SELECT id, name from a_block_element
}

index text_idx {
type = plain
source = text_src
path = /var/lib/manticore/data
}

searchd {
listen = 127.0.0.1:9312
listen = 127.0.0.1:9306:mysql
listen = 127.0.0.1:9308:http
pid_file = /var/run/manticore/searchd.pid
}
37 changes: 37 additions & 0 deletions clt_tests/tests/test-postgres-docker.rec
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
––– block: ./base/init –––
––– input –––
docker network create app-network --driver bridge > /dev/null; echo $?
––– output –––
0
––– input –––
docker run -d --name postgres --network app-network -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=qazQASD! -e POSTGRES_DB=api_db -p 5432:5432 -v $(pwd)/clt_tests/tests/base/init.sql:/docker-entrypoint-initdb.d/init.sql postgres:latest > /dev/null 2>&1; echo $?
––– output –––
0
––– input –––
timeout 35 grep -m2 'database system is ready to accept connections' <(docker logs -f postgres 2>&1)
––– output –––
#!/\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}\.\d{3}/!# UTC [%{NUMBER}] LOG: database system is ready to accept connections
#!/\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}\.\d{3}/!# UTC [%{NUMBER}] LOG: database system is ready to accept connections
––– input –––
docker run -d -e CREATE_PLAIN_TABLES=1 --name manticore --network app-network -v $(pwd)/clt_tests/tests/base/manticore-indexer-postgres.conf:/etc/manticoresearch/manticore.conf manticoresoftware/manticore:current
––– output –––
#!/[0-9a-z]+/!#
––– input –––
if timeout 60 grep -qm1 'accepting connections' <(docker logs -f manticore); then echo 'accepting connections'; else echo 'Manticore failed to start properly in 60 seconds'; fi
––– output –––
accepting connections
––– input –––
docker exec manticore mysql -h0 -P9306 -e "SHOW TABLES\G;"
––– output –––
*************************** 1. row ***************************
Index: text_idx
Type: local
––– input –––
docker exec manticore mysql -h0 -P9306 -e "SELECT * FROM text_idx\G;"
––– output –––
*************************** 1. row ***************************
id: 1
name: Element 1
*************************** 2. row ***************************
id: 2
name: Element 2

0 comments on commit 141f7d8

Please sign in to comment.