http://git-wip-us.apache.org/repos/asf/stratos/blob/de610a67/dependencies/fabric8/kubernetes-api/src/main/kubernetes/api/kubernetes.raml ---------------------------------------------------------------------- diff --git a/dependencies/fabric8/kubernetes-api/src/main/kubernetes/api/kubernetes.raml b/dependencies/fabric8/kubernetes-api/src/main/kubernetes/api/kubernetes.raml deleted file mode 100644 index 54461c5..0000000 --- a/dependencies/fabric8/kubernetes-api/src/main/kubernetes/api/kubernetes.raml +++ /dev/null @@ -1,204 +0,0 @@ -#%RAML 0.8 -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -baseUri: http://server/api/{version} -title: Kubernetes -version: v1beta1 -mediaType: application/json -documentation: - - title: Overview - content: | - The Kubernetes API currently manages 3 main resources: `pods`, - `replicationControllers`, and `services`. Pods correspond to - colocated groups of [Docker containers](http://docker.io) with - shared volumes, as supported by [Google Cloud Platform's - container-vm - images](https://developers.google.com/compute/docs/containers). - Singleton pods can be created directly via the `/pods` - endpoint. Sets of pods may created, maintained, and scaled using - replicationControllers. Services create load-balanced targets - for sets of pods. - - - title: Resource identifiers - content: | - Each resource has a string `id` and list of key-value - `labels`. The `id` is generated by the system and is guaranteed - to be unique in space and time across all resources. `labels` - is a map of string (key) to string (value). Each resource may - have at most one label with a particular key. Individual labels - are used to specify identifying metadata that can be used to - define sets of resources by specifying required labels. Examples - of typical pod label keys include `stage`, `service`, `name`, - `tier`, `partition`, and `track`, but you are free to develop - your own conventions. - - - title: Creation semantics - content: | - Creation is currently not idempotent. We plan to add a - modification token to each resource. A unique value for the token - should be provided by the user during creation. If the user - specifies a duplicate token at creation time, the system should - return an error with a pointer to the existing resource with that - token. In this way a user can deterministically recover from a - dropped connection during a resource creation request. - - - title: Update semantics - content: | - Custom verbs are minimized and are used only for 'edge triggered' - actions such as a reboot. Resource descriptions are generally set - up with `desiredState` for the user provided parameters and - `currentState` for the actual system state. While consistent - terminology is used across these two stanzas they do not match - member for member. - - When a new version of a resource is PUT the `desiredState` is - updated and available immediately. Over time the system will work - to bring the `currentState` into line with the `desiredState`. The - system will drive toward the most recent `desiredState` regardless - of previous versions of that stanza. In other words, if a value - is changed from 2 to 5 in one PUT and then back down to 3 in - another PUT the system isn't required to 'touch base' at 5 before - making 3 the `currentState`. - - When doing an update, we assume that the entire `desiredState` - stanza is specified. If a field is omitted it is assumed that the - user is looking to delete that field. It is viable for a user to - GET the resource, modify what they like in the `desiredState` or - labels stanzas and then PUT it back. If the `currentState` is - included in the PUT it will be silently ignored. - - While currently unspecified, it is intended that concurrent - modification should be accomplished with optimistic locking of - resources. We plan to add a modification token to each resource. If - this is included with the PUT operation the system will verify - that there haven't been other successful mutations to the - resource during a read/modify/write cycle. The correct client - action at this point is to GET the resource again, apply the - changes afresh and try submitting again. - - Note that updates currently only work for replicationControllers - and services, but not for pods. Label updates have not yet been - implemented, either. - -/pods: - get: - description: List all pods on this cluster - responses: - 200: - body: - example: !include examples/pod-list.json - post: - description: Create a new pod. currentState is ignored if present. - body: - schema: !include doc/pod-schema.json - example: !include examples/pod.json - - /{podId}: - get: - description: Get a specific pod - responses: - 200: - body: - example: !include examples/pod.json - put: - description: Update a pod - body: - schema: !include doc/pod-schema.json - example: !include examples/pod.json - delete: - description: Delete a specific pod - responses: - 200: - body: - example: | - { - "success": true - } - -/replicationControllers: - get: - description: List all replicationControllers on this cluster - responses: - 200: - body: - example: !include examples/controller-list.json - post: - description: Create a new controller. currentState is ignored if present. - body: - schema: !include doc/controller-schema.json - example: !include examples/controller.json - - /{controllerId}: - get: - description: Get a specific controller - responses: - 200: - body: - example: !include examples/controller.json - put: - description: Update a controller - body: - schema: !include doc/controller-schema.json - example: !include examples/controller.json - delete: - description: Delete a specific controller - responses: - 200: - body: - example: | - { - "success": true - } - -/services: - get: - description: List all services on this cluster - responses: - 200: - body: - example: !include examples/service-list.json - post: - description: Create a new service - body: - schema: !include doc/service-schema.json - example: !include examples/service.json - - /{serviceId}: - get: - description: Get a specific service - responses: - 200: - body: - example: !include examples/service.json - put: - description: Update a service - body: - schema: !include doc/service-schema.json - example: !include examples/service.json - delete: - description: Delete a specific service - responses: - 200: - body: - example: | - { - "success": true - } -
http://git-wip-us.apache.org/repos/asf/stratos/blob/de610a67/dependencies/fabric8/kubernetes-api/src/main/resources/log4j.properties ---------------------------------------------------------------------- diff --git a/dependencies/fabric8/kubernetes-api/src/main/resources/log4j.properties b/dependencies/fabric8/kubernetes-api/src/main/resources/log4j.properties deleted file mode 100644 index 73b9512..0000000 --- a/dependencies/fabric8/kubernetes-api/src/main/resources/log4j.properties +++ /dev/null @@ -1,27 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -# Root logger option -log4j.rootLogger=INFO, stdout - -# Direct log messages to stdout -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.Target=System.out -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/de610a67/dependencies/fabric8/kubernetes-api/src/test/java/io/fabric8/kubernetes/api/Apply.java ---------------------------------------------------------------------- diff --git a/dependencies/fabric8/kubernetes-api/src/test/java/io/fabric8/kubernetes/api/Apply.java b/dependencies/fabric8/kubernetes-api/src/test/java/io/fabric8/kubernetes/api/Apply.java deleted file mode 100644 index 4f19fb7..0000000 --- a/dependencies/fabric8/kubernetes-api/src/test/java/io/fabric8/kubernetes/api/Apply.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Copyright 2005-2014 Red Hat, Inc. - * - * Red Hat licenses this file to you under the Apache License, version - * 2.0 (the "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - * implied. See the License for the specific language governing - * permissions and limitations under the License. - */ -package io.fabric8.kubernetes.api; - -import java.io.File; - -/** - * Applies the given JSON file to the kubernetes environment - */ -public class Apply { - public static void main(String... args) { - if (args.length < 1) { - System.out.println("Usage jsonFileToApply"); - return; - } - try { - KubernetesClient kube = new KubernetesClient(); - System.out.println("Connecting to kubernetes on: " + kube.getAddress()); - - File file = new File(args[0]); - System.out.println("Applying file: " + file); - if (!file.exists() || !file.isFile()) { - System.out.println("File does not exist! " + file.getAbsolutePath()); - return; - } - Controller controller = new Controller(kube); - String answer = controller.apply(file); - - System.out.println("Applied!: " + answer); - } catch (Exception e) { - System.out.println("FAILED: " + e); - e.printStackTrace(); - } - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/de610a67/dependencies/fabric8/kubernetes-api/src/test/java/io/fabric8/kubernetes/api/ConfigComparePodTest.java ---------------------------------------------------------------------- diff --git a/dependencies/fabric8/kubernetes-api/src/test/java/io/fabric8/kubernetes/api/ConfigComparePodTest.java b/dependencies/fabric8/kubernetes-api/src/test/java/io/fabric8/kubernetes/api/ConfigComparePodTest.java deleted file mode 100644 index 80ae51a..0000000 --- a/dependencies/fabric8/kubernetes-api/src/test/java/io/fabric8/kubernetes/api/ConfigComparePodTest.java +++ /dev/null @@ -1,243 +0,0 @@ -/** - * Copyright 2005-2014 Red Hat, Inc. - * <p/> - * Red Hat licenses this file to you under the Apache License, version - * 2.0 (the "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * <p/> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p/> - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - * implied. See the License for the specific language governing - * permissions and limitations under the License. - */ -package io.fabric8.kubernetes.api; - -import io.fabric8.kubernetes.api.model.Pod; -import io.fabric8.kubernetes.api.model.PodBuilder; -import io.fabric8.kubernetes.api.model.PodStatus; -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import static io.fabric8.kubernetes.api.ConfigCompareServiceTest.assertCompareConfig; - -public class ConfigComparePodTest { - - private static final transient Logger LOG = LoggerFactory.getLogger(ConfigComparePodTest.class); - - @Test - public void testPodsEqual() throws Exception { - Pod entity1 = new PodBuilder().withNewMetadata().withName("foo"). - addToLabels("label1", "value1"). - addToLabels("label2", "value2"). - addToAnnotations("podAnnotation1", "podAnnValue1"). - endMetadata(). - withNewSpec(). - addNewContainer(). - withImage("fabric8/jenkins"). - addNewEnv().withName("foo").withValue("bar").endEnv(). - // TODO.... - // addNewPort().endPort(). - endContainer(). - endSpec(). - build(); - - Pod entity2 = new PodBuilder().withNewMetadata().withName("foo"). - addToLabels("label1", "value1"). - addToLabels("label2", "value2"). - addToAnnotations("podAnnotation1", "podAnnValue1"). - endMetadata(). - withNewSpec(). - addNewContainer(). - withImage("fabric8/jenkins"). - addNewEnv().withName("foo").withValue("bar").endEnv(). - // TODO.... - // addNewPort().endPort(). - endContainer(). - endSpec(). - build(); - - assertCompareConfig(entity1, entity2, true); - } - - @Test - public void testPodsEqualWithDifferentStatus() throws Exception { - Pod entity1 = new PodBuilder().withNewMetadata().withName("foo"). - addToLabels("label1", "value1"). - addToLabels("label2", "value2"). - addToAnnotations("podAnnotation1", "podAnnValue1"). - endMetadata(). - withNewSpec(). - addNewContainer(). - withImage("fabric8/jenkins"). - addNewEnv().withName("foo").withValue("bar").endEnv(). - // TODO.... - // addNewPort().endPort(). - endContainer(). - endSpec(). - build(); - - PodStatus status2 = new PodStatus(); - status2.setHostIP("abc"); - - Pod entity2 = new PodBuilder().withNewMetadata().withName("foo"). - addToLabels("label1", "value1"). - addToLabels("label2", "value2"). - addToAnnotations("podAnnotation1", "podAnnValue1"). - endMetadata(). - withNewSpec(). - addNewContainer(). - withImage("fabric8/jenkins"). - addNewEnv().withName("foo").withValue("bar").endEnv(). - // TODO.... - // addNewPort().endPort(). - endContainer(). - endSpec(). - withStatus(status2). - build(); - - assertCompareConfig(entity1, entity2, true); - } - - @Test - public void testPodsLabelsNotEqual() throws Exception { - Pod entity1 = new PodBuilder().withNewMetadata().withName("foo"). - addToLabels("label1", "value1"). - addToLabels("label2", "value2"). - addToAnnotations("podAnnotation1", "podAnnValue1"). - endMetadata(). - withNewSpec(). - addNewContainer(). - withImage("fabric8/jenkins"). - addNewEnv().withName("foo").withValue("bar").endEnv(). - // TODO.... - // addNewPort().endPort(). - endContainer(). - endSpec(). - build(); - - Pod entity2 = new PodBuilder().withNewMetadata().withName("foo"). - addToLabels("label1", "value1"). - addToLabels("label2", "notSame"). - addToAnnotations("podAnnotation1", "podAnnValue1"). - endMetadata(). - withNewSpec(). - addNewContainer(). - withImage("fabric8/jenkins"). - addNewEnv().withName("foo").withValue("bar").endEnv(). - // TODO.... - // addNewPort().endPort(). - endContainer(). - endSpec(). - build(); - - assertCompareConfig(entity1, entity2, false); - } - - @Test - public void testPodsAnnotationsNotEqual() throws Exception { - Pod entity1 = new PodBuilder().withNewMetadata().withName("foo"). - addToLabels("label1", "value1"). - addToLabels("label2", "value2"). - addToAnnotations("podAnnotation1", "podAnnValue1"). - endMetadata(). - withNewSpec(). - addNewContainer(). - withImage("fabric8/jenkins"). - addNewEnv().withName("foo").withValue("bar").endEnv(). - // TODO.... - // addNewPort().endPort(). - endContainer(). - endSpec(). - build(); - - Pod entity2 = new PodBuilder().withNewMetadata().withName("foo"). - addToLabels("label1", "value1"). - addToLabels("label2", "value2"). - addToAnnotations("podAnnotation1", "notSame"). - endMetadata(). - withNewSpec(). - addNewContainer(). - withImage("fabric8/jenkins"). - addNewEnv().withName("foo").withValue("bar").endEnv(). - // TODO.... - // addNewPort().endPort(). - endContainer(). - endSpec(). - build(); - - assertCompareConfig(entity1, entity2, false); - } - - @Test - public void testPodsImageEqual() throws Exception { - Pod entity1 = new PodBuilder().withNewMetadata().withName("foo"). - addToLabels("label1", "value1"). - addToLabels("label2", "value2"). - addToAnnotations("podAnnotation1", "podAnnValue1"). - endMetadata(). - withNewSpec(). - addNewContainer(). - withImage("fabric8/jenkins"). - addNewEnv().withName("foo").withValue("bar").endEnv(). - // TODO.... - // addNewPort().endPort(). - endContainer(). - endSpec(). - build(); - - Pod entity2 = new PodBuilder().withNewMetadata().withName("foo"). - addToLabels("label1", "value1"). - addToLabels("label2", "value2"). - addToAnnotations("podAnnotation1", "podAnnValue1"). - endMetadata(). - withNewSpec(). - addNewContainer(). - withImage("notSame"). - addNewEnv().withName("foo").withValue("bar").endEnv(). - // TODO.... - // addNewPort().endPort(). - endContainer(). - endSpec(). - build(); - - assertCompareConfig(entity1, entity2, false); - } - @Test - public void testPodsContainerEnvEqual() throws Exception { - Pod entity1 = new PodBuilder().withNewMetadata().withName("foo"). - addToLabels("label1", "value1"). - addToLabels("label2", "value2"). - addToAnnotations("podAnnotation1", "podAnnValue1"). - endMetadata(). - withNewSpec(). - addNewContainer(). - withImage("fabric8/jenkins"). - addNewEnv().withName("foo").withValue("bar").endEnv(). - // TODO.... - // addNewPort().endPort(). - endContainer(). - endSpec(). - build(); - - Pod entity2 = new PodBuilder().withNewMetadata().withName("foo"). - addToLabels("label1", "value1"). - addToLabels("label2", "value2"). - addToAnnotations("podAnnotation1", "podAnnValue1"). - endMetadata(). - withNewSpec(). - addNewContainer(). - withImage("fabric8/jenkins"). - addNewEnv().withName("foo").withValue("notSame").endEnv(). - // TODO.... - // addNewPort().endPort(). - endContainer(). - endSpec(). - build(); - - assertCompareConfig(entity1, entity2, false); - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/de610a67/dependencies/fabric8/kubernetes-api/src/test/java/io/fabric8/kubernetes/api/ConfigCompareReplicationControllerTest.java ---------------------------------------------------------------------- diff --git a/dependencies/fabric8/kubernetes-api/src/test/java/io/fabric8/kubernetes/api/ConfigCompareReplicationControllerTest.java b/dependencies/fabric8/kubernetes-api/src/test/java/io/fabric8/kubernetes/api/ConfigCompareReplicationControllerTest.java deleted file mode 100644 index 24ef845..0000000 --- a/dependencies/fabric8/kubernetes-api/src/test/java/io/fabric8/kubernetes/api/ConfigCompareReplicationControllerTest.java +++ /dev/null @@ -1,530 +0,0 @@ -/** - * Copyright 2005-2014 Red Hat, Inc. - * <p/> - * Red Hat licenses this file to you under the Apache License, version - * 2.0 (the "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * <p/> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p/> - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - * implied. See the License for the specific language governing - * permissions and limitations under the License. - */ -package io.fabric8.kubernetes.api; - -import io.fabric8.kubernetes.api.model.ReplicationController; -import io.fabric8.kubernetes.api.model.ReplicationControllerBuilder; -import io.fabric8.kubernetes.api.model.ReplicationControllerStatus; -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import static io.fabric8.kubernetes.api.ConfigCompareServiceTest.assertCompareConfig; - -public class ConfigCompareReplicationControllerTest { - - private static final transient Logger LOG = LoggerFactory.getLogger(ConfigCompareReplicationControllerTest.class); - - @Test - public void testReplicationControllersEqual() throws Exception { - ReplicationController entity1 = new ReplicationControllerBuilder().withNewMetadata().withName("foo"). - addToLabels("label1", "value1"). - addToLabels("label2", "value2"). - endMetadata(). - withNewSpec(). - addToSelector("label1", "value1"). - addToSelector("label2", "value2"). - withReplicas(2). - withNewTemplate().withNewMetadata(). - addToLabels("podLabel1", "podValue1"). - addToLabels("podLabel2", "podValue2"). - addToAnnotations("podAnnotation1", "podAnnValue1"). - endMetadata(). - withNewSpec(). - addNewContainer(). - withImage("fabric8/jenkins"). - addNewEnv().withName("foo").withValue("bar").endEnv(). - // TODO.... - // addNewPort().endPort(). - endContainer(). - endSpec(). - endTemplate(). - endSpec(). - build(); - - ReplicationController entity2 = new ReplicationControllerBuilder().withNewMetadata().withName("foo"). - addToLabels("label1", "value1"). - addToLabels("label2", "value2"). - endMetadata(). - withNewSpec(). - addToSelector("label1", "value1"). - addToSelector("label2", "value2"). - withReplicas(2). - withNewTemplate().withNewMetadata(). - addToLabels("podLabel1", "podValue1"). - addToLabels("podLabel2", "podValue2"). - addToAnnotations("podAnnotation1", "podAnnValue1"). - endMetadata(). - withNewSpec(). - addNewContainer(). - withImage("fabric8/jenkins"). - addNewEnv().withName("foo").withValue("bar").endEnv(). - // TODO.... - // addNewPort().endPort(). - endContainer(). - endSpec(). - endTemplate(). - endSpec(). - build(); - - assertCompareConfig(entity1, entity2, true); - } - - @Test - public void testReplicationControllersEqualWithDifferentStatus() throws Exception { - ReplicationController entity1 = new ReplicationControllerBuilder().withNewMetadata().withName("foo"). - addToLabels("label1", "value1"). - addToLabels("label2", "value2"). - endMetadata(). - withNewSpec(). - addToSelector("label1", "value1"). - addToSelector("label2", "value2"). - withReplicas(2). - withNewTemplate().withNewMetadata(). - addToLabels("podLabel1", "podValue1"). - addToLabels("podLabel2", "podValue2"). - addToAnnotations("podAnnotation1", "podAnnValue1"). - endMetadata(). - withNewSpec(). - addNewContainer(). - withImage("fabric8/jenkins"). - addNewEnv().withName("foo").withValue("bar").endEnv(). - // TODO.... - // addNewPort().endPort(). - endContainer(). - endSpec(). - endTemplate(). - endSpec(). - build(); - - ReplicationControllerStatus status = new ReplicationControllerStatus(); - status.setReplicas(7); - ReplicationController entity2 = new ReplicationControllerBuilder().withNewMetadata().withName("foo"). - addToLabels("label1", "value1"). - addToLabels("label2", "value2"). - endMetadata(). - withNewSpec(). - addToSelector("label1", "value1"). - addToSelector("label2", "value2"). - withReplicas(2). - withNewTemplate().withNewMetadata(). - addToLabels("podLabel1", "podValue1"). - addToLabels("podLabel2", "podValue2"). - addToAnnotations("podAnnotation1", "podAnnValue1"). - endMetadata(). - withNewSpec(). - addNewContainer(). - withImage("fabric8/jenkins"). - addNewEnv().withName("foo").withValue("bar").endEnv(). - // TODO.... - // addNewPort().endPort(). - endContainer(). - endSpec(). - endTemplate(). - endSpec(). - withStatus(status). - build(); - - assertCompareConfig(entity1, entity2, true); - } - - @Test - public void testReplicationControllersLabelsNotEqual() throws Exception { - ReplicationController entity1 = new ReplicationControllerBuilder().withNewMetadata().withName("foo"). - addToLabels("label1", "value1"). - addToLabels("label2", "value2"). - endMetadata(). - withNewSpec(). - addToSelector("label1", "value1"). - addToSelector("label2", "value2"). - withReplicas(2). - withNewTemplate().withNewMetadata(). - addToLabels("podLabel1", "podValue1"). - addToLabels("podLabel2", "podValue2"). - addToAnnotations("podAnnotation1", "podAnnValue1"). - endMetadata(). - withNewSpec(). - addNewContainer(). - withImage("fabric8/jenkins"). - addNewEnv().withName("foo").withValue("bar").endEnv(). - // TODO.... - // addNewPort().endPort(). - endContainer(). - endSpec(). - endTemplate(). - endSpec(). - build(); - - ReplicationController entity2 = new ReplicationControllerBuilder().withNewMetadata().withName("foo"). - addToLabels("label1", "value1"). - addToLabels("label2", "value2"). - endMetadata(). - withNewSpec(). - addToSelector("label1", "value1"). - addToSelector("label2", "value2"). - withReplicas(2). - withNewTemplate().withNewMetadata(). - addToLabels("notSame", "podValue1"). - addToLabels("podLabel2", "podValue2"). - addToAnnotations("podAnnotation1", "podAnnValue1"). - endMetadata(). - withNewSpec(). - addNewContainer(). - withImage("fabric8/jenkins"). - addNewEnv().withName("foo").withValue("bar").endEnv(). - // TODO.... - // addNewPort().endPort(). - endContainer(). - endSpec(). - endTemplate(). - endSpec(). - build(); - - assertCompareConfig(entity1, entity2, false); - } - - @Test - public void testReplicationControllersSelectorNotEqual() throws Exception { - ReplicationController entity1 = new ReplicationControllerBuilder().withNewMetadata().withName("foo"). - addToLabels("label1", "value1"). - addToLabels("label2", "value2"). - endMetadata(). - withNewSpec(). - addToSelector("label1", "value1"). - addToSelector("label2", "value2"). - withReplicas(2). - withNewTemplate().withNewMetadata(). - addToLabels("podLabel1", "podValue1"). - addToLabels("podLabel2", "podValue2"). - addToAnnotations("podAnnotation1", "podAnnValue1"). - endMetadata(). - withNewSpec(). - addNewContainer(). - withImage("fabric8/jenkins"). - addNewEnv().withName("foo").withValue("bar").endEnv(). - // TODO.... - // addNewPort().endPort(). - endContainer(). - endSpec(). - endTemplate(). - endSpec(). - build(); - - ReplicationController entity2 = new ReplicationControllerBuilder().withNewMetadata().withName("foo"). - addToLabels("label1", "value1"). - addToLabels("label2", "value2"). - endMetadata(). - withNewSpec(). - addToSelector("label1", "value1"). - addToSelector("label2", "notSame"). - withReplicas(2). - withNewTemplate().withNewMetadata(). - addToLabels("podLabel1", "podValue1"). - addToLabels("podLabel2", "podValue2"). - addToAnnotations("podAnnotation1", "podAnnValue1"). - endMetadata(). - withNewSpec(). - addNewContainer(). - withImage("fabric8/jenkins"). - addNewEnv().withName("foo").withValue("bar").endEnv(). - // TODO.... - // addNewPort().endPort(). - endContainer(). - endSpec(). - endTemplate(). - endSpec(). - build(); - - assertCompareConfig(entity1, entity2, false); - } - - @Test - public void testReplicationControllersReplicasNotEqual() throws Exception { - ReplicationController entity1 = new ReplicationControllerBuilder().withNewMetadata().withName("foo"). - addToLabels("label1", "value1"). - addToLabels("label2", "value2"). - endMetadata(). - withNewSpec(). - addToSelector("label1", "value1"). - addToSelector("label2", "value2"). - withReplicas(2). - withNewTemplate().withNewMetadata(). - addToLabels("podLabel1", "podValue1"). - addToLabels("podLabel2", "podValue2"). - addToAnnotations("podAnnotation1", "podAnnValue1"). - endMetadata(). - withNewSpec(). - addNewContainer(). - withImage("fabric8/jenkins"). - addNewEnv().withName("foo").withValue("bar").endEnv(). - // TODO.... - // addNewPort().endPort(). - endContainer(). - endSpec(). - endTemplate(). - endSpec(). - build(); - - ReplicationController entity2 = new ReplicationControllerBuilder().withNewMetadata().withName("foo"). - addToLabels("label1", "value1"). - addToLabels("label2", "value2"). - endMetadata(). - withNewSpec(). - addToSelector("label1", "value1"). - addToSelector("label2", "value2"). - withReplicas(4). - withNewTemplate().withNewMetadata(). - addToLabels("podLabel1", "podValue1"). - addToLabels("podLabel2", "podValue2"). - addToAnnotations("podAnnotation1", "podAnnValue1"). - endMetadata(). - withNewSpec(). - addNewContainer(). - withImage("fabric8/jenkins"). - addNewEnv().withName("foo").withValue("bar").endEnv(). - // TODO.... - // addNewPort().endPort(). - endContainer(). - endSpec(). - endTemplate(). - endSpec(). - build(); - - assertCompareConfig(entity1, entity2, false); - } - - @Test - public void testReplicationControllersAnnotationsNotEqual() throws Exception { - ReplicationController entity1 = new ReplicationControllerBuilder().withNewMetadata().withName("foo"). - addToLabels("label1", "value1"). - addToLabels("label2", "value2"). - endMetadata(). - withNewSpec(). - addToSelector("label1", "value1"). - addToSelector("label2", "value2"). - withReplicas(2). - withNewTemplate().withNewMetadata(). - addToLabels("podLabel1", "podValue1"). - addToLabels("podLabel2", "podValue2"). - addToAnnotations("podAnnotation1", "podAnnValue1"). - endMetadata(). - withNewSpec(). - addNewContainer(). - withImage("fabric8/jenkins"). - addNewEnv().withName("foo").withValue("bar").endEnv(). - // TODO.... - // addNewPort().endPort(). - endContainer(). - endSpec(). - endTemplate(). - endSpec(). - build(); - - ReplicationController entity2 = new ReplicationControllerBuilder().withNewMetadata().withName("foo"). - addToLabels("label1", "value1"). - addToLabels("label2", "value2"). - endMetadata(). - withNewSpec(). - addToSelector("label1", "value1"). - addToSelector("label2", "value2"). - withReplicas(2). - withNewTemplate().withNewMetadata(). - addToLabels("podLabel1", "podValue1"). - addToLabels("podLabel2", "podValue2"). - addToAnnotations("podAnnotation1", "notEqual"). - endMetadata(). - withNewSpec(). - addNewContainer(). - withImage("fabric8/jenkins"). - addNewEnv().withName("foo").withValue("bar").endEnv(). - // TODO.... - // addNewPort().endPort(). - endContainer(). - endSpec(). - endTemplate(). - endSpec(). - build(); - - assertCompareConfig(entity1, entity2, false); - } - - @Test - public void testReplicationControllersImageEqual() throws Exception { - ReplicationController entity1 = new ReplicationControllerBuilder().withNewMetadata().withName("foo"). - addToLabels("label1", "value1"). - addToLabels("label2", "value2"). - endMetadata(). - withNewSpec(). - addToSelector("label1", "value1"). - addToSelector("label2", "value2"). - withReplicas(2). - withNewTemplate().withNewMetadata(). - addToLabels("podLabel1", "podValue1"). - addToLabels("podLabel2", "podValue2"). - addToAnnotations("podAnnotation1", "podAnnValue1"). - endMetadata(). - withNewSpec(). - addNewContainer(). - withImage("fabric8/jenkins"). - addNewEnv().withName("foo").withValue("bar").endEnv(). - // TODO.... - // addNewPort().endPort(). - endContainer(). - endSpec(). - endTemplate(). - endSpec(). - build(); - - ReplicationController entity2 = new ReplicationControllerBuilder().withNewMetadata().withName("foo"). - addToLabels("label1", "value1"). - addToLabels("label2", "value2"). - endMetadata(). - withNewSpec(). - addToSelector("label1", "value1"). - addToSelector("label2", "value2"). - withReplicas(2). - withNewTemplate().withNewMetadata(). - addToLabels("podLabel1", "podValue1"). - addToLabels("podLabel2", "podValue2"). - addToAnnotations("podAnnotation1", "podAnnValue1"). - endMetadata(). - withNewSpec(). - addNewContainer(). - withImage("notEqual"). - addNewEnv().withName("foo").withValue("bar").endEnv(). - // TODO.... - // addNewPort().endPort(). - endContainer(). - endSpec(). - endTemplate(). - endSpec(). - build(); - - assertCompareConfig(entity1, entity2, false); - } - - @Test - public void testReplicationControllersContainerEnvEqual() throws Exception { - ReplicationController entity1 = new ReplicationControllerBuilder().withNewMetadata().withName("foo"). - addToLabels("label1", "value1"). - addToLabels("label2", "value2"). - endMetadata(). - withNewSpec(). - addToSelector("label1", "value1"). - addToSelector("label2", "value2"). - withReplicas(2). - withNewTemplate().withNewMetadata(). - addToLabels("podLabel1", "podValue1"). - addToLabels("podLabel2", "podValue2"). - addToAnnotations("podAnnotation1", "podAnnValue1"). - endMetadata(). - withNewSpec(). - addNewContainer(). - withImage("fabric8/jenkins"). - addNewEnv().withName("foo").withValue("bar").endEnv(). - // TODO.... - // addNewPort().endPort(). - endContainer(). - endSpec(). - endTemplate(). - endSpec(). - build(); - - ReplicationController entity2 = new ReplicationControllerBuilder().withNewMetadata().withName("foo"). - addToLabels("label1", "value1"). - addToLabels("label2", "value2"). - endMetadata(). - withNewSpec(). - addToSelector("label1", "value1"). - addToSelector("label2", "value2"). - withReplicas(2). - withNewTemplate().withNewMetadata(). - addToLabels("podLabel1", "podValue1"). - addToLabels("podLabel2", "podValue2"). - addToAnnotations("podAnnotation1", "podAnnValue1"). - endMetadata(). - withNewSpec(). - addNewContainer(). - withImage("fabric8/jenkins"). - addNewEnv().withName("foo").withValue("notEqual").endEnv(). - // TODO.... - // addNewPort().endPort(). - endContainer(). - endSpec(). - endTemplate(). - endSpec(). - build(); - - assertCompareConfig(entity1, entity2, false); - } - - @Test - public void testReplicationControllersAddVolumeNotEqual() throws Exception { - ReplicationController entity1 = new ReplicationControllerBuilder().withNewMetadata().withName("foo"). - addToLabels("label1", "value1"). - addToLabels("label2", "value2"). - endMetadata(). - withNewSpec(). - addToSelector("label1", "value1"). - addToSelector("label2", "value2"). - withReplicas(2). - withNewTemplate().withNewMetadata(). - addToLabels("podLabel1", "podValue1"). - addToLabels("podLabel2", "podValue2"). - addToAnnotations("podAnnotation1", "podAnnValue1"). - endMetadata(). - withNewSpec(). - addNewContainer(). - withImage("fabric8/jenkins"). - addNewVolumeMount().withName("cheese").withMountPath("/foo/cheese").endVolumeMount(). - addNewEnv().withName("foo").withValue("bar").endEnv(). - // TODO.... - // addNewPort().endPort(). - endContainer(). - endSpec(). - endTemplate(). - endSpec(). - build(); - - ReplicationController entity2 = new ReplicationControllerBuilder().withNewMetadata().withName("foo"). - addToLabels("label1", "value1"). - addToLabels("label2", "value2"). - endMetadata(). - withNewSpec(). - addToSelector("label1", "value1"). - addToSelector("label2", "value2"). - withReplicas(2). - withNewTemplate().withNewMetadata(). - addToLabels("podLabel1", "podValue1"). - addToLabels("podLabel2", "podValue2"). - addToAnnotations("podAnnotation1", "podAnnValue1"). - endMetadata(). - withNewSpec(). - addNewContainer(). - withImage("fabric8/jenkins"). - addNewEnv().withName("foo").withValue("bar").endEnv(). - // TODO.... - // addNewPort().endPort(). - endContainer(). - endSpec(). - endTemplate(). - endSpec(). - build(); - - assertCompareConfig(entity1, entity2, false); - } - -} http://git-wip-us.apache.org/repos/asf/stratos/blob/de610a67/dependencies/fabric8/kubernetes-api/src/test/java/io/fabric8/kubernetes/api/ConfigCompareServiceTest.java ---------------------------------------------------------------------- diff --git a/dependencies/fabric8/kubernetes-api/src/test/java/io/fabric8/kubernetes/api/ConfigCompareServiceTest.java b/dependencies/fabric8/kubernetes-api/src/test/java/io/fabric8/kubernetes/api/ConfigCompareServiceTest.java deleted file mode 100644 index 1c90d3d..0000000 --- a/dependencies/fabric8/kubernetes-api/src/test/java/io/fabric8/kubernetes/api/ConfigCompareServiceTest.java +++ /dev/null @@ -1,235 +0,0 @@ -/** - * Copyright 2005-2014 Red Hat, Inc. - * <p/> - * Red Hat licenses this file to you under the Apache License, version - * 2.0 (the "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * <p/> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p/> - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - * implied. See the License for the specific language governing - * permissions and limitations under the License. - */ -package io.fabric8.kubernetes.api; - -import io.fabric8.kubernetes.api.model.Service; -import io.fabric8.kubernetes.api.model.ServiceBuilder; -import io.fabric8.kubernetes.api.model.util.IntOrString; -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import static org.junit.Assert.assertEquals; - -public class ConfigCompareServiceTest { - - private static final transient Logger LOG = LoggerFactory.getLogger(ConfigCompareServiceTest.class); - - @Test - public void testServicesEqual() throws Exception { - Service entity1 = new ServiceBuilder().withNewMetadata().withName("foo"). - addToLabels("label1", "value1"). - addToLabels("label2", "value2"). - endMetadata(). - withNewSpec(). - addToSelector("label1", "value1"). - addToSelector("label2", "value2"). - addNewPort(). - withPort(123). - withTargetPort(new IntOrString(456)). - endPort(). - endSpec(). - build(); - - Service entity2 = new ServiceBuilder().withNewMetadata().withName("foo"). - addToLabels("label2", "value2"). - addToLabels("label1", "value1"). - endMetadata(). - withNewSpec(). - addToSelector("label1", "value1"). - addToSelector("label2", "value2"). - addNewPort(). - withPort(123). - withTargetPort(new IntOrString(456)). - endPort(). - endSpec(). - build(); - - assertCompareConfig(entity1, entity2, true); - } - @Test - - public void testServicesEqualWithStatusdifferences() throws Exception { - Service entity1 = new ServiceBuilder().withNewMetadata().withName("foo"). - addToLabels("label1", "value1"). - addToLabels("label2", "value2"). - withResourceVersion("1"). - endMetadata(). - withNewSpec(). - addToSelector("label1", "value1"). - addToSelector("label2", "value2"). - addNewPort(). - withPort(123). - withTargetPort(new IntOrString(456)). - endPort(). - endSpec(). - build(); - - Service entity2 = new ServiceBuilder().withNewMetadata().withName("foo"). - addToLabels("label2", "value2"). - addToLabels("label1", "value1"). - withResourceVersion("2"). - endMetadata(). - withNewSpec(). - addToSelector("label1", "value1"). - addToSelector("label2", "value2"). - addNewPort(). - withPort(123). - withTargetPort(new IntOrString(456)). - endPort(). - endSpec(). - build(); - - assertCompareConfig(entity1, entity2, true); - } - - @Test - public void testServicesPortNotEqual() throws Exception { - Service entity1 = new ServiceBuilder().withNewMetadata().withName("foo"). - addToLabels("label1", "value1"). - addToLabels("label2", "value2"). - endMetadata(). - withNewSpec(). - addToSelector("label1", "value1"). - addToSelector("label2", "value2"). - addNewPort(). - withPort(123). - withTargetPort(new IntOrString(456)). - endPort(). - endSpec(). - build(); - - Service entity2 = new ServiceBuilder().withNewMetadata().withName("foo"). - addToLabels("label2", "value2"). - addToLabels("label1", "value1"). - endMetadata(). - withNewSpec(). - addToSelector("label1", "value1"). - addToSelector("label2", "value2"). - addNewPort(). - withPort(456). - withTargetPort(new IntOrString(456)). - endPort(). - endSpec(). - build(); - - assertCompareConfig(entity1, entity2, false); - } - - @Test - public void testServicesContainerPortNotEqual() throws Exception { - Service entity1 = new ServiceBuilder().withNewMetadata().withName("foo"). - addToLabels("label1", "value1"). - addToLabels("label2", "value2"). - endMetadata(). - withNewSpec(). - addToSelector("label1", "value1"). - addToSelector("label2", "value2"). - addNewPort(). - withPort(123). - withTargetPort(new IntOrString(456)). - endPort(). - endSpec(). - build(); - - Service entity2 = new ServiceBuilder().withNewMetadata().withName("foo"). - addToLabels("label2", "value2"). - addToLabels("label1", "value1"). - endMetadata(). - withNewSpec(). - addToSelector("label1", "value1"). - addToSelector("label2", "value2"). - addNewPort(). - withPort(123). - withTargetPort(new IntOrString(555)). - endPort(). - endSpec(). - build(); - - assertCompareConfig(entity1, entity2, false); - } - - @Test - public void testServicesLabelsNotEqual() throws Exception { - Service entity1 = new ServiceBuilder().withNewMetadata().withName("foo"). - addToLabels("label1", "value1"). - addToLabels("label2", "value2"). - endMetadata(). - withNewSpec(). - addToSelector("label1", "value1"). - addToSelector("label2", "value2"). - addNewPort(). - withPort(123). - withTargetPort(new IntOrString(456)). - endPort(). - endSpec(). - build(); - - Service entity2 = new ServiceBuilder().withNewMetadata().withName("foo"). - addToLabels("label2", "value2"). - addToLabels("notSame", "value1"). - endMetadata(). - withNewSpec(). - addToSelector("label1", "value1"). - addToSelector("label2", "value2"). - addNewPort(). - withPort(123). - withTargetPort(new IntOrString(456)). - endPort(). - endSpec(). - build(); - - assertCompareConfig(entity1, entity2, false); - } - - @Test - public void testServicesSelectorNotEqual() throws Exception { - Service entity1 = new ServiceBuilder().withNewMetadata().withName("foo"). - addToLabels("label1", "value1"). - addToLabels("label2", "value2"). - endMetadata(). - withNewSpec(). - addToSelector("label1", "value1"). - addToSelector("label2", "value2"). - addNewPort(). - withPort(123). - withTargetPort(new IntOrString(456)). - endPort(). - endSpec(). - build(); - - Service entity2 = new ServiceBuilder().withNewMetadata().withName("foo"). - addToLabels("label2", "value2"). - addToLabels("label1", "value1"). - endMetadata(). - withNewSpec(). - addToSelector("label1", "value1"). - addToSelector("notSame", "value2"). - addNewPort(). - withPort(123). - withTargetPort(new IntOrString(456)). - endPort(). - endSpec(). - build(); - - assertCompareConfig(entity1, entity2, false); - } - - public static void assertCompareConfig(Object entity1, Object entity2, boolean expected) { - boolean actual = UserConfigurationCompare.configEqual(entity1, entity2); - assertEquals("Configuration compare for " + entity1 + " and " + entity2, expected, actual); - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/de610a67/dependencies/fabric8/kubernetes-api/src/test/java/io/fabric8/kubernetes/api/ConfigFileParseTest.java ---------------------------------------------------------------------- diff --git a/dependencies/fabric8/kubernetes-api/src/test/java/io/fabric8/kubernetes/api/ConfigFileParseTest.java b/dependencies/fabric8/kubernetes-api/src/test/java/io/fabric8/kubernetes/api/ConfigFileParseTest.java deleted file mode 100644 index 07aa012..0000000 --- a/dependencies/fabric8/kubernetes-api/src/test/java/io/fabric8/kubernetes/api/ConfigFileParseTest.java +++ /dev/null @@ -1,58 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * <p/> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p/> - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.fabric8.kubernetes.api; - -import io.fabric8.kubernetes.api.model.config.Config; -import io.fabric8.kubernetes.api.extensions.Configs; -import io.fabric8.kubernetes.api.model.config.Context; -import org.junit.Test; - -import java.io.File; - -import static io.fabric8.kubernetes.api.extensions.Configs.getOpenShiftConfigFile; -import static org.assertj.core.api.Assertions.assertThat; - -public class ConfigFileParseTest { - @Test - public void testParseConfig() throws Exception { - FindOpenShiftNamespaceTest.setOPenShfitConfigFileProperty(); - - File file = getOpenShiftConfigFile(); - assertThat(file).isFile().exists(); - - Config config = Configs.parseConfigs(); - assertThat(config).isNotNull(); - - String currentContextName = config.getCurrentContext(); - assertThat(currentContextName).describedAs("currentContext").isEqualTo("default/localhost:8443/admin"); - System.out.println("Found current context name: " + currentContextName); - - Context context = Configs.getCurrentContext(config); - assertThat(context).describedAs("currentContext").isNotNull(); - - assertThat(context.getNamespace()).describedAs("namespace").isEqualTo("jimmi-does-rock"); - assertThat(context.getUser()).describedAs("user").isEqualTo("admin/localhost:8443"); - assertThat(context.getCluster()).describedAs("cluster").isEqualTo("172-28-128-4:8443"); - - String token = Configs.getUserToken(config, context); - assertThat(token).describedAs("token").isEqualTo("ExpectedToken"); - - System.out.println("User " + context.getUser() + " has token: " + token); - - } - -} http://git-wip-us.apache.org/repos/asf/stratos/blob/de610a67/dependencies/fabric8/kubernetes-api/src/test/java/io/fabric8/kubernetes/api/Example.java ---------------------------------------------------------------------- diff --git a/dependencies/fabric8/kubernetes-api/src/test/java/io/fabric8/kubernetes/api/Example.java b/dependencies/fabric8/kubernetes-api/src/test/java/io/fabric8/kubernetes/api/Example.java deleted file mode 100644 index 56cbaaa..0000000 --- a/dependencies/fabric8/kubernetes-api/src/test/java/io/fabric8/kubernetes/api/Example.java +++ /dev/null @@ -1,134 +0,0 @@ -/** - * Copyright 2005-2014 Red Hat, Inc. - * - * Red Hat licenses this file to you under the Apache License, version - * 2.0 (the "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - * implied. See the License for the specific language governing - * permissions and limitations under the License. - */ -package io.fabric8.kubernetes.api; - -import io.fabric8.kubernetes.api.model.*; - -import java.util.*; - -import static io.fabric8.kubernetes.api.KubernetesHelper.getPorts; -import static io.fabric8.kubernetes.api.KubernetesHelper.getSelector; - -/** - * A simple example program testing out the REST API - */ -public class Example { - public static void main(String... args) { - KubernetesFactory kubeFactory = new KubernetesFactory(); - if (args.length > 0) { - kubeFactory.setAddress(args[0]); - } - System.out.println("Connecting to kubernetes on: " + kubeFactory.getAddress()); - - try { - Kubernetes kube = kubeFactory.createKubernetes(); - listPods(kube); - listServices(kube); - listReplicationControllers(kube); - createPod(kube, kubeFactory); - listPods(kube); - } catch (Exception e) { - System.out.println("FAILED: " + e); - e.printStackTrace(); - } - } - - protected static void createPod(Kubernetes kubernetes, KubernetesFactory kubernetesFactory) throws Exception { - String name = "console2"; - String image = "fabric8/hawtio"; - - Pod pod = new Pod(); - pod.getMetadata().setName(name); - - Map<String, String> labels = new HashMap<>(); - labels.put("fabric8", "true"); - labels.put("container", name); - - pod.getMetadata().setLabels(labels); - PodSpec podSpec = new PodSpec(); - pod.setSpec(podSpec); - - Container manifestContainer = new Container(); - manifestContainer.setName(name); - manifestContainer.setImage(image); - - List<Container> containers = new ArrayList<>(); - containers.add(manifestContainer); - podSpec.setContainers(containers); - - System.out.println("About to create pod on " + kubernetesFactory.getAddress() + " with " + pod); - kubernetes.createPod(pod, "mynamespace"); - System.out.println("Created pod: " + name); - System.out.println(); - } - - protected static void listPods(Kubernetes kube) { - System.out.println("Looking up pods"); - PodList pods = kube.getPods(Kubernetes.NAMESPACE_ALL); - //System.out.println("Got pods: " + pods); - List<Pod> items = pods.getItems(); - for (Pod item : items) { - System.out.println("Pod " + KubernetesHelper.getName(item) + " created: " + item.getMetadata().getCreationTimestamp()); - PodSpec spec = item.getSpec(); - if (spec != null) { - List<Container> containers = spec.getContainers(); - if (containers != null) { - for (Container container : containers) { - System.out.println("Container " + container.getImage() + " " + container.getCommand() + " ports: " + container.getPorts()); - } - } - } - Map<String, ContainerStatus> currentContainers = KubernetesHelper.getCurrentContainers(item); - System.out.println("Has " + currentContainers.size() + " container(s)"); - Set<Map.Entry<String, ContainerStatus>> entries = currentContainers.entrySet(); - for (Map.Entry<String, ContainerStatus> entry : entries) { - String id = entry.getKey(); - ContainerStatus info = entry.getValue(); - System.out.println("Current container: " + id + " info: " + info); - } - } - System.out.println(); - - } - - protected static void listServices(Kubernetes kube) { - System.out.println("Looking up services"); - ServiceList services = kube.getServices(Kubernetes.NAMESPACE_ALL); - List<Service> serviceItems = services.getItems(); - for (Service service : serviceItems) { - System.out.println("Service " + KubernetesHelper.getName(service) + " labels: " + service.getMetadata().getLabels() + " selector: " + getSelector(service) + " ports: " + getPorts(service)); - } - System.out.println(); - - } - - protected static void listReplicationControllers(Kubernetes kube) { - System.out.println("Looking up replicationControllers"); - ReplicationControllerList replicationControllers = kube.getReplicationControllers(Kubernetes.NAMESPACE_ALL); - List<ReplicationController> items = replicationControllers.getItems(); - for (ReplicationController item : items) { - ReplicationControllerSpec replicationControllerSpec = item.getSpec(); - if (replicationControllerSpec != null) { - System.out.println("ReplicationController " + KubernetesHelper.getName(item) + " labels: " + item.getMetadata().getLabels() - + " replicas: " + replicationControllerSpec.getReplicas() + " replicatorSelector: " + replicationControllerSpec.getSelector() + " podTemplate: " + replicationControllerSpec.getTemplate()); - } else { - System.out.println("ReplicationController " + KubernetesHelper.getName(item) + " labels: " + item.getMetadata().getLabels() + " no replicationControllerSpec"); - } - } - System.out.println(); - } - -} http://git-wip-us.apache.org/repos/asf/stratos/blob/de610a67/dependencies/fabric8/kubernetes-api/src/test/java/io/fabric8/kubernetes/api/FindOpenShiftNamespaceTest.java ---------------------------------------------------------------------- diff --git a/dependencies/fabric8/kubernetes-api/src/test/java/io/fabric8/kubernetes/api/FindOpenShiftNamespaceTest.java b/dependencies/fabric8/kubernetes-api/src/test/java/io/fabric8/kubernetes/api/FindOpenShiftNamespaceTest.java deleted file mode 100644 index 28abff8..0000000 --- a/dependencies/fabric8/kubernetes-api/src/test/java/io/fabric8/kubernetes/api/FindOpenShiftNamespaceTest.java +++ /dev/null @@ -1,41 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * <p/> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p/> - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.fabric8.kubernetes.api; - -import io.fabric8.kubernetes.api.extensions.Configs; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -public class FindOpenShiftNamespaceTest { - - @Test - public void testFindsCorrectOpenShiftNamespace() throws Exception { - setOPenShfitConfigFileProperty(); - String namespace = KubernetesClient.findDefaultOpenShiftNamespace(); - - assertEquals("default namespace", "jimmi-does-rock", namespace); - } - - public static void setOPenShfitConfigFileProperty() { - String basedir = System.getProperty("basedir", "."); - String configFile = basedir + "/src/test/resources/config.yml"; - - System.setProperty(Configs.OPENSHIFT_CONFIG_FILE_PROPERTY, configFile); - } - -} http://git-wip-us.apache.org/repos/asf/stratos/blob/de610a67/dependencies/fabric8/kubernetes-api/src/test/java/io/fabric8/kubernetes/api/KubernetesHelperTest.java ---------------------------------------------------------------------- diff --git a/dependencies/fabric8/kubernetes-api/src/test/java/io/fabric8/kubernetes/api/KubernetesHelperTest.java b/dependencies/fabric8/kubernetes-api/src/test/java/io/fabric8/kubernetes/api/KubernetesHelperTest.java deleted file mode 100644 index 4a23a8b..0000000 --- a/dependencies/fabric8/kubernetes-api/src/test/java/io/fabric8/kubernetes/api/KubernetesHelperTest.java +++ /dev/null @@ -1,71 +0,0 @@ -/** - * Copyright 2005-2014 Red Hat, Inc. - * - * Red Hat licenses this file to you under the Apache License, version - * 2.0 (the "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - * implied. See the License for the specific language governing - * permissions and limitations under the License. - */ -package io.fabric8.kubernetes.api; - -import io.fabric8.kubernetes.api.model.ObjectMeta; -import io.fabric8.kubernetes.api.model.Pod; -import io.fabric8.kubernetes.api.model.PodList; -import org.junit.Test; - -import java.util.HashMap; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.assertFalse; - -public class KubernetesHelperTest { - - @Test - public void testRemoveEmptyPods() throws Exception { - - Pod pod1 = new Pod(); - pod1.setMetadata(new ObjectMeta()); - pod1.getMetadata().setName("test1"); - - Pod pod2 = new Pod(); - pod2.setMetadata(new ObjectMeta()); - - PodList podSchema = new PodList(); - podSchema.getItems().add(pod1); - podSchema.getItems().add(pod2); - - KubernetesHelper.removeEmptyPods(podSchema); - - assertNotNull(podSchema); - assertEquals(1, podSchema.getItems().size()); - } - - @Test - public void testfilterMatchesIdOrLabels() throws Exception { - String text = "container=java,name=foo,food=cheese"; - String id = "foo"; - HashMap<String, String> map = new HashMap<>(); - map.put("container", "java"); - map.put("name", "foo"); - map.put("food", "cheese"); - assertTrue(text + " should = " + map, KubernetesHelper.filterMatchesIdOrLabels(text, id, map)); - } - - @Test - public void testfilterMatchesIdOrLabelsNoLabels() throws Exception { - String text = "container=java,name=foo,food=cheese"; - String id = "foo"; - HashMap<String, String> map = null; - assertFalse(text + " should not = " + map, KubernetesHelper.filterMatchesIdOrLabels(text, id, map)); - } - -} http://git-wip-us.apache.org/repos/asf/stratos/blob/de610a67/dependencies/fabric8/kubernetes-api/src/test/java/io/fabric8/kubernetes/api/ParseDateTimeTest.java ---------------------------------------------------------------------- diff --git a/dependencies/fabric8/kubernetes-api/src/test/java/io/fabric8/kubernetes/api/ParseDateTimeTest.java b/dependencies/fabric8/kubernetes-api/src/test/java/io/fabric8/kubernetes/api/ParseDateTimeTest.java deleted file mode 100644 index b0207bf..0000000 --- a/dependencies/fabric8/kubernetes-api/src/test/java/io/fabric8/kubernetes/api/ParseDateTimeTest.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Copyright 2005-2014 Red Hat, Inc. - * - * Red Hat licenses this file to you under the Apache License, version - * 2.0 (the "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - * implied. See the License for the specific language governing - * permissions and limitations under the License. - */ -package io.fabric8.kubernetes.api; - -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.Date; - -import static org.assertj.core.api.Assertions.assertThat; - -public class ParseDateTimeTest { - - private static final transient Logger LOG = LoggerFactory.getLogger(ParseDateTimeTest.class); - - @Test - public void testParseDateTime() throws Exception { - Date date = KubernetesHelper.parseDate("2015-03-26T17:11:55Z"); - assertThat(date).isNotNull(); - System.out.println("Parsed date: " + date); - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/de610a67/dependencies/fabric8/kubernetes-api/src/test/java/io/fabric8/kubernetes/api/ParseExamplesTest.java ---------------------------------------------------------------------- diff --git a/dependencies/fabric8/kubernetes-api/src/test/java/io/fabric8/kubernetes/api/ParseExamplesTest.java b/dependencies/fabric8/kubernetes-api/src/test/java/io/fabric8/kubernetes/api/ParseExamplesTest.java deleted file mode 100644 index b963c0e..0000000 --- a/dependencies/fabric8/kubernetes-api/src/test/java/io/fabric8/kubernetes/api/ParseExamplesTest.java +++ /dev/null @@ -1,128 +0,0 @@ -/** - * Copyright 2005-2014 Red Hat, Inc. - * - * Red Hat licenses this file to you under the Apache License, version - * 2.0 (the "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - * implied. See the License for the specific language governing - * permissions and limitations under the License. - */ -package io.fabric8.kubernetes.api; - -import com.fasterxml.jackson.databind.ObjectMapper; -import io.fabric8.kubernetes.api.model.*; -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.File; -import java.util.Collection; -import java.util.List; - -import static io.fabric8.kubernetes.api.KubernetesHelper.getContainerPorts; -import static io.fabric8.utils.Files.assertDirectoryExists; -import static io.fabric8.utils.Files.assertFileExists; -import static org.junit.Assert.*; - -/** - * Parses the example JSON - */ -public class ParseExamplesTest { - - private static final transient Logger LOG = LoggerFactory.getLogger(ParseExamplesTest.class); - - public static final String SYSTEM_PROPERTY_KUBE_DIR = "kube.dir"; - - @Test - public void testParsePodList() throws Exception { - KubernetesList podList = assertParseExampleFile("pod-list.json", KubernetesList.class); - List<HasMetadata> items = podList.getItems(); - assertNotEmpty("items", items); - - Pod pod = (Pod) items.get(0); - assertNotNull("pod1", pod); - assertEquals("pod1.name", "my-pod-1", KubernetesHelper.getName(pod)); - PodSpec podSpec = pod.getSpec(); - assertNotNull("pod1.podSpec", podSpec); - List<Container> containers = podSpec.getContainers(); - assertNotEmpty("pod1.podSpec.containers", containers); - Container container = containers.get(0); - assertNotNull("pod1.podSpec.container[0]", container); - assertEquals("pod1.podSpec.container[0].name", "nginx", container.getName()); - assertEquals("pod1.podSpec.container[0].image", "dockerfile/nginx", container.getImage()); - - LOG.info("pod1 container1 " + container); - - String json = KubernetesHelper.toJson(podList); - LOG.info("Got JSON: " + json); - } - - @Test - public void testParsePodListEmptyResults() throws Exception { - PodList podList = assertParseExampleFile("pod-list-empty-results.json", PodList.class); - List<Pod> items = podList.getItems(); - assertNotEmpty("items", items); - - Pod pod = items.get(0); - assertNotNull("pod1", pod); - assertEquals("127.0.0.1", pod.getStatus().getHostIP()); - } - - @Test - public void testParseService() throws Exception { - Service service = assertParseExampleFile("service.json", Service.class); - - assertEquals("Service", service.getKind()); - - Integer expectedPort = 9090; - assertEquals(expectedPort, getContainerPorts(service).iterator().next()); - - ObjectMapper mapper = KubernetesFactory.createObjectMapper(); - - //mapper.writer().writeValue(System.out, service); - } - - @Test - public void testParsePod() throws Exception { - assertParseExampleFile("pod.json", Pod.class); - } - - public static void assertNotEmpty(String name, Collection collection) { - assertNotNull(name + " is null!", collection); - assertFalse(name + " should not be empty!", collection.isEmpty()); - } - - public static <T> T assertParseExampleFile(String fileName, Class<T> clazz) throws Exception { - ObjectMapper mapper = KubernetesFactory.createObjectMapper(); - File exampleFile = new File(getKubernetesExamplesDir(), fileName); - assertFileExists(exampleFile); - T answer = mapper.reader(clazz).readValue(exampleFile); - assertNotNull("Null returned while unmarshalling " + exampleFile, answer); - LOG.info("Parsed: " + fileName + " as: " + answer); - return answer; - } - - public static File getKubernetesSourceDir() { - //String path = System.getProperty(SYSTEM_PROPERTY_KUBE_DIR, "../../../kubernetes"); - String basedir = System.getProperty("basedir", "."); - String kubeSourceDir = basedir + "/src/main/kubernetes"; - String path = System.getProperty(SYSTEM_PROPERTY_KUBE_DIR, kubeSourceDir); - File kubeDir = new File(path); - assertTrue("Kube directory " + kubeDir - + " does not exist! Please supply the correct value in the " + SYSTEM_PROPERTY_KUBE_DIR + " system property value", - kubeDir.exists()); - return kubeDir; - } - - public static File getKubernetesExamplesDir() { - File answer = new File(getKubernetesSourceDir(), "api/examples"); - assertDirectoryExists(answer); - return answer; - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/de610a67/dependencies/fabric8/kubernetes-api/src/test/java/io/fabric8/kubernetes/api/ParseServiceTest.java ---------------------------------------------------------------------- diff --git a/dependencies/fabric8/kubernetes-api/src/test/java/io/fabric8/kubernetes/api/ParseServiceTest.java b/dependencies/fabric8/kubernetes-api/src/test/java/io/fabric8/kubernetes/api/ParseServiceTest.java deleted file mode 100644 index 96b99b4..0000000 --- a/dependencies/fabric8/kubernetes-api/src/test/java/io/fabric8/kubernetes/api/ParseServiceTest.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * Copyright 2005-2014 Red Hat, Inc. - * - * Red Hat licenses this file to you under the Apache License, version - * 2.0 (the "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - * implied. See the License for the specific language governing - * permissions and limitations under the License. - */ -package io.fabric8.kubernetes.api; - -import io.fabric8.kubernetes.api.model.Service; -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.File; -import java.io.IOException; -import java.util.Set; - -import static io.fabric8.kubernetes.api.KubernetesHelper.getContainerPorts; -import static io.fabric8.kubernetes.api.KubernetesHelper.getPorts; -import static io.fabric8.utils.Files.assertFileExists; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -/** - * Parses the example JSON - */ -public class ParseServiceTest { - - private static final transient Logger LOG = LoggerFactory.getLogger(ParseServiceTest.class); - - @Test - public void testParseFabric8MQService() throws Exception { - Service service = assertParseTestFile("fmq-service.json", Service.class); - Set<Integer> ports = getPorts(service); - assertNotNull("ports", ports); - Set<Integer> containerPorts = getContainerPorts(service); - assertTrue("containerPorts " + containerPorts, containerPorts.iterator().next().intValue() > 0); - - String json = KubernetesHelper.toJson(service); - LOG.info("Got JSON: " + json); - } - - public <T> T assertParseTestFile(String relativePath, Class<T> clazz) throws IOException { - String baseDirPath = System.getProperty("basedir", "."); - File baseDir = new File(baseDirPath); - File json = new File(baseDirPath, "target/test-classes/" + relativePath); - assertFileExists(json); - - Object answer = KubernetesHelper.loadJson(json); - assertNotNull("Null returned while unmarshalling " + json, answer); - LOG.info("Parsed: " + json + " as: " + answer); - assertTrue("Result " + answer + " is not an instance of " + clazz.getName() + " but was " + (answer == null ? "null" : answer.getClass().getName()), - clazz.isInstance(answer)); - return clazz.cast(answer); - } -}
