Search in sources :

Example 46 with Build

use of io.fabric8.openshift.api.model.Build in project fabric8 by jboss-fuse.

the class ZooKeeperGroupTest method setUp.

@Before
public void setUp() throws Exception {
    int port = findFreePort();
    curator = CuratorFrameworkFactory.builder().connectString("localhost:" + port).retryPolicy(new RetryOneTime(1)).build();
    // curator.start();
    group = new ZooKeeperGroup<>(curator, PATH, NodeState.class);
// group.start();
// Starting curator and group is not necessary for the current tests.
}
Also used : RetryOneTime(org.apache.curator.retry.RetryOneTime) NodeState(io.fabric8.groups.NodeState) Before(org.junit.Before)

Example 47 with Build

use of io.fabric8.openshift.api.model.Build in project fabric8 by jboss-fuse.

the class GitDataStoreImplTestSupport method createGitDataStore.

protected GitDataStoreImpl createGitDataStore() throws Exception {
    RuntimeProperties runtimeProperties = createMockRuntimeProperties();
    CreateEnsembleOptions ensembleOptions = CreateEnsembleOptions.builder().zookeeperPassword("admin").build();
    recursiveDelete(runtimeProperties.getDataPath().toFile());
    BootstrapConfiguration.DataStoreOptions options = new BootstrapConfiguration.DataStoreOptions("root", new File("target/test-container"), zkURL, ensembleOptions);
    runtimeProperties.putRuntimeAttribute(DataStoreTemplate.class, new DataStoreBootstrapTemplate(options));
    FabricGitServiceImpl fabricGitService = new FabricGitServiceImpl();
    fabricGitService.bindRuntimeProperties(runtimeProperties);
    fabricGitService.activate();
    ComponentConfigurer componentConfigurer = new ComponentConfigurer();
    componentConfigurer.activate(null);
    ZkDataStoreImpl zkDataStore = new ZkDataStoreImpl() {

        @Override
        public String getDefaultVersion() {
            return "1.0";
        }
    };
    zkDataStore.bindCurator(curator);
    zkDataStore.bindRuntimeProperties(runtimeProperties);
    zkDataStore.activateComponent();
    final GitDataStoreImpl gitDataStore = new GitDataStoreImpl();
    gitDataStore.bindConfigurer(componentConfigurer);
    gitDataStore.bindGitService(fabricGitService);
    gitDataStore.bindRuntimeProperties(runtimeProperties);
    gitDataStore.bindGitProxyService(new GitProxyRegistrationHandler());
    gitDataStore.bindCurator(curator);
    gitDataStore.bindDataStore(zkDataStore);
    gitDataStore.activate(new HashMap<String, Object>());
    return gitDataStore;
}
Also used : BootstrapConfiguration(io.fabric8.zookeeper.bootstrap.BootstrapConfiguration) ZkDataStoreImpl(io.fabric8.service.ZkDataStoreImpl) ComponentConfigurer(io.fabric8.service.ComponentConfigurer) DataStoreBootstrapTemplate(io.fabric8.zookeeper.bootstrap.DataStoreBootstrapTemplate) AbstractRuntimeProperties(io.fabric8.api.scr.AbstractRuntimeProperties)

Example 48 with Build

use of io.fabric8.openshift.api.model.Build in project fabric8 by jboss-fuse.

the class FeatureResource method build.

public static FeatureResource build(Feature feature, String featureRange, Map<String, ? extends Resource> locToRes) throws BundleException {
    FeatureResource resource = new FeatureResource(feature);
    for (BundleInfo info : feature.getBundles()) {
        if (!info.isDependency()) {
            Resource res = locToRes.get(info.getLocation());
            if (res == null) {
                throw new IllegalStateException("Resource not found for url " + info.getLocation());
            }
            addIdentityRequirement(resource, res);
        }
    }
    for (Dependency dep : feature.getDependencies()) {
        if (!dep.isDependency()) {
            addDependency(resource, dep, featureRange);
        }
    }
    for (Capability cap : feature.getCapabilities()) {
        resource.addCapabilities(ResourceBuilder.parseCapability(resource, cap.getValue()));
    }
    for (Requirement req : feature.getRequirements()) {
        resource.addRequirements(ResourceBuilder.parseRequirement(resource, req.getValue()));
    }
    return resource;
}
Also used : ResourceUtils.addIdentityRequirement(io.fabric8.agent.resolver.ResourceUtils.addIdentityRequirement) Requirement(io.fabric8.agent.model.Requirement) BundleInfo(io.fabric8.agent.model.BundleInfo) Capability(io.fabric8.agent.model.Capability) Resource(org.osgi.resource.Resource) Dependency(io.fabric8.agent.model.Dependency)

Example 49 with Build

use of io.fabric8.openshift.api.model.Build in project fabric8 by jboss-fuse.

the class FeatureResource method build.

public static FeatureResource build(Feature feature, Conditional conditional, String featureRange, Map<String, ? extends Resource> locToRes) throws BundleException {
    Feature fcond = conditional.asFeature(feature.getName(), feature.getVersion());
    FeatureResource resource = build(fcond, featureRange, locToRes);
    for (String cond : conditional.getCondition()) {
        if (cond.startsWith("req:")) {
            cond = cond.substring("req:".length());
            List<org.osgi.resource.Requirement> reqs = ResourceBuilder.parseRequirement(resource, cond);
            resource.addRequirements(reqs);
        } else {
            Dependency dep = new Dependency();
            String[] p = cond.split("/");
            dep.setName(p[0]);
            if (p.length > 1) {
                dep.setVersion(p[1]);
            }
            addDependency(resource, dep, featureRange, true);
        }
    }
    Dependency dep = new Dependency();
    dep.setName(feature.getName());
    dep.setVersion(feature.getVersion());
    addDependency(resource, dep, featureRange, true);
    return resource;
}
Also used : ResourceUtils.addIdentityRequirement(io.fabric8.agent.resolver.ResourceUtils.addIdentityRequirement) Requirement(io.fabric8.agent.model.Requirement) Dependency(io.fabric8.agent.model.Dependency) Feature(io.fabric8.agent.model.Feature)

Example 50 with Build

use of io.fabric8.openshift.api.model.Build in project fabric8 by jboss-fuse.

the class ZookeeperPortServiceTest method init.

@Before
public void init() throws Exception {
    int port = findFreePort();
    cnxnFactory = startZooKeeper(port);
    curator1 = CuratorFrameworkFactory.builder().connectString("localhost:" + port).retryPolicy(new RetryOneTime(1000)).build();
    curator1.start();
    curator1.getZookeeperClient().blockUntilConnectedOrTimedOut();
    curator1.create().creatingParentsIfNeeded().forPath("/fabric/registry/ports/ip/localhost", new byte[0]);
    curator2 = CuratorFrameworkFactory.builder().connectString("localhost:" + port).retryPolicy(new RetryOneTime(1000)).build();
    curator2.start();
    curator2.getZookeeperClient().blockUntilConnectedOrTimedOut();
    portService1 = new ZookeeperPortService();
    portService1.bindCurator(curator1);
    portService1.activate();
    portService2 = new ZookeeperPortService();
    portService2.bindCurator(curator2);
    portService2.activate();
    c1 = Mockito.mock(Container.class);
    c2 = Mockito.mock(Container.class);
    Mockito.when(c1.getIp()).thenReturn("localhost");
    Mockito.when(c1.getId()).thenReturn("c1");
    Mockito.when(c2.getIp()).thenReturn("localhost");
    Mockito.when(c2.getId()).thenReturn("c2");
}
Also used : Container(io.fabric8.api.Container) RetryOneTime(org.apache.curator.retry.RetryOneTime) Before(org.junit.Before)

Aggregations

Test (org.junit.Test)255 ArrayList (java.util.ArrayList)74 BuildImageConfiguration (io.fabric8.maven.docker.config.BuildImageConfiguration)69 ImageConfiguration (io.fabric8.maven.docker.config.ImageConfiguration)68 HashMap (java.util.HashMap)66 File (java.io.File)53 ConfigMap (io.fabric8.kubernetes.api.model.ConfigMap)51 IOException (java.io.IOException)50 ConfigMapBuilder (io.fabric8.kubernetes.api.model.ConfigMapBuilder)45 Pod (io.fabric8.kubernetes.api.model.Pod)37 Map (java.util.Map)35 Service (io.fabric8.kubernetes.api.model.Service)34 FabricService (io.fabric8.api.FabricService)33 ResourceConfig (io.fabric8.maven.core.config.ResourceConfig)30 Container (io.fabric8.api.Container)29 RunImageConfiguration (io.fabric8.maven.docker.config.RunImageConfiguration)28 PodBuilder (io.fabric8.kubernetes.api.model.PodBuilder)27 List (java.util.List)26 ServicePortBuilder (io.fabric8.kubernetes.api.model.ServicePortBuilder)25 OpenShiftClient (io.fabric8.openshift.client.OpenShiftClient)25