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
6b86c1a2
Commit
6b86c1a2
authored
Mar 17, 2020
by
Spiros Koulouzis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added MissingVMTopologyException
parent
2a282261
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
263 additions
and
253 deletions
+263
-253
.travis.yml
.travis.yml
+1
-1
DRIPService.java
...er/src/main/java/nl/uva/sne/drip/service/DRIPService.java
+12
-6
ServiceTests.java
...r/src/test/java/nl/uva/sne/drip/service/ServiceTests.java
+245
-243
tosca_template_service.py
...flask-server/sure_tosca/service/tosca_template_service.py
+5
-3
No files found.
.travis.yml
View file @
6b86c1a2
...
...
@@ -12,7 +12,7 @@ matrix:
-
python -m unittest discover
-
docker build -t alogo53/planner:3.0.0 .
-
language
:
python
python
:
3.
8
python
:
3.
7
before_script
:
-
cd sure_tosca-flask-server
-
pip install -r requirements.txt
...
...
manager/src/main/java/nl/uva/sne/drip/service/DRIPService.java
View file @
6b86c1a2
...
...
@@ -16,6 +16,7 @@ import java.util.logging.Logger;
import
nl.uva.sne.drip.api.NotFoundException
;
import
nl.uva.sne.drip.commons.utils.ToscaHelper
;
import
nl.uva.sne.drip.model.Exceptions.MissingCredentialsException
;
import
nl.uva.sne.drip.model.Exceptions.MissingVMTopologyException
;
import
nl.uva.sne.drip.model.Exceptions.TypeExeption
;
import
nl.uva.sne.drip.model.Message
;
import
nl.uva.sne.drip.model.NodeTemplateMap
;
...
...
@@ -94,8 +95,11 @@ public class DRIPService {
return
credentials
.
get
(
0
);
}
private
ToscaTemplate
addCredentials
(
ToscaTemplate
toscaTemplate
)
throws
MissingCredentialsException
,
ApiException
,
TypeExeption
{
private
ToscaTemplate
addCredentials
(
ToscaTemplate
toscaTemplate
)
throws
MissingCredentialsException
,
ApiException
,
TypeExeption
,
MissingVMTopologyException
{
List
<
NodeTemplateMap
>
vmTopologies
=
helper
.
getVMTopologyTemplates
();
if
(
vmTopologies
==
null
){
throw
new
MissingVMTopologyException
(
"ToscaTemplate: "
+
toscaTemplate
+
" has no VM topology"
);
}
List
<
Credential
>
credentials
=
null
;
for
(
NodeTemplateMap
vmTopologyMap
:
vmTopologies
)
{
String
provider
=
helper
.
getTopologyProvider
(
vmTopologyMap
);
...
...
@@ -120,7 +124,7 @@ public class DRIPService {
return
execute
(
toscaTemplate
);
}
public
String
provision
(
String
id
)
throws
MissingCredentialsException
,
ApiException
,
TypeExeption
,
IOException
,
JsonProcessingException
,
TimeoutException
,
InterruptedException
,
NotFoundException
{
public
String
provision
(
String
id
)
throws
MissingCredentialsException
,
ApiException
,
TypeExeption
,
IOException
,
JsonProcessingException
,
TimeoutException
,
InterruptedException
,
NotFoundException
,
MissingVMTopologyException
{
ToscaTemplate
toscaTemplate
=
initExecution
(
id
);
toscaTemplate
=
addCredentials
(
toscaTemplate
);
toscaTemplate
=
setProvisionerOperation
(
toscaTemplate
,
PROVISIONER_OPERATION
.
PROVISION
);
...
...
@@ -169,13 +173,15 @@ public class DRIPService {
void
deleteActions
(
ToscaTemplate
toscaTemplate
)
throws
ApiException
,
TypeExeption
,
IOException
{
helper
.
uploadToscaTemplate
(
toscaTemplate
);
List
<
NodeTemplateMap
>
vmTopologies
=
helper
.
getVMTopologyTemplates
();
if
(
vmTopologies
!=
null
)
{
for
(
NodeTemplateMap
vmTopology
:
vmTopologies
)
{
CloudsStormSubTopology
.
StatusEnum
status
=
helper
.
getVMTopologyTemplateStatus
(
vmTopology
);
if
(!
status
.
equals
(
CloudsStormSubTopology
.
StatusEnum
.
DELETED
))
{
Logger
.
getLogger
(
ToscaHelper
.
class
.
getName
()).
log
(
Level
.
FINE
,
"Deleting VMs from "
+
vmTopology
);
}
}
}
}
...
...
manager/src/test/java/nl/uva/sne/drip/service/ServiceTests.java
View file @
6b86c1a2
...
...
@@ -42,6 +42,7 @@ 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.model.Exceptions.MissingCredentialsException
;
import
nl.uva.sne.drip.model.Exceptions.MissingVMTopologyException
;
import
nl.uva.sne.drip.model.Exceptions.TypeExeption
;
import
nl.uva.sne.drip.model.tosca.Credential
;
import
nl.uva.sne.drip.sure.tosca.client.ApiException
;
...
...
@@ -139,96 +140,97 @@ public class ServiceTests {
Assert
.
assertTrue
(
true
);
}
// /**
// * Test of saveFile method, of class ToscaTemplateService.
// *
// * @throws java.lang.Exception
// */
// @Test
// public void testToscaTemplateServiceSaveFile() throws Exception {
// Logger.getLogger(ServiceTests.class.getName()).log(Level.INFO, "saveFile");
// FileInputStream in = new FileInputStream(testApplicationExampleToscaFilePath);
// MultipartFile file = new MockMultipartFile("file", in);
// toscaTemplateID = toscaTemplateService.saveFile(file);
// Assert.assertNotNull(toscaTemplateID);
// testApplicationExampleToscaContents = toscaTemplateService.findByID(toscaTemplateID);
// Assert.assertNotNull(testApplicationExampleToscaContents);
// }
//
// /**
// * Test of updateToscaTemplateByID method, of class ToscaTemplateService.
// */
// @Test
// public void testToscaTemplateServiceUpdateToscaTemplateByID_String_MultipartFile() {
// FileInputStream in = null;
// try {
// Logger.getLogger(ServiceTests.class.getName()).log(Level.INFO, "updateToscaTemplateByID");
// if (toscaTemplateID == null) {
// testToscaTemplateServiceSaveFile();
// }
// in = new FileInputStream(testUpdatedApplicationExampleToscaFilePath);
// MultipartFile file = new MockMultipartFile("file", in);
// String expResult = toscaTemplateID;
// String result = toscaTemplateService.updateToscaTemplateByID(toscaTemplateID, file);
// assertEquals(expResult, result);
// String updatedTemplate = toscaTemplateService.findByID(result);
// Assert.assertNotNull(updatedTemplate);
// Assert.assertNotEquals(result, testApplicationExampleToscaContents);
// } catch (FileNotFoundException ex) {
// Logger.getLogger(ServiceTests.class.getName()).log(Level.SEVERE, null, ex);
// } catch (Exception ex) {
// Logger.getLogger(ServiceTests.class.getName()).log(Level.SEVERE, null, ex);
// } finally {
// try {
// if (in != null) {
// in.close();
// }
// } catch (IOException ex) {
// fail(ex.getMessage());
// Logger.getLogger(ServiceTests.class.getName()).log(Level.SEVERE, null, ex);
// }
// }
// }
//
// /**
// * Test of updateToscaTemplateByID method, of class ToscaTemplateService.
// *
// * @throws java.io.FileNotFoundException
// */
// @Test
// public void testToscaTemplateServiceUpdateToscaTemplateByID_Exception_MultipartFile() throws FileNotFoundException, IOException {
// FileInputStream in = new FileInputStream(testUpdatedApplicationExampleToscaFilePath);
// MultipartFile file = new MockMultipartFile("file", in);
// try {
// toscaTemplateService.updateToscaTemplateByID("0", file);
// } catch (Exception ex) {
// if (!(ex instanceof NoSuchElementException)) {
// fail(ex.getMessage());
// }
// }
// }
//
// /**
// * Test of findByID method, of class ToscaTemplateService.
// */
// @Test
// public void testToscaTemplateServiceFindByID() {
// try {
// Logger.getLogger(ServiceTests.class.getName()).log(Level.INFO, "findByID");
// if (toscaTemplateID == null) {
// testToscaTemplateServiceSaveFile();
// }
// String result = toscaTemplateService.findByID(toscaTemplateID);
// Assert.assertNotNull(result);
// assertEquals(testApplicationExampleToscaContents, result);
// } catch (JsonProcessingException ex) {
// fail(ex.getMessage());
// Logger.getLogger(ServiceTests.class.getName()).log(Level.SEVERE, null, ex);
// } catch (Exception ex) {
// fail(ex.getMessage());
// Logger.getLogger(ServiceTests.class.getName()).log(Level.SEVERE, null, ex);
// }
// }
/**
* Test of saveFile method, of class ToscaTemplateService.
*
* @throws java.lang.Exception
*/
@Test
public
void
testToscaTemplateServiceSaveFile
()
throws
Exception
{
Logger
.
getLogger
(
ServiceTests
.
class
.
getName
()).
log
(
Level
.
INFO
,
"saveFile"
);
FileInputStream
in
=
new
FileInputStream
(
testApplicationExampleToscaFilePath
);
MultipartFile
file
=
new
MockMultipartFile
(
"file"
,
in
);
toscaTemplateID
=
toscaTemplateService
.
saveFile
(
file
);
Assert
.
assertNotNull
(
toscaTemplateID
);
testApplicationExampleToscaContents
=
toscaTemplateService
.
findByID
(
toscaTemplateID
);
Assert
.
assertNotNull
(
testApplicationExampleToscaContents
);
}
/**
* Test of updateToscaTemplateByID method, of class ToscaTemplateService.
*/
@Test
public
void
testToscaTemplateServiceUpdateToscaTemplateByID_String_MultipartFile
()
{
FileInputStream
in
=
null
;
try
{
Logger
.
getLogger
(
ServiceTests
.
class
.
getName
()).
log
(
Level
.
INFO
,
"updateToscaTemplateByID"
);
if
(
toscaTemplateID
==
null
)
{
testToscaTemplateServiceSaveFile
();
}
in
=
new
FileInputStream
(
testUpdatedApplicationExampleToscaFilePath
);
MultipartFile
file
=
new
MockMultipartFile
(
"file"
,
in
);
String
expResult
=
toscaTemplateID
;
String
result
=
toscaTemplateService
.
updateToscaTemplateByID
(
toscaTemplateID
,
file
);
assertEquals
(
expResult
,
result
);
String
updatedTemplate
=
toscaTemplateService
.
findByID
(
result
);
Assert
.
assertNotNull
(
updatedTemplate
);
Assert
.
assertNotEquals
(
result
,
testApplicationExampleToscaContents
);
}
catch
(
FileNotFoundException
ex
)
{
Logger
.
getLogger
(
ServiceTests
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
}
catch
(
Exception
ex
)
{
Logger
.
getLogger
(
ServiceTests
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
}
finally
{
try
{
if
(
in
!=
null
)
{
in
.
close
();
}
}
catch
(
IOException
ex
)
{
fail
(
ex
.
getMessage
());
Logger
.
getLogger
(
ServiceTests
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
}
}
}
/**
* Test of updateToscaTemplateByID method, of class ToscaTemplateService.
*
* @throws java.io.FileNotFoundException
*/
@Test
public
void
testToscaTemplateServiceUpdateToscaTemplateByID_Exception_MultipartFile
()
throws
FileNotFoundException
,
IOException
{
FileInputStream
in
=
new
FileInputStream
(
testUpdatedApplicationExampleToscaFilePath
);
MultipartFile
file
=
new
MockMultipartFile
(
"file"
,
in
);
try
{
toscaTemplateService
.
updateToscaTemplateByID
(
"0"
,
file
);
}
catch
(
Exception
ex
)
{
if
(!(
ex
instanceof
NoSuchElementException
))
{
fail
(
ex
.
getMessage
());
}
}
}
/**
* Test of findByID method, of class ToscaTemplateService.
*/
@Test
public
void
testToscaTemplateServiceFindByID
()
{
try
{
Logger
.
getLogger
(
ServiceTests
.
class
.
getName
()).
log
(
Level
.
INFO
,
"findByID"
);
if
(
toscaTemplateID
==
null
)
{
testToscaTemplateServiceSaveFile
();
}
String
result
=
toscaTemplateService
.
findByID
(
toscaTemplateID
);
Assert
.
assertNotNull
(
result
);
assertEquals
(
testApplicationExampleToscaContents
,
result
);
}
catch
(
JsonProcessingException
ex
)
{
fail
(
ex
.
getMessage
());
Logger
.
getLogger
(
ServiceTests
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
}
catch
(
Exception
ex
)
{
fail
(
ex
.
getMessage
());
Logger
.
getLogger
(
ServiceTests
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
}
}
/**
* Test of deleteByID method, of class ToscaTemplateService.
*/
...
...
@@ -255,157 +257,157 @@ public class ServiceTests {
}
////
/**
////
* Test of getAllIds method, of class ToscaTemplateService.
////
*
////
* @throws java.lang.Exception
////
*/
////
@Test
////
public void testToscaTemplateServiceGetAllIds() throws Exception {
////
Logger.getLogger(ServiceTests.class.getName()).log(Level.INFO, "getAllIds");
////
testToscaTemplateServiceDeleteAll();
////
int numOfINst = 3;
////
for (int i = 1; i <= numOfINst; i++) {
////
testToscaTemplateServiceSaveFile();
////
}
////
List<String> result = toscaTemplateService.getAllIds();
////
assertEquals(numOfINst, result.size());
////
}
////
////
@Test
////
public void testToscaTemplateServiceDeleteAll() {
////
toscaTemplateService.deleteAll();
////
int size = toscaTemplateService.getAllIds().size();
////
assertEquals(0, size);
////
}
////
////
/**
////
* Test of save method, of class CredentialService.
////
*/
////
@Test
////
public void testCredentialServiceSave() {
////
Logger.getLogger(ServiceTests.class.getName()).log(Level.INFO, "save");
////
saveCredential();
////
}
////
////
@Test
////
public void testCredentialService() throws IOException, NoSuchAlgorithmException {
////
Logger.getLogger(ServiceTests.class.getName()).log(Level.INFO, "testCredentialService");
////
String keyStoreEncoded = Converter.encodeFileToBase64Binary(testCredentialPath);
////
////
Credential credential = new Credential();
////
credential.setCloudProviderName("ExoGENI");
////
Map<String, String> keys = new HashMap<>();
////
keys.put("keystore", keyStoreEncoded);
////
credential.setKeys(keys);
////
credential.setToken("1234");
////
credential.setTokenType("password");
////
credential.setUser("user");
////
////
String keyStoreEncodedFromCredential = credential.getKeys().get("keystore");
////
assertEquals(keyStoreEncoded, keyStoreEncodedFromCredential);
////
////
String copyTestCredentialPath = ".." + File.separator + "fake_credentials" + File.separator + "copy_of_test-geni.jks";
////
Converter.decodeBase64BToFile(keyStoreEncodedFromCredential, copyTestCredentialPath);
////
////
String keystorFileChecksum = Converter.getFileMD5(testCredentialPath);
////
String keystorFileCopyChecksum = Converter.getFileMD5(copyTestCredentialPath);
////
////
assertEquals(keystorFileChecksum, keystorFileCopyChecksum);
////
}
////
////
public String saveCredential() {
////
Logger.getLogger(ServiceTests.class.getName()).log(Level.INFO, "saveCredential");
////
Credential document = new Credential();
////
document.setCloudProviderName("exogeni");
////
Map<String, String> keys = new HashMap<>();
////
keys.put("keystore", "/qTlqams0Ppq2rnaOgL5am7ExGO2nMsOZYM61kiAnsvkOixUuoPy9r4d4OfhwQXXg3lZmeRITjNz4ps+hIDKuxodIQXgBtfMy9Kx8Syb9bIl/MQQls5hWyp9yHAl6vAampoxYu0170lceT1sds4OCz3tM9eF7/UoBQwXBPo94QhO1/vSbtICyVsm3Z2HeGKcBWobT3opZV2w30GqX/7OBmNeIG7RBMPuxLsUxJ9Alahi1zXOUjLkd2bmmVFREngmeubgCzPFxxCQQrZK6WratTzJKc1sRVNK5GJzTwi9BlcZSQSgprum9yVHUgQc6Ylmvdrkhn2g9SlluY2JAZyCZvHYaRBKE4o5bXBDumTy1YAPMNPTfpeeLz+YmH0GMfVwKkxtIBpjb045QseoIWcqxke60WWfJguaTqymXknmcqcLNz+UzUdfVfyurOy9X8xmTGCW5V4N");
////
document.setKeys(keys);
////
document.setToken("secret");
////
document.setTokenType("password");
////
////
return credentialService.save(document);
////
}
////
////
/**
////
* Test of findByID method, of class CredentialService.
////
*
////
* @throws java.lang.Exception
////
*/
////
@Test
////
public void testCredentialServiceFindByID() throws Exception {
////
Logger.getLogger(ServiceTests.class.getName()).log(Level.INFO, "findByID");
////
String id = saveCredential();
////
Credential result = credentialService.findByID(id);
////
assertNotNull(result);
////
}
////
////
/**
////
* Test of deleteByID method, of class CredentialService.
////
*
////
* @throws com.fasterxml.jackson.core.JsonProcessingException
////
*/
////
@Test
////
public void testCredentialServiceDeleteByID() throws JsonProcessingException {
////
Logger.getLogger(ServiceTests.class.getName()).log(Level.INFO, "deleteByID");
////
String id = saveCredential();
////
credentialService.deleteByID(id);
////
try {
////
Credential res = credentialService.findByID(id);
////
assertNotNull(res);
////
} catch (Exception ex) {
////
if (!(ex instanceof NoSuchElementException)) {
////
fail(ex.getMessage());
////
}
////
}
////
}
////
////
/**
////
* Test of getAllIds method, of class CredentialService.
////
*/
////
@Test
////
public void testCredentialServiceGetAllIds() {
////
Logger.getLogger(ServiceTests.class.getName()).log(Level.INFO, "getAllIds");
////
testCredentialServiceDeleteAll();
////
int numOfINst = 3;
////
for (int i = 1; i <= numOfINst; i++) {
////
saveCredential();
////
}
////
List<String> result = credentialService.getAllIds();
////
assertEquals(numOfINst, result.size());
////
}
////
////
/**
////
* Test of deleteAll method, of class CredentialService.
////
*/
////
@Test
////
public void testCredentialServiceDeleteAll() {
////
credentialService.deleteAll();
////
int size = credentialService.getAllIds().size();
////
assertEquals(0, size);
////
}
////
////
@Test
////
public void testProvision() throws FileNotFoundException, IOException, MissingCredentialsException, ApiException, TypeExeption, JsonProcessingException, TimeoutException, InterruptedException, NotFoundException {
////
if (ToscaHelper.isServiceUp(sureToscaBasePath) && ToscaHelper.isServiceUp("http://" + messageBrokerHost + ":15672")) {
////
Credential document = new Credential();
////
document.setCloudProviderName("exogeni");
////
Map<String, String> keys = new HashMap<>();
////
keys.put("keystore", "/qTlqams0Ppq2rnaOgL5am7ExGO2nMsOZYM61kiAnsvkOixUuoPy9r4d4OfhwQXXg3lZmeRITjNz4ps+hIDKuxodIQXgBtfMy9Kx8Syb9bIl/MQQls5hWyp9yHAl6vAampoxYu0170lceT1sds4OCz3tM9eF7/UoBQwXBPo94QhO1/vSbtICyVsm3Z2HeGKcBWobT3opZV2w30GqX/7OBmNeIG7RBMPuxLsUxJ9Alahi1zXOUjLkd2bmmVFREngmeubgCzPFxxCQQrZK6WratTzJKc1sRVNK5GJzTwi9BlcZSQSgprum9yVHUgQc6Ylmvdrkhn2g9SlluY2JAZyCZvHYaRBKE4o5bXBDumTy1YAPMNPTfpeeLz+YmH0GMfVwKkxtIBpjb045QseoIWcqxke60WWfJguaTqymXknmcqcLNz+UzUdfVfyurOy9X8xmTGCW5V4N");
////
document.setKeys(keys);
////
document.setToken("secret");
////
document.setTokenType("password");
////
////
String credentialID = credentialService.save(document);
////
assertNotNull(credentialID);
////
////
FileInputStream in = new FileInputStream(testApplicationExampleToscaFilePath);
////
////
MultipartFile file = new MockMultipartFile("file", in);
////
toscaTemplateID = toscaTemplateService.saveFile(file);
////
//
//
dripService.setRequestQeueName(provisionerQueueName);
//
//
String planedYemplateId = dripService.provision(toscaTemplateID);
////
}
//
}
/**
* Test of getAllIds method, of class ToscaTemplateService.
*
* @throws java.lang.Exception
*/
@Test
public
void
testToscaTemplateServiceGetAllIds
()
throws
Exception
{
Logger
.
getLogger
(
ServiceTests
.
class
.
getName
()).
log
(
Level
.
INFO
,
"getAllIds"
);
testToscaTemplateServiceDeleteAll
();
int
numOfINst
=
3
;
for
(
int
i
=
1
;
i
<=
numOfINst
;
i
++)
{
testToscaTemplateServiceSaveFile
();
}
List
<
String
>
result
=
toscaTemplateService
.
getAllIds
();
assertEquals
(
numOfINst
,
result
.
size
());
}
@Test
public
void
testToscaTemplateServiceDeleteAll
()
{
toscaTemplateService
.
deleteAll
();
int
size
=
toscaTemplateService
.
getAllIds
().
size
();
assertEquals
(
0
,
size
);
}
/**
* Test of save method, of class CredentialService.
*/
@Test
public
void
testCredentialServiceSave
()
{
Logger
.
getLogger
(
ServiceTests
.
class
.
getName
()).
log
(
Level
.
INFO
,
"save"
);
saveCredential
();
}
@Test
public
void
testCredentialService
()
throws
IOException
,
NoSuchAlgorithmException
{
Logger
.
getLogger
(
ServiceTests
.
class
.
getName
()).
log
(
Level
.
INFO
,
"testCredentialService"
);
String
keyStoreEncoded
=
Converter
.
encodeFileToBase64Binary
(
testCredentialPath
);
Credential
credential
=
new
Credential
();
credential
.
setCloudProviderName
(
"ExoGENI"
);
Map
<
String
,
String
>
keys
=
new
HashMap
<>();
keys
.
put
(
"keystore"
,
keyStoreEncoded
);
credential
.
setKeys
(
keys
);
credential
.
setToken
(
"1234"
);
credential
.
setTokenType
(
"password"
);
credential
.
setUser
(
"user"
);
String
keyStoreEncodedFromCredential
=
credential
.
getKeys
().
get
(
"keystore"
);
assertEquals
(
keyStoreEncoded
,
keyStoreEncodedFromCredential
);
String
copyTestCredentialPath
=
".."
+
File
.
separator
+
"fake_credentials"
+
File
.
separator
+
"copy_of_test-geni.jks"
;
Converter
.
decodeBase64BToFile
(
keyStoreEncodedFromCredential
,
copyTestCredentialPath
);
String
keystorFileChecksum
=
Converter
.
getFileMD5
(
testCredentialPath
);
String
keystorFileCopyChecksum
=
Converter
.
getFileMD5
(
copyTestCredentialPath
);
assertEquals
(
keystorFileChecksum
,
keystorFileCopyChecksum
);
}
public
String
saveCredential
()
{
Logger
.
getLogger
(
ServiceTests
.
class
.
getName
()).
log
(
Level
.
INFO
,
"saveCredential"
);
Credential
document
=
new
Credential
();
document
.
setCloudProviderName
(
"exogeni"
);
Map
<
String
,
String
>
keys
=
new
HashMap
<>();
keys
.
put
(
"keystore"
,
"/qTlqams0Ppq2rnaOgL5am7ExGO2nMsOZYM61kiAnsvkOixUuoPy9r4d4OfhwQXXg3lZmeRITjNz4ps+hIDKuxodIQXgBtfMy9Kx8Syb9bIl/MQQls5hWyp9yHAl6vAampoxYu0170lceT1sds4OCz3tM9eF7/UoBQwXBPo94QhO1/vSbtICyVsm3Z2HeGKcBWobT3opZV2w30GqX/7OBmNeIG7RBMPuxLsUxJ9Alahi1zXOUjLkd2bmmVFREngmeubgCzPFxxCQQrZK6WratTzJKc1sRVNK5GJzTwi9BlcZSQSgprum9yVHUgQc6Ylmvdrkhn2g9SlluY2JAZyCZvHYaRBKE4o5bXBDumTy1YAPMNPTfpeeLz+YmH0GMfVwKkxtIBpjb045QseoIWcqxke60WWfJguaTqymXknmcqcLNz+UzUdfVfyurOy9X8xmTGCW5V4N"
);
document
.
setKeys
(
keys
);
document
.
setToken
(
"secret"
);
document
.
setTokenType
(
"password"
);
return
credentialService
.
save
(
document
);
}
/**
* Test of findByID method, of class CredentialService.
*
* @throws java.lang.Exception
*/
@Test
public
void
testCredentialServiceFindByID
()
throws
Exception
{
Logger
.
getLogger
(
ServiceTests
.
class
.
getName
()).
log
(
Level
.
INFO
,
"findByID"
);
String
id
=
saveCredential
();
Credential
result
=
credentialService
.
findByID
(
id
);
assertNotNull
(
result
);
}
/**
* Test of deleteByID method, of class CredentialService.
*
* @throws com.fasterxml.jackson.core.JsonProcessingException
*/
@Test
public
void
testCredentialServiceDeleteByID
()
throws
JsonProcessingException
{
Logger
.
getLogger
(
ServiceTests
.
class
.
getName
()).
log
(
Level
.
INFO
,
"deleteByID"
);
String
id
=
saveCredential
();
credentialService
.
deleteByID
(
id
);
try
{
Credential
res
=
credentialService
.
findByID
(
id
);
assertNotNull
(
res
);
}
catch
(
Exception
ex
)
{
if
(!(
ex
instanceof
NoSuchElementException
))
{
fail
(
ex
.
getMessage
());
}
}
}
/**
* Test of getAllIds method, of class CredentialService.
*/
@Test
public
void
testCredentialServiceGetAllIds
()
{
Logger
.
getLogger
(
ServiceTests
.
class
.
getName
()).
log
(
Level
.
INFO
,
"getAllIds"
);
testCredentialServiceDeleteAll
();
int
numOfINst
=
3
;
for
(
int
i
=
1
;
i
<=
numOfINst
;
i
++)
{
saveCredential
();
}
List
<
String
>
result
=
credentialService
.
getAllIds
();
assertEquals
(
numOfINst
,
result
.
size
());
}
/**
* Test of deleteAll method, of class CredentialService.
*/
@Test
public
void
testCredentialServiceDeleteAll
()
{
credentialService
.
deleteAll
();
int
size
=
credentialService
.
getAllIds
().
size
();
assertEquals
(
0
,
size
);
}
@Test
public
void
testProvision
()
throws
FileNotFoundException
,
IOException
,
MissingCredentialsException
,
ApiException
,
TypeExeption
,
JsonProcessingException
,
TimeoutException
,
InterruptedException
,
NotFoundException
{
if
(
ToscaHelper
.
isServiceUp
(
sureToscaBasePath
)
&&
ToscaHelper
.
isServiceUp
(
"http://"
+
messageBrokerHost
+
":15672"
))
{
Credential
document
=
new
Credential
();
document
.
setCloudProviderName
(
"exogeni"
);
Map
<
String
,
String
>
keys
=
new
HashMap
<>();
keys
.
put
(
"keystore"
,
"/qTlqams0Ppq2rnaOgL5am7ExGO2nMsOZYM61kiAnsvkOixUuoPy9r4d4OfhwQXXg3lZmeRITjNz4ps+hIDKuxodIQXgBtfMy9Kx8Syb9bIl/MQQls5hWyp9yHAl6vAampoxYu0170lceT1sds4OCz3tM9eF7/UoBQwXBPo94QhO1/vSbtICyVsm3Z2HeGKcBWobT3opZV2w30GqX/7OBmNeIG7RBMPuxLsUxJ9Alahi1zXOUjLkd2bmmVFREngmeubgCzPFxxCQQrZK6WratTzJKc1sRVNK5GJzTwi9BlcZSQSgprum9yVHUgQc6Ylmvdrkhn2g9SlluY2JAZyCZvHYaRBKE4o5bXBDumTy1YAPMNPTfpeeLz+YmH0GMfVwKkxtIBpjb045QseoIWcqxke60WWfJguaTqymXknmcqcLNz+UzUdfVfyurOy9X8xmTGCW5V4N"
);
document
.
setKeys
(
keys
);
document
.
setToken
(
"secret"
);
document
.
setTokenType
(
"password"
);
String
credentialID
=
credentialService
.
save
(
document
);
assertNotNull
(
credentialID
);
FileInputStream
in
=
new
FileInputStream
(
testApplicationExampleToscaFilePath
);
MultipartFile
file
=
new
MockMultipartFile
(
"file"
,
in
);
toscaTemplateID
=
toscaTemplateService
.
saveFile
(
file
);
//
dripService.setRequestQeueName(provisionerQueueName);
//
String planedYemplateId = dripService.provision(toscaTemplateID);
}
}
}
sure_tosca-flask-server/sure_tosca/service/tosca_template_service.py
View file @
6b86c1a2
...
...
@@ -221,9 +221,11 @@ def get_node_templates(id, type_name=None, node_name=None, has_interfaces=None,
prop
=
None
queries
.
append
(
query
.
artifacts
!=
prop
)
query_results
=
query_db
(
queries
,
db
=
node_template_db
)
if
query_results
:
return
change_to_node_template_model
(
query_results
)
else
:
return
query_results
def
get_tosca_template_get_dsl_definitions
(
id
,
anchors
,
derived_from
):
...
...
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