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
dec39138
Commit
dec39138
authored
Mar 18, 2020
by
Spiros Koulouzis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added tests
parent
9b8e422c
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
7 deletions
+41
-7
ToscaHelper.java
.../main/java/nl/uva/sne/drip/commons/utils/ToscaHelper.java
+7
-7
DRIPService.java
...er/src/main/java/nl/uva/sne/drip/service/DRIPService.java
+2
-0
ServiceTests.java
...r/src/test/java/nl/uva/sne/drip/service/ServiceTests.java
+32
-0
No files found.
commons/src/main/java/nl/uva/sne/drip/commons/utils/ToscaHelper.java
View file @
dec39138
...
@@ -313,19 +313,19 @@ public class ToscaHelper {
...
@@ -313,19 +313,19 @@ public class ToscaHelper {
}
}
private
NODE_STATES
getNodeState
(
NodeTemplateMap
node
,
String
stateName
)
{
private
NODE_STATES
getNodeState
(
NodeTemplateMap
node
,
String
stateName
)
{
if
(
node
.
getNodeTemplate
().
getA
rtifact
s
()
!=
null
)
{
if
(
node
.
getNodeTemplate
().
getA
ttribute
s
()
!=
null
)
{
return
NODE_STATES
.
valueOf
((
String
)
node
.
getNodeTemplate
().
getA
rtifact
s
().
get
(
stateName
));
return
NODE_STATES
.
valueOf
((
String
)
node
.
getNodeTemplate
().
getA
ttribute
s
().
get
(
stateName
));
}
}
return
null
;
return
null
;
}
}
private
NodeTemplateMap
setNodeState
(
NodeTemplateMap
node
,
String
stateName
,
NODE_STATES
nodeState
)
{
private
NodeTemplateMap
setNodeState
(
NodeTemplateMap
node
,
String
stateName
,
NODE_STATES
nodeState
)
{
Map
<
String
,
Object
>
a
rtifacts
=
node
.
getNodeTemplate
().
getArtifact
s
();
Map
<
String
,
Object
>
a
ttributes
=
node
.
getNodeTemplate
().
getAttribute
s
();
if
(
a
rtifact
s
==
null
)
{
if
(
a
ttribute
s
==
null
)
{
a
rtifact
s
=
new
HashMap
<>();
a
ttribute
s
=
new
HashMap
<>();
}
}
a
rtifact
s
.
put
(
stateName
,
nodeState
.
toString
());
a
ttribute
s
.
put
(
stateName
,
nodeState
.
toString
());
node
.
getNodeTemplate
().
setArtifacts
(
artifact
s
);
node
.
getNodeTemplate
().
attributes
(
attribute
s
);
return
node
;
return
node
;
}
}
...
...
manager/src/main/java/nl/uva/sne/drip/service/DRIPService.java
View file @
dec39138
...
@@ -110,6 +110,8 @@ public class DRIPService {
...
@@ -110,6 +110,8 @@ public class DRIPService {
public
String
provision
(
String
id
)
throws
MissingCredentialsException
,
ApiException
,
TypeExeption
,
IOException
,
JsonProcessingException
,
TimeoutException
,
InterruptedException
,
NotFoundException
,
MissingVMTopologyException
{
public
String
provision
(
String
id
)
throws
MissingCredentialsException
,
ApiException
,
TypeExeption
,
IOException
,
JsonProcessingException
,
TimeoutException
,
InterruptedException
,
NotFoundException
,
MissingVMTopologyException
{
ToscaTemplate
toscaTemplate
=
initExecution
(
id
);
ToscaTemplate
toscaTemplate
=
initExecution
(
id
);
toscaTemplate
=
addCredentials
(
toscaTemplate
);
toscaTemplate
=
addCredentials
(
toscaTemplate
);
//Update ToscaTemplate so we can include the credentials
helper
.
uploadToscaTemplate
(
toscaTemplate
);
List
<
NodeTemplateMap
>
vmTopologies
=
helper
.
getVMTopologyTemplates
();
List
<
NodeTemplateMap
>
vmTopologies
=
helper
.
getVMTopologyTemplates
();
if
(
vmTopologies
==
null
||
vmTopologies
.
isEmpty
())
{
if
(
vmTopologies
==
null
||
vmTopologies
.
isEmpty
())
{
throw
new
MissingVMTopologyException
(
"ToscaTemplate: "
+
toscaTemplate
+
" has no VM Topologies"
);
throw
new
MissingVMTopologyException
(
"ToscaTemplate: "
+
toscaTemplate
+
" has no VM Topologies"
);
...
...
manager/src/test/java/nl/uva/sne/drip/service/ServiceTests.java
View file @
dec39138
...
@@ -33,6 +33,7 @@ import java.util.HashMap;
...
@@ -33,6 +33,7 @@ import java.util.HashMap;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.NoSuchElementException
;
import
java.util.NoSuchElementException
;
import
java.util.Set
;
import
java.util.concurrent.TimeoutException
;
import
java.util.concurrent.TimeoutException
;
import
java.util.logging.Level
;
import
java.util.logging.Level
;
import
java.util.logging.Logger
;
import
java.util.logging.Logger
;
...
@@ -44,6 +45,8 @@ import nl.uva.sne.drip.configuration.MongoConfig;
...
@@ -44,6 +45,8 @@ import nl.uva.sne.drip.configuration.MongoConfig;
import
nl.uva.sne.drip.model.Exceptions.MissingCredentialsException
;
import
nl.uva.sne.drip.model.Exceptions.MissingCredentialsException
;
import
nl.uva.sne.drip.model.Exceptions.MissingVMTopologyException
;
import
nl.uva.sne.drip.model.Exceptions.MissingVMTopologyException
;
import
nl.uva.sne.drip.model.Exceptions.TypeExeption
;
import
nl.uva.sne.drip.model.Exceptions.TypeExeption
;
import
nl.uva.sne.drip.model.NodeTemplate
;
import
nl.uva.sne.drip.model.NodeTemplateMap
;
import
nl.uva.sne.drip.model.tosca.Credential
;
import
nl.uva.sne.drip.model.tosca.Credential
;
import
nl.uva.sne.drip.model.tosca.ToscaTemplate
;
import
nl.uva.sne.drip.model.tosca.ToscaTemplate
;
import
nl.uva.sne.drip.sure.tosca.client.ApiException
;
import
nl.uva.sne.drip.sure.tosca.client.ApiException
;
...
@@ -96,6 +99,9 @@ public class ServiceTests {
...
@@ -96,6 +99,9 @@ public class ServiceTests {
@Autowired
@Autowired
CredentialService
credentialService
;
CredentialService
credentialService
;
@Autowired
ToscaHelper
helper
;
@Autowired
@Autowired
private
WebApplicationContext
wac
;
private
WebApplicationContext
wac
;
private
MockMvc
mockMvc
;
private
MockMvc
mockMvc
;
...
@@ -416,6 +422,32 @@ public class ServiceTests {
...
@@ -416,6 +422,32 @@ public class ServiceTests {
ToscaTemplate
toscaTemplate
=
dripService
.
initExecution
(
id
);
ToscaTemplate
toscaTemplate
=
dripService
.
initExecution
(
id
);
toscaTemplate
=
dripService
.
addCredentials
(
toscaTemplate
);
toscaTemplate
=
dripService
.
addCredentials
(
toscaTemplate
);
List
<
NodeTemplateMap
>
vmTopologies
=
helper
.
getVMTopologyTemplates
();
if
(
vmTopologies
==
null
||
vmTopologies
.
isEmpty
())
{
throw
new
MissingVMTopologyException
(
"ToscaTemplate: "
+
toscaTemplate
+
" has no VM Topologies"
);
}
for
(
NodeTemplateMap
vmTopology
:
vmTopologies
)
{
Map
<
String
,
Object
>
attributes
=
vmTopology
.
getNodeTemplate
().
getAttributes
();
assertNotNull
(
attributes
);
Assert
.
assertTrue
(
attributes
.
containsKey
(
"credential"
));
assertNotNull
(
attributes
.
get
(
"credential"
));
}
toscaTemplate
=
dripService
.
setDesieredSate
(
toscaTemplate
,
vmTopologies
,
ToscaHelper
.
NODE_STATES
.
PROVISION
);
Map
<
String
,
NodeTemplate
>
nodes
=
toscaTemplate
.
getTopologyTemplate
().
getNodeTemplates
();
Set
<
String
>
names
=
nodes
.
keySet
();
for
(
String
name
:
names
)
{
NodeTemplate
node
=
nodes
.
get
(
name
);
if
(
node
.
getType
().
equals
(
"tosca.nodes.ARTICONF.VM.topology"
))
{
Map
<
String
,
Object
>
attributes
=
node
.
getAttributes
();
assertNotNull
(
attributes
);
Assert
.
assertTrue
(
attributes
.
containsKey
(
"credential"
));
assertNotNull
(
attributes
.
get
(
"credential"
));
Assert
.
assertTrue
(
attributes
.
containsKey
(
"desired_state"
));
assertNotNull
(
attributes
.
get
(
"desired_state"
));
}
}
}
}
}
}
}
}
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