EOX GitLab Instance
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
VS
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ESA
PRISM
VS
Commits
f641f591
Commit
f641f591
authored
5 years ago
by
Mussab Abdalla
Browse files
Options
Downloads
Patches
Plain Diff
adding a basic test for registrar
parent
77dec68e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
.gitlab-ci.yml
+11
-9
11 additions, 9 deletions
.gitlab-ci.yml
conftest.py
+10
-0
10 additions, 0 deletions
conftest.py
core/registrar.py
+3
-2
3 additions, 2 deletions
core/registrar.py
registrar_test.py
+38
-0
38 additions, 0 deletions
registrar_test.py
requirements.txt
+2
-1
2 additions, 1 deletion
requirements.txt
with
64 additions
and
12 deletions
.gitlab-ci.yml
+
11
−
9
View file @
f641f591
...
...
@@ -88,15 +88,17 @@ test:
-
chmod +x env_setup.sh wait_for_container.sh
-
./env_setup.sh
-
docker swarm init
-
docker stack deploy -c docker-compose.
vhr18
.yml -c docker-compose.
vhr18
.dev.yml
vhr18
-pvs
-
./wait_for_container.sh
-
docker stack deploy -c docker-compose.
emg
.yml -c docker-compose.
emg
.dev.yml
emg
-pvs
#
- ./wait_for_container.sh
-
docker ps
-
docker ps -qf "name=vhr18-pvs_renderer"
# - docker exec -it $(docker ps -qf "name=vhr18-pvs_renderer") python3 /var/www/pvs/dev/pvs_instance/manage.py id list
# - docker ps -qf "name=emg-pvs_registrar"
# - docker exec -it $(docker ps -qf "name=emg-pvs_registrar") python3 /var/www/pvs/dev/pvs_instance/manage.py id list
# - docker exec -it $(docker ps -qf "name=emg-pvs_registrar") python3 /core/registrar.py --objects-prefix "OA/PH1B/0.1/b9/urn:eop:PHR:MULTISPECTRAL_0.5m:DS_PHR1B_201608070959189_FR1_PX_E012N32_0719_00974_4148/0000/PH1B_PHR_FUS_1A_20160807T095918_20160807T095920_TOU_1234_4148.DIMA.tar"
# - pytest -s registrar_test.py --name OA/PH1B/0.1/b9/urn:eop:PHR:MULTISPECTRAL_0.5m:DS_PHR1B_201608070959189_FR1_PX_E012N32_0719_00974_4148/0000/PH1B_PHR_FUS_1A_20160807T095918_20160807T095920_TOU_1234_4148.DIMA.tar
# after_script:
# - docker stack rm vhr18-pvs
# - docker volume rm vhr18-pvs_db-data
# - docker volume rm vhr18-pvs_redis-data
# - docker volume rm vhr18-pvs_traefik-data
# - docker volume rm vhr18-pvs_cache-db
# - docker volume rm emg-pvs_db-data
# - docker volume rm emg-pvs_redis-data
# - docker volume rm emg-pvs_instance-data
# - docker volume rm emg-pvs_cache-db
\ No newline at end of file
This diff is collapsed.
Click to expand it.
conftest.py
0 → 100644
+
10
−
0
View file @
f641f591
def
pytest_addoption
(
parser
):
parser
.
addoption
(
"
--name
"
,
action
=
"
store
"
,
default
=
"
default name
"
)
def
pytest_generate_tests
(
metafunc
):
# This is called for every test. Only get/set command line arguments
# if the argument is specified in the list of test "fixturenames".
option_value
=
metafunc
.
config
.
option
.
name
if
'
name
'
in
metafunc
.
fixturenames
and
option_value
is
not
None
:
metafunc
.
parametrize
(
"
name
"
,
[
option_value
])
\ No newline at end of file
This diff is collapsed.
Click to expand it.
core/registrar.py
+
3
−
2
View file @
f641f591
...
...
@@ -143,6 +143,7 @@ def registrar(
container
=
upload_container
,
options
=
{
"
prefix
"
:
objects_prefix
},
)
for
page
in
list_parts_gen
:
print
(
page
)
if
page
[
"
success
"
]:
for
item
in
page
[
"
listing
"
]:
if
item
[
"
name
"
].
endswith
(
"
.xml
"
):
...
...
@@ -154,7 +155,7 @@ def registrar(
elif
item
[
"
name
"
].
endswith
(
"
.vrt
"
):
data_package
=
item
[
"
name
"
]
has_vrt
=
True
el
se
:
el
if
not
item
[
"
name
"
].
endswith
(
"
.tar
"
)
:
raise
RegistrationError
(
"
Product with objects prefix
'
%s
'
has
"
"
wrong content
'
%s
'
.
"
...
...
@@ -312,7 +313,7 @@ if __name__ == "__main__":
setup_logging
(
arg_values
.
verbosity
)
collection
=
os
.
environ
.
get
(
'
C
ollection
'
)
collection
=
os
.
environ
.
get
(
'
C
OLLECTION
'
)
if
collection
is
None
:
logger
.
critical
(
"
Collection environment variable not set.
"
)
sys
.
exit
(
1
)
...
...
This diff is collapsed.
Click to expand it.
registrar_test.py
0 → 100644
+
38
−
0
View file @
f641f591
import
psycopg2
import
os
database_user
=
os
.
environ
[
'
DB_USER
'
]
database_password
=
os
.
environ
[
'
DB_PW
'
]
host
=
os
.
environ
[
'
DB_HOST
'
]
port
=
os
.
environ
[
'
DB_PORT
'
]
database
=
os
.
environ
[
'
DB_NAME
'
]
def
connect_to_db
(
eo_id
):
global
db_name
,
coverage_id
try
:
# connection = psycopg2.connect( "dbname=emg_db user=emg_user password=QkU)n=Wwr70w^o=4XS~*5)vfL[ij~C} host=127.0.0.1 port=84")
connection
=
psycopg2
.
connect
(
dbname
=
database
,
user
=
database_user
,
password
=
database_password
,
host
=
host
,
port
=
port
)
cursor
=
connection
.
cursor
()
db_name
=
connection
.
get_dsn_parameters
()[
"
dbname
"
]
postgreSQL_select_Query
=
"
SELECT identifier FROM coverages_eoobject WHERE identifier =
'
%s
'
;
"
%
eo_id
cursor
.
execute
(
postgreSQL_select_Query
)
coverage_id
=
cursor
.
fetchone
()[
0
]
except
(
Exception
,
psycopg2
.
Error
)
as
error
:
print
(
"
Error while connecting to PostgreSQL
"
,
error
)
finally
:
#closing database connection.
if
(
connection
):
cursor
.
close
()
connection
.
close
()
print
(
"
PostgreSQL connection is closed
"
)
def
test_db_name
(
name
):
identifier
=
name
.
split
(
'
/
'
)[
4
]
connect_to_db
(
identifier
)
assert
coverage_id
==
identifier
assert
db_name
==
database
This diff is collapsed.
Click to expand it.
requirements.txt
+
2
−
1
View file @
f641f591
pytest
\ No newline at end of file
pytest
psycopg2
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment