@Override public void connectionChanged( IConnection connection, String property, Object oldValue, Object newValue) { if (pod != null) { // we're done already return; } if (dcSelector == null) { if (deploymentConfig.equals(oldValue) && newValue instanceof IDeploymentConfig) { deploymentConfig = (IDeploymentConfig) newValue; dcSelector = deploymentConfig.getReplicaSelector(); } return; } // Wait for new pod once deployment is done if (newValue instanceof IPod) { IPod candidate = (IPod) newValue; String podName = candidate.getName(); if (!oldPods.contains(podName) && "Running".equals(candidate.getStatus()) && ResourceUtils.containsAll(dcSelector, candidate.getLabels())) { pod = candidate; } } }
@SuppressWarnings("unchecked") @Before public void setup() { podLabels.put("foo", "bar"); podLabels.put("xyz", "bar"); when(pod.getLabels()).thenReturn(podLabels); serviceSelector.put("foo", "bar"); when(buildConfig.getBuildOutputReference()).thenReturn(objectRef); when(objectRef.getName()).thenReturn(IMAGE_REF); when(build.getName()).thenReturn("build"); when(build.accept(any(CapabilityVisitor.class), anyBoolean())) .then( new Answer<Boolean>() { @Override public Boolean answer(InvocationOnMock invocation) throws Throwable { CapabilityVisitor<ITags, Boolean> vis = (CapabilityVisitor<ITags, Boolean>) invocation.getArguments()[0]; return vis.visit(tagsCap); } }); when(tagsCap.getTags()).thenReturn(Collections.emptyList()); }
@Override protected String buildArgs() { StringBuilder args = new StringBuilder(); args.append("port-forward "); addSkipTlsVerify(args); addServer(args); addToken(args) .append("-n ") .append(pod.getNamespace()) .append(" ") .append("-p ") .append(pod.getName()) .append(" "); for (PortPair pair : pairs) { args.append(pair.getLocalPort()).append(":").append(pair.getRemotePort()).append(" "); } return args.toString(); }
@Test public void testIsBuildPodWhenDoesNotHaveBuildAnnotation() { when(pod.isAnnotatedWith(OpenShiftAPIAnnotations.BUILD_NAME)).thenReturn(false); assertFalse(isBuildPod(pod)); }
@Test public void testIsBuildPodWhenHasBuildAnnotation() { when(pod.isAnnotatedWith(OpenShiftAPIAnnotations.BUILD_NAME)).thenReturn(true); assertTrue(isBuildPod(pod)); }