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
98c7bd7a
Commit
98c7bd7a
authored
Mar 19, 2020
by
Spiros Koulouzis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added tests
parent
d790ac01
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
89 additions
and
43 deletions
+89
-43
Converter.java
...rc/main/java/nl/uva/sne/drip/commons/utils/Converter.java
+28
-8
CloudStormService.java
...n/java/nl/uva/sne/drip/provisioner/CloudStormService.java
+3
-4
CloudStormServiceTest.java
...va/nl/uva/sne/drip/provisioner/CloudStormServiceTest.java
+58
-31
No files found.
commons/src/main/java/nl/uva/sne/drip/commons/utils/Converter.java
View file @
98c7bd7a
...
@@ -16,27 +16,20 @@
...
@@ -16,27 +16,20 @@
package
nl
.
uva
.
sne
.
drip
.
commons
.
utils
;
package
nl
.
uva
.
sne
.
drip
.
commons
.
utils
;
import
java.io.File
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileNotFoundException
;
import
java.io.FileNotFoundException
;
import
java.io.FileOutputStream
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.nio.charset.StandardCharsets
;
import
java.nio.charset.StandardCharsets
;
import
java.nio.file.FileVisitResult
;
import
java.nio.file.Files
;
import
java.nio.file.Files
;
import
java.nio.file.Path
;
import
java.nio.file.Paths
;
import
java.nio.file.Paths
;
import
java.nio.file.SimpleFileVisitor
;
import
java.nio.file.attribute.BasicFileAttributes
;
import
java.security.MessageDigest
;
import
java.security.MessageDigest
;
import
java.security.NoSuchAlgorithmException
;
import
java.security.NoSuchAlgorithmException
;
import
java.util.ArrayList
;
import
java.util.Base64
;
import
java.util.Base64
;
import
java.util.Enumeration
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.zip.ZipEntry
;
import
java.util.zip.ZipEntry
;
import
java.util.zip.ZipFile
;
import
java.util.zip.ZipOutputStream
;
import
java.util.zip.ZipOutputStream
;
import
org.json.JSONException
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
import
org.json.JSONObject
;
...
@@ -105,4 +98,31 @@ public class Converter {
...
@@ -105,4 +98,31 @@ public class Converter {
return
new
String
(
encodedBytes
,
StandardCharsets
.
UTF_8
);
return
new
String
(
encodedBytes
,
StandardCharsets
.
UTF_8
);
}
}
public
static
void
zipFolder
(
String
sourceDir
,
String
zipFile
)
throws
FileNotFoundException
,
IOException
{
FileOutputStream
fout
=
new
FileOutputStream
(
zipFile
);
try
(
ZipOutputStream
zout
=
new
ZipOutputStream
(
fout
))
{
File
fileSource
=
new
File
(
sourceDir
);
addDirectory
(
zout
,
fileSource
);
}
}
private
static
void
addDirectory
(
ZipOutputStream
zout
,
File
fileSource
)
throws
FileNotFoundException
,
IOException
{
File
[]
files
=
fileSource
.
listFiles
();
for
(
File
file
:
files
)
{
if
(
file
.
isDirectory
())
{
addDirectory
(
zout
,
file
);
continue
;
}
byte
[]
buffer
=
new
byte
[
1024
];
try
(
final
FileInputStream
fin
=
new
FileInputStream
(
file
))
{
zout
.
putNextEntry
(
new
ZipEntry
(
file
.
getName
()));
int
length
;
while
((
length
=
fin
.
read
(
buffer
))
>
0
)
{
zout
.
write
(
buffer
,
0
,
length
);
}
zout
.
closeEntry
();
}
}
}
}
}
provisioner/src/main/java/nl/uva/sne/drip/provisioner/CloudStormService.java
View file @
98c7bd7a
...
@@ -453,17 +453,16 @@ class CloudStormService {
...
@@ -453,17 +453,16 @@ class CloudStormService {
}
}
Map
<
String
,
String
>
provisionedFiles
=
new
HashMap
<>();
Map
<
String
,
String
>
provisionedFiles
=
new
HashMap
<>();
provisionedFiles
.
put
(
"type"
,
ENCODED_FILE_DATATYPE
);
provisionedFiles
.
put
(
"type"
,
ENCODED_FILE_DATATYPE
);
Path
zipPath
=
Paths
.
get
(
tempInputDirPath
+
TOPOLOGY_RELATIVE_PATH
+
File
.
separator
+
TOPOLOGY_FOLDER_NAME
+
".zip"
);
String
zipPath
=
(
tempInputDirPath
+
File
.
separator
+
TOPOLOGY_FOLDER_NAME
+
".zip"
);
Path
sourceFolderPath
=
Paths
.
get
(
tempInputDirPath
+
TOPOLOGY_RELATIVE_PATH
)
;
String
sourceFolderPath
=
tempInputDirPath
+
TOPOLOGY_RELATIVE_PATH
;
Converter
.
zipFolder
(
sourceFolderPath
,
zipPath
);
Converter
.
zipFolder
(
sourceFolderPath
,
zipPath
);
String
cloudStormZipFileContentsAsBase64
=
Converter
.
encodeFileToBase64Binary
(
zipPath
.
toFile
().
getAbsolutePath
()
);
String
cloudStormZipFileContentsAsBase64
=
Converter
.
encodeFileToBase64Binary
(
zipPath
);
provisionedFiles
.
put
(
"file_contents"
,
cloudStormZipFileContentsAsBase64
);
provisionedFiles
.
put
(
"file_contents"
,
cloudStormZipFileContentsAsBase64
);
provisionedFiles
.
put
(
"encoding"
,
"base64"
);
provisionedFiles
.
put
(
"encoding"
,
"base64"
);
provisionedFiles
.
put
(
"file_ext"
,
"zip"
);
provisionedFiles
.
put
(
"file_ext"
,
"zip"
);
artifacts
.
put
(
"provisioned_files"
,
provisionedFiles
);
artifacts
.
put
(
"provisioned_files"
,
provisionedFiles
);
vmTopologyMap
.
getNodeTemplate
().
setArtifacts
(
artifacts
);
vmTopologyMap
.
getNodeTemplate
().
setArtifacts
(
artifacts
);
return
vmTopologyMap
;
return
vmTopologyMap
;
}
}
...
...
provisioner/src/test/java/nl/uva/sne/drip/provisioner/CloudStormServiceTest.java
View file @
98c7bd7a
...
@@ -15,8 +15,11 @@ import com.jcraft.jsch.KeyPair;
...
@@ -15,8 +15,11 @@ import com.jcraft.jsch.KeyPair;
import
java.io.File
;
import
java.io.File
;
import
java.io.FileNotFoundException
;
import
java.io.FileNotFoundException
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.nio.file.Files
;
import
java.nio.file.Paths
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
nl.uva.sne.drip.commons.utils.Converter
;
import
nl.uva.sne.drip.commons.utils.ToscaHelper
;
import
nl.uva.sne.drip.commons.utils.ToscaHelper
;
import
nl.uva.sne.drip.model.Message
;
import
nl.uva.sne.drip.model.Message
;
import
nl.uva.sne.drip.model.NodeTemplateMap
;
import
nl.uva.sne.drip.model.NodeTemplateMap
;
...
@@ -32,6 +35,7 @@ import nl.uva.sne.drip.model.tosca.ToscaTemplate;
...
@@ -32,6 +35,7 @@ import nl.uva.sne.drip.model.tosca.ToscaTemplate;
import
static
nl
.
uva
.
sne
.
drip
.
provisioner
.
CloudStormService
.
APP_FOLDER_NAME
;
import
static
nl
.
uva
.
sne
.
drip
.
provisioner
.
CloudStormService
.
APP_FOLDER_NAME
;
import
static
nl
.
uva
.
sne
.
drip
.
provisioner
.
CloudStormService
.
INFRASTUCTURE_CODE_FILE_NAME
;
import
static
nl
.
uva
.
sne
.
drip
.
provisioner
.
CloudStormService
.
INFRASTUCTURE_CODE_FILE_NAME
;
import
static
nl
.
uva
.
sne
.
drip
.
provisioner
.
CloudStormService
.
INFS_FOLDER_NAME
;
import
static
nl
.
uva
.
sne
.
drip
.
provisioner
.
CloudStormService
.
INFS_FOLDER_NAME
;
import
static
nl
.
uva
.
sne
.
drip
.
provisioner
.
CloudStormService
.
TOPOLOGY_FOLDER_NAME
;
import
static
nl
.
uva
.
sne
.
drip
.
provisioner
.
CloudStormService
.
TOPOLOGY_RELATIVE_PATH
;
import
static
nl
.
uva
.
sne
.
drip
.
provisioner
.
CloudStormService
.
TOPOLOGY_RELATIVE_PATH
;
import
static
nl
.
uva
.
sne
.
drip
.
provisioner
.
CloudStormService
.
TOP_TOPOLOGY_FILE_NAME
;
import
static
nl
.
uva
.
sne
.
drip
.
provisioner
.
CloudStormService
.
TOP_TOPOLOGY_FILE_NAME
;
import
static
nl
.
uva
.
sne
.
drip
.
provisioner
.
CloudStormService
.
UC_FOLDER_NAME
;
import
static
nl
.
uva
.
sne
.
drip
.
provisioner
.
CloudStormService
.
UC_FOLDER_NAME
;
...
@@ -49,7 +53,7 @@ import static org.junit.Assert.*;
...
@@ -49,7 +53,7 @@ import static org.junit.Assert.*;
* @author S. Koulouzis
* @author S. Koulouzis
*/
*/
public
class
CloudStormServiceTest
{
public
class
CloudStormServiceTest
{
private
static
final
String
messageExampleDeleteRequestFilePath
=
".."
+
File
.
separator
+
"example_messages"
+
File
.
separator
+
"message_delete_request.json"
;
private
static
final
String
messageExampleDeleteRequestFilePath
=
".."
+
File
.
separator
+
"example_messages"
+
File
.
separator
+
"message_delete_request.json"
;
private
static
final
String
messageExampleProvisioneRequestFilePath
=
".."
+
File
.
separator
+
"example_messages"
+
File
.
separator
+
"message_provision_request.json"
;
private
static
final
String
messageExampleProvisioneRequestFilePath
=
".."
+
File
.
separator
+
"example_messages"
+
File
.
separator
+
"message_provision_request.json"
;
private
final
ObjectMapper
objectMapper
;
private
final
ObjectMapper
objectMapper
;
...
@@ -61,30 +65,30 @@ public class CloudStormServiceTest {
...
@@ -61,30 +65,30 @@ public class CloudStormServiceTest {
private
String
infrasCodeTempInputDirPath
;
private
String
infrasCodeTempInputDirPath
;
private
String
credentialsTempInputDirPath
;
private
String
credentialsTempInputDirPath
;
private
String
providersDBTempInputDirPath
;
private
String
providersDBTempInputDirPath
;
public
CloudStormServiceTest
()
{
public
CloudStormServiceTest
()
{
this
.
objectMapper
=
new
ObjectMapper
(
new
YAMLFactory
().
disable
(
YAMLGenerator
.
Feature
.
WRITE_DOC_START_MARKER
));
this
.
objectMapper
=
new
ObjectMapper
(
new
YAMLFactory
().
disable
(
YAMLGenerator
.
Feature
.
WRITE_DOC_START_MARKER
));
objectMapper
.
disable
(
SerializationFeature
.
WRITE_DATES_AS_TIMESTAMPS
);
objectMapper
.
disable
(
SerializationFeature
.
WRITE_DATES_AS_TIMESTAMPS
);
objectMapper
.
setSerializationInclusion
(
JsonInclude
.
Include
.
NON_NULL
);
objectMapper
.
setSerializationInclusion
(
JsonInclude
.
Include
.
NON_NULL
);
}
}
@BeforeClass
@BeforeClass
public
static
void
setUpClass
()
{
public
static
void
setUpClass
()
{
}
}
@AfterClass
@AfterClass
public
static
void
tearDownClass
()
{
public
static
void
tearDownClass
()
{
}
}
@Before
@Before
public
void
setUp
()
throws
IOException
,
JsonProcessingException
,
ApiException
{
public
void
setUp
()
throws
IOException
,
JsonProcessingException
,
ApiException
{
String
[]
argv
=
new
String
[
0
];
String
[]
argv
=
new
String
[
0
];
RPCServer
.
init
(
argv
);
RPCServer
.
init
(
argv
);
sureToscaBasePath
=
RPCServer
.
getProp
().
getProperty
(
"sure-tosca.base.path"
);
sureToscaBasePath
=
RPCServer
.
getProp
().
getProperty
(
"sure-tosca.base.path"
);
initPaths
();
initPaths
();
}
}
@After
@After
public
void
tearDown
()
{
public
void
tearDown
()
{
}
}
...
@@ -192,16 +196,18 @@ public class CloudStormServiceTest {
...
@@ -192,16 +196,18 @@ public class CloudStormServiceTest {
/**
/**
* Test of writeCloudStormInfrasCodeFiles method, of class
* Test of writeCloudStormInfrasCodeFiles method, of class
* CloudStormService.
* CloudStormService.
*
* @throws java.lang.Exception
*/
*/
@Test
@Test
public
void
testWriteCloudStormInfrasCodeFiles
()
throws
Exception
{
public
void
testWriteCloudStormInfrasCodeFiles
()
throws
Exception
{
if
(
ToscaHelper
.
isServiceUp
(
sureToscaBasePath
))
{
if
(
ToscaHelper
.
isServiceUp
(
sureToscaBasePath
))
{
System
.
out
.
println
(
"writeCloudStormInfrasCodeFiles"
);
System
.
out
.
println
(
"writeCloudStormInfrasCodeFiles"
);
testWriteCloudStormInfrasFiles
(
messageExampleProvisioneRequestFilePath
,
CloudsStormSubTopology
.
StatusEnum
.
FRESH
,
OpCode
.
OperationEnum
.
PROVISION
);
testWriteCloudStormInfrasFiles
(
messageExampleProvisioneRequestFilePath
,
CloudsStormSubTopology
.
StatusEnum
.
FRESH
,
OpCode
.
OperationEnum
.
PROVISION
);
testWriteCloudStormInfrasFiles
(
messageExampleDeleteRequestFilePath
,
CloudsStormSubTopology
.
StatusEnum
.
RUNNING
,
OpCode
.
OperationEnum
.
DELETE
);
testWriteCloudStormInfrasFiles
(
messageExampleDeleteRequestFilePath
,
CloudsStormSubTopology
.
StatusEnum
.
RUNNING
,
OpCode
.
OperationEnum
.
DELETE
);
}
}
}
}
/**
/**
...
@@ -218,9 +224,9 @@ public class CloudStormServiceTest {
...
@@ -218,9 +224,9 @@ public class CloudStormServiceTest {
result
=
instance
.
getKeyPair
();
result
=
instance
.
getKeyPair
();
assertNotNull
(
result
);
assertNotNull
(
result
);
}
}
}
}
private
void
initPaths
()
throws
FileNotFoundException
{
private
void
initPaths
()
throws
FileNotFoundException
{
tempInputDirPath
=
System
.
getProperty
(
"java.io.tmpdir"
)
+
File
.
separator
+
"Input-"
+
Long
.
toString
(
System
.
nanoTime
())
+
File
.
separator
;
tempInputDirPath
=
System
.
getProperty
(
"java.io.tmpdir"
)
+
File
.
separator
+
"Input-"
+
Long
.
toString
(
System
.
nanoTime
())
+
File
.
separator
;
tempInputDir
=
new
File
(
tempInputDirPath
);
tempInputDir
=
new
File
(
tempInputDirPath
);
...
@@ -228,36 +234,36 @@ public class CloudStormServiceTest {
...
@@ -228,36 +234,36 @@ public class CloudStormServiceTest {
throw
new
FileNotFoundException
(
"Could not create input directory: "
+
tempInputDir
.
getAbsolutePath
());
throw
new
FileNotFoundException
(
"Could not create input directory: "
+
tempInputDir
.
getAbsolutePath
());
}
}
topologyTempInputDirPath
=
tempInputDirPath
+
TOPOLOGY_RELATIVE_PATH
;
topologyTempInputDirPath
=
tempInputDirPath
+
TOPOLOGY_RELATIVE_PATH
;
topologyTempInputDir
=
new
File
(
topologyTempInputDirPath
);
topologyTempInputDir
=
new
File
(
topologyTempInputDirPath
);
if
(!(
topologyTempInputDir
.
mkdirs
()))
{
if
(!(
topologyTempInputDir
.
mkdirs
()))
{
throw
new
FileNotFoundException
(
"Could not create input directory: "
+
topologyTempInputDir
.
getAbsolutePath
());
throw
new
FileNotFoundException
(
"Could not create input directory: "
+
topologyTempInputDir
.
getAbsolutePath
());
}
}
credentialsTempInputDirPath
=
tempInputDirPath
+
File
.
separator
+
INFS_FOLDER_NAME
+
File
.
separator
+
UC_FOLDER_NAME
;
credentialsTempInputDirPath
=
tempInputDirPath
+
File
.
separator
+
INFS_FOLDER_NAME
+
File
.
separator
+
UC_FOLDER_NAME
;
File
credentialsTempInputDir
=
new
File
(
credentialsTempInputDirPath
);
File
credentialsTempInputDir
=
new
File
(
credentialsTempInputDirPath
);
if
(!(
credentialsTempInputDir
.
mkdirs
()))
{
if
(!(
credentialsTempInputDir
.
mkdirs
()))
{
throw
new
FileNotFoundException
(
"Could not create input directory: "
+
credentialsTempInputDir
.
getAbsolutePath
());
throw
new
FileNotFoundException
(
"Could not create input directory: "
+
credentialsTempInputDir
.
getAbsolutePath
());
}
}
providersDBTempInputDirPath
=
tempInputDirPath
+
File
.
separator
+
INFS_FOLDER_NAME
+
File
.
separator
+
UD_FOLDER_NAME
;
providersDBTempInputDirPath
=
tempInputDirPath
+
File
.
separator
+
INFS_FOLDER_NAME
+
File
.
separator
+
UD_FOLDER_NAME
;
File
providersDBTempInputDir
=
new
File
(
providersDBTempInputDirPath
);
File
providersDBTempInputDir
=
new
File
(
providersDBTempInputDirPath
);
if
(!(
providersDBTempInputDir
.
mkdirs
()))
{
if
(!(
providersDBTempInputDir
.
mkdirs
()))
{
throw
new
FileNotFoundException
(
"Could not create input directory: "
+
providersDBTempInputDir
.
getAbsolutePath
());
throw
new
FileNotFoundException
(
"Could not create input directory: "
+
providersDBTempInputDir
.
getAbsolutePath
());
}
}
infrasCodeTempInputDirPath
=
tempInputDirPath
+
File
.
separator
+
APP_FOLDER_NAME
;
infrasCodeTempInputDirPath
=
tempInputDirPath
+
File
.
separator
+
APP_FOLDER_NAME
;
File
infrasCodeTempInputDir
=
new
File
(
infrasCodeTempInputDirPath
);
File
infrasCodeTempInputDir
=
new
File
(
infrasCodeTempInputDirPath
);
if
(!(
infrasCodeTempInputDir
.
mkdirs
()))
{
if
(!(
infrasCodeTempInputDir
.
mkdirs
()))
{
throw
new
FileNotFoundException
(
"Could not create input directory: "
+
topologyTempInputDir
.
getAbsolutePath
());
throw
new
FileNotFoundException
(
"Could not create input directory: "
+
topologyTempInputDir
.
getAbsolutePath
());
}
}
}
}
private
CloudStormService
getService
(
String
messagefilePath
)
throws
IOException
,
JsonProcessingException
,
ApiException
{
private
CloudStormService
getService
(
String
messagefilePath
)
throws
IOException
,
JsonProcessingException
,
ApiException
{
Message
message
=
objectMapper
.
readValue
(
new
File
(
messagefilePath
),
Message
.
class
);
Message
message
=
objectMapper
.
readValue
(
new
File
(
messagefilePath
),
Message
.
class
);
return
new
CloudStormService
(
RPCServer
.
getProp
(),
message
.
getToscaTemplate
());
return
new
CloudStormService
(
RPCServer
.
getProp
(),
message
.
getToscaTemplate
());
}
}
private
void
testWriteCloudStormInfrasFiles
(
String
path
,
CloudsStormSubTopology
.
StatusEnum
status
,
OpCode
.
OperationEnum
opCode
)
throws
IOException
,
JsonProcessingException
,
ApiException
,
Exception
{
private
void
testWriteCloudStormInfrasFiles
(
String
path
,
CloudsStormSubTopology
.
StatusEnum
status
,
OpCode
.
OperationEnum
opCode
)
throws
IOException
,
JsonProcessingException
,
ApiException
,
Exception
{
CloudStormService
instance
=
getService
(
path
);
CloudStormService
instance
=
getService
(
path
);
initPaths
();
initPaths
();
...
@@ -268,17 +274,17 @@ public class CloudStormServiceTest {
...
@@ -268,17 +274,17 @@ public class CloudStormServiceTest {
CloudsStormTopTopology
_top
=
objectMapper
.
readValue
(
new
File
(
tempInputDirPath
+
TOPOLOGY_RELATIVE_PATH
CloudsStormTopTopology
_top
=
objectMapper
.
readValue
(
new
File
(
tempInputDirPath
+
TOPOLOGY_RELATIVE_PATH
+
TOP_TOPOLOGY_FILE_NAME
),
+
TOP_TOPOLOGY_FILE_NAME
),
CloudsStormTopTopology
.
class
);
CloudsStormTopTopology
.
class
);
for
(
CloudsStormSubTopology
cloudsStormSubTopology
:
_top
.
getTopologies
())
{
for
(
CloudsStormSubTopology
cloudsStormSubTopology
:
_top
.
getTopologies
())
{
assertEquals
(
status
,
cloudsStormSubTopology
.
getStatus
());
assertEquals
(
status
,
cloudsStormSubTopology
.
getStatus
());
}
}
List
<
CloudsStormSubTopology
>
cloudStormSubtopologies
=
(
List
<
CloudsStormSubTopology
>)
subTopologiesAndVMs
.
get
(
"cloud_storm_subtopologies"
);
List
<
CloudsStormSubTopology
>
cloudStormSubtopologies
=
(
List
<
CloudsStormSubTopology
>)
subTopologiesAndVMs
.
get
(
"cloud_storm_subtopologies"
);
instance
.
writeCloudStormInfrasCodeFiles
(
infrasCodeTempInputDirPath
,
cloudStormSubtopologies
);
instance
.
writeCloudStormInfrasCodeFiles
(
infrasCodeTempInputDirPath
,
cloudStormSubtopologies
);
File
infrasCodeFile
=
new
File
(
infrasCodeTempInputDirPath
+
File
.
separator
+
INFRASTUCTURE_CODE_FILE_NAME
);
File
infrasCodeFile
=
new
File
(
infrasCodeTempInputDirPath
+
File
.
separator
+
INFRASTUCTURE_CODE_FILE_NAME
);
assertTrue
(
infrasCodeFile
.
exists
());
assertTrue
(
infrasCodeFile
.
exists
());
CloudsStormInfrasCode
cloudsStormInfrasCode
=
objectMapper
.
readValue
(
infrasCodeFile
,
CloudsStormInfrasCode
.
class
);
CloudsStormInfrasCode
cloudsStormInfrasCode
=
objectMapper
.
readValue
(
infrasCodeFile
,
CloudsStormInfrasCode
.
class
);
for
(
InfrasCode
code
:
cloudsStormInfrasCode
.
getInfrasCodes
())
{
for
(
InfrasCode
code
:
cloudsStormInfrasCode
.
getInfrasCodes
())
{
assertEquals
(
opCode
,
code
.
getOpCode
().
getOperation
());
assertEquals
(
opCode
,
code
.
getOpCode
().
getOperation
());
}
}
...
@@ -286,20 +292,41 @@ public class CloudStormServiceTest {
...
@@ -286,20 +292,41 @@ public class CloudStormServiceTest {
/**
/**
* Test of addCloudStromArtifacts method, of class CloudStormService.
* Test of addCloudStromArtifacts method, of class CloudStormService.
*
* @throws java.lang.Exception
*/
*/
@Test
@Test
public
void
testAddCloudStromArtifacts
()
throws
Exception
{
public
void
testAddCloudStromArtifacts
()
throws
Exception
{
if
(
ToscaHelper
.
isServiceUp
(
sureToscaBasePath
))
{
if
(
ToscaHelper
.
isServiceUp
(
sureToscaBasePath
))
{
System
.
out
.
println
(
"addCloudStromArtifacts"
);
}
testWriteCloudStormInfrasFiles
(
messageExampleProvisioneRequestFilePath
,
CloudsStormSubTopology
.
StatusEnum
.
FRESH
,
OpCode
.
OperationEnum
.
PROVISION
);
System
.
out
.
println
(
"addCloudStromArtifacts"
);
CloudStormService
instance
=
getService
(
messageExampleProvisioneRequestFilePath
);
initPaths
();
List
<
NodeTemplateMap
>
vmTopologiesMaps
=
instance
.
getHelper
().
getVMTopologyTemplates
();
CloudStormService
instance
=
getService
(
messageExampleProvisioneRequestFilePath
);
for
(
NodeTemplateMap
vmTopologyMap
:
vmTopologiesMaps
)
{
List
<
NodeTemplateMap
>
vmTopologiesMaps
=
instance
.
getHelper
().
getVMTopologyTemplates
();
vmTopologyMap
=
instance
.
addCloudStromArtifacts
(
vmTopologyMap
,
tempInputDirPath
);
for
(
NodeTemplateMap
vmTopologyMap
:
vmTopologiesMaps
)
{
File
zipFile
=
new
File
(
tempInputDirPath
+
File
.
separator
+
TOPOLOGY_FOLDER_NAME
+
".zip"
);
vmTopologyMap
=
instance
.
addCloudStromArtifacts
(
vmTopologyMap
,
tempInputDirPath
);
assertTrue
(
zipFile
.
exists
());
assertTrue
(
zipFile
.
length
()
>
1
);
String
contentType
=
Files
.
probeContentType
(
Paths
.
get
(
zipFile
.
getAbsolutePath
()));
assertEquals
(
"application/zip"
,
contentType
);
Map
<
String
,
Object
>
artifacts
=
vmTopologyMap
.
getNodeTemplate
().
getArtifacts
();
assertNotNull
(
artifacts
);
assertTrue
(
artifacts
.
containsKey
(
"provisioned_files"
));
Map
<
String
,
String
>
provisionedFiles
=
(
Map
<
String
,
String
>)
artifacts
.
get
(
"provisioned_files"
);
assertNotNull
(
provisionedFiles
);
assertTrue
(
provisionedFiles
.
containsKey
(
"file_contents"
));
String
cloudStormZipFileContentsAsBase64
=
provisionedFiles
.
get
(
"file_contents"
);
String
testZipPath
=
tempInputDirPath
+
File
.
separator
+
"test.zip"
;
Converter
.
decodeBase64BToFile
(
cloudStormZipFileContentsAsBase64
,
testZipPath
);
contentType
=
Files
.
probeContentType
(
Paths
.
get
(
testZipPath
));
assertEquals
(
"application/zip"
,
contentType
);
assertEquals
(
Converter
.
getFileMD5
(
zipFile
.
getAbsolutePath
()),
Converter
.
getFileMD5
(
testZipPath
));
assertTrue
(
provisionedFiles
.
containsKey
(
"encoding"
));
assertTrue
(
provisionedFiles
.
containsKey
(
"file_ext"
));
}
}
}
}
}
}
}
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