ttomcat-1778514358873.zip-extract/apache-tomcat-11.0.18-src/test/org/apache/catalina/tribes/membership/cloud/TestKubernetesJson.java

Path
ttomcat-1778514358873.zip-extract/apache-tomcat-11.0.18-src/test/org/apache/catalina/tribes/membership/cloud/TestKubernetesJson.java
Status
scanned
Type
file
Name
TestKubernetesJson.java
Extension
.java
Programming language
Java
Mime type
text/plain
File type
ASCII text, with CRLF line terminators
Tag

      
    
Rootfs path

      
    
Size
17872 (17.5 KB)
MD5
a21da0d9ba556fc1c3aafeb05b8e793e
SHA1
c287b3eaa8b62dec7b5d49152fbe9c9927d32bab
SHA256
d48d410f9d32a5ed497f4443091abb851020ea01b1680d215b29bc5c1a543c7e
SHA512

      
    
SHA1_git
f2ce592d7f08916a45e9d2f8cd475a29763eaa10
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
TestKubernetesJson.java | 17.5 KB |

/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.catalina.tribes.membership.cloud; import java.io.StringReader; import java.time.Instant; import java.util.ArrayList; import java.util.List; import org.junit.Assert; import org.junit.Test; import org.apache.catalina.tribes.membership.MemberImpl; public class TestKubernetesJson extends KubernetesMembershipProvider { private static final String OPENSHIFT_JSON_POD_LIST = "{ " + " \"kind\": \"PodList\", " + " \"apiVersion\": \"v1\", " + " \"metadata\": { " + " \"selfLink\": \"/api/v1/namespaces/tomcat-in-the-cloud/pods\", " + " \"resourceVersion\": \"1120453180\" " + " }, " + " \"items\": [ " + " { " + " \"metadata\": { " + " \"name\": \"tomcat-in-the-cloud-5bc6dc7cf8-ndpdm\", " + " \"generateName\": \"tomcat-in-the-cloud-5bc6dc7cf8-\", " + " \"namespace\": \"tomcat-in-the-cloud\", " + " \"selfLink\": \"/api/v1/namespaces/tomcat-in-the-cloud/pods/tomcat-in-the-cloud-5bc6dc7cf8-ndpdm\", " + " \"uid\": \"29cc7dec-cc8d-11e8-943e-02ec8e61afcf\", " + " \"resourceVersion\": \"1120373053\", " + " \"creationTimestamp\": \"2018-10-10T13:05:29Z\", " + " \"labels\": { " + " \"pod-template-hash\": \"1672873794\", " + " \"run\": \"tomcat-in-the-cloud\" " + " }, " + " \"annotations\": { " + " \"kubernetes.io/limit-ranger\": \"LimitRanger plugin set: cpu, memory request for container tomcat-in-the-cloud; cpu, memory limit for container tomcat-in-the-cloud\", " + " \"openshift.io/scc\": \"restricted\" " + " }, " + " \"ownerReferences\": [ " + " { " + " \"apiVersion\": \"apps/v1\", " + " \"kind\": \"ReplicaSet\", " + " \"name\": \"tomcat-in-the-cloud-5bc6dc7cf8\", " + " \"uid\": \"12c4fa68-cc8d-11e8-943e-02ec8e61afcf\", " + " \"controller\": true, " + " \"blockOwnerDeletion\": true " + " } " + " ] " + " }, " + " \"spec\": { " + " \"volumes\": [ " + " { " + " \"name\": \"default-token-n87wf\", " + " \"secret\": { " + " \"secretName\": \"default-token-n87wf\", " + " \"defaultMode\": 420 " + " } " + " } " + " ], " + " \"containers\": [ " + " { " + " \"name\": \"tomcat-in-the-cloud\", " + " \"image\": \"docker.io/jfclere/test\", " + " \"ports\": [ " + " { " + " \"containerPort\": 8080, " + " \"protocol\": \"TCP\" " + " } " + " ], " + " \"resources\": { " + " \"limits\": { " + " \"cpu\": \"1\", " + " \"memory\": \"512Mi\" " + " }, " + " \"requests\": { " + " \"cpu\": \"20m\", " + " \"memory\": \"256Mi\" " + " } " + " }, " + " \"volumeMounts\": [ " + " { " + " \"name\": \"default-token-n87wf\", " + " \"readOnly\": true, " + " \"mountPath\": \"/var/run/secrets/kubernetes.io/serviceaccount\" " + " } " + " ], " + " \"terminationMessagePath\": \"/dev/termination-log\", " + " \"terminationMessagePolicy\": \"File\", " + " \"imagePullPolicy\": \"Always\", " + " \"securityContext\": { " + " \"capabilities\": { " + " \"drop\": [ " + " \"KILL\", " + " \"MKNOD\", " + " \"NET_RAW\", " + " \"SETGID\", " + " \"SETUID\" " + " ] " + " }, " + " \"runAsUser\": 1119270000 " + " } " + " } " + " ], " + " \"restartPolicy\": \"Always\", " + " \"terminationGracePeriodSeconds\": 30, " + " \"dnsPolicy\": \"ClusterFirst\", " + " \"nodeSelector\": { " + " \"type\": \"compute\" " + " }, " + " \"serviceAccountName\": \"default\", " + " \"serviceAccount\": \"default\", " + " \"nodeName\": \"ip-172-31-18-231.ca-central-1.compute.internal\", " + " \"securityContext\": { " + " \"seLinuxOptions\": { " + " \"level\": \"s0:c345,c295\" " + " }, " + " \"fsGroup\": 1119270000 " + " }, " + " \"imagePullSecrets\": [ " + " { " + " \"name\": \"default-dockercfg-lx7wg\" " + " } " + " ], " + " \"schedulerName\": \"default-scheduler\", " + " \"tolerations\": [ " + " { " + " \"key\": \"node.kubernetes.io/memory-pressure\", " + " \"operator\": \"Exists\", " + " \"effect\": \"NoSchedule\" " + " } " + " ], " + " \"priority\": 0 " + " }, " + " \"status\": { " + " \"phase\": \"Running\", " + " \"conditions\": [ " + " { " + " \"type\": \"Initialized\", " + " \"status\": \"True\", " + " \"lastProbeTime\": null, " + " \"lastTransitionTime\": \"2018-10-10T13:05:30Z\" " + " }, " + " { " + " \"type\": \"Ready\", " + " \"status\": \"True\", " + " \"lastProbeTime\": null, " + " \"lastTransitionTime\": \"2018-10-10T13:06:30Z\" " + " }, " + " { " + " \"type\": \"ContainersReady\", " + " \"status\": \"True\", " + " \"lastProbeTime\": null, " + " \"lastTransitionTime\": null " + " }, " + " { " + " \"type\": \"PodScheduled\", " + " \"status\": \"True\", " + " \"lastProbeTime\": null, " + " \"lastTransitionTime\": \"2018-10-10T13:05:30Z\" " + " } " + " ], " + " \"hostIP\": \"172.31.18.231\", " + " \"podIP\": \"10.130.140.153\", " + " \"startTime\": \"2018-10-10T13:05:30Z\", " + " \"containerStatuses\": [ " + " { " + " \"name\": \"tomcat-in-the-cloud\", " + " \"state\": { " + " \"running\": { " + " \"startedAt\": \"2018-10-10T13:06:29Z\" " + " } " + " }, " + " \"lastState\": { " + " " + " }, " + " \"ready\": true, " + " \"restartCount\": 0, " + " \"image\": \"docker.io/jfclere/test:latest\", " + " \"imageID\": \"docker.io/jfclere/test@sha256:d36155492516915ecf448fe62769f61b5f9ab795bc8ae1e72a199ee6485cbea2\", " + " \"containerID\": \"cri-o://a173e05e66730efd5e5df6e9b2681b5c37de44b81cc22f2455077b3008a5284c\" " + " } " + " ], " + " \"qosClass\": \"Burstable\" " + " } " + " }, " + " { " + " \"metadata\": { " + " \"name\": \"tomcat-in-the-cloud-5bc6dc7cf8-w454k\", " + " \"generateName\": \"tomcat-in-the-cloud-5bc6dc7cf8-\", " + " \"namespace\": \"tomcat-in-the-cloud\", " + " \"selfLink\": \"/api/v1/namespaces/tomcat-in-the-cloud/pods/tomcat-in-the-cloud-5bc6dc7cf8-w454k\", " + " \"uid\": \"12cd7ae2-cc8d-11e8-943e-02ec8e61afcf\", " + " \"resourceVersion\": \"1120369623\", " + " \"creationTimestamp\": \"2018-10-10T13:04:51Z\", " + " \"labels\": { " + " \"pod-template-hash\": \"1672873794\", " + " \"run\": \"tomcat-in-the-cloud\" " + " }, " + " \"annotations\": { " + " \"kubernetes.io/limit-ranger\": \"LimitRanger plugin set: cpu, memory request for container tomcat-in-the-cloud; cpu, memory limit for container tomcat-in-the-cloud\", " + " \"openshift.io/scc\": \"restricted\" " + " }, " + " \"ownerReferences\": [ " + " { " + " \"apiVersion\": \"apps/v1\", " + " \"kind\": \"ReplicaSet\", " + " \"name\": \"tomcat-in-the-cloud-5bc6dc7cf8\", " + " \"uid\": \"12c4fa68-cc8d-11e8-943e-02ec8e61afcf\", " + " \"controller\": true, " + " \"blockOwnerDeletion\": true " + " } " + " ] " + " }, " + " \"spec\": { " + " \"volumes\": [ " + " { " + " \"name\": \"default-token-n87wf\", " + " \"secret\": { " + " \"secretName\": \"default-token-n87wf\", " + " \"defaultMode\": 420 " + " } " + " } " + " ], " + " \"containers\": [ " + " { " + " \"name\": \"tomcat-in-the-cloud\", " + " \"image\": \"docker.io/jfclere/test\", " + " \"ports\": [ " + " { " + " \"containerPort\": 8080, " + " \"protocol\": \"TCP\" " + " } " + " ], " + " \"resources\": { " + " \"limits\": { " + " \"cpu\": \"1\", " + " \"memory\": \"512Mi\" " + " }, " + " \"requests\": { " + " \"cpu\": \"20m\", " + " \"memory\": \"256Mi\" " + " } " + " }, " + " \"volumeMounts\": [ " + " { " + " \"name\": \"default-token-n87wf\", " + " \"readOnly\": true, " + " \"mountPath\": \"/var/run/secrets/kubernetes.io/serviceaccount\" " + " } " + " ], " + " \"terminationMessagePath\": \"/dev/termination-log\", " + " \"terminationMessagePolicy\": \"File\", " + " \"imagePullPolicy\": \"Always\", " + " \"securityContext\": { " + " \"capabilities\": { " + " \"drop\": [ " + " \"KILL\", " + " \"MKNOD\", " + " \"NET_RAW\", " + " \"SETGID\", " + " \"SETUID\" " + " ] " + " }, " + " \"runAsUser\": 1119270000 " + " } " + " } " + " ], " + " \"restartPolicy\": \"Always\", " + " \"terminationGracePeriodSeconds\": 30, " + " \"dnsPolicy\": \"ClusterFirst\", " + " \"nodeSelector\": { " + " \"type\": \"compute\" " + " }, " + " \"serviceAccountName\": \"default\", " + " \"serviceAccount\": \"default\", " + " \"nodeName\": \"ip-172-31-23-191.ca-central-1.compute.internal\", " + " \"securityContext\": { " + " \"seLinuxOptions\": { " + " \"level\": \"s0:c345,c295\" " + " }, " + " \"fsGroup\": 1119270000 " + " }, " + " \"imagePullSecrets\": [ " + " { " + " \"name\": \"default-dockercfg-lx7wg\" " + " } " + " ], " + " \"schedulerName\": \"default-scheduler\", " + " \"tolerations\": [ " + " { " + " \"key\": \"node.kubernetes.io/memory-pressure\", " + " \"operator\": \"Exists\", " + " \"effect\": \"NoSchedule\" " + " } " + " ], " + " \"priority\": 0 " + " }, " + " \"status\": { " + " \"phase\": \"Running\", " + " \"conditions\": [ " + " { " + " \"type\": \"Initialized\", " + " \"status\": \"True\", " + " \"lastProbeTime\": null, " + " \"lastTransitionTime\": \"2018-10-10T13:04:51Z\" " + " }, " + " { " + " \"type\": \"Ready\", " + " \"status\": \"True\", " + " \"lastProbeTime\": null, " + " \"lastTransitionTime\": \"2018-10-10T13:05:15Z\" " + " }, " + " { " + " \"type\": \"ContainersReady\", " + " \"status\": \"True\", " + " \"lastProbeTime\": null, " + " \"lastTransitionTime\": null " + " }, " + " { " + " \"type\": \"PodScheduled\", " + " \"status\": \"True\", " + " \"lastProbeTime\": null, " + " \"lastTransitionTime\": \"2018-10-10T13:04:51Z\" " + " } " + " ], " + " \"hostIP\": \"172.31.23.191\", " + " \"podIP\": \"10.129.123.39\", " + " \"startTime\": \"2018-10-10T13:04:51Z\", " + " \"containerStatuses\": [ " + " { " + " \"name\": \"tomcat-in-the-cloud\", " + " \"state\": { " + " \"running\": { " + " \"startedAt\": \"2018-10-10T13:05:14Z\" " + " } " + " }, " + " \"lastState\": { " + " " + " }, " + " \"ready\": true, " + " \"restartCount\": 0, " + " \"image\": \"docker.io/jfclere/test:latest\", " + " \"imageID\": \"docker.io/jfclere/test@sha256:d36155492516915ecf448fe62769f61b5f9ab795bc8ae1e72a199ee6485cbea2\", " + " \"containerID\": \"cri-o://401533326c8224ef5a3f40234dd26c1030925d659757e0b26c09ff1e728c78f1\" " + " } " + " ], " + " \"qosClass\": \"Burstable\" " + " } " + " } " + " ] " + "}"; @Test public void testJson() throws Exception { startTime = Instant.now(); List<MemberImpl> members = new ArrayList<>(); parsePods(new StringReader(OPENSHIFT_JSON_POD_LIST), members); Assert.assertTrue(members.size() == 2); Assert.assertTrue("10.130.140.153".equals(members.get(0).getHostname())); Assert.assertTrue( "tcp://10.130.140.153:0".equals(members.get(0).getName())); members.clear(); } }
Detected license expression
apache-2.0
Detected license expression (SPDX)
Apache-2.0
Percentage of license text
13.01
Copyrights

      
    
Holders

      
    
Authors

      
    
License detections License expression License expression SPDX
apache_2_0-4bde3f57-78aa-4201-96bf-531cba09e7de apache-2.0 Apache-2.0
URL Start line End line
http://www.apache.org/licenses/LICENSE-2.0 9 9