Search in sources :

Example 31 with EffectiveModel

use of org.opentosca.toscana.model.EffectiveModel in project TOSCAna by StuPro-TOSCAna.

the class FileCreatorTest method checkMultipleApplicationServices.

@Test
public void checkMultipleApplicationServices() throws IOException, JSONException {
    String serviceName = "mydb";
    envUser = System.getenv(CF_ENVIRONMENT_USER);
    envPw = System.getenv(CF_ENVIRONMENT_PW);
    envHost = System.getenv(CF_ENVIRONMENT_HOST);
    envOrga = System.getenv(CF_ENVIRONMENT_ORGA);
    envSpace = System.getenv(CF_ENVIRONMENT_SPACE);
    connection = createConnection();
    Application app = new Application("app", 1, context);
    Application secondApp = new Application("appSec", 2, context);
    app.setProvider(new Provider(Provider.CloudFoundryProviderType.PIVOTAL));
    app.setConnection(connection);
    secondApp.setProvider(new Provider(Provider.CloudFoundryProviderType.PIVOTAL));
    secondApp.setConnection(connection);
    app.addService(service1, ServiceTypes.MYSQL);
    secondApp.addService(serviceName, ServiceTypes.MYSQL);
    EffectiveModel lamp = new EffectiveModelFactory().create(TestCsars.VALID_LAMP_NO_INPUT_TEMPLATE, logMock());
    RootNode webApplicationNode = null;
    RootNode mysqlDatabaseNode = null;
    for (RootNode node : lamp.getNodes()) {
        if (node instanceof WebApplication) {
            webApplicationNode = node;
        }
        if (node instanceof MysqlDatabase) {
            mysqlDatabaseNode = node;
        }
    }
    app.addConfigMysql(service1, "my_db/configSql.sql");
    app.addExecuteFile("my_app/configure_myphpapp.sh", webApplicationNode);
    secondApp.addConfigMysql(serviceName, "database/config.sql");
    secondApp.addExecuteFile("database/dbinit.sh", mysqlDatabaseNode);
    List<Application> applications = new ArrayList<>();
    applications.add(app);
    applications.add(secondApp);
    FileCreator fileCreator = new FileCreator(fileAccess, applications, context);
    fileCreator.createFiles();
    File targetFile = new File(targetDir, outputPath + FILEPRAEFIX_DEPLOY + deploy_name + FILESUFFIX_DEPLOY);
    String deployscriptContent = FileUtils.readFileToString(targetFile);
    String expectedContent = "check python\n" + "python replace.py ../../app1/my_app/configure_myphpapp.sh /var/www/html/ /home/vcap/app/htdocs/\n" + "python replace.py ../../app2/database/dbinit.sh /var/www/html/ /home/vcap/app/htdocs/\n" + "cf push app -f ../manifest.yml --no-start\n" + "cf push appSec -f ../manifest.yml --no-start\n" + "python readCredentials.py app cleardb mysql cleardb\n" + "python configureMysql.py ../../app1/my_db/configSql.sql\n" + "cf start app\n" + "python executeCommand.py app /home/vcap/app/htdocs/my_app/configure_myphpapp.sh\n" + "python readCredentials.py appSec cleardb mysql mydb\n" + "python configureMysql.py ../../app2/database/config.sql\n" + "cf start appSec\n" + "python executeCommand.py appSec /home/vcap/app/database/dbinit.sh\n";
    assertTrue(deployscriptContent.contains(expectedContent));
// assertEquals(expectedContent, deployscriptContent);
}
Also used : RootNode(org.opentosca.toscana.model.node.RootNode) MysqlDatabase(org.opentosca.toscana.model.node.MysqlDatabase) FileCreator(org.opentosca.toscana.plugins.cloudfoundry.filecreator.FileCreator) ArrayList(java.util.ArrayList) WebApplication(org.opentosca.toscana.model.node.WebApplication) Application(org.opentosca.toscana.plugins.cloudfoundry.application.Application) WebApplication(org.opentosca.toscana.model.node.WebApplication) File(java.io.File) EffectiveModel(org.opentosca.toscana.model.EffectiveModel) EffectiveModelFactory(org.opentosca.toscana.model.EffectiveModelFactory) Provider(org.opentosca.toscana.plugins.cloudfoundry.application.Provider) BaseUnitTest(org.opentosca.toscana.core.BaseUnitTest) Test(org.junit.Test)

Example 32 with EffectiveModel

use of org.opentosca.toscana.model.EffectiveModel in project TOSCAna by StuPro-TOSCAna.

the class FileCreatorTest method setUp.

@Before
public void setUp() throws IOException {
    EffectiveModel lamp = new EffectiveModelFactory().create(TestCsars.VALID_LAMP_NO_INPUT_TEMPLATE, logMock());
    this.context = setUpMockTransformationContext(lamp);
    appName = "testApp";
    testApp = new Application("testApp", 1, context);
    testApp.setName(appName);
    File sourceDir = new File(tmpdir, "sourceDir");
    targetDir = new File(tmpdir, "targetDir");
    sourceDir.mkdir();
    targetDir.mkdir();
    fileAccess = new PluginFileAccess(sourceDir, targetDir, logMock());
    List<Application> applications = new ArrayList<>();
    applications.add(testApp);
    fileCreator = new FileCreator(fileAccess, applications, context);
}
Also used : PluginFileAccess(org.opentosca.toscana.core.plugin.PluginFileAccess) FileCreator(org.opentosca.toscana.plugins.cloudfoundry.filecreator.FileCreator) ArrayList(java.util.ArrayList) Application(org.opentosca.toscana.plugins.cloudfoundry.application.Application) WebApplication(org.opentosca.toscana.model.node.WebApplication) File(java.io.File) EffectiveModel(org.opentosca.toscana.model.EffectiveModel) EffectiveModelFactory(org.opentosca.toscana.model.EffectiveModelFactory) Before(org.junit.Before)

Example 33 with EffectiveModel

use of org.opentosca.toscana.model.EffectiveModel in project TOSCAna by StuPro-TOSCAna.

the class CsarServiceImplIT method setUp.

@Before
public void setUp() throws InvalidCsarException {
    EffectiveModelFactory modelFactory = mock(EffectiveModelFactory.class);
    EffectiveModel model = modelMock();
    when(modelFactory.create(any(Csar.class))).thenReturn(model);
    csarService = new CsarServiceImpl(csarDao);
    Log log = new LogImpl(new File(tmpdir, "log"));
    csar = new CsarImpl(new File(""), identifier, log);
}
Also used : Log(org.opentosca.toscana.core.transformation.logging.Log) LogImpl(org.opentosca.toscana.core.transformation.logging.LogImpl) File(java.io.File) EffectiveModelFactory(org.opentosca.toscana.model.EffectiveModelFactory) EffectiveModel(org.opentosca.toscana.model.EffectiveModel) Before(org.junit.Before)

Aggregations

EffectiveModel (org.opentosca.toscana.model.EffectiveModel)33 EffectiveModelFactory (org.opentosca.toscana.model.EffectiveModelFactory)31 Test (org.junit.Test)22 BaseUnitTest (org.opentosca.toscana.core.BaseUnitTest)22 File (java.io.File)9 Before (org.junit.Before)9 PluginFileAccess (org.opentosca.toscana.core.plugin.PluginFileAccess)5 Database (org.opentosca.toscana.model.node.Database)5 Application (org.opentosca.toscana.plugins.cloudfoundry.application.Application)5 Log (org.opentosca.toscana.core.transformation.logging.Log)4 WebApplication (org.opentosca.toscana.model.node.WebApplication)4 Artifact (org.opentosca.toscana.model.artifact.Artifact)3 WebServer (org.opentosca.toscana.model.node.WebServer)3 FileCreator (org.opentosca.toscana.plugins.cloudfoundry.filecreator.FileCreator)3 ArrayList (java.util.ArrayList)2 CsarImpl (org.opentosca.toscana.core.csar.CsarImpl)2 PropertyInstance (org.opentosca.toscana.core.transformation.properties.PropertyInstance)2 EndpointCapability (org.opentosca.toscana.model.capability.EndpointCapability)2 Compute (org.opentosca.toscana.model.node.Compute)2 RootNode (org.opentosca.toscana.model.node.RootNode)2