@@ -0,0 +1,3056 @@
+package com.liveperson.ephemerals.examples;%0A%0Aimport com.liveperson.ephemerals.SeleniumEphemeral;%0Aimport com.liveperson.ephemerals.provider.kubernetes.KubernetesDeploymentContext;%0Aimport com.liveperson.ephemerals.provider.kubernetes.KubernetesDeploymentHandler;%0Aimport org.junit.After;%0Aimport org.junit.Assert;%0Aimport org.junit.Test;%0Aimport org.openqa.selenium.remote.DesiredCapabilities;%0Aimport org.openqa.selenium.remote.RemoteWebDriver;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0Aimport java.util.Random;%0Aimport java.util.concurrent.Callable;%0Aimport java.util.concurrent.ExecutorService;%0Aimport java.util.concurrent.Executors;%0Aimport java.util.concurrent.Future;%0A%0A/**%0A * A test example of deploying multiple Ephemeral instances at the same time.%0A *%0A * Created by waseemh on 11/16/16.%0A */%0A%0Apublic class SeleniumParallelEphemeralTest extends EphemeralAbstractTest %7B%0A%0A    List%3CSeleniumEphemeral%3E seleniumEphemerals = new ArrayList%3C%3E();%0A%0A    @Test%0A    public void test() throws Exception %7B%0A%0A        //Define fixed thread pool with SIZE=10%0A        ExecutorService executor = Executors.newFixedThreadPool(10);%0A%0A        //Submit Ephemeral deployment tasks to cluster using thread pool%0A        List%3CFuture%3CRemoteWebDriver%3E%3E remoteWebDriverFutureList = new ArrayList%3C%3E();%0A        for(int i=0; i%3C 10; i++) %7B%0A            Future%3CRemoteWebDriver%3E future = executor.submit(callableTask);%0A            remoteWebDriverFutureList.add(future);%0A        %7D%0A%0A        //Get result of all tasks%0A        for (Future%3CRemoteWebDriver%3E future : remoteWebDriverFutureList) %7B%0A%0A            RemoteWebDriver remoteWebDriver = future.get();%0A%0A            remoteWebDriver.get(%22http://yahoo.com%22);%0A            Assert.assertNotNull(remoteWebDriver.findElementById(%22uh-logo%22));%0A%0A            remoteWebDriver.quit();%0A%0A        %7D%0A%0A    %7D%0A%0A    @After%0A    public void teardown() %7B%0A        for(SeleniumEphemeral seleniumEphemeral : seleniumEphemerals) %7B%0A            seleniumEphemeral.destroy();%0A        %7D%0A    %7D%0A%0A    //A callable callableTask for launching browser session on cluster%0A    Callable%3CRemoteWebDriver%3E callableTask = () -%3E %7B%0A%0A        SeleniumEphemeral seleniumEphemeral = new SeleniumEphemeral.Builder%0A                (new KubernetesDeploymentContext(%0A                        new KubernetesDeploymentHandler.Builder(%0A                                getKubernetesService())%0A                                .build()))%0A                .withDesiredCapabilities(RandomCapability.randomize()) //randomize between firefox and chrome%0A                .build();%0A%0A        seleniumEphemerals.add(seleniumEphemeral);%0A%0A        return seleniumEphemeral.get();%0A    %7D;%0A%0A%0A    public final static class RandomCapability %7B%0A%0A        final static Random rand = new Random();%0A%0A        final static DesiredCapabilities%5B%5D desiredCapabilitiesArray = new DesiredCapabilities%5B%5D%7BDesiredCapabilities.firefox(),DesiredCapabilities.chrome()%7D;%0A%0A        public static DesiredCapabilities randomize() %7B%0A            return desiredCapabilitiesArray%5Brand.nextInt(desiredCapabilitiesArray.length)%5D;%0A        %7D%0A%0A    %7D%0A%0A%0A%0A%7D%0A

add parallel test