Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
DBRepo
Manage
Activity
Members
Labels
Plan
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Contributor 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
FAIR Data Austria DB Repository
DBRepo
Commits
a1a97886
Commit
a1a97886
authored
4 years ago
by
Martin Weise
Browse files
Options
Downloads
Patches
Plain Diff
total 59 tests
parent
d0035515
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!81
New stable release
,
!43
Merge dev to master
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
.gitlab-ci.yml
+4
-0
4 additions, 0 deletions
.gitlab-ci.yml
fda-container-service/rest-service/src/test/java/at/tuwien/service/ContainerServiceIntegrationTest.java
+64
-20
64 additions, 20 deletions
...va/at/tuwien/service/ContainerServiceIntegrationTest.java
with
68 additions
and
20 deletions
.gitlab-ci.yml
+
4
−
0
View file @
a1a97886
...
@@ -29,6 +29,7 @@ build-metadata-db:
...
@@ -29,6 +29,7 @@ build-metadata-db:
test-backend-container
:
test-backend-container
:
stage
:
test
stage
:
test
script
:
script
:
-
docker system prune -f
-
"
./fda-container-service/rest-service/src/test/resources/integration-test.before"
-
"
./fda-container-service/rest-service/src/test/resources/integration-test.before"
-
"
mvn
-f
fda-container-service/pom.xml
clean
test
verify"
-
"
mvn
-f
fda-container-service/pom.xml
clean
test
verify"
-
"
./fda-container-service/rest-service/src/test/resources/integration-test.after"
-
"
./fda-container-service/rest-service/src/test/resources/integration-test.after"
...
@@ -49,6 +50,7 @@ test-backend-container:
...
@@ -49,6 +50,7 @@ test-backend-container:
test-backend-database
:
test-backend-database
:
stage
:
test
stage
:
test
script
:
script
:
-
docker system prune -f
-
"
./fda-database-service/rest-service/src/test/resources/integration-test.before"
-
"
./fda-database-service/rest-service/src/test/resources/integration-test.before"
-
"
mvn
-f
fda-database-service/pom.xml
clean
test
verify"
-
"
mvn
-f
fda-database-service/pom.xml
clean
test
verify"
-
"
./fda-database-service/rest-service/src/test/resources/integration-test.after"
-
"
./fda-database-service/rest-service/src/test/resources/integration-test.after"
...
@@ -81,6 +83,7 @@ test-backend-gateway:
...
@@ -81,6 +83,7 @@ test-backend-gateway:
test-backend-query
:
test-backend-query
:
stage
:
test
stage
:
test
script
:
script
:
-
docker system prune -f
-
"
./fda-query-service/rest-service/src/test/resources/integration-test.before"
-
"
./fda-query-service/rest-service/src/test/resources/integration-test.before"
-
"
mvn
-f
fda-query-service/pom.xml
clean
test
verify"
-
"
mvn
-f
fda-query-service/pom.xml
clean
test
verify"
-
"
./fda-query-service/rest-service/src/test/resources/integration-test.after"
-
"
./fda-query-service/rest-service/src/test/resources/integration-test.after"
...
@@ -101,6 +104,7 @@ test-backend-query:
...
@@ -101,6 +104,7 @@ test-backend-query:
test-backend-table
:
test-backend-table
:
stage
:
test
stage
:
test
script
:
script
:
-
docker system prune -f
-
"
./fda-table-service/rest-service/src/test/resources/integration-test.before"
-
"
./fda-table-service/rest-service/src/test/resources/integration-test.before"
-
"
mvn
-f
fda-table-service/pom.xml
clean
test
verify"
-
"
mvn
-f
fda-table-service/pom.xml
clean
test
verify"
-
"
./fda-table-service/rest-service/src/test/resources/integration-test.after"
-
"
./fda-table-service/rest-service/src/test/resources/integration-test.after"
...
...
This diff is collapsed.
Click to expand it.
fda-container-service/rest-service/src/test/java/at/tuwien/service/ContainerServiceIntegrationTest.java
+
64
−
20
View file @
a1a97886
...
@@ -3,11 +3,10 @@ package at.tuwien.service;
...
@@ -3,11 +3,10 @@ package at.tuwien.service;
import
at.tuwien.BaseUnitTest
;
import
at.tuwien.BaseUnitTest
;
import
at.tuwien.api.container.ContainerCreateRequestDto
;
import
at.tuwien.api.container.ContainerCreateRequestDto
;
import
at.tuwien.api.container.ContainerStateDto
;
import
at.tuwien.api.container.ContainerStateDto
;
import
at.tuwien.api.container.image.ImageCreateDto
;
import
at.tuwien.entities.container.Container
;
import
at.tuwien.entities.container.Container
;
import
at.tuwien.entities.container.image.ContainerImage
;
import
at.tuwien.exception.ContainerNotFoundException
;
import
at.tuwien.exception.ContainerNotFoundException
;
import
at.tuwien.exception.ContainerNotRunningException
;
import
at.tuwien.exception.ContainerNotRunningException
;
import
at.tuwien.exception.ContainerStillRunningException
;
import
at.tuwien.exception.DockerClientException
;
import
at.tuwien.exception.DockerClientException
;
import
at.tuwien.repository.ContainerRepository
;
import
at.tuwien.repository.ContainerRepository
;
import
at.tuwien.repository.ImageRepository
;
import
at.tuwien.repository.ImageRepository
;
...
@@ -17,7 +16,6 @@ import com.github.dockerjava.api.exception.NotModifiedException;
...
@@ -17,7 +16,6 @@ import com.github.dockerjava.api.exception.NotModifiedException;
import
com.github.dockerjava.api.model.*
;
import
com.github.dockerjava.api.model.*
;
import
org.junit.jupiter.api.AfterEach
;
import
org.junit.jupiter.api.AfterEach
;
import
org.junit.jupiter.api.BeforeEach
;
import
org.junit.jupiter.api.BeforeEach
;
import
org.junit.jupiter.api.Disabled
;
import
org.junit.jupiter.api.Test
;
import
org.junit.jupiter.api.Test
;
import
org.junit.jupiter.api.extension.ExtendWith
;
import
org.junit.jupiter.api.extension.ExtendWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -27,7 +25,6 @@ import org.springframework.test.context.junit.jupiter.SpringExtension;
...
@@ -27,7 +25,6 @@ import org.springframework.test.context.junit.jupiter.SpringExtension;
import
javax.transaction.Transactional
;
import
javax.transaction.Transactional
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.*;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.*;
...
@@ -40,9 +37,6 @@ public class ContainerServiceIntegrationTest extends BaseUnitTest {
...
@@ -40,9 +37,6 @@ public class ContainerServiceIntegrationTest extends BaseUnitTest {
@Autowired
@Autowired
private
ContainerService
containerService
;
private
ContainerService
containerService
;
@Autowired
private
ImageService
imageService
;
@Autowired
@Autowired
private
HostConfig
hostConfig
;
private
HostConfig
hostConfig
;
...
@@ -55,6 +49,9 @@ public class ContainerServiceIntegrationTest extends BaseUnitTest {
...
@@ -55,6 +49,9 @@ public class ContainerServiceIntegrationTest extends BaseUnitTest {
@Autowired
@Autowired
private
DockerClient
dockerClient
;
private
DockerClient
dockerClient
;
private
Long
CONTAINER_1_ID
,
CONTAINER_2_ID
;
private
String
CONTAINER_1_HASH
;
@Transactional
@Transactional
@BeforeEach
@BeforeEach
public
void
beforeEach
()
{
public
void
beforeEach
()
{
...
@@ -68,6 +65,7 @@ public class ContainerServiceIntegrationTest extends BaseUnitTest {
...
@@ -68,6 +65,7 @@ public class ContainerServiceIntegrationTest extends BaseUnitTest {
.
withEnableIpv6
(
false
)
.
withEnableIpv6
(
false
)
.
exec
();
.
exec
();
imageRepository
.
save
(
IMAGE_1
);
imageRepository
.
save
(
IMAGE_1
);
imageRepository
.
save
(
IMAGE_2
);
/* create container */
/* create container */
final
CreateContainerResponse
request
=
dockerClient
.
createContainerCmd
(
IMAGE_1_REPOSITORY
+
":"
+
IMAGE_1_TAG
)
final
CreateContainerResponse
request
=
dockerClient
.
createContainerCmd
(
IMAGE_1_REPOSITORY
+
":"
+
IMAGE_1_TAG
)
.
withEnv
(
IMAGE_1_ENVIRONMENT
)
.
withEnv
(
IMAGE_1_ENVIRONMENT
)
...
@@ -79,8 +77,10 @@ public class ContainerServiceIntegrationTest extends BaseUnitTest {
...
@@ -79,8 +77,10 @@ public class ContainerServiceIntegrationTest extends BaseUnitTest {
.
exec
();
.
exec
();
/* start container */
/* start container */
dockerClient
.
startContainerCmd
(
request
.
getId
()).
exec
();
dockerClient
.
startContainerCmd
(
request
.
getId
()).
exec
();
CONTAINER_1
.
setHash
(
request
.
getId
());
CONTAINER_1_HASH
=
request
.
getId
();
containerRepository
.
save
(
CONTAINER_1
);
CONTAINER_1
.
setHash
(
CONTAINER_1_HASH
);
CONTAINER_1_ID
=
containerRepository
.
save
(
CONTAINER_1
).
getId
();
CONTAINER_2_ID
=
containerRepository
.
save
(
CONTAINER_2
).
getId
();
}
}
@Transactional
@Transactional
...
@@ -115,29 +115,29 @@ public class ContainerServiceIntegrationTest extends BaseUnitTest {
...
@@ -115,29 +115,29 @@ public class ContainerServiceIntegrationTest extends BaseUnitTest {
public
void
findIpAddress_succeeds
()
throws
ContainerNotRunningException
{
public
void
findIpAddress_succeeds
()
throws
ContainerNotRunningException
{
/* test */
/* test */
final
Map
<
String
,
String
>
response
=
containerService
.
findIpAddresses
(
CONTAINER_1
.
getHash
()
);
final
Map
<
String
,
String
>
response
=
containerService
.
findIpAddresses
(
CONTAINER_1
_HASH
);
assertTrue
(
response
.
containsKey
(
"fda-userdb"
));
assertTrue
(
response
.
containsKey
(
"fda-userdb"
));
assertEquals
(
CONTAINER_1_IP
,
response
.
get
(
"fda-userdb"
));
assertEquals
(
CONTAINER_1_IP
,
response
.
get
(
"fda-userdb"
));
}
}
@Test
@Test
public
void
findIpAddress_notRunning_fails
()
{
public
void
findIpAddress_notRunning_fails
()
{
dockerClient
.
stopContainerCmd
(
CONTAINER_1
.
getHash
()
).
exec
();
dockerClient
.
stopContainerCmd
(
CONTAINER_1
_HASH
).
exec
();
/* test */
/* test */
assertThrows
(
ContainerNotRunningException
.
class
,
()
->
{
assertThrows
(
ContainerNotRunningException
.
class
,
()
->
{
containerService
.
findIpAddresses
(
CONTAINER_1
.
getHash
()
);
containerService
.
findIpAddresses
(
CONTAINER_1
_HASH
);
});
});
}
}
@Test
@Test
public
void
findIpAddress_notFound_fails
()
{
public
void
findIpAddress_notFound_fails
()
{
dockerClient
.
stopContainerCmd
(
CONTAINER_1
.
getHash
()
).
exec
();
dockerClient
.
stopContainerCmd
(
CONTAINER_1
_HASH
).
exec
();
dockerClient
.
removeContainerCmd
(
CONTAINER_1
.
getHash
()
).
exec
();
dockerClient
.
removeContainerCmd
(
CONTAINER_1
_HASH
).
exec
();
/* test */
/* test */
assertThrows
(
ContainerNotFoundException
.
class
,
()
->
{
assertThrows
(
ContainerNotFoundException
.
class
,
()
->
{
containerService
.
findIpAddresses
(
CONTAINER_1
.
getHash
()
);
containerService
.
findIpAddresses
(
CONTAINER_1
_HASH
);
});
});
}
}
...
@@ -145,18 +145,18 @@ public class ContainerServiceIntegrationTest extends BaseUnitTest {
...
@@ -145,18 +145,18 @@ public class ContainerServiceIntegrationTest extends BaseUnitTest {
public
void
getContainerState_succeeds
()
{
public
void
getContainerState_succeeds
()
{
/* test */
/* test */
final
ContainerStateDto
response
=
containerService
.
getContainerState
(
CONTAINER_1
.
getHash
()
);
final
ContainerStateDto
response
=
containerService
.
getContainerState
(
CONTAINER_1
_HASH
);
assertEquals
(
ContainerStateDto
.
RUNNING
,
response
);
assertEquals
(
ContainerStateDto
.
RUNNING
,
response
);
}
}
@Test
@Test
public
void
getContainerState_notFound_fails
()
{
public
void
getContainerState_notFound_fails
()
{
dockerClient
.
stopContainerCmd
(
CONTAINER_1
.
getHash
()
).
exec
();
dockerClient
.
stopContainerCmd
(
CONTAINER_1
_HASH
).
exec
();
dockerClient
.
removeContainerCmd
(
CONTAINER_1
.
getHash
()
).
exec
();
dockerClient
.
removeContainerCmd
(
CONTAINER_1
_HASH
).
exec
();
/* test */
/* test */
assertThrows
(
DockerClientException
.
class
,
()
->
{
assertThrows
(
DockerClientException
.
class
,
()
->
{
containerService
.
getContainerState
(
CONTAINER_1
.
getHash
()
);
containerService
.
getContainerState
(
CONTAINER_1
_HASH
);
});
});
}
}
...
@@ -185,7 +185,7 @@ public class ContainerServiceIntegrationTest extends BaseUnitTest {
...
@@ -185,7 +185,7 @@ public class ContainerServiceIntegrationTest extends BaseUnitTest {
@Test
@Test
public
void
change_start_succeeds
()
{
public
void
change_start_succeeds
()
{
dockerClient
.
stopContainerCmd
(
CONTAINER_1
.
getHash
()
).
exec
();
dockerClient
.
stopContainerCmd
(
CONTAINER_1
_HASH
).
exec
();
/* test */
/* test */
containerService
.
start
(
CONTAINER_1_ID
);
containerService
.
start
(
CONTAINER_1_ID
);
...
@@ -198,4 +198,48 @@ public class ContainerServiceIntegrationTest extends BaseUnitTest {
...
@@ -198,4 +198,48 @@ public class ContainerServiceIntegrationTest extends BaseUnitTest {
containerService
.
stop
(
CONTAINER_1_ID
);
containerService
.
stop
(
CONTAINER_1_ID
);
}
}
@Test
public
void
change_stop_notFoundDocker_fails
()
{
/* test */
assertThrows
(
DockerClientException
.
class
,
()
->
{
containerService
.
stop
(
CONTAINER_2_ID
);
});
}
@Test
public
void
remove_succeeds
()
{
dockerClient
.
stopContainerCmd
(
CONTAINER_1_HASH
).
exec
();
/* test */
containerService
.
remove
(
CONTAINER_1_ID
);
}
@Test
public
void
remove_notFound_fails
()
{
/* test */
assertThrows
(
ContainerNotFoundException
.
class
,
()
->
{
containerService
.
remove
(
9999999L
);
});
}
@Test
public
void
remove_docker_fails
()
{
/* test */
assertThrows
(
DockerClientException
.
class
,
()
->
{
containerService
.
remove
(
CONTAINER_2_ID
);
});
}
@Test
public
void
remove_stillRunning_fails
()
{
/* test */
assertThrows
(
ContainerStillRunningException
.
class
,
()
->
{
containerService
.
remove
(
CONTAINER_1_ID
);
});
}
}
}
This diff is collapsed.
Click to expand it.
Martin Weise
@mweise
mentioned in commit
37ad7609
·
3 years ago
mentioned in commit
37ad7609
mentioned in commit 37ad76090ae582bea7d46e4db6153798926b5646
Toggle commit list
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