use of org.ligoj.app.plugin.prov.model.TerraformStatus in project plugin-prov by ligoj.
the class TerraformResourceTest method applyTerraformIOE.
private void applyTerraformIOE(final TerraformResource resource) {
Assertions.assertThrows(IOException.class, () -> {
applyTerraform(resource);
});
// Nice, as expected, but more check to do
final TerraformStatus task = resource.runner.getTask("service:prov:test:account");
Assertions.assertNotNull(task);
Assertions.assertTrue(task.isFinished());
Assertions.assertTrue(resource.runner.getTask("service:prov:test:account").isFailed());
}
use of org.ligoj.app.plugin.prov.model.TerraformStatus in project plugin-prov by ligoj.
the class TerraformResourceTest method applyTerraformInternal.
@Test
public void applyTerraformInternal() throws IOException, InterruptedException {
final File log = new File(MOCK_PATH, "main.log");
final File tf = new File(MOCK_PATH, "main.tf");
final TerraformResource resource = newResource(Mockito.mock(Terraforming.class), false);
applyTerraform(resource);
// Synchronization of sub processes
Awaitility.await().atMost(5, TimeUnit.SECONDS).until(() -> tf.exists() && log.exists() && IOUtils.toString(log.toURI(), "UTF-8").contains("show"));
Thread.yield();
Assertions.assertTrue(tf.exists());
Assertions.assertTrue(log.exists());
final String logString = IOUtils.toString(log.toURI(), "UTF-8");
Assertions.assertTrue(logString.contains("plan"));
Assertions.assertTrue(logString.contains("apply"));
Assertions.assertTrue(logString.contains("show"));
// Check the log file is well handled
final ByteArrayOutputStream bos = new ByteArrayOutputStream();
((StreamingOutput) resource.getTerraformLog(subscription).getEntity()).write(bos);
Assertions.assertEquals(logString, bos.toString(StandardCharsets.UTF_8));
// Check the task status
final TerraformStatus task = resource.runner.getTask("service:prov:test:account");
Assertions.assertTrue(task.isFinished());
Assertions.assertFalse(task.isFailed());
Assertions.assertNotNull(task.getStart());
Assertions.assertNotNull(task.getAuthor());
Assertions.assertEquals(DEFAULT_USER, task.getAuthor());
Assertions.assertEquals("service:prov:test:account", task.getLocked().getId());
Assertions.assertNotNull(task.getEnd());
Assertions.assertEquals(TerraformStep.SHOW, task.getStep());
}
Aggregations