use of org.opentosca.toscana.core.transformation.Transformation in project TOSCAna by StuPro-TOSCAna.
the class DeploymentPropertyTest method check.
@Test
public void check() {
try {
File input = new File(this.tmpdir, "in");
File output = new File(this.tmpdir, "out");
PropertyInstance instance = new PropertyInstance(new HashSet<>(platform.properties), mock(Transformation.class));
if (this.input != null) {
instance.set(Platform.DEPLOY_AFTER_TRANSFORMATION_KEY, this.input);
}
Csar csar = new CsarImpl(input, "csarId", logMock());
Transformation t = new TransformationImpl(csar, platform, logMock(), mock(EffectiveModel.class));
Transformation transformation = spy(t);
when(transformation.getInputs()).thenReturn(instance);
TransformationContext context = new TransformationContext(transformation, output);
Assert.assertEquals(expected, context.performDeployment());
} catch (Exception e) {
e.printStackTrace(System.out);
if (expectedException == null || !expectedException.isInstance(e)) {
fail();
}
}
}
use of org.opentosca.toscana.core.transformation.Transformation in project TOSCAna by StuPro-TOSCAna.
the class LifecycleAwarePluginTest method setUp.
@Before
public void setUp() throws Exception {
Csar csar = new CsarImpl(tmpdir, "csarId", logMock());
Transformation t = new TransformationImpl(csar, TestPlugins.PLATFORM1, logMock(), mock(EffectiveModel.class));
context = spy(new TransformationContext(t, tmpdir));
doReturn(false).when(context).performDeployment();
lifecycle = spy(new TestTransformationLifecycle(context));
checkModel = true;
plugin = new LifecycleTestPlugin(TestPlugins.PLATFORM1);
}
use of org.opentosca.toscana.core.transformation.Transformation in project TOSCAna by StuPro-TOSCAna.
the class TransformerHealthIndicatorTest method initTestEnvironment.
private void initTestEnvironment() {
// Create Dummy Csar
// DummyCsar csar = new DummyCsar("test");
Csar csar = new CsarImpl(new File(""), MOCK_CSAR_NAME, logMock());
csar = spy(csar);
Map<String, Transformation> transformations = new HashMap<>();
Set<Platform> platformSet = new HashSet<>();
for (Object[] d : MOCK_DATA) {
// Initialize transformation Mock
Transformation transformation = new TransformationImpl(csar, (Platform) d[0], logMock(), modelMock());
transformation.setState((TransformationState) d[1]);
transformations.put(((Platform) d[0]).id, transformation);
// Add platform to supported platform list
platformSet.add((Platform) d[0]);
}
// Add Transformations to csar
when(csar.getTransformations()).thenReturn(transformations);
// Platforms
when(pluginService.getSupportedPlatforms()).thenReturn(platformSet);
// Repository
when(repository.findAll()).thenReturn(Collections.singletonList(csar));
}
use of org.opentosca.toscana.core.transformation.Transformation in project TOSCAna by StuPro-TOSCAna.
the class KubernetesLampIT method getInputs.
@Override
protected PropertyInstance getInputs(EffectiveModel model) throws NoSuchPropertyException {
Set<InputProperty> prop = new HashSet<>(plugin.getPlatform().properties);
prop.addAll(model.getInputs().values());
PropertyInstance instance = new PropertyInstance(prop, mock(Transformation.class));
if (System.getenv("DH_USERNAME") != null) {
// This Transformation is performed by pushing to a registry
instance.set(DOCKER_PUSH_TO_REGISTRY_PROPERTY_KEY, "true");
instance.set(DOCKER_REGISTRY_USERNAME_PROPERTY_KEY, System.getenv("DH_USERNAME"));
instance.set(DOCKER_REGISTRY_PASSWORD_PROPERTY_KEY, System.getenv("DH_PASSWORD"));
instance.set(DOCKER_REGISTRY_URL_PROPERTY_KEY, System.getenv("DH_URL"));
instance.set(DOCKER_REGISTRY_REPOSITORY_PROPERTY_KEY, System.getenv("DH_REPOSITORY"));
} else {
// This Transformation is performed by storing the files in Tar archives
instance.set(DOCKER_PUSH_TO_REGISTRY_PROPERTY_KEY, "false");
}
return instance;
}
use of org.opentosca.toscana.core.transformation.Transformation in project TOSCAna by StuPro-TOSCAna.
the class TransformationController method getOutputs.
/**
* Returns the outputs of a Transformation.
* <p>
* <table summary="">
* <tr>
* <td>HTTP-Code</td>
* <td>Mime-Type</td>
* <td>Description (Returned if)</td>
* </tr>
* <tr>
* <td>200</td>
* <td>application/hal+json</td>
* <td>Returns a List of the outputs. (Empty if no deployment has been executed)</td>
* </tr>
* <tr>
* <td>400</td>
* <td>application/json</td>
* <td>Returned if the transformation is not in a valid state (has to be in DONE or ERROR) to set inputs</td>
* </tr>
* <tr>
* <td>404</td>
* <td>application/json</td>
* <td>Returns a error message if the csar is not found or if the csar does not have a transformation for the given
* name (see returned error message for details)</td>
* </tr>
* </table>
*/
@ApiOperation(value = "Retrieve the outputs and their values", tags = { "transformations" }, notes = "This operation returns the outputs of a deployment. Retrieval of the outputs is not possible " + "if the transformation (including deployment) is not done yet")
@ApiResponses({ @ApiResponse(code = 200, message = "The operation was executed successfully", response = GetOutputsResponse.class), @ApiResponse(code = 404, message = "There is no CSAR for the given identifier or the CSAR does not have " + "a transformation for the specified platform", response = RestErrorResponse.class), @ApiResponse(code = 400, message = "The state of the transformation is invalid (not ERROR or DONE)", response = RestErrorResponse.class) })
@RequestMapping(path = "/{platform}/outputs", method = { RequestMethod.GET }, produces = "application/hal+json")
public ResponseEntity<GetOutputsResponse> getOutputs(@ApiParam(value = "The unique identifier for the CSAR", required = true, example = "test") @PathVariable(name = "csarId") String csarId, @ApiParam(value = "The identifier for the platform", required = true, example = "kubernetes") @PathVariable(name = "platform") String platformId) {
Csar csar = findByCsarId(csarId);
Transformation transformation = findTransformationByPlatform(csar, platformId);
if (transformation.getState() != TransformationState.DONE && transformation.getState() != TransformationState.ERROR) {
throw new IllegalTransformationStateException("The Transformation has not finished yet!");
}
List<OutputProperty> outputs = transformation.getOutputs();
List<OutputWrap> wrappedOutputs = outputs.stream().map(OutputWrap::new).collect(Collectors.toList());
return ResponseEntity.ok(new GetOutputsResponse(csarId, platformId, wrappedOutputs));
}
Aggregations