Package com.axemblr.provisionr.api

Examples of com.axemblr.provisionr.api.Provisionr


    @Rule
    public ExpectedException exception = ExpectedException.none();

    @Test
    public void testCreatePoolStartsTheManagementProcess() throws Exception {
        final Provisionr service = newProvisionrMockWithId(TEST_PROVISIONR_ID);
        final Pool pool = mock(Pool.class);

        final List<Provisionr> services = ImmutableList.of(service);
        final List<PoolTemplate> templates = ImmutableList.of();
        CreatePoolCommand command = new CreatePoolCommand(services, templates) {
View Full Code Here


        command.setId("service");
        command.setKey("key");
        command.setTemplate(template.getId());

        Provisionr service = mock(Provisionr.class);
        Provider provider = newProviderMockWithBuilder();
        when(service.getDefaultProvider()).thenReturn(Optional.of(provider));

        Pool pool = command.createPoolFromArgumentsAndServiceDefaults(service);

        assertThat(pool.getSoftware().getRepositories()).hasSize(1);
        assertThat(pool.getSoftware().getPackages()).contains("jenkins").contains("git-core");
View Full Code Here

        CreatePoolCommand command = newPoolCommandWithMockedAdminAccess();
        command.setId("service");
        command.setKey("key");
        command.setProviderOptions(Lists.newArrayList("spotBid=0.07"));

        Provisionr service = mock(Provisionr.class);
        Provider provider = newProviderMockWithBuilder();
        when(service.getDefaultProvider()).thenReturn(Optional.of(provider));

        command.createPoolFromArgumentsAndServiceDefaults(service);

        @SuppressWarnings("unchecked")
        ArgumentCaptor<Map<String, String>> argument = (ArgumentCaptor<Map<String, String>>) (Object)
View Full Code Here

    public void testBlockDeviceOptions() {
        CreatePoolCommand command = newPoolCommandWithMockedAdminAccess();
        command.setId("service");
        command.setKey("key");

        Provisionr service = mock(Provisionr.class);
        Provider provider = newProviderMockWithBuilder();
        when(service.getDefaultProvider()).thenReturn(Optional.of(provider));

        Pool pool = command.createPoolFromArgumentsAndServiceDefaults(service);
        assertThat(pool.getHardware().getBlockDevices()).isEmpty();

        command.setBlockDeviceOptions(Lists.newArrayList("/dev/sda2:8", "/dev/sda9:2"));
View Full Code Here

        pool = command.createPoolFromArgumentsAndServiceDefaults(service);

    }

    private Provisionr newProvisionrMockWithId(String id) {
        Provisionr service = mock(Provisionr.class);
        when(service.getId()).thenReturn(id);
        return service;
    }
View Full Code Here

    public static final String TEST_BUSINESS_KEY = "dummy";
    public static final String PROCESS_INSTANCE_ID = "123";

    @Test
    public void testDestroyPool() throws Exception {
        Provisionr service = mock(Provisionr.class);
        when(service.getId()).thenReturn(TEST_PROVISIONR_ID);

        ProcessEngine processEngine = mockProcessEngine(PROCESS_INSTANCE_ID, TEST_BUSINESS_KEY, TEST_PROVISIONR_ID);

        DestroyPoolCommand command = new DestroyPoolCommand(ImmutableList.of(service), processEngine);
        command.setBusinessKey(TEST_BUSINESS_KEY);
View Full Code Here

        assertThat(outputStream.toString()).isEqualTo("Services: p1, p2\n");
    }

    private Provisionr newProvisionrMockWithId(String id) {
        Provisionr service = mock(Provisionr.class);
        when(service.getId()).thenReturn(id);
        return service;
    }
View Full Code Here

    }

    @Test
    public void startProvisioningProcess() throws Exception {
        waitForProcessDeployment(CloudStackProvisionr.ID);
        Provisionr provisionr = getOsgiService(Provisionr.class, 5000);

//        listAvailableJceProviders();

        final Provider provider = collectProviderCredentialsFromSystemProperties()
            // TODO: get more options as needed for CloudStack
            .createProvider();

        final Network network = Network.builder()
            .addRules(Rule.builder().anySource().tcp().port(22).createRule())
            .createNetwork();

        final Software software = Software.builder().baseOperatingSystem("ubuntu-10.04")
            .packages("nginx").createSoftware();

        final AdminAccess adminAccess = AdminAccess.builder().asCurrentUser().createAdminAccess();

        final Hardware hardware = Hardware.builder().type("offering").createHardware();

        final Pool pool = Pool.builder().network(network).provider(provider).adminAccess(adminAccess)
            .software(software).hardware(hardware).minSize(1).expectedSize(1).createPool();

        String processId = provisionr.startPoolManagementProcess(UUID.randomUUID().toString(), pool);
        waitForProcessEnd(processId);
        // TODO: check that the environment is clean
    }
View Full Code Here

    }

    private void startProvisioningProcess(String spotBid) throws Exception {
        waitForProcessDeployment(AmazonProvisionr.MANAGEMENT_PROCESS_KEY);

        final Provisionr provisionr = getOsgiService(Provisionr.class, 5000);

        Provider provider = collectProviderCredentialsFromSystemProperties()
            .option(ProviderOptions.REGION, getProviderProperty(
                ProviderOptions.REGION, ProviderOptions.DEFAULT_REGION))
            .createProvider();

        if (spotBid != null) {
            provider = provider.toBuilder()
                    .option(ProviderOptions.SPOT_BID, spotBid)
                    .createProvider();
        }

        final Network network = Network.builder().addRules(
            Rule.builder().anySource().icmp().createRule(),
            Rule.builder().anySource().port(22).protocol(Protocol.TCP).createRule()
        ).createNetwork();

        final Hardware hardware = Hardware.builder().type("t1.micro").createHardware();

        final AdminAccess adminAccess = AdminAccess.builder().asCurrentUser().createAdminAccess();

        final String destinationPath = "/home/" + adminAccess.getUsername() + "/axemblr.html";
        final Software software = Software.builder()
            .baseOperatingSystem("ubuntu-12.04")
            .file("http://axemblr.com", destinationPath)
            .createSoftware();

        PoolTemplate jenkins = XmlTemplate.newXmlTemplate(Resources.toString(Resources
            .getResource(PoolTemplate.class, DEFAULT_JENKINS_TEMPLATE_PATH), Charsets.UTF_8));

        final Pool pool = jenkins.apply(Pool.builder()
            .provider(provider)
            .network(network)
            .adminAccess(adminAccess)
            .software(software)
            .hardware(hardware)
            .minSize(TEST_POOL_SIZE)
            .expectedSize(TEST_POOL_SIZE)
            .createPool());

        final String businessKey = "j-" + UUID.randomUUID().toString();
        String processInstanceId = provisionr.startPoolManagementProcess(businessKey, pool);

        try {
            waitForPoolStatus(provisionr, businessKey, PoolStatus.READY);

            List<Machine> machines = provisionr.getMachines(businessKey);
            assertTrue(machines.size() >= TEST_POOL_SIZE && machines.size() <= TEST_POOL_SIZE);

            for (Machine machine : machines) {
                assertSshCommand(machine, adminAccess, "test -f " + destinationPath);

                /* These are added through the Jenkins Debian template */
                assertSshCommand(machine, adminAccess, "hash git >/dev/null 2>&1");
                assertSshCommand(machine, adminAccess, "hash java >/dev/null 2>&1");
                assertSshCommand(machine, adminAccess, "test -f /etc/apt/sources.list.d/jenkins.list");
            }
        } finally {
            provisionr.destroyPool(businessKey);

            waitForPoolStatus(provisionr, businessKey, PoolStatus.TERMINATED);
            waitForProcessEnd(processInstanceId);
        }
    }
View Full Code Here

TOP

Related Classes of com.axemblr.provisionr.api.Provisionr

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.