Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
haskell-pgmq
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
haskell-pgmq
Commits
e25f1411
Verified
Commit
e25f1411
authored
Jul 19, 2024
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[tests] fix pgmq docker image
Also, fixes to getting conn info from env vars (for tests)
parent
46ed4e1e
Pipeline
#6412
failed with stages
in 15 minutes and 4 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
28 additions
and
23 deletions
+28
-23
.gitlab-ci.yml
.gitlab-ci.yml
+1
-1
README.md
README.md
+1
-1
Broker.hs
tests/Test/Integration/Broker.hs
+5
-6
Simple.hs
tests/Test/Integration/PGMQ/Simple.hs
+12
-7
Worker.hs
tests/Test/Integration/Worker.hs
+5
-6
integration-tests.hs
tests/integration-tests.hs
+4
-2
No files found.
.gitlab-ci.yml
View file @
e25f1411
...
...
@@ -22,7 +22,7 @@ pgmq-integration-tests:
stage
:
integration-tests
image
:
haskell:9.4.7-slim
services
:
-
name
:
quay.io/tembo/pg16-pgmq:latest
-
name
:
docker.io/cgenie/pgmq:16-1.3.3.1
alias
:
pgmq
variables
:
# Configure postgres service (https://hub.docker.com/_/postgres/)
...
...
README.md
View file @
e25f1411
...
...
@@ -11,7 +11,7 @@ There is a binary in [./bin/simple-test/Main.hs](./bin/simple-test/Main.hs), it
First, let's decide which container to use:
```
shell
export
PGMQ_CONTAINER
=
quay.io/tembo/pg-16.pgmq:latest
export
PGMQ_CONTAINER
=
docker.io/cgenie/pgmq:16-1.3.3.1
```
However with the above, some tests might fail because some functions
throw errors when a table is not there (e.g.
`pgmq.drop_queue`
).
...
...
tests/Test/Integration/Broker.hs
View file @
e25f1411
...
...
@@ -14,10 +14,10 @@ where
import
Async.Worker.Broker.PGMQ
(
BrokerInitParams
(
..
),
PGMQBroker
)
import
Async.Worker.Broker.Types
qualified
as
BT
import
Control.Exception
(
bracket
)
import
Database.PostgreSQL.Simple
qualified
as
PSQL
import
Data.Aeson
(
ToJSON
(
..
),
FromJSON
(
..
),
withText
)
import
Data.Text
qualified
as
T
import
Test.Hspec
import
Test.Integration.PGMQ.Simple
(
getEnvConnectInfo
)
data
TestEnv
b
=
...
...
@@ -38,11 +38,10 @@ instance FromJSON Message where
pure
$
Message
{
text
=
T
.
unpack
text
}
pgmqBrokerInitParams
::
BT
.
BrokerInitParams
PGMQBroker
Message
pgmqBrokerInitParams
=
PGMQBrokerInitParams
$
PSQL
.
defaultConnectInfo
{
PSQL
.
connectUser
=
"postgres"
,
PSQL
.
connectDatabase
=
"postgres"
}
pgmqBrokerInitParams
::
IO
(
BT
.
BrokerInitParams
PGMQBroker
Message
)
pgmqBrokerInitParams
=
do
connectInfo
<-
getEnvConnectInfo
pure
$
PGMQBrokerInitParams
connectInfo
withBroker
::
(
BT
.
HasBroker
b
Message
)
...
...
tests/Test/Integration/PGMQ/Simple.hs
View file @
e25f1411
module
Test.Integration.PGMQ.Simple
(
pgmqSimpleTests
)
(
pgmqSimpleTests
,
getEnvConnectInfo
)
where
import
Async.Worker.Broker
qualified
as
B
...
...
@@ -23,17 +24,21 @@ data TestEnv =
testQueue
::
B
.
Queue
testQueue
=
"test"
setUpConn
::
IO
TestEnv
setUpConn
=
do
getEnvConnectInfo
::
IO
PSQL
.
ConnectInfo
getEnvConnectInfo
=
do
pgUser
<-
lookupEnv
"POSTGRES_USER"
pgDb
<-
lookupEnv
"POSTGRES_DB"
pgPass
<-
lookupEnv
"POSTGRES_PASSWORD"
pgHost
<-
lookupEnv
"POSTGRES_HOST"
-- https://hackage.haskell.org/package/postgresql-simple-0.7.0.0/docs/Database-PostgreSQL-Simple.html#t:ConnectInfo
let
connInfo
=
PSQL
.
defaultConnectInfo
{
PSQL
.
connectUser
=
fromMaybe
"postgres"
pgUser
,
PSQL
.
connectDatabase
=
fromMaybe
"postgres"
pgDb
,
PSQL
.
connectHost
=
fromMaybe
"localhost"
pgHost
,
PSQL
.
connectPassword
=
fromMaybe
"postgres"
pgPass
}
pure
$
PSQL
.
defaultConnectInfo
{
PSQL
.
connectUser
=
fromMaybe
"postgres"
pgUser
,
PSQL
.
connectDatabase
=
fromMaybe
"postgres"
pgDb
,
PSQL
.
connectHost
=
fromMaybe
"localhost"
pgHost
,
PSQL
.
connectPassword
=
fromMaybe
"postgres"
pgPass
}
setUpConn
::
IO
TestEnv
setUpConn
=
do
connInfo
<-
getEnvConnectInfo
conn
<-
PSQL
.
connect
connInfo
return
$
TestEnv
{
conn
,
queue
=
testQueue
}
...
...
tests/Test/Integration/Worker.hs
View file @
e25f1411
...
...
@@ -21,8 +21,8 @@ import Control.Concurrent.STM (atomically)
import
Control.Concurrent.STM.TVar
import
Control.Exception
(
bracket
,
Exception
,
throwIO
)
import
Data.Aeson
(
ToJSON
(
..
),
FromJSON
(
..
),
object
,
(
.=
),
(
.:
),
withObject
)
import
Database.PostgreSQL.Simple
qualified
as
PSQL
import
Test.Hspec
import
Test.Integration.PGMQ.Simple
(
getEnvConnectInfo
)
data
TestEnv
b
=
...
...
@@ -153,8 +153,7 @@ second :: Int
second
=
1000000
pgmqWorkerBrokerInitParams
::
BT
.
BrokerInitParams
PGMQBroker
(
Job
Message
)
pgmqWorkerBrokerInitParams
=
PGMQBrokerInitParams
$
PSQL
.
defaultConnectInfo
{
PSQL
.
connectUser
=
"postgres"
,
PSQL
.
connectDatabase
=
"postgres"
}
pgmqWorkerBrokerInitParams
::
IO
(
BT
.
BrokerInitParams
PGMQBroker
(
Job
Message
))
pgmqWorkerBrokerInitParams
=
do
connectInfo
<-
getEnvConnectInfo
pure
$
PGMQBrokerInitParams
connectInfo
tests/integration-tests.hs
View file @
e25f1411
...
...
@@ -10,8 +10,10 @@ import Test.Tasty.Hspec
main
::
IO
()
main
=
do
brokerSpec
<-
testSpec
"brokerTests"
(
brokerTests
pgmqBrokerInitParams
)
workerSpec
<-
testSpec
"workerTests"
(
workerTests
pgmqWorkerBrokerInitParams
)
pgmqBInitParams
<-
pgmqBrokerInitParams
brokerSpec
<-
testSpec
"brokerTests"
(
brokerTests
pgmqBInitParams
)
pgmqWBInitParams
<-
pgmqWorkerBrokerInitParams
workerSpec
<-
testSpec
"workerTests"
(
workerTests
pgmqWBInitParams
)
pgmqSimpleSpec
<-
testSpec
"pgmqSimpleTests"
pgmqSimpleTests
defaultMain
$
testGroup
"integration tests"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment