From 9d73c44acad7db39014084e228941dfd02093939 Mon Sep 17 00:00:00 2001 From: Jeff Cantrill Date: Wed, 6 Jan 2016 12:50:15 -0500 Subject: [PATCH] [OSJC-233] Make service#targetPort return string. Remove v1beta3 --- .../internal/restclient/DefaultClient.java | 3 +- .../restclient/KubernetesAPIVersion.java | 1 + .../restclient/OpenShiftAPIVersion.java | 1 + .../internal/restclient/URLBuilder.java | 36 +- .../internal/restclient/model/Service.java | 6 +- .../restclient/model/ServicePort.java | 20 +- .../ResourcePropertiesRegistry.java | 4 +- .../openshift/restclient/ResourceKind.java | 3 - .../server/ITemplateProcessing.java | 2 +- .../openshift/restclient/model/IService.java | 7 +- .../restclient/model/IServicePort.java | 6 +- .../DefaultClientIntegrationTest.java | 2 +- .../restclient/ResourceFactoryTest.java | 3 +- .../internal/restclient/URLBuilderTest.java | 35 +- ...rverTemplateProcessingIntegrationTest.java | 6 +- .../restclient/model/PortFactory.java | 3 + .../restclient/model/ProjectTest.java | 2 +- .../restclient/model/v1/ServiceTest.java | 4 +- .../model/v1beta3/BuildConfigTest.java | 163 ------- .../restclient/model/v1beta3/BuildTest.java | 49 -- .../model/v1beta3/DeploymentConfigTest.java | 127 ----- .../model/v1beta3/ImageStreamTest.java | 57 --- .../restclient/model/v1beta3/PVCTest.java | 53 --- .../model/v1beta3/PersistentVolumeTest.java | 130 ----- .../restclient/model/v1beta3/PodTest.java | 76 --- .../model/v1beta3/ProjectRequestTest.java | 63 --- .../restclient/model/v1beta3/ProjectTest.java | 51 -- .../v1beta3/ReplicationControllerTest.java | 66 --- .../model/v1beta3/ResourceTest.java | 56 --- .../restclient/model/v1beta3/RouteTest.java | 90 ---- .../restclient/model/v1beta3/SecretTest.java | 64 --- .../model/v1beta3/ServiceAccountTest.java | 83 ---- .../restclient/model/v1beta3/ServiceTest.java | 131 ------ .../restclient/model/v1beta3/StatusTest.java | 54 --- .../model/v1beta3/TemplateTest.java | 79 ---- .../v1beta3/UnrecognizedResourceTest.java | 51 -- .../restclient/model/v1beta3/UserTest.java | 45 -- .../openshift/restclient/utils/Samples.java | 21 - .../samples/openshift3/v1beta3_build.json | 52 -- .../openshift3/v1beta3_build_config.json | 71 --- .../openshift3/v1beta3_deployment_config.json | 83 ---- .../openshift3/v1beta3_image_stream.json | 21 - .../openshift3/v1beta3_persistent_volume.json | 20 - .../samples/openshift3/v1beta3_pod.json | 108 ----- .../samples/openshift3/v1beta3_project.json | 26 - .../openshift3/v1beta3_project_request.json | 9 - .../samples/openshift3/v1beta3_pvc.json | 28 -- .../v1beta3_replication_controller.json | 83 ---- .../samples/openshift3/v1beta3_route.json | 31 -- .../openshift3/v1beta3_route_wo_tls.json | 25 - .../samples/openshift3/v1beta3_secret.json | 17 - .../samples/openshift3/v1beta3_service.json | 38 -- .../openshift3/v1beta3_service_account.json | 25 - .../samples/openshift3/v1beta3_status.json | 10 - .../samples/openshift3/v1beta3_template.json | 444 ------------------ .../openshift3/v1beta3_unrecognized.json | 40 -- .../samples/openshift3/v1beta3_user.json | 16 - 57 files changed, 57 insertions(+), 2743 deletions(-) delete mode 100644 src/test/java/com/openshift/internal/restclient/model/v1beta3/BuildConfigTest.java delete mode 100644 src/test/java/com/openshift/internal/restclient/model/v1beta3/BuildTest.java delete mode 100644 src/test/java/com/openshift/internal/restclient/model/v1beta3/DeploymentConfigTest.java delete mode 100644 src/test/java/com/openshift/internal/restclient/model/v1beta3/ImageStreamTest.java delete mode 100644 src/test/java/com/openshift/internal/restclient/model/v1beta3/PVCTest.java delete mode 100644 src/test/java/com/openshift/internal/restclient/model/v1beta3/PersistentVolumeTest.java delete mode 100644 src/test/java/com/openshift/internal/restclient/model/v1beta3/PodTest.java delete mode 100644 src/test/java/com/openshift/internal/restclient/model/v1beta3/ProjectRequestTest.java delete mode 100644 src/test/java/com/openshift/internal/restclient/model/v1beta3/ProjectTest.java delete mode 100644 src/test/java/com/openshift/internal/restclient/model/v1beta3/ReplicationControllerTest.java delete mode 100644 src/test/java/com/openshift/internal/restclient/model/v1beta3/ResourceTest.java delete mode 100644 src/test/java/com/openshift/internal/restclient/model/v1beta3/RouteTest.java delete mode 100644 src/test/java/com/openshift/internal/restclient/model/v1beta3/SecretTest.java delete mode 100644 src/test/java/com/openshift/internal/restclient/model/v1beta3/ServiceAccountTest.java delete mode 100644 src/test/java/com/openshift/internal/restclient/model/v1beta3/ServiceTest.java delete mode 100644 src/test/java/com/openshift/internal/restclient/model/v1beta3/StatusTest.java delete mode 100644 src/test/java/com/openshift/internal/restclient/model/v1beta3/TemplateTest.java delete mode 100644 src/test/java/com/openshift/internal/restclient/model/v1beta3/UnrecognizedResourceTest.java delete mode 100644 src/test/java/com/openshift/internal/restclient/model/v1beta3/UserTest.java delete mode 100644 src/test/resources/samples/openshift3/v1beta3_build.json delete mode 100644 src/test/resources/samples/openshift3/v1beta3_build_config.json delete mode 100644 src/test/resources/samples/openshift3/v1beta3_deployment_config.json delete mode 100644 src/test/resources/samples/openshift3/v1beta3_image_stream.json delete mode 100644 src/test/resources/samples/openshift3/v1beta3_persistent_volume.json delete mode 100644 src/test/resources/samples/openshift3/v1beta3_pod.json delete mode 100644 src/test/resources/samples/openshift3/v1beta3_project.json delete mode 100644 src/test/resources/samples/openshift3/v1beta3_project_request.json delete mode 100644 src/test/resources/samples/openshift3/v1beta3_pvc.json delete mode 100644 src/test/resources/samples/openshift3/v1beta3_replication_controller.json delete mode 100644 src/test/resources/samples/openshift3/v1beta3_route.json delete mode 100644 src/test/resources/samples/openshift3/v1beta3_route_wo_tls.json delete mode 100644 src/test/resources/samples/openshift3/v1beta3_secret.json delete mode 100644 src/test/resources/samples/openshift3/v1beta3_service.json delete mode 100644 src/test/resources/samples/openshift3/v1beta3_service_account.json delete mode 100644 src/test/resources/samples/openshift3/v1beta3_status.json delete mode 100644 src/test/resources/samples/openshift3/v1beta3_template.json delete mode 100644 src/test/resources/samples/openshift3/v1beta3_unrecognized.json delete mode 100644 src/test/resources/samples/openshift3/v1beta3_user.json diff --git a/src/main/java/com/openshift/internal/restclient/DefaultClient.java b/src/main/java/com/openshift/internal/restclient/DefaultClient.java index 130c3850..c187f46e 100644 --- a/src/main/java/com/openshift/internal/restclient/DefaultClient.java +++ b/src/main/java/com/openshift/internal/restclient/DefaultClient.java @@ -403,7 +403,7 @@ private Map getTypeMappings(String apiVersion){ if(typeMappings.isEmpty()){ //OpenShift endpoints final String version = StringUtils.defaultIfEmpty(apiVersion, getOpenShiftAPIVersion()); - final String osEndpoint = String.format("%s/%s", OpenShiftAPIVersion.v1beta3.toString().equals(version) ? OS_API_LEGACY_ENDPOINT : OS_API_ENDPOINT, version); + final String osEndpoint = String.format("%s/%s", OS_API_ENDPOINT, version); typeMappings.put(ResourceKind.BUILD, osEndpoint); typeMappings.put(ResourceKind.BUILD_CONFIG, osEndpoint); typeMappings.put(ResourceKind.DEPLOYMENT_CONFIG, osEndpoint); @@ -422,7 +422,6 @@ private Map getTypeMappings(String apiVersion){ typeMappings.put(ResourceKind.TEMPLATE, osEndpoint); typeMappings.put(ResourceKind.USER, osEndpoint); //not real kinds - typeMappings.put(ResourceKind.TEMPLATE_CONFIG, osEndpoint); typeMappings.put(ResourceKind.PROCESSED_TEMPLATES, osEndpoint); //Kubernetes endpoints diff --git a/src/main/java/com/openshift/internal/restclient/KubernetesAPIVersion.java b/src/main/java/com/openshift/internal/restclient/KubernetesAPIVersion.java index 02787a83..80efcb7b 100644 --- a/src/main/java/com/openshift/internal/restclient/KubernetesAPIVersion.java +++ b/src/main/java/com/openshift/internal/restclient/KubernetesAPIVersion.java @@ -15,6 +15,7 @@ * @author Jeff Cantrill */ public enum KubernetesAPIVersion implements APIModelVersion{ + @Deprecated v1beta3(2), v1(3); diff --git a/src/main/java/com/openshift/internal/restclient/OpenShiftAPIVersion.java b/src/main/java/com/openshift/internal/restclient/OpenShiftAPIVersion.java index 6a567bac..7285d3e5 100644 --- a/src/main/java/com/openshift/internal/restclient/OpenShiftAPIVersion.java +++ b/src/main/java/com/openshift/internal/restclient/OpenShiftAPIVersion.java @@ -15,6 +15,7 @@ * @author Jeff Cantrill */ public enum OpenShiftAPIVersion implements APIModelVersion{ + @Deprecated v1beta3(2), v1(3); diff --git a/src/main/java/com/openshift/internal/restclient/URLBuilder.java b/src/main/java/com/openshift/internal/restclient/URLBuilder.java index 25a52cb5..a9444e02 100644 --- a/src/main/java/com/openshift/internal/restclient/URLBuilder.java +++ b/src/main/java/com/openshift/internal/restclient/URLBuilder.java @@ -69,7 +69,6 @@ public class URLBuilder { kindMap.put(ResourceKind.SECRET, "secrets"); kindMap.put(ResourceKind.SERVICE_ACCOUNT, "serviceaccounts"); - kindMap.put(ResourceKind.TEMPLATE_CONFIG, "templateconfig");//mechanism for processing templates pre v1beta3 kindMap.put(ResourceKind.PROCESSED_TEMPLATES, "processedtemplates");//mechanism for processing templates } @@ -81,7 +80,6 @@ public class URLBuilder { private String namespace; private String subResource; - private boolean watch; URLBuilder(URL baseUrl, Map typeMappings, IResource resource) { this(baseUrl, typeMappings); @@ -95,11 +93,7 @@ public class URLBuilder { URLBuilder namespace(String namespace){ if(StringUtils.isBlank(namespace)) return this; - if(typeMappingIsForV1Beta1()) { - addParmeter("namespace", namespace); - }else { - this.namespace = namespace; - } + this.namespace = namespace; return this; } @@ -145,11 +139,7 @@ URL build() { if (kind == null) throw new RuntimeException( "Unable to build a URL because the ResourceKind is unknown"); - if(typeMappingIsForV1Beta1()) { - buildWithNamespaceAsQueryParam(url); - }else { - buildWithNamespaceInPath(url); - } + buildWithNamespaceInPath(url); try { if(LOG.isDebugEnabled()) { @@ -161,12 +151,6 @@ URL build() { } } - - private boolean typeMappingIsForV1Beta1() { - String mapping = typeMappings.get(kind); - return mapping.contains("v1beta1"); - } - private void buildWithNamespaceInPath(StringBuilder url) { url.append("/") .append(typeMappings.get(kind)); @@ -184,22 +168,6 @@ private void buildWithNamespaceInPath(StringBuilder url) { url = appendParameters(url); } - private URL buildWithNamespaceAsQueryParam(StringBuilder url) { - url.append("/") - .append(typeMappings.get(kind)).append("/") - .append(kindMap.get(kind)); - if (name != null) { - url.append("/").append(name); - } - url = appendParameters(url); - try { - LOG.debug(String.format("Built url: %s", url.toString())); - return new URL(url.toString()); - } catch (MalformedURLException e) { - throw new RuntimeException(e); - } - } - private StringBuilder appendParameters(StringBuilder url) { if (!params.isEmpty()) { url.append(IHttpClient.QUESTION_MARK); diff --git a/src/main/java/com/openshift/internal/restclient/model/Service.java b/src/main/java/com/openshift/internal/restclient/model/Service.java index 44ed34d3..1afb6918 100644 --- a/src/main/java/com/openshift/internal/restclient/model/Service.java +++ b/src/main/java/com/openshift/internal/restclient/model/Service.java @@ -72,7 +72,7 @@ public List getPorts() { private List getPorts(boolean modifiable) { List ports = new ArrayList<>(); - if(get(SERVICE_PORT).getType() == ModelType.UNDEFINED) return ports; + if(!get(SERVICE_PORT).isDefined()) return ports; for (ModelNode node : get(SERVICE_PORT).asList()) { ports.add(new ServicePort(node)); } @@ -125,9 +125,9 @@ public void setTargetPort(int port) { } @Override - public int getTargetPort() { + public String getTargetPort() { IServicePort port = getLowestPort(); - return port != null ? port.getTargetPort() : 0; + return port != null ? port.getTargetPort() : "0"; } @Override diff --git a/src/main/java/com/openshift/internal/restclient/model/ServicePort.java b/src/main/java/com/openshift/internal/restclient/model/ServicePort.java index e97ab4fb..66717cb8 100644 --- a/src/main/java/com/openshift/internal/restclient/model/ServicePort.java +++ b/src/main/java/com/openshift/internal/restclient/model/ServicePort.java @@ -17,6 +17,7 @@ import java.util.HashMap; import java.util.Map; +import org.apache.commons.lang.StringUtils; import org.jboss.dmr.ModelNode; import com.openshift.restclient.model.IServicePort; @@ -66,8 +67,8 @@ public void setName(String name) { } @Override - public int getTargetPort() { - return asInt(getNode(), KEY_MAP, PROPERTY_TARGET_PORT); + public String getTargetPort() { + return asString(getNode(), KEY_MAP, PROPERTY_TARGET_PORT); } @Override @@ -75,6 +76,14 @@ public void setTargetPort(int port) { set(getNode(), KEY_MAP, PROPERTY_TARGET_PORT, port); } + @Override + public void setTargetPort(String name) { + if(StringUtils.isNumeric(name)) { + setTargetPort((Integer.parseInt(name))); + return; + } + set(getNode(), KEY_MAP, PROPERTY_TARGET_PORT, name); + } @Override public void setPort(int port) { @@ -101,7 +110,7 @@ public int hashCode() { final int prime = 31; int result = 1; result = prime * result + getPort(); - result = prime * result + getTargetPort(); + result = prime * result + getTargetPort().hashCode(); result = prime * result + ((getName() == null) ? 0 : getName().hashCode()); result = prime * result + ((getProtocol() == null) ? 0 : getProtocol().hashCode()); return result; @@ -118,7 +127,10 @@ public boolean equals(Object obj) { ServicePort other = (ServicePort) obj; if (getPort() != other.getPort()) return false; - if (getTargetPort() != other.getTargetPort()) + if (getTargetPort() == null) { + if (other.getTargetPort() != null) + return false; + } else if (!getTargetPort().equals(other.getTargetPort())) return false; if (getName() == null) { if (other.getName() != null) diff --git a/src/main/java/com/openshift/internal/restclient/model/properties/ResourcePropertiesRegistry.java b/src/main/java/com/openshift/internal/restclient/model/properties/ResourcePropertiesRegistry.java index ed242131..735a558a 100644 --- a/src/main/java/com/openshift/internal/restclient/model/properties/ResourcePropertiesRegistry.java +++ b/src/main/java/com/openshift/internal/restclient/model/properties/ResourcePropertiesRegistry.java @@ -56,11 +56,11 @@ public static final ResourcePropertiesRegistry getInstance(){ } public KubernetesAPIVersion [] getSupportedKubernetesVersions(){ - return KubernetesAPIVersion.values(); + return new KubernetesAPIVersion[] {KubernetesAPIVersion.v1}; } public OpenShiftAPIVersion[] getSupportedOpenShiftVersions(){ - return OpenShiftAPIVersion.values(); + return new OpenShiftAPIVersion[] {OpenShiftAPIVersion.v1}; } /** diff --git a/src/main/java/com/openshift/restclient/ResourceKind.java b/src/main/java/com/openshift/restclient/ResourceKind.java index 3b1c70a6..dff6407c 100644 --- a/src/main/java/com/openshift/restclient/ResourceKind.java +++ b/src/main/java/com/openshift/restclient/ResourceKind.java @@ -59,8 +59,6 @@ public final class ResourceKind { public static final String CONFIG = "Config";//not rest resource; public static final String LIST = "List"; public static final String STATUS = "Status";//not rest resource - @Deprecated - public static final String TEMPLATE_CONFIG = "TemplateConfig";//mechanism for processing templates pre v1beta3 public static final String PROCESSED_TEMPLATES = "ProcessedTemplates";//mechanism for processing templates /** @@ -114,7 +112,6 @@ public static Collection values() { set.add(CONFIG); set.add(LIST); set.add(STATUS); - set.add(TEMPLATE_CONFIG ); set.add("ProcessedTemplates"); values = Collections.unmodifiableCollection(set); } diff --git a/src/main/java/com/openshift/restclient/capability/server/ITemplateProcessing.java b/src/main/java/com/openshift/restclient/capability/server/ITemplateProcessing.java index 851c41f6..13c461dd 100644 --- a/src/main/java/com/openshift/restclient/capability/server/ITemplateProcessing.java +++ b/src/main/java/com/openshift/restclient/capability/server/ITemplateProcessing.java @@ -25,7 +25,7 @@ public interface ITemplateProcessing extends ICapability { * * @param template The template to process * @param namespace The namespace to use when processing the template - * @return IConfig pre v1beta3; ITemplate otherwise + * @return ITemplate */ T process(ITemplate template, String namespace); } diff --git a/src/main/java/com/openshift/restclient/model/IService.java b/src/main/java/com/openshift/restclient/model/IService.java index 0a313831..fc939996 100644 --- a/src/main/java/com/openshift/restclient/model/IService.java +++ b/src/main/java/com/openshift/restclient/model/IService.java @@ -62,7 +62,12 @@ public interface IService extends IResource{ */ Map getSelector(); - int getTargetPort(); + /** + * The port this service targets on the + * pod + * @return + */ + String getTargetPort(); /** * Returns the IP of the service. diff --git a/src/main/java/com/openshift/restclient/model/IServicePort.java b/src/main/java/com/openshift/restclient/model/IServicePort.java index 44acfc82..e87a6cef 100644 --- a/src/main/java/com/openshift/restclient/model/IServicePort.java +++ b/src/main/java/com/openshift/restclient/model/IServicePort.java @@ -28,11 +28,13 @@ public interface IServicePort { void setPort(int port); /** - * The target port on the pod it services + * The target port on the pod it services. An integer + * or named port on the pod spec * @return */ - int getTargetPort(); + String getTargetPort(); void setTargetPort(int port); + void setTargetPort(String name); /** * IP protocol (TCP, UDP) diff --git a/src/test/java/com/openshift/internal/restclient/DefaultClientIntegrationTest.java b/src/test/java/com/openshift/internal/restclient/DefaultClientIntegrationTest.java index 07d32dd0..6074e1ae 100644 --- a/src/test/java/com/openshift/internal/restclient/DefaultClientIntegrationTest.java +++ b/src/test/java/com/openshift/internal/restclient/DefaultClientIntegrationTest.java @@ -57,7 +57,7 @@ public void testListTemplates(){ try { project = factory.create(VERSION, ResourceKind.PROJECT); project.setName(helper.generateNamespace()); - template = factory.create(Samples.V1BETA3_TEMPLATE.getContentAsString()); + template = factory.create(Samples.V1_TEMPLATE.getContentAsString()); template.setNamespace(project.getName()); project = client.create(project); diff --git a/src/test/java/com/openshift/internal/restclient/ResourceFactoryTest.java b/src/test/java/com/openshift/internal/restclient/ResourceFactoryTest.java index 10890bff..58efe802 100644 --- a/src/test/java/com/openshift/internal/restclient/ResourceFactoryTest.java +++ b/src/test/java/com/openshift/internal/restclient/ResourceFactoryTest.java @@ -33,8 +33,7 @@ public class ResourceFactoryTest { public void testV1Beta3Implementations() { List v1beta3Exlusions = Arrays.asList(new String [] { ResourceKind.CONFIG, - ResourceKind.PROCESSED_TEMPLATES, - ResourceKind.TEMPLATE_CONFIG + ResourceKind.PROCESSED_TEMPLATES }); ResourceFactory factory = new ResourceFactory(mock(IClient.class)); final String version = OpenShiftAPIVersion.v1beta3.toString(); diff --git a/src/test/java/com/openshift/internal/restclient/URLBuilderTest.java b/src/test/java/com/openshift/internal/restclient/URLBuilderTest.java index b28b390b..68ef0731 100644 --- a/src/test/java/com/openshift/internal/restclient/URLBuilderTest.java +++ b/src/test/java/com/openshift/internal/restclient/URLBuilderTest.java @@ -37,68 +37,53 @@ public class URLBuilderTest { @Before public void setup() throws MalformedURLException { - mappings.put(ResourceKind.SERVICE, "api/v1beta3"); - mappings.put(ResourceKind.PROJECT, "osapi/v1beta3"); + mappings.put(ResourceKind.SERVICE, "api/v1"); + mappings.put(ResourceKind.PROJECT, "oapi/v1"); builder = new URLBuilder(new URL(BASE_URL), mappings); } @Test public void testBuildingURLForAWatchService() throws Exception { - IResource resource = givenAResource(ResourceKind.SERVICE, KubernetesAPIVersion.v1beta3,"foo"); + IResource resource = givenAResource(ResourceKind.SERVICE, KubernetesAPIVersion.v1,"foo"); String url = builder. resource(resource) .watch() .addParmeter("resourceVersion", "123") .build().toString(); - assertEquals(String.format("%s/api/v1beta3/namespaces/foo/services?watch=true&resourceVersion=123", BASE_URL),url.toString()); + assertEquals(String.format("%s/api/v1/namespaces/foo/services?watch=true&resourceVersion=123", BASE_URL),url.toString()); } @Test public void testBuildingURLForAProjectUsingResource() throws Exception { - IResource resource = givenAResource(ResourceKind.PROJECT, KubernetesAPIVersion.v1beta3,"foo"); + IResource resource = givenAResource(ResourceKind.PROJECT, KubernetesAPIVersion.v1,"foo"); String url = builder. resource(resource) .name("foo") .build().toString(); - assertEquals(String.format("%s/osapi/v1beta3/projects/foo", BASE_URL),url.toString()); + assertEquals(String.format("%s/oapi/v1/projects/foo", BASE_URL),url.toString()); } @Test public void testBaseURLWithTrailingSlash() throws Exception { builder = new URLBuilder(new URL(BASE_URL + "///"), mappings); - IResource resource = givenAResource(ResourceKind.SERVICE, KubernetesAPIVersion.v1beta3,"foo"); + IResource resource = givenAResource(ResourceKind.SERVICE, KubernetesAPIVersion.v1,"foo"); String url = whenBuildingTheURLFor(resource, "foo"); - assertEquals(String.format("%s/api/v1beta3/namespaces/foo/services/bar", BASE_URL),url.toString()); + assertEquals(String.format("%s/api/v1/namespaces/foo/services/bar", BASE_URL),url.toString()); } - @Test - public void testV1Beta3() { - IResource resource = givenAResource(ResourceKind.SERVICE, KubernetesAPIVersion.v1beta3,"foo"); - String url = whenBuildingTheURLFor(resource, "foo"); - - assertEquals(String.format("%s/api/v1beta3/namespaces/foo/services/bar", BASE_URL),url.toString()); - } - - @Test - public void testV1Beta3WithoutANamespace() { - IResource resource = givenAResource(ResourceKind.SERVICE, KubernetesAPIVersion.v1beta3,null); - String url = whenBuildingTheURLFor(resource, ""); - - assertEquals(String.format("%s/api/v1beta3/services/bar", BASE_URL),url.toString()); - } @Test public void testAddingASubResource() { - IResource resource = givenAResource(ResourceKind.SERVICE, KubernetesAPIVersion.v1beta3, "foo"); + IResource resource = givenAResource(ResourceKind.SERVICE, KubernetesAPIVersion.v1, "foo"); String url = builder. resource(resource) .name("bar") .subresource("aSubResource") .build().toString(); - assertEquals(String.format("%s/api/v1beta3/namespaces/foo/services/bar/aSubResource", BASE_URL),url.toString()); + assertEquals(String.format("%s/api/v1/namespaces/foo/services/bar/aSubResource", BASE_URL),url.toString()); } private String whenBuildingTheURLFor(IResource resource, String namespace) { diff --git a/src/test/java/com/openshift/internal/restclient/capability/server/ServerTemplateProcessingIntegrationTest.java b/src/test/java/com/openshift/internal/restclient/capability/server/ServerTemplateProcessingIntegrationTest.java index 5dbfe1eb..9f4daabb 100644 --- a/src/test/java/com/openshift/internal/restclient/capability/server/ServerTemplateProcessingIntegrationTest.java +++ b/src/test/java/com/openshift/internal/restclient/capability/server/ServerTemplateProcessingIntegrationTest.java @@ -19,10 +19,8 @@ import org.slf4j.LoggerFactory; import com.openshift.internal.restclient.IntegrationTestHelper; -import com.openshift.internal.restclient.model.properties.ResourcePropertiesRegistry; import com.openshift.internal.restclient.model.template.Template; import com.openshift.restclient.IClient; -import com.openshift.restclient.ResourceKind; import com.openshift.restclient.capability.CapabilityVisitor; import com.openshift.restclient.capability.server.ITemplateProcessing; import com.openshift.restclient.model.IResource; @@ -33,7 +31,7 @@ * @author Jeff Cantrill */ public class ServerTemplateProcessingIntegrationTest { - private static final String VERSION = "v1beta3"; + private static final String VERSION = "v1"; private static final String COMMON = "openshift"; @@ -50,7 +48,7 @@ public void setup () throws MalformedURLException{ @Test public void testProcessAndApplyTemplate() throws Exception{ final Collection results = new ArrayList(); - ModelNode node = ModelNode.fromJSONString(Samples.V1BETA3_TEMPLATE.getContentAsString()); + ModelNode node = ModelNode.fromJSONString(Samples.V1_TEMPLATE.getContentAsString()); final Template template = new Template(node, client, null); template.setNamespace(COMMON); try { diff --git a/src/test/java/com/openshift/internal/restclient/model/PortFactory.java b/src/test/java/com/openshift/internal/restclient/model/PortFactory.java index 11a46d7a..c15b6ded 100644 --- a/src/test/java/com/openshift/internal/restclient/model/PortFactory.java +++ b/src/test/java/com/openshift/internal/restclient/model/PortFactory.java @@ -20,6 +20,9 @@ public class PortFactory { public static ServicePort createServicePort(String name, String proto, int port, int targetPort) { + return createServicePort(name, proto, port, String.valueOf(targetPort)); + } + public static ServicePort createServicePort(String name, String proto, int port, String targetPort) { ModelNode node = new ModelNode(); node.get("name").set(name); node.get("protocol").set(proto); diff --git a/src/test/java/com/openshift/internal/restclient/model/ProjectTest.java b/src/test/java/com/openshift/internal/restclient/model/ProjectTest.java index 70809a25..68b0fcff 100644 --- a/src/test/java/com/openshift/internal/restclient/model/ProjectTest.java +++ b/src/test/java/com/openshift/internal/restclient/model/ProjectTest.java @@ -38,7 +38,7 @@ public class ProjectTest { @Before public void setup(){ - project = new ResourceFactory(client){}.create(OpenShiftAPIVersion.v1beta3.toString(), ResourceKind.PROJECT); + project = new ResourceFactory(client){}.create(OpenShiftAPIVersion.v1.toString(), ResourceKind.PROJECT); project.setName("aprojectname"); } diff --git a/src/test/java/com/openshift/internal/restclient/model/v1/ServiceTest.java b/src/test/java/com/openshift/internal/restclient/model/v1/ServiceTest.java index e75ee450..70fd55fe 100644 --- a/src/test/java/com/openshift/internal/restclient/model/v1/ServiceTest.java +++ b/src/test/java/com/openshift/internal/restclient/model/v1/ServiceTest.java @@ -51,13 +51,13 @@ public void testGetPortalIP() { @Test public void testGetTargetPort() { - assertEquals(3306, service.getTargetPort()); + assertEquals("3306", service.getTargetPort()); } @Test public void testSetTargetPort() { service.setTargetPort(5030); - assertEquals(5030, service.getTargetPort()); + assertEquals("5030", service.getTargetPort()); } @Test diff --git a/src/test/java/com/openshift/internal/restclient/model/v1beta3/BuildConfigTest.java b/src/test/java/com/openshift/internal/restclient/model/v1beta3/BuildConfigTest.java deleted file mode 100644 index e7c5d78d..00000000 --- a/src/test/java/com/openshift/internal/restclient/model/v1beta3/BuildConfigTest.java +++ /dev/null @@ -1,163 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 Red Hat, Inc. Distributed under license by Red Hat, Inc. - * All rights reserved. This program is made available under the terms of the - * Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: Red Hat, Inc. - ******************************************************************************/ -package com.openshift.internal.restclient.model.v1beta3; - -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import java.net.URL; -import java.util.HashMap; -import java.util.Map; - -import org.jboss.dmr.ModelNode; -import org.junit.BeforeClass; -import org.junit.Test; - -import com.openshift.internal.restclient.OpenShiftAPIVersion; -import com.openshift.internal.restclient.ResourceFactory; -import com.openshift.internal.restclient.model.BuildConfig; -import com.openshift.internal.restclient.model.build.GitBuildSource; -import com.openshift.internal.restclient.model.build.ImageChangeTrigger; -import com.openshift.internal.restclient.model.build.STIBuildStrategy; -import com.openshift.internal.restclient.model.build.WebhookTrigger; -import com.openshift.internal.restclient.model.properties.ResourcePropertiesRegistry; -import com.openshift.restclient.IClient; -import com.openshift.restclient.ResourceKind; -import com.openshift.restclient.images.DockerImageURI; -import com.openshift.restclient.model.IBuildConfig; -import com.openshift.restclient.model.build.BuildSourceType; -import com.openshift.restclient.model.build.BuildStrategyType; -import com.openshift.restclient.model.build.BuildTriggerType; -import com.openshift.restclient.model.build.IBuildSource; -import com.openshift.restclient.model.build.IBuildStrategy; -import com.openshift.restclient.model.build.IBuildTrigger; -import com.openshift.restclient.model.build.IGitBuildSource; -import com.openshift.restclient.model.build.ISTIBuildStrategy; -import com.openshift.restclient.utils.Samples; - -/** - * @author Jeff Cantrill - */ -public class BuildConfigTest { - - private static IBuildConfig config; - private static IClient client; - - @BeforeClass - public static void setup() throws Exception{ - client = mock(IClient.class); - when(client.getBaseURL()).thenReturn(new URL("https://localhost:8443")); - when(client.getOpenShiftAPIVersion()).thenReturn("v1beta3"); - ModelNode node = ModelNode.fromJSONString(Samples.V1BETA3_BUILD_CONFIG.getContentAsString()); - config = new BuildConfig(node, client, null); - } - - private static Map getPropertyKeys() { - return ResourcePropertiesRegistry.getInstance().get("v1beta3", ResourceKind.BUILD_CONFIG); - } - - @Test - public void getBuildTriggers(){ - assertBuildTriggers(config.getBuildTriggers().toArray(new IBuildTrigger[]{})); - } - - @Test - public void addBuildTriggers() { - BuildConfig writeConfig = new ResourceFactory(client){}.create(OpenShiftAPIVersion.v1beta3.name(), ResourceKind.BUILD_CONFIG); - - writeConfig.addBuildTrigger(new WebhookTrigger(BuildTriggerType.GITHUB, "secret101", null)); - writeConfig.addBuildTrigger(new WebhookTrigger(BuildTriggerType.GENERIC, "secret101", null)); - writeConfig.addBuildTrigger(new ImageChangeTrigger("", "", "")); - - assertBuildTriggers(reCreateBuildConfig(writeConfig).getBuildTriggers().toArray(new IBuildTrigger[]{})); - } - - @Test - public void getOutputRespositoryName(){ - assertEquals("origin-ruby-sample:latest", config.getOutputRepositoryName()); - } - - @Test - public void getSourceURI(){ - assertEquals("git://github.com/openshift/ruby-hello-world.git", config.getSourceURI()); - } - - @Test - public void getGitBuildSource(){ - IBuildSource source = config.getBuildSource(); - assertGitBuildSource(source); - } - - @Test - public void setGitBuildSource() { - BuildConfig writeConfig = new ResourceFactory(client){}.create(OpenShiftAPIVersion.v1beta3.name(), ResourceKind.BUILD_CONFIG); - - Map env = new HashMap(); - env.put("foo", "bar"); - writeConfig.setBuildSource(new GitBuildSource("git://github.com/openshift/ruby-hello-world.git", "", "foobar")); - - assertGitBuildSource(reCreateBuildConfig(writeConfig).getBuildSource()); - } - - @Test - public void getSTIBuildStrategy() { - IBuildStrategy strategy = config.getBuildStrategy(); - assertSourceBuildStrategy(strategy); - } - - @Test - public void setSTIBuildStrategy() { - BuildConfig writeConfig = new ResourceFactory(client){}.create(OpenShiftAPIVersion.v1beta3.name(), ResourceKind.BUILD_CONFIG); - - Map env = new HashMap(); - env.put("foo", "bar"); - writeConfig.setBuildStrategy(new STIBuildStrategy("ruby-20-centos7:latest", "alocation", true, env)); - - assertSourceBuildStrategy(reCreateBuildConfig(writeConfig).getBuildStrategy()); - } - - private void assertBuildTriggers(IBuildTrigger[] triggers) { - IBuildTrigger [] exp = new IBuildTrigger[]{ - new WebhookTrigger(BuildTriggerType.GITHUB, "secret101","https://localhost:8443"), - new WebhookTrigger(BuildTriggerType.GENERIC, "secret101","https://localhost:8443"), - new ImageChangeTrigger("", "", "") - }; - assertArrayEquals(exp, triggers); - } - - private void assertGitBuildSource(IBuildSource source) { - assertEquals(BuildSourceType.GIT, source.getType()); - assertEquals("git://github.com/openshift/ruby-hello-world.git", source.getURI()); - assertEquals("foobar", source.getContextDir()); - assertTrue(source instanceof IGitBuildSource); - - IGitBuildSource git = (IGitBuildSource)source; - assertEquals("Exp. to get the source ref","", git.getRef()); - } - - private void assertSourceBuildStrategy(IBuildStrategy strategy) { - assertEquals(BuildStrategyType.SOURCE, strategy.getType()); - assertTrue(strategy instanceof ISTIBuildStrategy); - - ISTIBuildStrategy sti = (ISTIBuildStrategy)strategy; - assertEquals(new DockerImageURI("ruby-20-centos7:latest"), sti.getImage()); - assertEquals("alocation", sti.getScriptsLocation()); - assertEquals(true, sti.incremental()); - assertEquals(1, sti.getEnvironmentVariables().size()); - assertTrue("Exp. to find the environment variable",sti.getEnvironmentVariables().containsKey("foo")); - assertEquals("bar",sti.getEnvironmentVariables().get("foo")); - } - - private BuildConfig reCreateBuildConfig(BuildConfig config) { - return new BuildConfig(config.getNode(), client, null); - } -} diff --git a/src/test/java/com/openshift/internal/restclient/model/v1beta3/BuildTest.java b/src/test/java/com/openshift/internal/restclient/model/v1beta3/BuildTest.java deleted file mode 100644 index f3b03e72..00000000 --- a/src/test/java/com/openshift/internal/restclient/model/v1beta3/BuildTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 Red Hat, Inc. Distributed under license by Red Hat, Inc. - * All rights reserved. This program is made available under the terms of the - * Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: Red Hat, Inc. - ******************************************************************************/ -package com.openshift.internal.restclient.model.v1beta3; - -import static org.junit.Assert.*; -import static org.mockito.Mockito.mock; - -import org.jboss.dmr.ModelNode; -import org.junit.BeforeClass; -import org.junit.Test; - -import com.openshift.internal.restclient.model.Build; -import com.openshift.internal.restclient.model.properties.ResourcePropertiesRegistry; -import com.openshift.restclient.IClient; -import com.openshift.restclient.ResourceKind; -import com.openshift.restclient.model.IBuild; -import com.openshift.restclient.utils.Samples; - -/** - * @author Jeff Cantrill - */ -public class BuildTest { - - private static IBuild build; - - @BeforeClass - public static void setup(){ - IClient client = mock(IClient.class); - ModelNode node = ModelNode.fromJSONString(Samples.V1BETA3_BUILD.getContentAsString()); - build = new Build(node, client, ResourcePropertiesRegistry.getInstance().get("v1beta3", ResourceKind.BUILD)); - } - - @Test - public void getStatus(){ - assertEquals("Pending", build.getStatus()); - } - - @Test - public void getMessage(){ - assertEquals("Some status message", build.getMessage()); - } - -} diff --git a/src/test/java/com/openshift/internal/restclient/model/v1beta3/DeploymentConfigTest.java b/src/test/java/com/openshift/internal/restclient/model/v1beta3/DeploymentConfigTest.java deleted file mode 100644 index a32ecdf2..00000000 --- a/src/test/java/com/openshift/internal/restclient/model/v1beta3/DeploymentConfigTest.java +++ /dev/null @@ -1,127 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 Red Hat, Inc. Distributed under license by Red Hat, Inc. - * All rights reserved. This program is made available under the terms of the - * Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: Red Hat, Inc. - ******************************************************************************/ -package com.openshift.internal.restclient.model.v1beta3; - -import static org.junit.Assert.*; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; -import static com.openshift.internal.util.JBossDmrExtentions.*; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.jboss.dmr.ModelNode; -import org.junit.Before; -import org.junit.Test; - -import com.openshift.internal.restclient.model.DeploymentConfig; -import com.openshift.internal.restclient.model.properties.ResourcePropertiesRegistry; -import com.openshift.restclient.IClient; -import com.openshift.restclient.ResourceKind; -import com.openshift.restclient.images.DockerImageURI; -import com.openshift.restclient.model.IDeploymentConfig; -import com.openshift.restclient.model.IPort; -import com.openshift.restclient.utils.Samples; - -/** - * @author Jeff Cantrill - */ -public class DeploymentConfigTest { - - private static final String VERSION = "v1beta3"; - private IDeploymentConfig config; - private IClient client; - private ModelNode node; - private Map propertyKeys; - - @Before - public void setup(){ - client = mock(IClient.class); - node = ModelNode.fromJSONString(Samples.V1BETA3_DEPLOYMENT_CONIFIG.getContentAsString()); - propertyKeys = ResourcePropertiesRegistry.getInstance().get(VERSION, ResourceKind.DEPLOYMENT_CONFIG); - config = new DeploymentConfig(node, client, propertyKeys); - } - - @Test - public void getLabels() { - assertArrayEquals(new String[] {"template"},config.getLabels().keySet().toArray(new String[] {})); - } - @Test - public void getReplicas(){ - assertEquals(1, config.getReplicas()); - } - - @Test - public void setReplicas(){ - config.setReplicas(3); - assertEquals(3, config.getReplicas()); - } - - @Test - public void setReplicaSelector() { - Map exp = new HashMap(); - exp.put("foo", "bar"); - node = ModelNode.fromJSONString(Samples.V1_DEPLOYMENT_CONIFIG.getContentAsString()); - DeploymentConfig config = new DeploymentConfig(node, client, ResourcePropertiesRegistry.getInstance().get(VERSION, ResourceKind.DEPLOYMENT_CONFIG)); - config.setReplicaSelector(exp); - assertEquals(exp, config.getReplicaSelector()); - } - - @Test - public void getReplicaSelector() { - Map exp = new HashMap(); - exp.put("name", "database"); - assertEquals(exp, config.getReplicaSelector()); - } - - @Test - public void getTriggerTypes() { - assertArrayEquals(new String[] {"ConfigChange"}, config.getTriggerTypes().toArray(new String[] {})); - } - - @Test - public void testGetDeploymentStrategyTypes() { - assertEquals("Recreate", config.getDeploymentStrategyType()); - } - - @Test - public void testAddContainer() { - //remove containers hack - String[] path = getPath(DeploymentConfig.DEPLOYMENTCONFIG_CONTAINERS); - node.get(path).clear(); - - //setup - DockerImageURI uri = new DockerImageURI("aproject/an_image_name"); - IPort port = mock(IPort.class); - when(port.getProtocol()).thenReturn("TCP"); - when(port.getContainerPort()).thenReturn(8080); - Set ports = new HashSet<>(); - ports.add(port); - - config.addContainer(uri, ports, new HashMap()); - - List containers = node.get(path).asList(); - assertEquals(1, containers.size()); - - //expectations - ModelNode portNode = new ModelNode(); - portNode.get("protocol").set(port.getProtocol()); - portNode.get("containerPort").set(port.getContainerPort()); - - ModelNode exp = new ModelNode(); - exp.get("name").set(uri.getName()); - exp.get("image").set(uri.getUriWithoutHost()); - exp.get("ports").add(portNode); - - assertEquals(exp.toJSONString(false) , containers.get(0).toJSONString(false)); - } -} diff --git a/src/test/java/com/openshift/internal/restclient/model/v1beta3/ImageStreamTest.java b/src/test/java/com/openshift/internal/restclient/model/v1beta3/ImageStreamTest.java deleted file mode 100644 index 8bfdfa13..00000000 --- a/src/test/java/com/openshift/internal/restclient/model/v1beta3/ImageStreamTest.java +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 Red Hat, Inc. Distributed under license by Red Hat, Inc. - * All rights reserved. This program is made available under the terms of the - * Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: Red Hat, Inc. - ******************************************************************************/ -package com.openshift.internal.restclient.model.v1beta3; - -import static org.junit.Assert.*; -import static org.mockito.Mockito.mock; - -import org.jboss.dmr.ModelNode; -import org.junit.BeforeClass; -import org.junit.Test; - -import com.openshift.internal.restclient.model.ImageStream; -import com.openshift.internal.restclient.model.properties.ResourcePropertiesRegistry; -import com.openshift.restclient.IClient; -import com.openshift.restclient.ResourceKind; -import com.openshift.restclient.images.DockerImageURI; -import com.openshift.restclient.model.IImageStream; -import com.openshift.restclient.utils.Samples; - -/** - * @author Jeff Cantrill - */ -public class ImageStreamTest { - private static final String VERSION = "v1beta3"; - private static IClient client; - - @BeforeClass - public static void setup(){ - client = mock(IClient.class); - } - - @Test - public void getDockerImageRepository() { - IImageStream repo = getImageStream(); - assertEquals(new DockerImageURI("172.30.159.174:5000/test/origin-ruby-sample"), repo.getDockerImageRepository()); - } - - @Test - public void setDockerImageRepository() { - DockerImageURI newUri = new DockerImageURI("172.30.244.213:5000/tests/origin-ruby-sample"); - IImageStream repo = getImageStream(); - repo.setDockerImageRepository(newUri); - assertEquals(newUri, repo.getDockerImageRepository()); - } - - private IImageStream getImageStream() { - ModelNode node = ModelNode.fromJSONString(Samples.V1BETA3_IMAGE_STREAM.getContentAsString()); - IImageStream repo = new ImageStream(node, client, ResourcePropertiesRegistry.getInstance().get(VERSION, ResourceKind.IMAGE_STREAM)); - return repo; - } -} diff --git a/src/test/java/com/openshift/internal/restclient/model/v1beta3/PVCTest.java b/src/test/java/com/openshift/internal/restclient/model/v1beta3/PVCTest.java deleted file mode 100644 index bf522feb..00000000 --- a/src/test/java/com/openshift/internal/restclient/model/v1beta3/PVCTest.java +++ /dev/null @@ -1,53 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 Red Hat, Inc. Distributed under license by Red Hat, Inc. - * All rights reserved. This program is made available under the terms of the - * Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: Red Hat, Inc. - ******************************************************************************/ -package com.openshift.internal.restclient.model.v1beta3; - -import static org.junit.Assert.*; -import static org.mockito.Mockito.mock; - -import org.junit.Before; -import org.junit.Test; - -import com.openshift.internal.restclient.ResourceFactory; -import com.openshift.restclient.IClient; -import com.openshift.restclient.model.volume.IPersistentVolumeClaim; -import com.openshift.restclient.model.volume.PVCAccessModes; -import com.openshift.restclient.utils.Samples; - -/** - * @author Jeff Cantrill - */ -public class PVCTest { - - private static final String VERSION = "v1beta3"; - private IPersistentVolumeClaim claim; - - @Before - public void setup(){ - IClient client = mock(IClient.class); - claim = new ResourceFactory(client).create(Samples.V1BETA3_PVC.getContentAsString()); - assertEquals(VERSION, claim.getApiVersion()); - } - - @Test - public void testGetAccessModes(){ - assertArrayEquals(new String[] {PVCAccessModes.READ_WRITE_ONCE}, claim.getAccessModes().toArray()); - } - - @Test - public void testGetStatus(){ - assertEquals("Pending", claim.getStatus()); - } - - @Test - public void testGetRequestedStorage(){ - assertEquals("15m", claim.getRequestedStorage()); - } - -} diff --git a/src/test/java/com/openshift/internal/restclient/model/v1beta3/PersistentVolumeTest.java b/src/test/java/com/openshift/internal/restclient/model/v1beta3/PersistentVolumeTest.java deleted file mode 100644 index 07b05582..00000000 --- a/src/test/java/com/openshift/internal/restclient/model/v1beta3/PersistentVolumeTest.java +++ /dev/null @@ -1,130 +0,0 @@ -package com.openshift.internal.restclient.model.v1beta3; - -import java.util.Arrays; -import java.util.HashSet; -import java.util.Set; - -import org.jboss.dmr.ModelNode; -import org.junit.Before; -import org.junit.Test; - -import com.openshift.internal.restclient.model.volume.property.HostPathVolumeProperties; -import com.openshift.internal.restclient.model.volume.property.NfsVolumeProperties; -import com.openshift.internal.restclient.model.volume.PersistentVolume; -import com.openshift.internal.restclient.model.properties.ResourcePropertiesRegistry; -import com.openshift.restclient.IClient; -import com.openshift.restclient.ResourceKind; -import com.openshift.restclient.model.volume.IPersistentVolume; -import com.openshift.restclient.model.volume.property.IHostPathVolumeProperties; -import com.openshift.restclient.model.volume.property.INfsVolumeProperties; -import com.openshift.restclient.utils.MemoryUnit; -import com.openshift.restclient.utils.Samples; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.mock; - - -public class PersistentVolumeTest { - - private static final String VERSION = "v1beta3"; - private static final Samples sample = Samples.V1BETA3_PERSISTENT_VOLUME; - private IPersistentVolume pv; - private IClient client; - - @Before - public void setUp() { - client = mock(IClient.class); - ModelNode node = ModelNode.fromJSONString(sample.getContentAsString()); - pv = new PersistentVolume(node, client, ResourcePropertiesRegistry.getInstance().get(VERSION, ResourceKind.PERSISTENT_VOLUME)); - } - - @Test - public void testGetCapacityString() { - pv.setCapacity(13L, MemoryUnit.Pi); - long capacity = pv.getCapacity("Ki"); - assertEquals(14293651161088L, capacity); - - capacity = pv.getCapacity("Ti"); - assertEquals(13312L, capacity); - - capacity = pv.getCapacity("Pi"); - assertEquals(13L, capacity); - } - - @Test - public void testGetCapacity() { - pv.setCapacity(13L, MemoryUnit.Pi); - long capacity = pv.getCapacity(); - assertEquals(14636698788954112L, capacity); - } - - @Test - public void testSetCapacity() { - pv.setCapacity(1L, MemoryUnit.Ki); - long capacity = pv.getCapacity(); - assertEquals(1024L, capacity); - - pv.setCapacity(31L, MemoryUnit.Ti); - capacity = pv.getCapacity(MemoryUnit.Ti); - assertEquals(31L, capacity); - } - - @Test(expected = ArithmeticException.class) - public void testSetCapacityOverflow() { - /* - * 2^4 * 2 ^60 = 2^64, LONG_MAX is only 2^64-1 - */ - pv.setCapacity(16L, MemoryUnit.Ei); - pv.getCapacity(); - } - - @Test - public void testGetCapacityUnit() { - pv.setCapacity(1L, MemoryUnit.Ki); - MemoryUnit unit = pv.getCapacityUnit(); - assertEquals(MemoryUnit.Ki, unit); - - pv.setCapacity(1L, MemoryUnit.Pi); - unit = pv.getCapacityUnit(); - assertEquals(MemoryUnit.Pi, unit); - } - - @Test - public void testAccessModes() { - pv.setAccessModes("ReadWriteOnce"); - Set modes = pv.getAccessModes(); - assertTrue(modes.contains("ReadWriteOnce")); - - pv.setAccessModes("ReadWriteOnce", "ReadOnlyMany", "ReadWriteMany"); - modes = pv.getAccessModes(); - Set expected = new HashSet<>(); - expected.addAll(Arrays.asList("ReadWriteOnce", "ReadOnlyMany", "ReadWriteMany")); - assertTrue(modes.containsAll(expected)); - } - - @Test - public void testReclaimPolicy() { - pv.setReclaimPolicy("Recycle"); - String policy = pv.getReclaimPolicy(); - assertEquals(policy, "Recycle"); - } - - @Test - public void testNFSVolume() { - INfsVolumeProperties volume = new NfsVolumeProperties("10.10.10.10", "/tmp/dir", true); - pv.setPersistentVolumeProperties(volume); - volume = (INfsVolumeProperties) pv.getPersistentVolumeProperties(); - assertEquals("/tmp/dir", volume.getPath()); - assertEquals("10.10.10.10", volume.getServer()); - assertEquals(true, volume.isReadOnly()); - } - - @Test - public void testHostPathVolume() { - IHostPathVolumeProperties volume = new HostPathVolumeProperties("/tmp/dir"); - pv.setPersistentVolumeProperties(volume); - volume = (IHostPathVolumeProperties) pv.getPersistentVolumeProperties(); - assertEquals("/tmp/dir", volume.getPath()); - } -} diff --git a/src/test/java/com/openshift/internal/restclient/model/v1beta3/PodTest.java b/src/test/java/com/openshift/internal/restclient/model/v1beta3/PodTest.java deleted file mode 100644 index c953a992..00000000 --- a/src/test/java/com/openshift/internal/restclient/model/v1beta3/PodTest.java +++ /dev/null @@ -1,76 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 Red Hat, Inc. Distributed under license by Red Hat, Inc. - * All rights reserved. This program is made available under the terms of the - * Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: Red Hat, Inc. - ******************************************************************************/ -package com.openshift.internal.restclient.model.v1beta3; - -import static org.junit.Assert.*; -import static org.mockito.Mockito.mock; - -import java.util.HashSet; -import java.util.Set; - -import org.jboss.dmr.ModelNode; -import org.junit.BeforeClass; -import org.junit.Test; - -import com.openshift.internal.restclient.model.Pod; -import com.openshift.internal.restclient.model.Port; -import com.openshift.internal.restclient.model.properties.ResourcePropertiesRegistry; -import com.openshift.restclient.IClient; -import com.openshift.restclient.ResourceKind; -import com.openshift.restclient.model.IPod; -import com.openshift.restclient.model.IPort; -import com.openshift.restclient.utils.Samples; - -/** - * @author Jeff Cantrill - */ -public class PodTest { - - private static final String VERSION = "v1beta3"; - private static IPod pod; - - @BeforeClass - public static void setup(){ - IClient client = mock(IClient.class); - ModelNode node = ModelNode.fromJSONString(Samples.V1BETA3_POD.getContentAsString()); - pod = new Pod(node, client, ResourcePropertiesRegistry.getInstance().get(VERSION, ResourceKind.POD)); - } - - @Test - public void testGetHost(){ - assertEquals("127.0.0.1", pod.getHost()); - } - - @Test - public void testGetStatus(){ - assertEquals("Failed", pod.getStatus()); - } - - @Test - public void testGetImages(){ - String [] exp = new String []{"openshift/origin-sti-builder:v0.5"}; - assertArrayEquals(exp, pod.getImages().toArray()); - } - - @Test - public void getIP() { - assertEquals("172.17.0.2", pod.getIP()); - } - - @Test - public void getContainerPorts() { - Set ports = new HashSet(); - Port port = new Port(new ModelNode()); - port.setName("http"); - port.setProtocol("TCP"); - port.setContainerPort(8080); - ports.add(port); - assertEquals(ports, pod.getContainerPorts()); - } -} diff --git a/src/test/java/com/openshift/internal/restclient/model/v1beta3/ProjectRequestTest.java b/src/test/java/com/openshift/internal/restclient/model/v1beta3/ProjectRequestTest.java deleted file mode 100644 index 69414808..00000000 --- a/src/test/java/com/openshift/internal/restclient/model/v1beta3/ProjectRequestTest.java +++ /dev/null @@ -1,63 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 Red Hat, Inc. Distributed under license by Red Hat, Inc. - * All rights reserved. This program is made available under the terms of the - * Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: Red Hat, Inc. - ******************************************************************************/ -package com.openshift.internal.restclient.model.v1beta3; - -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.mock; - - -import org.jboss.dmr.ModelNode; -import org.junit.Before; -import org.junit.Test; - -import com.openshift.internal.restclient.model.project.OpenshiftProjectRequest; -import com.openshift.internal.restclient.model.properties.ResourcePropertiesRegistry; -import com.openshift.restclient.IClient; -import com.openshift.restclient.ResourceKind; -import com.openshift.restclient.model.project.IProjectRequest; -import com.openshift.restclient.utils.Samples; - -/** - * Test to validate the lookup paths are correct for the version - * @author Jeff Cantrill - */ -public class ProjectRequestTest{ - - private static final String VERSION = "v1beta3"; - private IProjectRequest request; - - @Before - public void setUp(){ - IClient client = mock(IClient.class); - ModelNode node = ModelNode.fromJSONString(Samples.V1BETA3_PROJECT_REQUEST.getContentAsString()); - request = new OpenshiftProjectRequest(node, client, ResourcePropertiesRegistry.getInstance().get(VERSION, ResourceKind.PROJECT_REQUEST)); - } - - @Test - public void setDisplayName() { - request.setDisplayName("the other display name"); - assertEquals("the other display name", request.getDisplayName()); - } - - @Test - public void testGetDisplayName() { - assertEquals("the display name", request.getDisplayName()); - } - - @Test - public void testGetDescription() { - assertEquals("The project description", request.getDescription()); - } - - @Test - public void testSetDescription() { - request.setDescription("The other project description"); - assertEquals("The other project description", request.getDescription()); - } -} \ No newline at end of file diff --git a/src/test/java/com/openshift/internal/restclient/model/v1beta3/ProjectTest.java b/src/test/java/com/openshift/internal/restclient/model/v1beta3/ProjectTest.java deleted file mode 100644 index f6fe7451..00000000 --- a/src/test/java/com/openshift/internal/restclient/model/v1beta3/ProjectTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 Red Hat, Inc. Distributed under license by Red Hat, Inc. - * All rights reserved. This program is made available under the terms of the - * Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: Red Hat, Inc. - ******************************************************************************/ -package com.openshift.internal.restclient.model.v1beta3; - -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.mock; - - -import org.jboss.dmr.ModelNode; -import org.junit.Before; -import org.junit.Test; - -import com.openshift.internal.restclient.model.Project; -import com.openshift.internal.restclient.model.properties.ResourcePropertiesRegistry; -import com.openshift.restclient.IClient; -import com.openshift.restclient.ResourceKind; -import com.openshift.restclient.model.IProject; -import com.openshift.restclient.utils.Samples; - -/** - * Test to validate the lookup paths are correct for the version - * @author Jeff Cantrill - */ -public class ProjectTest{ - - private static final String VERSION = "v1beta3"; - private IProject project; - - @Before - public void setUp(){ - IClient client = mock(IClient.class); - ModelNode node = ModelNode.fromJSONString(Samples.V1BETA3_PROJECT.getContentAsString()); - project = new Project(node, client, ResourcePropertiesRegistry.getInstance().get(VERSION, ResourceKind.PROJECT)); - } - - @Test - public void testGetDisplayName() { - assertEquals("OpenShift 3 Sample", project.getDisplayName()); - } - - @Test - public void testGetDescription() { - assertEquals("This is an example project to demonstrate OpenShift v3", project.getDescription()); - } -} \ No newline at end of file diff --git a/src/test/java/com/openshift/internal/restclient/model/v1beta3/ReplicationControllerTest.java b/src/test/java/com/openshift/internal/restclient/model/v1beta3/ReplicationControllerTest.java deleted file mode 100644 index 0524ad12..00000000 --- a/src/test/java/com/openshift/internal/restclient/model/v1beta3/ReplicationControllerTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 Red Hat, Inc. Distributed under license by Red Hat, Inc. - * All rights reserved. This program is made available under the terms of the - * Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: Red Hat, Inc. - ******************************************************************************/ -package com.openshift.internal.restclient.model.v1beta3; - -import static org.junit.Assert.*; -import static org.mockito.Mockito.mock; - -import java.util.HashMap; -import java.util.Map; - -import org.jboss.dmr.ModelNode; -import org.junit.BeforeClass; -import org.junit.Test; - -import com.openshift.internal.restclient.model.ReplicationController; -import com.openshift.internal.restclient.model.properties.ResourcePropertiesRegistry; -import com.openshift.restclient.IClient; -import com.openshift.restclient.ResourceKind; -import com.openshift.restclient.model.IReplicationController; -import com.openshift.restclient.utils.Samples; - -/** - * @author Jeff Cantrill - */ -public class ReplicationControllerTest { - - private static IReplicationController rc; - - @BeforeClass - public static void setup(){ - IClient client = mock(IClient.class); - ModelNode node = ModelNode.fromJSONString(Samples.V1BETA3_REPLICATION_CONTROLLER.getContentAsString()); - rc = new ReplicationController(node, client, ResourcePropertiesRegistry.getInstance().get("v1beta3", ResourceKind.REPLICATION_CONTROLLER)); - } - - @Test - public void getReplicaSelector() { - Map labels = new HashMap(); - labels.put("name", "database"); - labels.put("deployment", "database-1"); - labels.put("deploymentconfig", "database"); - assertEquals(labels, rc.getReplicaSelector()); - } - - @Test - public void getDesiredReplicaCount(){ - assertEquals(1, rc.getDesiredReplicaCount()); - } - - @Test - public void getCurrentReplicaCount(){ - assertEquals(2, rc.getCurrentReplicaCount()); - } - - @Test - public void testGetImages(){ - String [] exp = new String []{"openshift/mysql-55-centos7"}; - assertArrayEquals(exp , rc.getImages().toArray()); - } -} diff --git a/src/test/java/com/openshift/internal/restclient/model/v1beta3/ResourceTest.java b/src/test/java/com/openshift/internal/restclient/model/v1beta3/ResourceTest.java deleted file mode 100644 index 1986f3ca..00000000 --- a/src/test/java/com/openshift/internal/restclient/model/v1beta3/ResourceTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 Red Hat, Inc. Distributed under license by Red Hat, Inc. - * All rights reserved. This program is made available under the terms of the - * Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: Red Hat, Inc. - ******************************************************************************/ -package com.openshift.internal.restclient.model.v1beta3; - -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.mock; - -import org.jboss.dmr.ModelNode; -import org.junit.Before; -import org.junit.Test; - -import com.openshift.internal.restclient.model.Build; -import com.openshift.internal.restclient.model.KubernetesResource; -import com.openshift.internal.restclient.model.properties.ResourcePropertiesRegistry; -import com.openshift.restclient.IClient; -import com.openshift.restclient.ResourceKind; -import com.openshift.restclient.model.IResource; -import com.openshift.restclient.utils.Samples; - -/** - * @author Jeff Cantrill - */ -public class ResourceTest { - - private static final String VERSION = "v1beta3"; - private static IResource resource; - - @Before - public void setup(){ - IClient client = mock(IClient.class); - ModelNode node = ModelNode.fromJSONString(Samples.V1BETA3_SERVICE.getContentAsString()); - resource = new KubernetesResource(node, client, ResourcePropertiesRegistry.getInstance().get(VERSION, ResourceKind.SERVICE)) {}; - } - - @Test - public void getNamespace(){ - assertEquals("test", resource.getNamespace()); - } - - @Test - public void getNamespaceWhenUndefinedShouldReturnEmptyString(){ - IClient client = mock(IClient.class); - ModelNode node = ModelNode.fromJSONString(Samples.V1BETA3_SERVICE.getContentAsString()); - node.get("metadata").remove("namespace");//.set(new ModelNode(ModelType.UNDEFINED)); - resource = new Build(node, client, ResourcePropertiesRegistry.getInstance().get(VERSION, ResourceKind.PROJECT)); - assertEquals("", resource.getNamespace()); - } - - -} diff --git a/src/test/java/com/openshift/internal/restclient/model/v1beta3/RouteTest.java b/src/test/java/com/openshift/internal/restclient/model/v1beta3/RouteTest.java deleted file mode 100644 index 1a4ff1f7..00000000 --- a/src/test/java/com/openshift/internal/restclient/model/v1beta3/RouteTest.java +++ /dev/null @@ -1,90 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 Red Hat, Inc. Distributed under license by Red Hat, Inc. - * All rights reserved. This program is made available under the terms of the - * Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: Red Hat, Inc. - ******************************************************************************/ -package com.openshift.internal.restclient.model.v1beta3; - -import static org.junit.Assert.*; -import static org.mockito.Mockito.*; - - -import org.jboss.dmr.ModelNode; -import org.junit.Before; -import org.junit.Test; - -import com.openshift.internal.restclient.model.Route; -import com.openshift.internal.restclient.model.properties.ResourcePropertiesRegistry; -import com.openshift.restclient.IClient; -import com.openshift.restclient.ResourceKind; -import com.openshift.restclient.model.route.IRoute; -import com.openshift.restclient.model.route.ITLSConfig; -import com.openshift.restclient.model.route.TLSTerminationType; -import com.openshift.restclient.utils.Samples; - -/** - * Test to validate the lookup paths are correct for the version - * @author Jeff Cantrill - */ -public class RouteTest{ - - private static final String VERSION = "v1beta3"; - private static final Samples sample = Samples.V1BETA3_ROUTE; - private IRoute route; - private IClient client; - - @Before - public void setUp(){ - client = mock(IClient.class); - ModelNode node = ModelNode.fromJSONString(sample.getContentAsString()); - route = new Route(node, client, ResourcePropertiesRegistry.getInstance().get(VERSION, ResourceKind.ROUTE)); - } - - @Test - public void getTLSConfigWhenUndefined() { - ModelNode node = ModelNode.fromJSONString(Samples.V1BETA3_ROUTE_WO_TLS.getContentAsString()); - route = new Route(node, client, ResourcePropertiesRegistry.getInstance().get(VERSION, ResourceKind.ROUTE)); - assertNull(route.getTLSConfig()); - } - - @Test - public void testGetHost() { - assertEquals("www.example.com", route.getHost()); - } - - @Test - public void testGetPath() { - assertEquals("/abc", route.getPath()); - } - - @Test - public void testGetAndSetPath() { - route.setPath("/def"); - assertEquals("/def", route.getPath()); - } - - @Test - public void getServiceName() throws Exception { - assertEquals("frontend", route.getServiceName()); - } - - @Test - public void setServiceName() throws Exception { - route.setServiceName("frontend-alt"); - assertEquals("frontend-alt", route.getServiceName()); - } - - @Test - public void getTLSConfig() throws Exception { - ITLSConfig tls = route.getTLSConfig(); - assertEquals(TLSTerminationType.EDGE, tls.getTerminationType()); - assertEquals("theCert", tls.getCertificate()); - assertEquals("theCACert", tls.getCACertificate()); - assertEquals("theKey", tls.getKey()); - } - - -} diff --git a/src/test/java/com/openshift/internal/restclient/model/v1beta3/SecretTest.java b/src/test/java/com/openshift/internal/restclient/model/v1beta3/SecretTest.java deleted file mode 100644 index 3a805828..00000000 --- a/src/test/java/com/openshift/internal/restclient/model/v1beta3/SecretTest.java +++ /dev/null @@ -1,64 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 Red Hat, Inc. Distributed under license by Red Hat, Inc. - * All rights reserved. This program is made available under the terms of the - * Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: Red Hat, Inc. - ******************************************************************************/ -package com.openshift.internal.restclient.model.v1beta3; - -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.mock; - -import java.io.ByteArrayInputStream; - -import org.jboss.dmr.ModelNode; -import org.junit.Before; -import org.junit.Test; - -import com.openshift.internal.restclient.model.Secret; -import com.openshift.internal.restclient.model.properties.ResourcePropertiesRegistry; -import com.openshift.restclient.IClient; -import com.openshift.restclient.ResourceKind; -import com.openshift.restclient.model.secret.ISecret; -import com.openshift.restclient.utils.Samples; - -/** - * Test to validate that Secret object works as expected - * @author Jiri Pechanec - */ -public class SecretTest{ - - private static final String VERSION = "v1beta3"; - private static final Samples sample = Samples.V1BETA3_SECRET; - private ISecret secret; - - @Before - public void setUp() { - IClient client = mock(IClient.class); - ModelNode node = ModelNode.fromJSONString(sample.getContentAsString()); - secret = new Secret(node, client, ResourcePropertiesRegistry.getInstance().get(VERSION, ResourceKind.SECRET)); - } - - @Test - public void testSecretType() { - assertEquals("Opaque", secret.getType()); - } - - @Test - public void testGetData() { - assertEquals("value-1\r\n", new String(secret.getData("id-rsa.pub"))); - assertEquals("value-2\r\n\r\n", new String(secret.getData("id-rsa"))); - } - - @Test - public void testAddAndGetData() { - secret.addData("my-key1", "secret word".getBytes()); - secret.addData("my-key2", new ByteArrayInputStream("blah blah".getBytes())); - assertEquals("secret word", new String(secret.getData("my-key1"))); - assertEquals("blah blah", new String(secret.getData("my-key2"))); - } - - -} diff --git a/src/test/java/com/openshift/internal/restclient/model/v1beta3/ServiceAccountTest.java b/src/test/java/com/openshift/internal/restclient/model/v1beta3/ServiceAccountTest.java deleted file mode 100644 index 7ce1aa99..00000000 --- a/src/test/java/com/openshift/internal/restclient/model/v1beta3/ServiceAccountTest.java +++ /dev/null @@ -1,83 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 Red Hat, Inc. Distributed under license by Red Hat, Inc. - * All rights reserved. This program is made available under the terms of the - * Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: Red Hat, Inc. - ******************************************************************************/ -package com.openshift.internal.restclient.model.v1beta3; - -import com.openshift.internal.restclient.model.ServiceAccount; -import com.openshift.internal.restclient.model.properties.ResourcePropertiesRegistry; -import com.openshift.restclient.IClient; -import com.openshift.restclient.ResourceKind; -import com.openshift.restclient.model.serviceaccount.IServiceAccount; -import com.openshift.restclient.utils.Samples; -import org.jboss.dmr.ModelNode; -import org.junit.Before; -import org.junit.Test; - -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.mock; - -/** - * @author David Simansky | dsimansk@redhat.com - */ -public class ServiceAccountTest { - - private static final String VERSION = "v1beta3"; - private static final Samples sample = Samples.V1BETA3_SERVICE_ACCOUNT; - private IServiceAccount serviceAccount; - - @Before - public void setUp() { - IClient client = mock(IClient.class); - ModelNode node = ModelNode.fromJSONString(sample.getContentAsString()); - serviceAccount = new ServiceAccount(node, client, ResourcePropertiesRegistry.getInstance().get(VERSION, - ResourceKind.SERVICE_ACCOUNT)); - } - - @Test - public void testGetSecrets() { - String[] expSecrets = new String []{"deployer-token-luifi", "deployer-dockercfg-jq62e"}; - assertArrayEquals(expSecrets, serviceAccount.getSecrets().toArray()); - } - - @Test - public void testGetImagePullSecrets() { - String[] expSecrets = new String []{"deployer-dockercfg-jq62e"}; - assertArrayEquals(expSecrets, serviceAccount.getImagePullSecrets().toArray()); - } - - @Test - public void testAddSecret() { - serviceAccount.addSecret("my-test-secret"); - assertEquals(3, serviceAccount.getSecrets().size()); - assertTrue(serviceAccount.getSecrets().contains("my-test-secret")); - } - - @Test - public void testAddNullSecret() { - serviceAccount.addSecret(null); - assertEquals(3, serviceAccount.getSecrets().size()); - assertTrue(serviceAccount.getSecrets().contains("")); - } - - @Test - public void testAddImagePullSecret() { - serviceAccount.addImagePullSecret("my-test-secret"); - assertEquals(2, serviceAccount.getImagePullSecrets().size()); - assertTrue(serviceAccount.getImagePullSecrets().contains("my-test-secret")); - } - - @Test - public void testAddNullImagePullSecret() { - serviceAccount.addImagePullSecret(null); - assertEquals(2, serviceAccount.getImagePullSecrets().size()); - assertTrue(serviceAccount.getImagePullSecrets().contains("")); - } - -} diff --git a/src/test/java/com/openshift/internal/restclient/model/v1beta3/ServiceTest.java b/src/test/java/com/openshift/internal/restclient/model/v1beta3/ServiceTest.java deleted file mode 100644 index bced13de..00000000 --- a/src/test/java/com/openshift/internal/restclient/model/v1beta3/ServiceTest.java +++ /dev/null @@ -1,131 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 Red Hat, Inc. Distributed under license by Red Hat, Inc. - * All rights reserved. This program is made available under the terms of the - * Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: Red Hat, Inc. - ******************************************************************************/ -package com.openshift.internal.restclient.model.v1beta3; - -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.mock; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; - -import org.jboss.dmr.ModelNode; -import org.junit.Before; -import org.junit.Test; - -import com.openshift.internal.restclient.model.PortFactory; -import com.openshift.internal.restclient.model.Service; -import com.openshift.internal.restclient.model.properties.ResourcePropertiesRegistry; -import com.openshift.restclient.IClient; -import com.openshift.restclient.ResourceKind; -import com.openshift.restclient.model.IService; -import com.openshift.restclient.model.IServicePort; -import com.openshift.restclient.utils.Samples; - -/** - * Test to validate the lookup paths are correct for the version - * @author Jeff Cantrill - */ -public class ServiceTest{ - - private static final String VERSION = "v1beta3"; - private IService service; - - @Before - public void setUp(){ - IClient client = mock(IClient.class); - ModelNode node = ModelNode.fromJSONString(Samples.V1BETA3_SERVICE.getContentAsString()); - service = new Service(node, client, ResourcePropertiesRegistry.getInstance().get(VERSION, ResourceKind.SERVICE)); - } - - @Test - public void testGetPortalIP() { - assertEquals("172.30.174.188", service.getPortalIP()); - } - - @Test - public void testGetTargetPort() { - assertEquals(3306, service.getTargetPort()); - } - - @Test - public void testSetTargetPort() { - service.setTargetPort(5030); - assertEquals(5030, service.getTargetPort()); - } - - @Test - public void testGetPort() { - assertEquals(5434, service.getPort()); - } - - @Test - public void testSetPort() { - service.setPort(5055); - assertEquals(5055, service.getPort()); - } - - @Test - public void testGetSelector() { - Map selector = new HashMap(); - selector.put("name", "database"); - assertEquals(selector, service.getSelector()); - } - - @Test - public void testSetSelectorSimple() { - Map selector = new HashMap(); - selector.put("name", "myselector"); - service.setSelector("name","myselector"); - assertEquals(selector, service.getSelector()); - } - - @Test - public void testGetName() { - assertEquals("database", service.getName()); - } - - @Test - public void testSetName() { - ((Service) service).setName("hello-openshift"); - assertEquals("hello-openshift", service.getName()); - } - - @Test - public void testGetNamespace() { - assertEquals("test", service.getNamespace()); - } - - @Test - public void testSetNamespace() { - // pre-condition - // operation - ((Service) service).setNamespace("foo"); - // verification - assertEquals("foo", service.getNamespace()); - } - - @Test - public void testGetPorts() { - IServicePort [] ports = service.getPorts().toArray(new IServicePort[] {}); - assertEquals(2, ports.length); - assertEquals(PortFactory.createServicePort("db", "TCP", 5434, 3306), ports[0]); - assertEquals(PortFactory.createServicePort("other", "TCP", 9999, 8888), ports[1]); - } - - @Test - public void testSetPorts() { - IServicePort port = PortFactory.createServicePort("newport", "TCP", 4444, 5555); - service.setPorts(Arrays.asList(port)); - IServicePort [] ports = service.getPorts().toArray(new IServicePort[] {}); - assertEquals(1, service.getPorts().size()); - assertEquals(port, ports[0]); - } - -} diff --git a/src/test/java/com/openshift/internal/restclient/model/v1beta3/StatusTest.java b/src/test/java/com/openshift/internal/restclient/model/v1beta3/StatusTest.java deleted file mode 100644 index 4650f9a6..00000000 --- a/src/test/java/com/openshift/internal/restclient/model/v1beta3/StatusTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 Red Hat, Inc. Distributed under license by Red Hat, Inc. - * All rights reserved. This program is made available under the terms of the - * Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: Red Hat, Inc. - ******************************************************************************/ -package com.openshift.internal.restclient.model.v1beta3; - -import static org.junit.Assert.*; -import static org.mockito.Mockito.*; - -import org.jboss.dmr.ModelNode; -import org.junit.BeforeClass; -import org.junit.Test; - -import com.openshift.internal.restclient.model.Status; -import com.openshift.internal.restclient.model.properties.ResourcePropertiesRegistry; -import com.openshift.restclient.IClient; -import com.openshift.restclient.ResourceKind; -import com.openshift.restclient.model.IStatus; -import com.openshift.restclient.utils.Samples; - -/** - * Test to validate the lookup paths are correct for the version - * @author Jeff Cantrill - */ -public class StatusTest{ - - private static IStatus status; - - @BeforeClass - public static void setUp(){ - IClient client = mock(IClient.class); - ModelNode node = ModelNode.fromJSONString(Samples.V1BETA3_Status.getContentAsString()); - status = new Status(node, client, ResourcePropertiesRegistry.getInstance().get("v1beta3", ResourceKind.STATUS)); - } - - @Test - public void testGetMessage() { - assertEquals("\"/api/v1beta1/services/ruby-helloworld-sample\" is forbidden because foo cannot get on services with name \"ruby-helloworld-sample\" in default", status.getMessage()); - } - - @Test - public void testGetCode() { - assertEquals(403, status.getCode()); - } - - @Test - public void testGetStatus() { - assertEquals("Failure", status.getStatus()); - } -} diff --git a/src/test/java/com/openshift/internal/restclient/model/v1beta3/TemplateTest.java b/src/test/java/com/openshift/internal/restclient/model/v1beta3/TemplateTest.java deleted file mode 100644 index f28dfac9..00000000 --- a/src/test/java/com/openshift/internal/restclient/model/v1beta3/TemplateTest.java +++ /dev/null @@ -1,79 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 Red Hat, Inc. Distributed under license by Red Hat, Inc. - * All rights reserved. This program is made available under the terms of the - * Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: Red Hat, Inc. - ******************************************************************************/ -package com.openshift.internal.restclient.model.v1beta3; - -import static org.junit.Assert.*; -import static org.mockito.Mockito.*; - -import java.util.Map; - -import org.jboss.dmr.ModelNode; -import org.junit.Before; -import org.junit.Test; - -import com.openshift.internal.restclient.ResourceFactory; -import com.openshift.internal.restclient.model.template.Template; -import com.openshift.restclient.IClient; -import com.openshift.restclient.model.template.IParameter; -import com.openshift.restclient.model.template.ITemplate; -import com.openshift.restclient.utils.Samples; - -/** - * Test to validate the lookup paths are correct for the version - * - * @author Jeff Cantrill - */ -public class TemplateTest{ - - private static final String VERSION = "v1beta3"; - private ITemplate template; - - @Before - public void setUp(){ - IClient client = mock(IClient.class); - when(client.getResourceFactory()).thenReturn(new ResourceFactory(client){}); - ModelNode node = ModelNode.fromJSONString(Samples.V1BETA3_TEMPLATE.getContentAsString()); - template = new Template(node, client, null); - } - @Test - public void testGetApiVersion() { - assertEquals(VERSION, template.getApiVersion()); - } - - @Test - public void testGetItems() { - assertEquals("Exp. the number of items to be more than zero", 8, template.getItems().size()); - } - - @Test - public void testGetParameters() { - Map parameters = template.getParameters(); - assertEquals("Exp. the number of items to be more than zero",5, parameters.size()); - IParameter param = parameters.get("MYSQL_PASSWORD"); - assertNotNull(param); - assertEquals("",param.getValue()); - assertEquals("[a-zA-Z0-9]{8}",param.getFrom()); - assertEquals("expression",param.getGeneratorName()); - assertEquals("database password",param.getDescription()); - assertTrue("required", param.isRequired()); - } - - @Test - public void testGetLabels() { - assertEquals("Exp. to retrieve the labels",2, template.getLabels().size()); - assertEquals("bar", template.getLabels().get("foo")); - } - - @Test - public void testGetObjectLabels() { - assertEquals("Exp. to retrieve the object labels",1, template.getObjectLabels().size()); - assertEquals("application-template-stibuild", template.getObjectLabels().get("template")); - } - -} diff --git a/src/test/java/com/openshift/internal/restclient/model/v1beta3/UnrecognizedResourceTest.java b/src/test/java/com/openshift/internal/restclient/model/v1beta3/UnrecognizedResourceTest.java deleted file mode 100644 index d547c9f6..00000000 --- a/src/test/java/com/openshift/internal/restclient/model/v1beta3/UnrecognizedResourceTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 Red Hat, Inc. Distributed under license by Red Hat, Inc. - * All rights reserved. This program is made available under the terms of the - * Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: Red Hat, Inc. - ******************************************************************************/ -package com.openshift.internal.restclient.model.v1beta3; - -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.mock; - -import org.junit.Before; -import org.junit.Test; - -import com.openshift.internal.restclient.ResourceFactory; -import com.openshift.restclient.IClient; -import com.openshift.restclient.model.IResource; -import com.openshift.restclient.utils.Samples; - -/** - * Test to validate the lookup paths are correct for the version - * @author Jeff Cantrill - */ -public class UnrecognizedResourceTest{ - - private IResource service; - - @Before - public void setUp(){ - IClient client = mock(IClient.class); - service = new ResourceFactory(client).create(Samples.V1BETA3_UNRECOGNIZED.getContentAsString(), false); - } - - @Test - public void testGetName() { - assertEquals("database", service.getName()); - } - - @Test - public void testGetNamespace() { - assertEquals("test", service.getNamespace()); - } - - @Test - public void testGetKind() { - assertEquals("IMadeThisOneUp", service.getKind()); - } - -} diff --git a/src/test/java/com/openshift/internal/restclient/model/v1beta3/UserTest.java b/src/test/java/com/openshift/internal/restclient/model/v1beta3/UserTest.java deleted file mode 100644 index cc064328..00000000 --- a/src/test/java/com/openshift/internal/restclient/model/v1beta3/UserTest.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 Red Hat, Inc. Distributed under license by Red Hat, Inc. - * All rights reserved. This program is made available under the terms of the - * Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: Red Hat, Inc. - ******************************************************************************/ -package com.openshift.internal.restclient.model.v1beta3; - -import static org.junit.Assert.*; -import static org.mockito.Mockito.*; - -import org.jboss.dmr.ModelNode; -import org.junit.Before; -import org.junit.Test; - -import com.openshift.internal.restclient.model.properties.ResourcePropertiesRegistry; -import com.openshift.internal.restclient.model.user.OpenShiftUser; -import com.openshift.restclient.IClient; -import com.openshift.restclient.ResourceKind; -import com.openshift.restclient.model.user.IUser; -import com.openshift.restclient.utils.Samples; - -/** - * Test to validate the lookup paths are correct for the version - * @author Jeff Cantrill - */ -public class UserTest{ - - private static final String VERSION = "v1beta3"; - private IUser resource; - - @Before - public void setUp(){ - IClient client = mock(IClient.class); - ModelNode node = ModelNode.fromJSONString(Samples.V1BETA3_USER.getContentAsString()); - resource = new OpenShiftUser(node, client, ResourcePropertiesRegistry.getInstance().get(VERSION, ResourceKind.USER)); - } - - @Test - public void testFullName() { - assertEquals("Foo Master", resource.getFullName()); - } -} diff --git a/src/test/java/com/openshift/restclient/utils/Samples.java b/src/test/java/com/openshift/restclient/utils/Samples.java index d016ab71..5da23842 100644 --- a/src/test/java/com/openshift/restclient/utils/Samples.java +++ b/src/test/java/com/openshift/restclient/utils/Samples.java @@ -20,27 +20,6 @@ */ public enum Samples { - //v1beta3 - V1BETA3_BUILD_CONFIG("openshift3/v1beta3_build_config.json"), - V1BETA3_DEPLOYMENT_CONIFIG("openshift3/v1beta3_deployment_config.json"), - V1BETA3_IMAGE_STREAM("openshift3/v1beta3_image_stream.json"), - V1BETA3_BUILD("openshift3/v1beta3_build.json"), - V1BETA3_POD("openshift3/v1beta3_pod.json"), - V1BETA3_PROJECT("openshift3/v1beta3_project.json"), - V1BETA3_PROJECT_REQUEST("openshift3/v1beta3_project_request.json"), - V1BETA3_PVC("openshift3/v1beta3_pvc.json"), - V1BETA3_PERSISTENT_VOLUME("openshift3/v1beta3_persistent_volume.json"), - V1BETA3_REPLICATION_CONTROLLER("openshift3/v1beta3_replication_controller.json"), - V1BETA3_ROUTE("openshift3/v1beta3_route.json"), - V1BETA3_ROUTE_WO_TLS("openshift3/v1beta3_route_wo_tls.json"), - V1BETA3_SERVICE("openshift3/v1beta3_service.json"), - V1BETA3_SERVICE_ACCOUNT("openshift3/v1beta3_service_account.json"), - V1BETA3_TEMPLATE("openshift3/v1beta3_template.json"), - V1BETA3_Status("openshift3/v1beta3_status.json"), - V1BETA3_USER("openshift3/v1beta3_user.json"), - V1BETA3_SECRET("openshift3/v1beta3_secret.json"), - V1BETA3_UNRECOGNIZED("openshift3/v1_unrecognized.json"), - //v1 V1_BUILD_CONFIG("openshift3/v1_build_config.json"), V1_BUILD_CONFIG_LIST("openshift3/v1_build_config_list.json"), diff --git a/src/test/resources/samples/openshift3/v1beta3_build.json b/src/test/resources/samples/openshift3/v1beta3_build.json deleted file mode 100644 index 29b632d7..00000000 --- a/src/test/resources/samples/openshift3/v1beta3_build.json +++ /dev/null @@ -1,52 +0,0 @@ -{ - "kind": "Build", - "apiVersion": "v1beta3", - "metadata": { - "name": "ruby-sample-build-1", - "namespace": "test", - "selfLink": "/osapi/v1beta1/builds/ruby-sample-build-1?namespace=test", - "uid": "44d28bfd-f41b-11e4-a871-080027893417", - "resourceVersion": "58374", - "creationTimestamp": "2015-05-06T18:11:08Z", - "labels": { - "buildconfig": "ruby-sample-build", - "name": "ruby-sample-build", - "template": "application-template-stibuild" - } - }, - "spec": { - "source": { - "type": "Git", - "git": { - "uri": "git://github.com/openshift/ruby-hello-world.git" - } - }, - "strategy": { - "type": "STI", - "stiStrategy": { - "from": { - "kind": "DockerImage", - "name": "openshift/ruby-20-centos7:latest" - }, - "incremental": true - } - }, - "output": { - "to": { - "kind": "ImageStream", - "name": "origin-ruby-sample" - } - }, - "resources": {} - }, - "status": { - "phase": "Pending", - "message" : "Some status message", - "duration": 0, - "config": { - "kind": "BuildConfig", - "namespace": "test", - "name": "ruby-sample-build" - } - } -} \ No newline at end of file diff --git a/src/test/resources/samples/openshift3/v1beta3_build_config.json b/src/test/resources/samples/openshift3/v1beta3_build_config.json deleted file mode 100644 index 120f6c6d..00000000 --- a/src/test/resources/samples/openshift3/v1beta3_build_config.json +++ /dev/null @@ -1,71 +0,0 @@ -{ - "kind": "BuildConfig", - "apiVersion": "v1beta3", - "metadata": { - "name": "ruby-sample-build", - "namespace": "test", - "selfLink": "/osapi/v1beta3/namespaces/test/buildconfigs/ruby-sample-build", - "uid": "a87b6692-00a5-11e5-8ebb-080027893417", - "resourceVersion": "259", - "creationTimestamp": "2015-05-22T17:12:00Z", - "labels": { - "mylabel": "abe", - "name": "ruby-sample-build", - "template": "application-template-stibuild" - } - }, - "spec": { - "triggers": [ - { - "type": "github", - "github": { - "secret": "secret101" - } - }, - { - "type": "generic", - "generic": { - "secret": "secret101" - } - }, - { - "type": "imageChange", - "imageChange": { - "lastTriggeredImageID": "openshift/ruby-20-centos7:latest" - } - } - ], - "source": { - "type": "Git", - "git": { - "uri": "git://github.com/openshift/ruby-hello-world.git" - }, - "contextDir" : "foobar" - }, - "strategy": { - "type": "Source", - "sourceStrategy": { - "from": { - "kind": "ImageStreamTag", - "name": "ruby-20-centos7:latest" - }, - "scripts" : "alocation", - "env" : [{ - "name" : "foo", - "value" : "bar" - }], - "incremental": true - } - }, - "output": { - "to": { - "kind": "ImageStreamTag", - "name": "origin-ruby-sample:latest" - } - }, - "resources": {} - }, - "status": { - "lastVersion": 1 - } -} diff --git a/src/test/resources/samples/openshift3/v1beta3_deployment_config.json b/src/test/resources/samples/openshift3/v1beta3_deployment_config.json deleted file mode 100644 index e5d1b3f0..00000000 --- a/src/test/resources/samples/openshift3/v1beta3_deployment_config.json +++ /dev/null @@ -1,83 +0,0 @@ -{ - "kind": "DeploymentConfig", - "apiVersion": "v1beta3", - "metadata": { - "name": "database", - "namespace": "test", - "selfLink": "/osapi/v1beta1/deploymentConfigs/database?namespace=test", - "uid": "87c13e02-f41a-11e4-bc91-080027893417", - "resourceVersion": "58335", - "creationTimestamp": "2015-05-06T18:05:51Z", - "labels": { - "template": "application-template-stibuild" - } - }, - "spec": { - "strategy": { - "type": "Recreate", - "resources": {} - }, - "triggers": [ - { - "type": "ConfigChange" - } - ], - "replicas": 1, - "selector": { - "name": "database" - }, - "template": { - "metadata": { - "creationTimestamp": null, - "labels": { - "name": "database" - } - }, - "spec": { - "volumes": null, - "containers": [ - { - "name": "ruby-helloworld-database", - "image": "openshift/mysql-55-centos7", - "ports": [ - { - "containerPort": 3306, - "protocol": "TCP" - } - ], - "env": [ - { - "name": "MYSQL_USER", - "value": "userGCU" - }, - { - "name": "MYSQL_PASSWORD", - "value": "F6LJ6CDH" - }, - { - "name": "MYSQL_DATABASE", - "value": "root" - } - ], - "resources": {}, - "terminationMessagePath": "/dev/termination-log", - "imagePullPolicy": "IfNotPresent", - "capabilities": {} - } - ], - "restartPolicy": "Always", - "dnsPolicy": "ClusterFirst" - } - } - }, - "status": { - "latestVersion": 1, - "details": { - "causes": [ - { - "type": "ConfigChange" - } - ] - } - } -} \ No newline at end of file diff --git a/src/test/resources/samples/openshift3/v1beta3_image_stream.json b/src/test/resources/samples/openshift3/v1beta3_image_stream.json deleted file mode 100644 index 515e108a..00000000 --- a/src/test/resources/samples/openshift3/v1beta3_image_stream.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "kind": "ImageStream", - "apiVersion": "v1beta3", - "metadata": { - "name": "origin-ruby-sample", - "namespace": "test", - "selfLink": "/osapi/v1beta1/imageStreams/origin-ruby-sample?namespace=test", - "uid": "87ba7a8c-f41a-11e4-bc91-080027893417", - "resourceVersion": "58329", - "creationTimestamp": "2015-05-06T18:05:51Z", - "labels": { - "template": "application-template-stibuild" - } - }, - "spec": { - "dockerImageRepository": "172.30.159.174:5000/test/origin-ruby-sample" - }, - "status": { - "dockerImageRepository": "172.30.159.174:5000/test/origin-ruby-sample" - } -} \ No newline at end of file diff --git a/src/test/resources/samples/openshift3/v1beta3_persistent_volume.json b/src/test/resources/samples/openshift3/v1beta3_persistent_volume.json deleted file mode 100644 index 76f8f0bf..00000000 --- a/src/test/resources/samples/openshift3/v1beta3_persistent_volume.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "apiVersion": "v1beta3", - "kind": "PersistentVolume", - "metadata": { - "name": "pv0003" - }, - "spec": { - "capacity": { - "storage": "13Pi" - }, - "accessModes": [ - "ReadWriteOnce" - ], - "persistentVolumeReclaimPolicy": "Recycle", - "nfs": { - "path": "/tmp", - "server": "172.17.0.2" - } - } -} diff --git a/src/test/resources/samples/openshift3/v1beta3_pod.json b/src/test/resources/samples/openshift3/v1beta3_pod.json deleted file mode 100644 index dd4aca5b..00000000 --- a/src/test/resources/samples/openshift3/v1beta3_pod.json +++ /dev/null @@ -1,108 +0,0 @@ -{ - "kind": "Pod", - "apiVersion": "v1beta3", - "metadata": { - "name": "ruby-sample-build-1", - "namespace": "test", - "selfLink": "/api/v1beta1/pods/ruby-sample-build-1?namespace=test", - "uid": "44d68d4c-f41b-11e4-a871-080027893417", - "resourceVersion": "58407", - "creationTimestamp": "2015-05-06T18:11:08Z", - "labels": { - "build": "ruby-sample-build-1", - "buildconfig": "ruby-sample-build", - "name": "ruby-sample-build", - "template": "application-template-stibuild" - } - }, - "spec": { - "volumes": [ - { - "name": "docker-socket", - "hostPath": { - "path": "/var/run/docker.sock" - }, - "emptyDir": null, - "gcePersistentDisk": null, - "gitRepo": null, - "secret": null, - "nfs": null, - "iscsi": null, - "glusterfs": null - } - ], - "containers": [ - { - "name": "sti-build", - "image": "openshift/origin-sti-builder:v0.5", - "args": [ - "--loglevel=0" - ], - "ports": [ - { - "name" : "http", - "containerPort": 8080, - "protocol": "TCP" - } - ], - "env": [ - { - "name": "BUILD", - "value": "{\"kind\":\"Build\",\"apiVersion\":\"v1beta1\",\"metadata\":{\"name\":\"ruby-sample-build-1\",\"namespace\":\"test\",\"selfLink\":\"/osapi/v1beta1/builds/ruby-sample-build-1?namespace=test\",\"uid\":\"44d28bfd-f41b-11e4-a871-080027893417\",\"resourceVersion\":\"58370\",\"creationTimestamp\":\"2015-05-06T18:11:08Z\",\"labels\":{\"buildconfig\":\"ruby-sample-build\",\"name\":\"ruby-sample-build\",\"template\":\"application-template-stibuild\"}},\"parameters\":{\"source\":{\"type\":\"Git\",\"git\":{\"uri\":\"git://github.com/openshift/ruby-hello-world.git\"}},\"strategy\":{\"type\":\"STI\",\"stiStrategy\":{\"builderImage\":\"openshift/ruby-20-centos7:latest\",\"image\":\"openshift/ruby-20-centos7:latest\"}},\"output\":{\"to\":{\"kind\":\"ImageStream\",\"name\":\"origin-ruby-sample\"},\"dockerImageReference\":\"172.30.159.174:5000/test/origin-ruby-sample\",\"imageTag\":\"test/origin-ruby-sample\",\"registry\":\"172.30.159.174:5000\"},\"resources\":{}},\"status\":\"Pending\",\"duration\":0,\"config\":{\"kind\":\"BuildConfig\",\"namespace\":\"test\",\"name\":\"ruby-sample-build\"}}" - }, - { - "name": "SOURCE_REPOSITORY", - "value": "git://github.com/openshift/ruby-hello-world.git" - }, - { - "name": "BUILD_LOGLEVEL", - "value": "0" - } - ], - "resources": {}, - "volumeMounts": [ - { - "name": "docker-socket", - "mountPath": "/var/run/docker.sock" - } - ], - "terminationMessagePath": "/dev/termination-log", - "privileged": true, - "imagePullPolicy": "IfNotPresent", - "capabilities": {} - } - ], - "restartPolicy": "Never", - "dnsPolicy": "ClusterFirst", - "host": "openshiftdev.local" - }, - "status": { - "phase": "Failed", - "Condition": [ - { - "type": "Ready", - "status": "False" - } - ], - "hostIP": "127.0.0.1", - "podIP": "172.17.0.2", - "containerStatuses": [ - { - "name": "sti-build", - "state": { - "termination": { - "exitCode": 255, - "startedAt": "2015-05-06T18:12:42Z", - "finishedAt": "2015-05-06T18:13:56Z" - } - }, - "lastState": {}, - "ready": false, - "restartCount": 0, - "image": "openshift/origin-sti-builder:v0.5", - "imageID": "docker://c14cdbc8674ce37e02bff9a6b44c67eae25c4cd07e0034fa5762d0090248e393", - "containerID": "docker://296e5aae27673a2b59f3812ac0b6f0b924db4101690e3d0be300bb38a31c0f54" - } - ] - } -} \ No newline at end of file diff --git a/src/test/resources/samples/openshift3/v1beta3_project.json b/src/test/resources/samples/openshift3/v1beta3_project.json deleted file mode 100644 index 5f59f910..00000000 --- a/src/test/resources/samples/openshift3/v1beta3_project.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "kind": "Project", - "apiVersion": "v1beta3", - "metadata": { - "name": "test", - "selfLink": "/osapi/v1beta3/projects/test", - "uid": "af9a59ac-1f5d-11e5-8f6c-080027893417", - "resourceVersion": "207", - "creationTimestamp": "2015-06-30T19:24:54Z", - "annotations": { - "openshift.io/description": "This is an example project to demonstrate OpenShift v3", - "openshift.io/display-name": "OpenShift 3 Sample", - "openshift.io/sa.scc.mcs": "s0:c6,c0", - "openshift.io/sa.scc.uid-range": "1000030000/10000" - } - }, - "spec": { - "finalizers": [ - "openshift.io/origin", - "kubernetes" - ] - }, - "status": { - "phase": "Active" - } -} diff --git a/src/test/resources/samples/openshift3/v1beta3_project_request.json b/src/test/resources/samples/openshift3/v1beta3_project_request.json deleted file mode 100644 index fb0e75cd..00000000 --- a/src/test/resources/samples/openshift3/v1beta3_project_request.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "kind": "ProjectRequest", - "apiVersion": "v1beta3", - "metadata": { - "name": "test", - }, - "displayName": "the display name", - "description": "The project description" -} diff --git a/src/test/resources/samples/openshift3/v1beta3_pvc.json b/src/test/resources/samples/openshift3/v1beta3_pvc.json deleted file mode 100644 index e35e0126..00000000 --- a/src/test/resources/samples/openshift3/v1beta3_pvc.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "kind": "PersistentVolumeClaim", - "apiVersion": "v1beta3", - "metadata": { - "name": "my-amq-claim", - "namespace": "hello-world", - "selfLink": "/api/v1beta3/namespaces/hello-world/persistentvolumeclaims/my-amq-claim", - "uid": "8e0d2780-531a-11e5-8a7f-080027893417", - "resourceVersion": "74493", - "creationTimestamp": "2015-09-04T15:35:22Z", - "labels": { - "application": "foo" - } - }, - "spec": { - "accessModes": [ - "ReadWriteOnce" - ], - "resources": { - "requests": { - "storage": "15m" - } - } - }, - "status": { - "phase": "Pending" - } -} diff --git a/src/test/resources/samples/openshift3/v1beta3_replication_controller.json b/src/test/resources/samples/openshift3/v1beta3_replication_controller.json deleted file mode 100644 index 5287790a..00000000 --- a/src/test/resources/samples/openshift3/v1beta3_replication_controller.json +++ /dev/null @@ -1,83 +0,0 @@ -{ - "kind": "ReplicationController", - "apiVersion": "v1beta3", - "metadata": { - "name": "database-1", - "namespace": "test", - "selfLink": "/api/v1beta1/replicationControllers/database-1?namespace=test", - "uid": "87ce9449-f41a-11e4-bc91-080027893417", - "resourceVersion": "58400", - "creationTimestamp": "2015-05-06T18:05:51Z", - "labels": { - "template": "application-template-stibuild" - }, - "annotations": { - "deploymentConfig": "database", - "deploymentStatus": "Failed", - "deploymentVersion": "1", - "encodedDeploymentConfig": "{\"kind\":\"DeploymentConfig\",\"apiVersion\":\"v1beta1\",\"metadata\":{\"name\":\"database\",\"namespace\":\"test\",\"selfLink\":\"/osapi/v1beta1/deploymentConfigs/database?namespace=test\",\"uid\":\"87c13e02-f41a-11e4-bc91-080027893417\",\"resourceVersion\":\"58335\",\"creationTimestamp\":\"2015-05-06T18:05:51Z\",\"labels\":{\"template\":\"application-template-stibuild\"}},\"triggers\":[{\"type\":\"ConfigChange\"}],\"template\":{\"strategy\":{\"type\":\"Recreate\",\"resources\":{}},\"controllerTemplate\":{\"replicas\":1,\"replicaSelector\":{\"name\":\"database\"},\"podTemplate\":{\"desiredState\":{\"manifest\":{\"version\":\"v1beta2\",\"id\":\"\",\"volumes\":null,\"containers\":[{\"name\":\"ruby-helloworld-database\",\"image\":\"openshift/mysql-55-centos7\",\"ports\":[{\"containerPort\":3306,\"protocol\":\"TCP\"}],\"env\":[{\"name\":\"MYSQL_USER\",\"key\":\"MYSQL_USER\",\"value\":\"userGCU\"},{\"name\":\"MYSQL_PASSWORD\",\"key\":\"MYSQL_PASSWORD\",\"value\":\"F6LJ6CDH\"},{\"name\":\"MYSQL_DATABASE\",\"key\":\"MYSQL_DATABASE\",\"value\":\"root\"}],\"resources\":{},\"terminationMessagePath\":\"/dev/termination-log\",\"imagePullPolicy\":\"PullIfNotPresent\",\"capabilities\":{}}],\"restartPolicy\":{\"always\":{}},\"dnsPolicy\":\"ClusterFirst\"}},\"labels\":{\"name\":\"database\"}}}},\"latestVersion\":1,\"details\":{\"causes\":[{\"type\":\"ConfigChange\"}]}}", - "pod": "deploy-database-1aozvq" - } - }, - "spec": { - "replicas": 1, - "selector": { - "deployment": "database-1", - "deploymentconfig": "database", - "name": "database" - }, - "template": { - "metadata": { - "creationTimestamp": null, - "labels": { - "deployment": "database-1", - "deploymentconfig": "database", - "name": "database" - }, - "annotations": { - "deployment": "database-1", - "deploymentConfig": "database", - "deploymentVersion": "1" - } - }, - "spec": { - "volumes": null, - "containers": [ - { - "name": "ruby-helloworld-database", - "image": "openshift/mysql-55-centos7", - "ports": [ - { - "containerPort": 3306, - "protocol": "TCP" - } - ], - "env": [ - { - "name": "MYSQL_USER", - "value": "userGCU" - }, - { - "name": "MYSQL_PASSWORD", - "value": "F6LJ6CDH" - }, - { - "name": "MYSQL_DATABASE", - "value": "root" - } - ], - "resources": {}, - "terminationMessagePath": "/dev/termination-log", - "imagePullPolicy": "IfNotPresent", - "capabilities": {} - } - ], - "restartPolicy": "Always", - "dnsPolicy": "ClusterFirst" - } - } - }, - "status": { - "replicas": 2 - } -} \ No newline at end of file diff --git a/src/test/resources/samples/openshift3/v1beta3_route.json b/src/test/resources/samples/openshift3/v1beta3_route.json deleted file mode 100644 index e6bd3b27..00000000 --- a/src/test/resources/samples/openshift3/v1beta3_route.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "kind": "Route", - "apiVersion": "v1beta3", - "metadata": { - "name": "route-edge", - "namespace": "int-test-8805", - "selfLink": "/osapi/v1beta1/routes/route-edge?namespace=int-test-8805", - "uid": "3282de5a-f5b7-11e4-a898-080027893417", - "resourceVersion": "1697", - "creationTimestamp": "2015-05-08T19:19:50Z", - "labels": { - "mytemplate": "myvalue", - "template": "application-template-stibuild" - } - }, - "spec": { - "host": "www.example.com", - "path": "/abc", - "to": { - "kind": "Service", - "name": "frontend" - }, - "tls": { - "termination": "edge", - "certificate": "theCert", - "key": "theKey", - "caCertificate": "theCACert" - } - }, - "status": {} -} \ No newline at end of file diff --git a/src/test/resources/samples/openshift3/v1beta3_route_wo_tls.json b/src/test/resources/samples/openshift3/v1beta3_route_wo_tls.json deleted file mode 100644 index 07da87f1..00000000 --- a/src/test/resources/samples/openshift3/v1beta3_route_wo_tls.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "kind": "Route", - "apiVersion": "v1beta3", - "metadata": { - "name": "route-edge", - "namespace": "int-test-8805", - "selfLink": "/osapi/v1beta1/routes/route-edge?namespace=int-test-8805", - "uid": "3282de5a-f5b7-11e4-a898-080027893417", - "resourceVersion": "1697", - "creationTimestamp": "2015-05-08T19:19:50Z", - "labels": { - "mytemplate": "myvalue", - "template": "application-template-stibuild" - } - }, - "spec": { - "host": "www.example.com", - "path": "/abc", - "to": { - "kind": "Service", - "name": "frontend" - }, - }, - "status": {} -} \ No newline at end of file diff --git a/src/test/resources/samples/openshift3/v1beta3_secret.json b/src/test/resources/samples/openshift3/v1beta3_secret.json deleted file mode 100644 index 77e472f2..00000000 --- a/src/test/resources/samples/openshift3/v1beta3_secret.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "kind": "Secret", - "apiVersion": "v1beta3", - "metadata": { - "name": "ssh-key-secret", - "namespace": "jpechane", - "selfLink": "/api/v1beta3/namespaces/jpechane/secrets/ssh-key-secret", - "uid": "973d9e78-09e4-11e5-8c4f-3c970e192b12", - "resourceVersion": "36074", - "creationTimestamp": "2015-06-03T11:35:09Z" - }, - "data": { - "id-rsa": "dmFsdWUtMg0KDQo=", - "id-rsa.pub": "dmFsdWUtMQ0K" - }, - "type": "Opaque" -} \ No newline at end of file diff --git a/src/test/resources/samples/openshift3/v1beta3_service.json b/src/test/resources/samples/openshift3/v1beta3_service.json deleted file mode 100644 index 67a0a6ae..00000000 --- a/src/test/resources/samples/openshift3/v1beta3_service.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "kind": "Service", - "apiVersion": "v1beta3", - "metadata": { - "name": "database", - "namespace": "test", - "selfLink": "/api/v1beta1/services/database?namespace=test", - "uid": "87bebd68-f41a-11e4-bc91-080027893417", - "resourceVersion": "58333", - "creationTimestamp": "2015-05-06T18:05:51Z", - "labels": { - "template": "application-template-stibuild" - } - }, - "spec": { - "ports": [ - { - "name": "db", - "protocol": "TCP", - "port": 5434, - "targetPort": 3306 - }, - { - "name": "other", - "protocol": "TCP", - "port": 9999, - "targetPort": 8888, - "nodePort": 0 - } - ], - "selector": { - "name": "database" - }, - "portalIP": "172.30.174.188", - "sessionAffinity": "None" - }, - "status": {} -} \ No newline at end of file diff --git a/src/test/resources/samples/openshift3/v1beta3_service_account.json b/src/test/resources/samples/openshift3/v1beta3_service_account.json deleted file mode 100644 index 65fb6066..00000000 --- a/src/test/resources/samples/openshift3/v1beta3_service_account.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "kind": "ServiceAccount", - "apiVersion": "v1beta3", - "metadata": { - "name": "deployer", - "namespace": "default", - "selfLink": "/api/v1/namespaces/default/serviceaccounts/deployer", - "uid": "1e45af09-1961-11e5-8647-525400ed540c", - "resourceVersion": "117", - "creationTimestamp": "2015-06-23T04:34:21Z" - }, - "secrets": [ - { - "name": "deployer-token-luifi" - }, - { - "name": "deployer-dockercfg-jq62e" - } - ], - "imagePullSecrets": [ - { - "name": "deployer-dockercfg-jq62e" - } - ] -} diff --git a/src/test/resources/samples/openshift3/v1beta3_status.json b/src/test/resources/samples/openshift3/v1beta3_status.json deleted file mode 100644 index 2b2755a3..00000000 --- a/src/test/resources/samples/openshift3/v1beta3_status.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "kind": "Status", - "apiVersion": "v1beta3", - "metadata": {}, - "status": "Failure", - "message": "\"/api/v1beta1/services/ruby-helloworld-sample\" is forbidden because foo cannot get on services with name \"ruby-helloworld-sample\" in default", - "reason": "Forbidden", - "details": {}, - "code": 403 -} \ No newline at end of file diff --git a/src/test/resources/samples/openshift3/v1beta3_template.json b/src/test/resources/samples/openshift3/v1beta3_template.json deleted file mode 100644 index d22b455c..00000000 --- a/src/test/resources/samples/openshift3/v1beta3_template.json +++ /dev/null @@ -1,444 +0,0 @@ -{ - "kind": "Template", - "apiVersion": "v1beta3", - "metadata": { - "name": "ruby-helloworld-sample", - "namespace": "openshift", - "selfLink": "/osapi/v1beta3/namespaces/openshift/templates/ruby-helloworld-sample", - "uid": "d38531fa-3d1c-11e5-8539-080027bdffff", - "resourceVersion": "22556", - "creationTimestamp": "2015-08-07T15:56:12Z", - "annotations": { - "description": "This example shows how to create a simple ruby application in openshift origin v3", - "iconClass": "icon-ruby", - "tags": "instant-app,ruby,mysql" - }, - "labels" : { - "foo" : "bar", - "abc" : "xyz" - } - }, - "objects": [ - { - "kind": "Service", - "apiVersion": "v1", - "metadata": { - "name": "frontend", - "creationTimestamp": null - }, - "spec": { - "ports": [ - { - "name": "web", - "protocol": "TCP", - "port": 5432, - "targetPort": 8080, - "nodePort": 0 - } - ], - "selector": { - "name": "frontend" - }, - "portalIP": "", - "type": "ClusterIP", - "sessionAffinity": "None" - }, - "status": { - "loadBalancer": {} - } - }, - { - "kind": "Route", - "apiVersion": "v1", - "metadata": { - "name": "route-edge", - "creationTimestamp": null - }, - "spec": { - "host": "www.example.com", - "to": { - "kind": "Service", - "name": "frontend" - }, - "tls": { - "termination": "edge", - "certificate": "-----BEGIN CERTIFICATE-----\nMIIDIjCCAgqgAwIBAgIBATANBgkqhkiG9w0BAQUFADCBoTELMAkGA1UEBhMCVVMx\nCzAJBgNVBAgMAlNDMRUwEwYDVQQHDAxEZWZhdWx0IENpdHkxHDAaBgNVBAoME0Rl\nZmF1bHQgQ29tcGFueSBMdGQxEDAOBgNVBAsMB1Rlc3QgQ0ExGjAYBgNVBAMMEXd3\ndy5leGFtcGxlY2EuY29tMSIwIAYJKoZIhvcNAQkBFhNleGFtcGxlQGV4YW1wbGUu\nY29tMB4XDTE1MDExMjE0MTk0MVoXDTE2MDExMjE0MTk0MVowfDEYMBYGA1UEAwwP\nd3d3LmV4YW1wbGUuY29tMQswCQYDVQQIDAJTQzELMAkGA1UEBhMCVVMxIjAgBgkq\nhkiG9w0BCQEWE2V4YW1wbGVAZXhhbXBsZS5jb20xEDAOBgNVBAoMB0V4YW1wbGUx\nEDAOBgNVBAsMB0V4YW1wbGUwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAMrv\ngu6ZTTefNN7jjiZbS/xvQjyXjYMN7oVXv76jbX8gjMOmg9m0xoVZZFAE4XyQDuCm\n47VRx5Qrf/YLXmB2VtCFvB0AhXr5zSeWzPwaAPrjA4ebG+LUo24ziS8KqNxrFs1M\nmNrQUgZyQC6XIe1JHXc9t+JlL5UZyZQC1IfaJulDAgMBAAGjDTALMAkGA1UdEwQC\nMAAwDQYJKoZIhvcNAQEFBQADggEBAFCi7ZlkMnESvzlZCvv82Pq6S46AAOTPXdFd\nTMvrh12E1sdVALF1P1oYFJzG1EiZ5ezOx88fEDTW+Lxb9anw5/KJzwtWcfsupf1m\nV7J0D3qKzw5C1wjzYHh9/Pz7B1D0KthQRATQCfNf8s6bbFLaw/dmiIUhHLtIH5Qc\nyfrejTZbOSP77z8NOWir+BWWgIDDB2//3AkDIQvT20vmkZRhkqSdT7et4NmXOX/j\njhPti4b2Fie0LeuvgaOdKjCpQQNrYthZHXeVlOLRhMTSk3qUczenkKTOhvP7IS9q\n+Dzv5hqgSfvMG392KWh5f8xXfJNs4W5KLbZyl901MeReiLrPH3w=\n-----END CERTIFICATE-----", - "key": "-----BEGIN PRIVATE KEY-----\nMIICeAIBADANBgkqhkiG9w0BAQEFAASCAmIwggJeAgEAAoGBAMrvgu6ZTTefNN7j\njiZbS/xvQjyXjYMN7oVXv76jbX8gjMOmg9m0xoVZZFAE4XyQDuCm47VRx5Qrf/YL\nXmB2VtCFvB0AhXr5zSeWzPwaAPrjA4ebG+LUo24ziS8KqNxrFs1MmNrQUgZyQC6X\nIe1JHXc9t+JlL5UZyZQC1IfaJulDAgMBAAECgYEAnxOjEj/vrLNLMZE1Q9H7PZVF\nWdP/JQVNvQ7tCpZ3ZdjxHwkvf//aQnuxS5yX2Rnf37BS/TZu+TIkK4373CfHomSx\nUTAn2FsLmOJljupgGcoeLx5K5nu7B7rY5L1NHvdpxZ4YjeISrRtEPvRakllENU5y\ngJE8c2eQOx08ZSRE4TkCQQD7dws2/FldqwdjJucYijsJVuUdoTqxP8gWL6bB251q\nelP2/a6W2elqOcWId28560jG9ZS3cuKvnmu/4LG88vZFAkEAzphrH3673oTsHN+d\nuBd5uyrlnGjWjuiMKv2TPITZcWBjB8nJDSvLneHF59MYwejNNEof2tRjgFSdImFH\nmi995wJBAMtPjW6wiqRz0i41VuT9ZgwACJBzOdvzQJfHgSD9qgFb1CU/J/hpSRIM\nkYvrXK9MbvQFvG6x4VuyT1W8mpe1LK0CQAo8VPpffhFdRpF7psXLK/XQ/0VLkG3O\nKburipLyBg/u9ZkaL0Ley5zL5dFBjTV2Qkx367Ic2b0u9AYTCcgi2DsCQQD3zZ7B\nv7BOm7MkylKokY2MduFFXU0Bxg6pfZ7q3rvg8gqhUFbaMStPRYg6myiDiW/JfLhF\nTcFT4touIo7oriFJ\n-----END PRIVATE KEY-----", - "caCertificate": "-----BEGIN CERTIFICATE-----\nMIIEFzCCAv+gAwIBAgIJALK1iUpF2VQLMA0GCSqGSIb3DQEBBQUAMIGhMQswCQYD\nVQQGEwJVUzELMAkGA1UECAwCU0MxFTATBgNVBAcMDERlZmF1bHQgQ2l0eTEcMBoG\nA1UECgwTRGVmYXVsdCBDb21wYW55IEx0ZDEQMA4GA1UECwwHVGVzdCBDQTEaMBgG\nA1UEAwwRd3d3LmV4YW1wbGVjYS5jb20xIjAgBgkqhkiG9w0BCQEWE2V4YW1wbGVA\nZXhhbXBsZS5jb20wHhcNMTUwMTEyMTQxNTAxWhcNMjUwMTA5MTQxNTAxWjCBoTEL\nMAkGA1UEBhMCVVMxCzAJBgNVBAgMAlNDMRUwEwYDVQQHDAxEZWZhdWx0IENpdHkx\nHDAaBgNVBAoME0RlZmF1bHQgQ29tcGFueSBMdGQxEDAOBgNVBAsMB1Rlc3QgQ0Ex\nGjAYBgNVBAMMEXd3dy5leGFtcGxlY2EuY29tMSIwIAYJKoZIhvcNAQkBFhNleGFt\ncGxlQGV4YW1wbGUuY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA\nw2rK1J2NMtQj0KDug7g7HRKl5jbf0QMkMKyTU1fBtZ0cCzvsF4CqV11LK4BSVWaK\nrzkaXe99IVJnH8KdOlDl5Dh/+cJ3xdkClSyeUT4zgb6CCBqg78ePp+nN11JKuJlV\nIG1qdJpB1J5O/kCLsGcTf7RS74MtqMFo96446Zvt7YaBhWPz6gDaO/TUzfrNcGLA\nEfHVXkvVWqb3gqXUztZyVex/gtP9FXQ7gxTvJml7UkmT0VAFjtZnCqmFxpLZFZ15\n+qP9O7Q2MpsGUO/4vDAuYrKBeg1ZdPSi8gwqUP2qWsGd9MIWRv3thI2903BczDc7\nr8WaIbm37vYZAS9G56E4+wIDAQABo1AwTjAdBgNVHQ4EFgQUugLrSJshOBk5TSsU\nANs4+SmJUGwwHwYDVR0jBBgwFoAUugLrSJshOBk5TSsUANs4+SmJUGwwDAYDVR0T\nBAUwAwEB/zANBgkqhkiG9w0BAQUFAAOCAQEAaMJ33zAMV4korHo5aPfayV3uHoYZ\n1ChzP3eSsF+FjoscpoNSKs91ZXZF6LquzoNezbfiihK4PYqgwVD2+O0/Ty7UjN4S\nqzFKVR4OS/6lCJ8YncxoFpTntbvjgojf1DEataKFUN196PAANc3yz8cWHF4uvjPv\nWkgFqbIjb+7D1YgglNyovXkRDlRZl0LD1OQ0ZWhd4Ge1qx8mmmanoBeYZ9+DgpFC\nj9tQAbS867yeOryNe7sEOIpXAAqK/DTu0hB6+ySsDfMo4piXCc2aA/eI2DCuw08e\nw17Dz9WnupZjVdwTKzDhFgJZMLDqn37HQnT6EemLFqbcR0VPEnfyhDtZIQ==\n-----END CERTIFICATE-----" - } - }, - "status": {} - }, - { - "kind": "ImageStream", - "apiVersion": "v1", - "metadata": { - "name": "origin-ruby-sample", - "creationTimestamp": null - }, - "spec": {}, - "status": { - "dockerImageRepository": "" - } - }, - { - "kind": "ImageStream", - "apiVersion": "v1", - "metadata": { - "name": "ruby-20-centos7", - "creationTimestamp": null - }, - "spec": { - "dockerImageRepository": "openshift/ruby-20-centos7" - }, - "status": { - "dockerImageRepository": "" - } - }, - { - "kind": "BuildConfig", - "apiVersion": "v1", - "metadata": { - "name": "ruby-sample-build", - "creationTimestamp": null, - "labels": { - "name": "ruby-sample-build" - } - }, - "spec": { - "triggers": [ - { - "type": "GitHub", - "github": { - "secret": "secret101" - } - }, - { - "type": "Generic", - "generic": { - "secret": "secret101" - } - }, - { - "type": "ImageChange", - "imageChange": {} - } - ], - "source": { - "type": "Git", - "git": { - "uri": "https://github.com/openshift/ruby-hello-world.git" - } - }, - "strategy": { - "type": "Source", - "sourceStrategy": { - "from": { - "kind": "ImageStreamTag", - "name": "ruby-20-centos7:latest" - } - } - }, - "output": { - "to": { - "kind": "ImageStreamTag", - "name": "origin-ruby-sample:latest" - } - }, - "resources": {} - }, - "status": { - "lastVersion": 0 - } - }, - { - "kind": "DeploymentConfig", - "apiVersion": "v1", - "metadata": { - "name": "frontend", - "creationTimestamp": null - }, - "spec": { - "strategy": { - "type": "Rolling", - "rollingParams": { - "updatePeriodSeconds": 1, - "intervalSeconds": 1, - "timeoutSeconds": 120, - "pre": { - "failurePolicy": "Abort", - "execNewPod": { - "command": [ - "/bin/true" - ], - "env": [ - { - "name": "CUSTOM_VAR1", - "value": "custom_value1" - } - ], - "containerName": "ruby-helloworld" - } - }, - "post": { - "failurePolicy": "Ignore", - "execNewPod": { - "command": [ - "/bin/false" - ], - "env": [ - { - "name": "CUSTOM_VAR2", - "value": "custom_value2" - } - ], - "containerName": "ruby-helloworld" - } - } - }, - "resources": {} - }, - "triggers": [ - { - "type": "ImageChange", - "imageChangeParams": { - "automatic": true, - "containerNames": [ - "ruby-helloworld" - ], - "from": { - "kind": "ImageStreamTag", - "name": "origin-ruby-sample:latest" - } - } - }, - { - "type": "ConfigChange" - } - ], - "replicas": 2, - "selector": { - "name": "frontend" - }, - "template": { - "metadata": { - "creationTimestamp": null, - "labels": { - "name": "frontend" - } - }, - "spec": { - "containers": [ - { - "name": "ruby-helloworld", - "image": "origin-ruby-sample", - "ports": [ - { - "containerPort": 8080, - "protocol": "TCP" - } - ], - "env": [ - { - "name": "ADMIN_USERNAME", - "value": "${ADMIN_USERNAME}" - }, - { - "name": "ADMIN_PASSWORD", - "value": "${ADMIN_PASSWORD}" - }, - { - "name": "MYSQL_USER", - "value": "${MYSQL_USER}" - }, - { - "name": "MYSQL_PASSWORD", - "value": "${MYSQL_PASSWORD}" - }, - { - "name": "MYSQL_DATABASE", - "value": "${MYSQL_DATABASE}" - } - ], - "resources": {}, - "terminationMessagePath": "/dev/termination-log", - "imagePullPolicy": "IfNotPresent", - "securityContext": { - "capabilities": {}, - "privileged": false - } - } - ], - "restartPolicy": "Always", - "dnsPolicy": "ClusterFirst" - } - } - }, - "status": {} - }, - { - "kind": "Service", - "apiVersion": "v1", - "metadata": { - "name": "database", - "creationTimestamp": null - }, - "spec": { - "ports": [ - { - "name": "db", - "protocol": "TCP", - "port": 5434, - "targetPort": 3306, - "nodePort": 0 - } - ], - "selector": { - "name": "database" - }, - "portalIP": "", - "type": "ClusterIP", - "sessionAffinity": "None" - }, - "status": { - "loadBalancer": {} - } - }, - { - "kind": "DeploymentConfig", - "apiVersion": "v1", - "metadata": { - "name": "database", - "creationTimestamp": null - }, - "spec": { - "strategy": { - "type": "Recreate", - "recreateParams": { - "pre": { - "failurePolicy": "Abort", - "execNewPod": { - "command": [ - "/bin/true" - ], - "env": [ - { - "name": "CUSTOM_VAR1", - "value": "custom_value1" - } - ], - "containerName": "ruby-helloworld-database" - } - }, - "post": { - "failurePolicy": "Ignore", - "execNewPod": { - "command": [ - "/bin/false" - ], - "env": [ - { - "name": "CUSTOM_VAR2", - "value": "custom_value2" - } - ], - "containerName": "ruby-helloworld-database" - } - } - }, - "resources": {} - }, - "triggers": [ - { - "type": "ConfigChange" - } - ], - "replicas": 1, - "selector": { - "name": "database" - }, - "template": { - "metadata": { - "creationTimestamp": null, - "labels": { - "name": "database" - } - }, - "spec": { - "containers": [ - { - "name": "ruby-helloworld-database", - "image": "openshift/mysql-55-centos7:latest", - "ports": [ - { - "containerPort": 3306, - "protocol": "TCP" - } - ], - "env": [ - { - "name": "MYSQL_USER", - "value": "${MYSQL_USER}" - }, - { - "name": "MYSQL_PASSWORD", - "value": "${MYSQL_PASSWORD}" - }, - { - "name": "MYSQL_DATABASE", - "value": "${MYSQL_DATABASE}" - } - ], - "resources": {}, - "terminationMessagePath": "/dev/termination-log", - "imagePullPolicy": "Always", - "securityContext": { - "capabilities": {}, - "privileged": false - } - } - ], - "restartPolicy": "Always", - "dnsPolicy": "ClusterFirst" - } - } - }, - "status": {} - } - ], - "parameters": [ - { - "name": "ADMIN_USERNAME", - "description": "administrator username", - "generate": "expression", - "from": "admin[A-Z0-9]{3}" - }, - { - "name": "ADMIN_PASSWORD", - "description": "administrator password", - "generate": "expression", - "from": "[a-zA-Z0-9]{8}" - }, - { - "name": "MYSQL_USER", - "description": "database username", - "generate": "expression", - "from": "user[A-Z0-9]{3}" - }, - { - "name": "MYSQL_PASSWORD", - "description": "database password", - "generate": "expression", - "from": "[a-zA-Z0-9]{8}", - "required" : true - }, - { - "name": "MYSQL_DATABASE", - "description": "database name", - "value": "root" - } - ], - "labels": { - "template": "application-template-stibuild" - } -} diff --git a/src/test/resources/samples/openshift3/v1beta3_unrecognized.json b/src/test/resources/samples/openshift3/v1beta3_unrecognized.json deleted file mode 100644 index 3c78b731..00000000 --- a/src/test/resources/samples/openshift3/v1beta3_unrecognized.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "kind": "IMadeThisOneUp", - "apiVersion": "v1", - "metadata": { - "name": "database", - "namespace": "test", - "creationTimestamp": "2015-06-10T20:00:39Z", - "labels": { - "foo": "bar", - "template": "application-template-stibuild" - } - }, - "spec": { - "ports": [ - { - "name": "db", - "protocol": "TCP", - "port": 5434, - "targetPort": 3306, - "nodePort": 0 - }, - { - "name": "other", - "protocol": "TCP", - "port": 9999, - "targetPort": 8888, - "nodePort": 0 - } - ], - "selector": { - "name": "database" - }, - "portalIP": "172.30.57.114", - "type": "ClusterIP", - "sessionAffinity": "None" - }, - "status": { - "loadBalancer": {} - } -} \ No newline at end of file diff --git a/src/test/resources/samples/openshift3/v1beta3_user.json b/src/test/resources/samples/openshift3/v1beta3_user.json deleted file mode 100644 index 64916b9e..00000000 --- a/src/test/resources/samples/openshift3/v1beta3_user.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "kind": "User", - "apiVersion": "v1beta3", - "metadata": { - "name": "jordan", - "selfLink": "/osapi/v1beta3/users/jordan", - "uid": "c09e427e-fff6-11e4-bde0-3c970e4b7ffe", - "resourceVersion": "744", - "creationTimestamp": "2015-05-21T20:19:58Z" - }, - "identities": [ - "anypassword:jordan" - ], - "fullName" : "Foo Master", - "groups": null -} \ No newline at end of file