Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CONF
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
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UvA
CONF
Commits
32e580e0
Commit
32e580e0
authored
Mar 16, 2020
by
Spiros Koulouzis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added check to test the was trying to connect to sure-tosca
parent
4abc6571
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
18 deletions
+42
-18
DRIPService.java
...er/src/main/java/nl/uva/sne/drip/service/DRIPService.java
+2
-1
ServiceTests.java
...r/src/test/java/nl/uva/sne/drip/service/ServiceTests.java
+40
-17
No files found.
manager/src/main/java/nl/uva/sne/drip/service/DRIPService.java
View file @
32e580e0
...
@@ -167,7 +167,8 @@ public class DRIPService {
...
@@ -167,7 +167,8 @@ public class DRIPService {
return
toscaTemplate
;
return
toscaTemplate
;
}
}
void
deleteActions
(
ToscaTemplate
toscaTemplate
)
throws
ApiException
,
TypeExeption
{
void
deleteActions
(
ToscaTemplate
toscaTemplate
)
throws
ApiException
,
TypeExeption
,
IOException
{
helper
.
uploadToscaTemplate
(
toscaTemplate
);
List
<
NodeTemplateMap
>
vmTopologies
=
helper
.
getVMTopologyTemplates
();
List
<
NodeTemplateMap
>
vmTopologies
=
helper
.
getVMTopologyTemplates
();
for
(
NodeTemplateMap
vmTopology
:
vmTopologies
){
for
(
NodeTemplateMap
vmTopology
:
vmTopologies
){
CloudsStormSubTopology
.
StatusEnum
status
=
helper
.
getVMTopologyTemplateStatus
(
vmTopology
);
CloudsStormSubTopology
.
StatusEnum
status
=
helper
.
getVMTopologyTemplateStatus
(
vmTopology
);
...
...
manager/src/test/java/nl/uva/sne/drip/service/ServiceTests.java
View file @
32e580e0
...
@@ -28,6 +28,8 @@ import java.io.File;
...
@@ -28,6 +28,8 @@ import java.io.File;
import
java.io.FileInputStream
;
import
java.io.FileInputStream
;
import
java.io.FileNotFoundException
;
import
java.io.FileNotFoundException
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.net.HttpURLConnection
;
import
java.net.URL
;
import
java.security.NoSuchAlgorithmException
;
import
java.security.NoSuchAlgorithmException
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
...
@@ -37,12 +39,14 @@ import java.util.logging.Level;
...
@@ -37,12 +39,14 @@ import java.util.logging.Level;
import
java.util.logging.Logger
;
import
java.util.logging.Logger
;
import
nl.uva.sne.drip.Swagger2SpringBoot
;
import
nl.uva.sne.drip.Swagger2SpringBoot
;
import
nl.uva.sne.drip.commons.utils.Converter
;
import
nl.uva.sne.drip.commons.utils.Converter
;
import
nl.uva.sne.drip.commons.utils.ToscaHelper
;
import
nl.uva.sne.drip.configuration.MongoConfig
;
import
nl.uva.sne.drip.configuration.MongoConfig
;
import
nl.uva.sne.drip.model.tosca.Credential
;
import
nl.uva.sne.drip.model.tosca.Credential
;
import
org.junit.Assert
;
import
org.junit.Assert
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
import
static
org
.
junit
.
Assert
.
fail
;
import
static
org
.
junit
.
Assert
.
fail
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.mock.web.MockMultipartFile
;
import
org.springframework.mock.web.MockMultipartFile
;
import
org.springframework.test.context.web.WebAppConfiguration
;
import
org.springframework.test.context.web.WebAppConfiguration
;
import
org.springframework.test.web.servlet.MockMvc
;
import
org.springframework.test.web.servlet.MockMvc
;
...
@@ -73,6 +77,9 @@ public class ServiceTests {
...
@@ -73,6 +77,9 @@ public class ServiceTests {
private
WebApplicationContext
wac
;
private
WebApplicationContext
wac
;
private
MockMvc
mockMvc
;
private
MockMvc
mockMvc
;
@Value
(
"${sure-tosca.base.path}"
)
private
String
sureToscaBasePath
;
private
static
final
MongodStarter
starter
=
MongodStarter
.
getDefaultInstance
();
private
static
final
MongodStarter
starter
=
MongodStarter
.
getDefaultInstance
();
private
static
MongodExecutable
_mongodExe
;
private
static
MongodExecutable
_mongodExe
;
private
static
MongodProcess
_mongod
;
private
static
MongodProcess
_mongod
;
...
@@ -213,27 +220,43 @@ public class ServiceTests {
...
@@ -213,27 +220,43 @@ public class ServiceTests {
*/
*/
@Test
@Test
public
void
testToscaTemplateServiceDeleteByID
()
{
public
void
testToscaTemplateServiceDeleteByID
()
{
try
{
if
(
isServiceUp
(
sureToscaBasePath
))
{
Logger
.
getLogger
(
ServiceTests
.
class
.
getName
()).
log
(
Level
.
INFO
,
"deleteByID"
);
if
(
toscaTemplateID
==
null
)
{
testToscaTemplateServiceSaveFile
();
}
toscaTemplateService
.
deleteByID
(
toscaTemplateID
);
String
id
=
toscaTemplateService
.
findByID
(
toscaTemplateID
);
}
catch
(
Exception
ex
)
{
if
(!(
ex
instanceof
NoSuchElementException
))
{
fail
(
ex
.
getMessage
());
Logger
.
getLogger
(
ServiceTests
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
}
}
finally
{
try
{
try
{
testToscaTemplateServiceSaveFile
();
Logger
.
getLogger
(
ServiceTests
.
class
.
getName
()).
log
(
Level
.
INFO
,
"deleteByID"
);
if
(
toscaTemplateID
==
null
)
{
testToscaTemplateServiceSaveFile
();
}
toscaTemplateService
.
deleteByID
(
toscaTemplateID
);
String
id
=
toscaTemplateService
.
findByID
(
toscaTemplateID
);
}
catch
(
Exception
ex
)
{
}
catch
(
Exception
ex
)
{
fail
(
ex
.
getMessage
());
if
(!(
ex
instanceof
NoSuchElementException
))
{
Logger
.
getLogger
(
ServiceTests
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
fail
(
ex
.
getMessage
());
Logger
.
getLogger
(
ServiceTests
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
}
}
finally
{
try
{
testToscaTemplateServiceSaveFile
();
}
catch
(
Exception
ex
)
{
fail
(
ex
.
getMessage
());
Logger
.
getLogger
(
ServiceTests
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
}
}
}
}
}
}
public
static
Boolean
isServiceUp
(
String
serviceBasePath
)
{
try
{
URL
serviceUrl
=
new
URL
(
serviceBasePath
);
HttpURLConnection
connection
=
(
HttpURLConnection
)
serviceUrl
.
openConnection
();
//Set request to header to reduce load as Subirkumarsao said.
connection
.
setRequestMethod
(
"HEAD"
);
int
code
=
connection
.
getResponseCode
();
}
catch
(
IOException
ex
)
{
return
false
;
}
return
true
;
}
}
/**
/**
...
...
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