stratos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From im...@apache.org
Subject [1/3] stratos git commit: Initial implementation of kubernetes iaas createInstance(), terminateInstance() methods
Date Sun, 21 Dec 2014 16:10:43 GMT
Repository: stratos
Updated Branches:
  refs/heads/master 9a355d9a0 -> 405ff36de


http://git-wip-us.apache.org/repos/asf/stratos/blob/405ff36d/components/org.apache.stratos.kubernetes.client/src/test/java/org/apache/stratos/kubernetes/client/live/KubernetesApiClientLiveTest.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.kubernetes.client/src/test/java/org/apache/stratos/kubernetes/client/live/KubernetesApiClientLiveTest.java
b/components/org.apache.stratos.kubernetes.client/src/test/java/org/apache/stratos/kubernetes/client/live/KubernetesApiClientLiveTest.java
index 03dc7d8..6a7bd9b 100644
--- a/components/org.apache.stratos.kubernetes.client/src/test/java/org/apache/stratos/kubernetes/client/live/KubernetesApiClientLiveTest.java
+++ b/components/org.apache.stratos.kubernetes.client/src/test/java/org/apache/stratos/kubernetes/client/live/KubernetesApiClientLiveTest.java
@@ -20,28 +20,19 @@
  */
 package org.apache.stratos.kubernetes.client.live;
 
-import java.net.InetAddress;
-import java.net.URL;
-
 import junit.framework.TestCase;
-
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.kubernetes.client.KubernetesApiClient;
 import org.apache.stratos.kubernetes.client.exceptions.KubernetesClientException;
-import org.apache.stratos.kubernetes.client.model.Container;
-import org.apache.stratos.kubernetes.client.model.Label;
-import org.apache.stratos.kubernetes.client.model.Manifest;
-import org.apache.stratos.kubernetes.client.model.Pod;
-import org.apache.stratos.kubernetes.client.model.Port;
-import org.apache.stratos.kubernetes.client.model.ReplicationController;
-import org.apache.stratos.kubernetes.client.model.Selector;
-import org.apache.stratos.kubernetes.client.model.Service;
-import org.apache.stratos.kubernetes.client.model.State;
+import org.apache.stratos.kubernetes.client.model.*;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
+import java.net.InetAddress;
+import java.net.URL;
+
 @Category(org.apache.stratos.kubernetes.client.LiveTests.class)
 public class KubernetesApiClientLiveTest extends TestCase{
 
@@ -74,7 +65,7 @@ public class KubernetesApiClientLiveTest extends TestCase{
         pod.setApiVersion("v1beta1");
         pod.setId(podId);
         pod.setKind("Pod");
-        Label l = new Label();
+        Labels l = new Labels();
         l.setName("nirmal");
         pod.setLabels(l);
         State desiredState = new State();
@@ -88,9 +79,9 @@ public class KubernetesApiClientLiveTest extends TestCase{
         p.setContainerPort(8379);
         p.setHostPort(8379);
         c.setPorts(new Port[] { p });
-        m.setContainers(new Container[] { c });
+        m.addContainer(c);
         desiredState.setManifest(m);
-        pod.setDesiredState(desiredState);
+        pod.setState(desiredState);
         if (log.isDebugEnabled()) {
             log.debug("Creating a Pod "+pod);
         }
@@ -134,7 +125,7 @@ public class KubernetesApiClientLiveTest extends TestCase{
         }
 	    assertEquals(true, match);
 	    
-	    Pod[] selectedPods = client.queryPods(new Label[]{l});
+	    Pod[] selectedPods = client.queryPods(new Labels[]{l});
 	    assertEquals(1, selectedPods.length);
 	    
 	    if (log.isDebugEnabled()) {
@@ -154,15 +145,15 @@ public class KubernetesApiClientLiveTest extends TestCase{
 	        assertEquals(true, e instanceof KubernetesClientException);
 	    }
 	    
-	    selectedPods = client.queryPods(new Label[]{l});
+	    selectedPods = client.queryPods(new Labels[]{l});
         assertEquals(0, selectedPods.length);
         
-        Label ll = new Label();
+        Labels ll = new Labels();
         ll.setName("nirmal2");
-        selectedPods = client.queryPods(new Label[]{l, ll});
+        selectedPods = client.queryPods(new Labels[]{l, ll});
         assertEquals(0, selectedPods.length);
         
-        selectedPods = client.queryPods(new Label[]{});
+        selectedPods = client.queryPods(new Labels[]{});
         assertEquals(0, selectedPods.length);
 	}
 	
@@ -192,16 +183,16 @@ public class KubernetesApiClientLiveTest extends TestCase{
         Port p = new Port();
         p.setContainerPort(80);
         container.setPorts(new Port[] { p });
-        manifest.setContainers(new Container[] { container });
+        manifest.addContainer(container);
         podState.setManifest(manifest);
-        podTemplate.setDesiredState(podState);
-        Label l1 = new Label();
+        podTemplate.setState(podState);
+        Labels l1 = new Labels();
         l1.setName("nirmal");
         podTemplate.setLabels(l1);
 
         desiredState.setPodTemplate(podTemplate);
         contr.setDesiredState(desiredState);
-        Label l2 = new Label();
+        Labels l2 = new Labels();
         l2.setName("nirmal");
         contr.setLabels(l2);
         if (log.isDebugEnabled()) {
@@ -219,24 +210,28 @@ public class KubernetesApiClientLiveTest extends TestCase{
         
         assertEquals(1, client.getAllReplicationControllers().length);
         
-        Pod[] pods = client.queryPods(new Label[]{l1});
+        Pod[] pods = client.queryPods(new Labels[]{l1});
         assertEquals(replicas, pods.length);
         
         // test incorrect replica count
         replicas = -1;
         try {
-            client.updateReplicationController(id, replicas);
+            ReplicationController replicationController = client.getReplicationController(id);
+            replicationController.getDesiredState().setReplicas(replicas);
+            client.updateReplicationController(replicationController);
         } catch (Exception e) {
             assertEquals(true, e instanceof KubernetesClientException);
             assertEquals(true, e.getMessage().contains("update failed"));
         }
         
         replicas = 0;
-        client.updateReplicationController(id, replicas);
-        
+        ReplicationController replicationController = client.getReplicationController(id);
+        replicationController.getDesiredState().setReplicas(replicas);
+        client.updateReplicationController(replicationController);
+
         Thread.sleep(10000);
         
-        pods = client.queryPods(new Label[]{l1});
+        pods = client.queryPods(new Labels[]{l1});
         assertEquals(replicas, pods.length);
         
         client.deleteReplicationController(id);
@@ -264,7 +259,9 @@ public class KubernetesApiClientLiveTest extends TestCase{
         }
         
         try {
-            client.updateReplicationController(bogusContrId, 3);
+            replicationController = client.getReplicationController(bogusContrId);
+            replicationController.getDesiredState().setReplicas(3);
+            client.updateReplicationController(replicationController);
         } catch (Exception e) {
             assertEquals(true, e instanceof KubernetesClientException);
             assertEquals("Replication Controller ["+bogusContrId+"] doesn't exist.", e.getMessage());
@@ -291,7 +288,7 @@ public class KubernetesApiClientLiveTest extends TestCase{
 	    String publicIp = address.getHostAddress();
 	    serv.setPublicIPs(new String[]{publicIp});
 	    
-	    Label l = new Label();
+	    Labels l = new Labels();
 	    l.setName("nirmal");
 	    
 	    serv.setLabels(l);

http://git-wip-us.apache.org/repos/asf/stratos/blob/405ff36d/components/org.apache.stratos.kubernetes.client/src/test/java/org/apache/stratos/kubernetes/client/unit/PodUnitTest.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.kubernetes.client/src/test/java/org/apache/stratos/kubernetes/client/unit/PodUnitTest.java
b/components/org.apache.stratos.kubernetes.client/src/test/java/org/apache/stratos/kubernetes/client/unit/PodUnitTest.java
index 81961d9..65d2108 100644
--- a/components/org.apache.stratos.kubernetes.client/src/test/java/org/apache/stratos/kubernetes/client/unit/PodUnitTest.java
+++ b/components/org.apache.stratos.kubernetes.client/src/test/java/org/apache/stratos/kubernetes/client/unit/PodUnitTest.java
@@ -23,7 +23,7 @@ package org.apache.stratos.kubernetes.client.unit;
 import junit.framework.TestCase;
 
 import org.apache.stratos.kubernetes.client.model.Container;
-import org.apache.stratos.kubernetes.client.model.Label;
+import org.apache.stratos.kubernetes.client.model.Labels;
 import org.apache.stratos.kubernetes.client.model.Manifest;
 import org.apache.stratos.kubernetes.client.model.Pod;
 import org.apache.stratos.kubernetes.client.model.Port;
@@ -53,7 +53,7 @@ public class PodUnitTest extends TestCase{
         pod.setResourceVersion(apiVersion);
         String kind = "Pod";
         pod.setKind(kind);
-        Label l = new Label();
+        Labels l = new Labels();
         l.setName("nirmal");
         pod.setLabels(l);
         State desiredState = new State();
@@ -67,9 +67,9 @@ public class PodUnitTest extends TestCase{
         p.setContainerPort(8379);
         p.setHostPort(8379);
         c.setPorts(new Port[] { p });
-        m.setContainers(new Container[] { c });
+        m.addContainer(c);
         desiredState.setManifest(m);
-        pod.setDesiredState(desiredState);
+        pod.setState(desiredState);
         State currentState = desiredState;
         pod.setCurrentState(currentState);
         

http://git-wip-us.apache.org/repos/asf/stratos/blob/405ff36d/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/behaviour/CartridgeMgtBehaviour.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/behaviour/CartridgeMgtBehaviour.java
b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/behaviour/CartridgeMgtBehaviour.java
index 384d494..1419f00 100644
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/behaviour/CartridgeMgtBehaviour.java
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/behaviour/CartridgeMgtBehaviour.java
@@ -109,7 +109,7 @@ public abstract class CartridgeMgtBehaviour implements Serializable {
                         if ("DEPLOYMENT".equals(payloadParamSubstring)) {
                             isDeploymentParam = true;
                         }
-                        payloadData.add(payloadParamSubstring, property.getValue());
+                        payloadData.add(payloadParamSubstring, String.valueOf(property.getValue()));
                     }
                 }
             }

http://git-wip-us.apache.org/repos/asf/stratos/blob/405ff36d/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/manager/CartridgeSubscriptionManager.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/manager/CartridgeSubscriptionManager.java
b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/manager/CartridgeSubscriptionManager.java
index 4e74b42..d2a92e1 100644
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/manager/CartridgeSubscriptionManager.java
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/manager/CartridgeSubscriptionManager.java
@@ -342,7 +342,7 @@ public class CartridgeSubscriptionManager {
 					continue;
 				}
 				if (prop.getName().equals(CartridgeConstants.LB_CLUSTER_ID)) {
-					return prop.getValue();
+					return String.valueOf(prop.getValue());
 				}
 			}
 		}
@@ -493,7 +493,8 @@ public class CartridgeSubscriptionManager {
             for(Property property : subscriptionData.getProperties().getProperties()){
                 if (property.getName().startsWith(CartridgeConstants.CUSTOM_PAYLOAD_PARAM_NAME_PREFIX))
{
                     String payloadParamName = property.getName();
-                    cartridgeSubscription.getPayloadData().add(payloadParamName.substring(payloadParamName.indexOf(".")
+ 1), property.getValue());
+                    cartridgeSubscription.getPayloadData().add(payloadParamName.substring(
+                            payloadParamName.indexOf(".") + 1), String.valueOf(property.getValue()));
                 }
             }
         }

http://git-wip-us.apache.org/repos/asf/stratos/blob/405ff36d/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/utils/ApplicationManagementUtil.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/utils/ApplicationManagementUtil.java
b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/utils/ApplicationManagementUtil.java
index f570755..84fb2e3 100644
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/utils/ApplicationManagementUtil.java
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/utils/ApplicationManagementUtil.java
@@ -223,7 +223,7 @@ public class ApplicationManagementUtil {
                 if ((property != null) && (property.getValue() != null)) {
                     org.apache.stratos.cloud.controller.stub.Property newProperty = new org.apache.stratos.cloud.controller.stub.Property();
                     newProperty.setName(property.getName());
-                    newProperty.setValue(property.getValue());
+                    newProperty.setValue(String.valueOf(property.getValue()));
                     stubProps.addProperties(newProperty);
                 }
             }
@@ -243,7 +243,7 @@ public class ApplicationManagementUtil {
                 if ((property != null) && (property.getValue() != null)) {
                     org.apache.stratos.autoscaler.stub.Property newProperty = new org.apache.stratos.autoscaler.stub.Property();
                     newProperty.setName(property.getName());
-                    newProperty.setValue(property.getValue());
+                    newProperty.setValue(String.valueOf(property.getValue()));
                     stubProps.addProperties(newProperty);
                 }
             }


Mime
View raw message