Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
ef4f6064
Commit
ef4f6064
authored
Oct 12, 2017
by
Stan Hu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test PostgreSQL 9.6 and postgres_fdw with Geo specs
parent
8df74d55
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
67 additions
and
2 deletions
+67
-2
.gitlab-ci.yml
.gitlab-ci.yml
+19
-0
lib/gitlab/geo.rb
lib/gitlab/geo.rb
+12
-0
scripts/prepare_postgres_fdw.sh
scripts/prepare_postgres_fdw.sh
+10
-0
spec/lib/gitlab/geo_spec.rb
spec/lib/gitlab/geo_spec.rb
+21
-1
spec/spec_helper.rb
spec/spec_helper.rb
+4
-0
spec/workers/geo/file_download_dispatch_worker_spec.rb
spec/workers/geo/file_download_dispatch_worker_spec.rb
+1
-1
No files found.
.gitlab-ci.yml
View file @
ef4f6064
...
...
@@ -69,6 +69,12 @@ stages:
-
redis:alpine
-
docker.elastic.co/elasticsearch/elasticsearch:5.5.2
.use-pg-9-6
:
&use-pg-9-6
services
:
-
postgres:9.6
-
redis:alpine
-
docker.elastic.co/elasticsearch/elasticsearch:5.5.2
.use-mysql
:
&use-mysql
services
:
-
mysql:latest
...
...
@@ -117,6 +123,17 @@ stages:
<<
:
*use-pg
<<
:
*except-docs
.rspec-geo-pg-9-6
:
&rspec-metadata-pg-geo
<<
:
*use-pg-9-6
<<
:
*except-docs
stage
:
test
script
:
-
export NO_KNAPSACK=1
-
export CACHE_CLASSES=true
-
source scripts/prepare_postgres_fdw.sh
-
scripts/gitaly-test-spawn
-
bundle exec rspec --color --format documentation --tag geo spec/
.rspec-metadata-mysql
:
&rspec-metadata-mysql
<<
:
*rspec-metadata
<<
:
*use-mysql
...
...
@@ -338,6 +355,8 @@ rspec-pg 22 25: *rspec-metadata-pg
rspec-pg 23 25
:
*rspec-metadata-pg
rspec-pg 24 25
:
*rspec-metadata-pg
rspec-pg geo
:
*rspec-metadata-pg-geo
rspec-mysql 0 25
:
*rspec-metadata-mysql
rspec-mysql 1 25
:
*rspec-metadata-mysql
rspec-mysql 2 25
:
*rspec-metadata-mysql
...
...
lib/gitlab/geo.rb
View file @
ef4f6064
...
...
@@ -74,6 +74,18 @@ module Gitlab
GeoNode
.
where
(
host:
host
,
port:
port
).
exists?
end
def
self
.
fdw?
self
.
cache_value
(
:geo_fdw?
)
do
::
Geo
::
BaseRegistry
.
connection
.
execute
(
"SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = '
#{
self
.
fdw_schema
}
' AND table_type = 'FOREIGN TABLE'"
).
first
.
fetch
(
'count'
).
to_i
.
positive?
end
end
def
self
.
fdw_schema
'gitlab_secondary'
.
freeze
end
def
self
.
repository_sync_job
Sidekiq
::
Cron
::
Job
.
find
(
'geo_repository_sync_worker'
)
end
...
...
scripts/prepare_postgres_fdw.sh
0 → 100755
View file @
ef4f6064
#!/bin/bash
psql
-h
postgres
-U
postgres gitlabhq_geo_test
<<
EOF
CREATE EXTENSION postgres_fdw;
CREATE SERVER gitlab_secondary FOREIGN DATA WRAPPER postgres_fdw OPTIONS (host 'localhost', dbname 'gitlabhq_test');
CREATE USER MAPPING FOR current_user SERVER gitlab_secondary OPTIONS (user 'postgres', password '');
CREATE SCHEMA gitlab_secondary;
IMPORT FOREIGN SCHEMA public FROM SERVER gitlab_secondary INTO gitlab_secondary;
GRANT USAGE ON FOREIGN SERVER gitlab_secondary TO current_user;
EOF
spec/lib/gitlab/geo_spec.rb
View file @
ef4f6064
require
'spec_helper'
describe
Gitlab
::
Geo
do
describe
Gitlab
::
Geo
,
:geo
do
include
::
EE
::
GeoHelpers
set
(
:primary_node
)
{
create
(
:geo_node
,
:primary
)
}
...
...
@@ -18,6 +18,26 @@ describe Gitlab::Geo do
end
end
describe
'fdw?'
do
let
(
:fdw_check
)
{
"SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = 'gitlab_secondary' AND table_type = 'FOREIGN TABLE'"
}
before
do
allow
(
::
Geo
::
BaseRegistry
.
connection
).
to
receive
(
:execute
).
with
(
anything
).
and_call_original
end
it
'returns true when PostgreSQL FDW is enabled'
do
expect
(
::
Geo
::
BaseRegistry
.
connection
).
to
receive
(
:execute
).
with
(
fdw_check
).
and_return
([{
'count'
=>
1
}])
expect
(
described_class
.
fdw?
).
to
be_truthy
end
it
'returns false when PostgreSQL FDW is not enabled'
do
expect
(
::
Geo
::
BaseRegistry
.
connection
).
to
receive
(
:execute
).
with
(
fdw_check
).
and_return
([{
'count'
=>
0
}])
expect
(
described_class
.
fdw?
).
to
be_falsey
end
end
describe
'primary?'
do
context
'when current node is a primary node'
do
it
'returns true'
do
...
...
spec/spec_helper.rb
View file @
ef4f6064
...
...
@@ -181,6 +181,10 @@ RSpec.configure do |config|
example
.
run
if
Group
.
supports_nested_groups?
end
config
.
around
(
:each
,
:geo
)
do
|
example
|
example
.
run
if
Gitlab
::
Database
.
postgresql?
end
config
.
around
(
:each
,
:postgresql
)
do
|
example
|
example
.
run
if
Gitlab
::
Database
.
postgresql?
end
...
...
spec/workers/geo/file_download_dispatch_worker_spec.rb
View file @
ef4f6064
require
'spec_helper'
describe
Geo
::
FileDownloadDispatchWorker
,
:
postgresql
do
describe
Geo
::
FileDownloadDispatchWorker
,
:
geo
do
include
::
EE
::
GeoHelpers
set
(
:primary
)
{
create
(
:geo_node
,
:primary
,
host:
'primary-geo-node'
)
}
...
...
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