Search in sources :

Example 1 with OrkaClientProxyFactory

use of io.jenkins.plugins.orka.helpers.OrkaClientProxyFactory in project macstadium-orka-plugin by jenkinsci.

the class NodeNameCheckTest method when_check_node_should_return_correct_validation_type.

@Test
public void when_check_node_should_return_correct_validation_type() throws IOException {
    OrkaNode firstNode = new OrkaNode("macpro-1", "127.0.0.1", 12, this.firstNodeAvailableCPU, "32Gi", "20Gi", "macpro-1", "ready");
    OrkaNode secondNode = new OrkaNode("macpro-2", "127.0.0.2", 24, this.secondNodeAvailableCPU, "64Gi", "32Gi", "macpro2", "ready");
    OrkaNode thirdNode = new OrkaNode("macpro-3", "127.0.0.3", 24, this.thirdNodeAvailableCPU, "64Gi", "32Gi", "macpro-3", "ready");
    List<OrkaNode> response = Arrays.asList(firstNode, secondNode, thirdNode);
    OrkaClientProxyFactory factory = mock(OrkaClientProxyFactory.class);
    OrkaClientProxy clientProxy = mock(OrkaClientProxy.class);
    when(factory.getOrkaClientProxy(anyString(), anyString(), anyBoolean())).thenReturn(clientProxy);
    when(clientProxy.getNodes()).thenReturn(response);
    OrkaAgent.DescriptorImpl descriptor = new OrkaAgent.DescriptorImpl();
    descriptor.setClientProxyFactory(factory);
    FormValidation validation = descriptor.doCheckNode(null, "endpoint", "credentialsId", false, null, false, 12);
    assertEquals(this.validationKind, validation.kind);
}
Also used : OrkaClientProxy(io.jenkins.plugins.orka.helpers.OrkaClientProxy) FormValidation(hudson.util.FormValidation) OrkaClientProxyFactory(io.jenkins.plugins.orka.helpers.OrkaClientProxyFactory) OrkaNode(io.jenkins.plugins.orka.client.OrkaNode) Test(org.junit.Test)

Example 2 with OrkaClientProxyFactory

use of io.jenkins.plugins.orka.helpers.OrkaClientProxyFactory in project macstadium-orka-plugin by jenkinsci.

the class OrkaComputerLauncher method launch.

@Override
public void launch(SlaveComputer slaveComputer, TaskListener listener) throws IOException, InterruptedException {
    OrkaAgent agent = (OrkaAgent) slaveComputer.getNode();
    if (this.vmExists()) {
        if (this.launcher == null) {
            this.launcher = this.getLauncher(agent.getVmCredentialsId());
        }
        this.launcher.launch(slaveComputer, listener);
        return;
    }
    OrkaClientProxy client = new OrkaClientProxyFactory().getOrkaClientProxy(agent.getOrkaEndpoint(), agent.getOrkaCredentialsId(), agent.getUseJenkinsProxySettings());
    PrintStream logger = listener.getLogger();
    if (!createConfiguration(agent, client, logger)) {
        return;
    }
    DeploymentResponse deploymentResponse = this.deployVM(agent, client, logger);
    if (deploymentResponse == null) {
        return;
    }
    this.host = StringUtils.isNotBlank(this.redirectHost) ? redirectHost : deploymentResponse.getHost();
    this.port = deploymentResponse.getSSHPort();
    this.launcher = this.getLauncher(agent.getVmCredentialsId());
    Jenkins.get().updateNode(slaveComputer.getNode());
    listener.getLogger().println("Waiting for VM to boot");
    this.waitForVM(this.host, this.port);
    this.launcher.launch(slaveComputer, listener);
}
Also used : PrintStream(java.io.PrintStream) OrkaClientProxy(io.jenkins.plugins.orka.helpers.OrkaClientProxy) OrkaClientProxyFactory(io.jenkins.plugins.orka.helpers.OrkaClientProxyFactory) DeploymentResponse(io.jenkins.plugins.orka.client.DeploymentResponse)

Example 3 with OrkaClientProxyFactory

use of io.jenkins.plugins.orka.helpers.OrkaClientProxyFactory in project macstadium-orka-plugin by jenkinsci.

the class NodeItemsFillTest method when_fill_node_items_should_return_correct_size.

@Test
public void when_fill_node_items_should_return_correct_size() throws IOException {
    OrkaNode firstNode = new OrkaNode("macpro-1", "127.0.0.1", 12, this.firstNodeAvailableCPU, "32Gi", "20Gi", "macpro-1", "ready");
    OrkaNode secondNode = new OrkaNode("macpro-2", "127.0.0.2", 24, this.secondNodeAvailableCPU, "64Gi", "32Gi", "macpro2", "ready");
    OrkaNode thirdNode = new OrkaNode("macpro-3", "127.0.0.3", 24, this.thirdNodeAvailableCPU, "64Gi", "32Gi", "macpro-3", "ready");
    List<OrkaNode> response = Arrays.asList(firstNode, secondNode, thirdNode);
    OrkaClientProxyFactory clientProxyFactory = mock(OrkaClientProxyFactory.class);
    OrkaClientProxy clientProxy = mock(OrkaClientProxy.class);
    when(clientProxyFactory.getOrkaClientProxy(anyString(), anyString(), anyBoolean())).thenReturn(clientProxy);
    when(clientProxy.getNodes()).thenReturn(response);
    OrkaAgent.DescriptorImpl descriptor = new OrkaAgent.DescriptorImpl();
    descriptor.setClientProxyFactory(clientProxyFactory);
    ListBoxModel nodes = descriptor.doFillNodeItems(this.endpoint, this.credentials, false);
    assertEquals(this.resultSize, nodes.size());
}
Also used : OrkaClientProxy(io.jenkins.plugins.orka.helpers.OrkaClientProxy) OrkaClientProxyFactory(io.jenkins.plugins.orka.helpers.OrkaClientProxyFactory) OrkaNode(io.jenkins.plugins.orka.client.OrkaNode) ListBoxModel(hudson.util.ListBoxModel) Test(org.junit.Test)

Example 4 with OrkaClientProxyFactory

use of io.jenkins.plugins.orka.helpers.OrkaClientProxyFactory in project macstadium-orka-plugin by jenkinsci.

the class NodeResourcesCheckTest method when_check_node_should_return_correct_validation_type.

@Test
public void when_check_node_should_return_correct_validation_type() throws IOException {
    OrkaNode firstNode = new OrkaNode(FIRST_NODE, "127.0.0.1", 12, 12, "32Gi", "20Gi", FIRST_NODE, "ready");
    OrkaNode secondNode = new OrkaNode(SECOND_NODE, "127.0.0.2", 24, 12, "64Gi", "32Gi", SECOND_NODE, "ready");
    OrkaNode thirdNode = new OrkaNode(THIRD_NODE, "127.0.0.3", 24, 0, "64Gi", "32Gi", THIRD_NODE, "ready");
    List<OrkaNode> response = Arrays.asList(firstNode, secondNode, thirdNode);
    OrkaVM firstVM = new OrkaVM(BIG_VM, "not deployed", 24, "Mojave.img", "firstImage", "default");
    OrkaVM secondVM = new OrkaVM(SMALL_VM, "not deployed", 12, "Mojave.img", "secondImage", "default");
    List<OrkaVM> vmResponse = Arrays.asList(firstVM, secondVM);
    OrkaClientProxyFactory factory = mock(OrkaClientProxyFactory.class);
    OrkaClientProxy clientProxy = mock(OrkaClientProxy.class);
    when(factory.getOrkaClientProxy(anyString(), anyString(), anyBoolean())).thenReturn(clientProxy);
    when(clientProxy.getNodes()).thenReturn(response);
    when(clientProxy.getVMs()).thenReturn(vmResponse);
    OrkaAgent.DescriptorImpl descriptor = new OrkaAgent.DescriptorImpl();
    descriptor.setClientProxyFactory(factory);
    FormValidation validation = descriptor.doCheckNode(this.selectedNode, "endpoint", "credentialsId", false, this.vm, this.createNewVMConfig, this.requiredCPU);
    assertEquals(this.validationKind, validation.kind);
}
Also used : OrkaClientProxy(io.jenkins.plugins.orka.helpers.OrkaClientProxy) FormValidation(hudson.util.FormValidation) OrkaVM(io.jenkins.plugins.orka.client.OrkaVM) OrkaClientProxyFactory(io.jenkins.plugins.orka.helpers.OrkaClientProxyFactory) OrkaNode(io.jenkins.plugins.orka.client.OrkaNode) Test(org.junit.Test)

Aggregations

OrkaClientProxy (io.jenkins.plugins.orka.helpers.OrkaClientProxy)4 OrkaClientProxyFactory (io.jenkins.plugins.orka.helpers.OrkaClientProxyFactory)4 OrkaNode (io.jenkins.plugins.orka.client.OrkaNode)3 Test (org.junit.Test)3 FormValidation (hudson.util.FormValidation)2 ListBoxModel (hudson.util.ListBoxModel)1 DeploymentResponse (io.jenkins.plugins.orka.client.DeploymentResponse)1 OrkaVM (io.jenkins.plugins.orka.client.OrkaVM)1 PrintStream (java.io.PrintStream)1