Skip to content
This repository has been archived by the owner on Jun 7, 2021. It is now read-only.

Commit

Permalink
Add Protocols.KUBE_PING to our clustering for use on OpenShift 3
Browse files Browse the repository at this point in the history
This just hardcodes OpenShift detection into the clustering Stack for
now until we come up with a generic Environment abstraction.
  • Loading branch information
bbrowning committed Oct 30, 2015
1 parent a503326 commit bb2f0c4
Show file tree
Hide file tree
Showing 10 changed files with 230 additions and 4 deletions.
Expand Up @@ -24,6 +24,10 @@ public static Protocol PING() {
return new Protocol( "PING" );
}

public static Protocol KUBE_PING() {
return new Protocol( "openshift.KUBE_PING" );
}

public static Protocol MERGE3() {
return new Protocol( "MERGE3" );
}
Expand Down
Expand Up @@ -54,10 +54,16 @@ public List<Protocol> protocols() {
}

public static Stack defaultUDPStack() {
return new Stack("udp")
.transport(Transports.UDP("jgroups-udp"))
.protocol(Protocols.PING())
.protocol(Protocols.FD_SOCK("jgroups-udp-fd"))
Stack stack = new Stack("udp")
.transport(Transports.UDP("jgroups-udp"));

if (System.getenv("OPENSHIFT_BUILD_NAME") != null || System.getenv("OPENSHIFT_BUILD_REFERENCE") != null) {
stack.protocol(Protocols.KUBE_PING());
} else {
stack.protocol(Protocols.PING());
}

return stack.protocol(Protocols.FD_SOCK("jgroups-udp-fd"))
.protocol(Protocols.FD_ALL())
.protocol(Protocols.VERIFY_SUSPECT())
.protocol(Protocols.pbcast.NAKACK2())
Expand Down
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
~ JBoss, Home of Professional Open Source.
~ Copyright 2010, Red Hat, Inc., and individual contributors
~ as indicated by the @author tags. See the copyright.txt file in the
~ distribution for a full listing of individual contributors.
~
~ This is free software; you can redistribute it and/or modify it
~ under the terms of the GNU Lesser General Public License as
~ published by the Free Software Foundation; either version 2.1 of
~ the License, or (at your option) any later version.
~
~ This software is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
~ Lesser General Public License for more details.
~
~ You should have received a copy of the GNU Lesser General Public
~ License along with this software; if not, write to the Free
~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
~ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-->

<module xmlns="urn:jboss:module:1.3" name="org.jgroups">

<resources>
<artifact name="org.jgroups:jgroups:${version.org.jgroups}"/>
</resources>

<dependencies>
<module name="javax.api"/>

<!-- We override the module.xml purely to add this dependency -->
<module name="org.openshift.ping"/>

</dependencies>
</module>
@@ -0,0 +1,10 @@
<module xmlns="urn:jboss:module:1.3" name="org.openshift.ping">
<resources>
<artifact name="org.projectodd.openshift.ping:openshift-ping-common:${version.org.openshift.ping}"/>
<artifact name="org.projectodd.openshift.ping:openshift-ping-kube:${version.org.openshift.ping}"/>
</resources>

<dependencies>
<module name="org.jgroups"/>
</dependencies>
</module>
1 change: 1 addition & 0 deletions clustering/pom.xml
Expand Up @@ -26,6 +26,7 @@
<module>api</module>
<module>runtime</module>
<module>modules</module>
<module>test</module>
</modules>

</project>
65 changes: 65 additions & 0 deletions clustering/test/pom.xml
@@ -0,0 +1,65 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright 2015 Red Hat, Inc. and/or its affiliates.
~
~ Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.wildfly.swarm</groupId>
<artifactId>wildfly-swarm-clustering-parent</artifactId>
<version>1.0.0.Alpha6-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>

<groupId>org.wildfly.swarm</groupId>
<artifactId>wildfly-swarm-clustering-test</artifactId>

<name>WildFly Swarm: Clustering Test</name>
<description>WildFly Swarm: Clustering Test</description>

<packaging>jar</packaging>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
</plugin>
</plugins>
</build>

<dependencies>
<dependency>
<groupId>org.wildfly.swarm</groupId>
<artifactId>wildfly-swarm-clustering</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.wildfly.swarm</groupId>
<artifactId>wildfly-swarm-clustering-modules</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.wildfly.swarm</groupId>
<artifactId>wildfly-swarm-arquillian</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

</project>
@@ -0,0 +1,35 @@
package org.wildfly.swarm.clustering;

import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.RunAsClient;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.EmptyAsset;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.wildfly.swarm.ContainerFactory;
import org.wildfly.swarm.container.Container;
import org.wildfly.swarm.container.JARArchive;

@RunWith(Arquillian.class)
public class ClusteringArquillianTest implements ContainerFactory {

@Deployment(testable = false)
public static Archive createDeployment() {
JARArchive deployment = ShrinkWrap.create(JARArchive.class);
deployment.add(EmptyAsset.INSTANCE, "nothing");
return deployment;
}

@Override
public Container newContainer(String... args) throws Exception {
return new Container().fraction( new ClusteringFraction() );
}

@Test
@RunAsClient
public void testNothing() {

}
}
@@ -0,0 +1,25 @@
package org.wildfly.swarm.clustering;

import org.junit.Test;
import org.wildfly.swarm.container.Container;

public class ClusteringInVmTest {

@Test
public void testDefaultFraction() throws Exception {
Container container = new Container();
// By not specifying a ClusteringFraction we test the default fraction
container.start().stop();
}

@Test
public void testCanFindKubePing() throws Exception {
Container container = new Container();
container.fraction(new ClusteringFraction()
.defaultChannel(new Channel("swarm-clustering"))
.defaultStack(new Stack("udp")
.transport(Transports.UDP("jgroups-udp"))
.protocol(Protocols.KUBE_PING())));
container.start().stop();
}
}
@@ -0,0 +1,39 @@
package org.wildfly.swarm.clustering;

import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.RunAsClient;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.EmptyAsset;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.wildfly.swarm.ContainerFactory;
import org.wildfly.swarm.container.Container;
import org.wildfly.swarm.container.JARArchive;

@RunWith(Arquillian.class)
public class ClusteringOpenShiftArquillianTest implements ContainerFactory {

@Deployment(testable = false)
public static Archive createDeployment() {
JARArchive deployment = ShrinkWrap.create(JARArchive.class);
deployment.add(EmptyAsset.INSTANCE, "nothing");
return deployment;
}

@Override
public Container newContainer(String... args) throws Exception {
return new Container().fraction(new ClusteringFraction()
.defaultChannel(new Channel("swarm-clustering"))
.defaultStack(new Stack("udp")
.transport(Transports.UDP("jgroups-udp"))
.protocol(Protocols.KUBE_PING())));
}

@Test
@RunAsClient
public void testNothing() {

}
}
3 changes: 3 additions & 0 deletions pom.xml
Expand Up @@ -75,6 +75,9 @@
<version.okhttp>2.4.0</version.okhttp>
<version.okio>1.4.0</version.okio>

<version.org.openshift.ping>1.0.0.Beta5-swarm-1</version.org.openshift.ping>
<version.org.jgroups>3.6.6.Final</version.org.jgroups>

<maven.min.version>3.2.1</maven.min.version>

<!-- Surefire args -->
Expand Down

0 comments on commit bb2f0c4

Please sign in to comment.