Skip to content

Commit cfa4486

Browse files
authored
Fix for port in use intermittent nightly failures. (#2405)
* assigning the free ports from a single to avoid port conflicts * fix ItPodsRestart test failure
1 parent 3f971af commit cfa4486

19 files changed

+86
-89
lines changed

integration-tests/src/test/java/oracle/weblogic/kubernetes/ItConfigDistributionStrategy.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -785,7 +785,7 @@ private void createDomain() {
785785
createPV(pvName, domainUid, this.getClass().getSimpleName());
786786
createPVC(pvName, pvcName, domainUid, domainNamespace);
787787

788-
t3ChannelPort = getNextFreePort(31518, 32767);
788+
t3ChannelPort = getNextFreePort();
789789

790790
// create a temporary WebLogic domain property file
791791
File domainPropertiesFile = assertDoesNotThrow(()

integration-tests/src/test/java/oracle/weblogic/kubernetes/ItFmwDiiSample.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.createSecretWithUsernamePassword;
4848
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.getExternalServicePodName;
4949
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.installAndVerifyOperator;
50-
import static oracle.weblogic.kubernetes.utils.DbUtils.getNewSuffixCount;
5150
import static oracle.weblogic.kubernetes.utils.FileUtils.replaceStringInFile;
5251
import static oracle.weblogic.kubernetes.utils.TestUtils.callWebAppAndWaitTillReady;
5352
import static oracle.weblogic.kubernetes.utils.TestUtils.getNextFreePort;
@@ -118,7 +117,7 @@ public static void initAll(@Namespaces(3) List<String> namespaces) {
118117
assertNotNull(namespaces.get(2), "Namespace is null");
119118
domainNamespace = namespaces.get(2);
120119

121-
int dbPort = 30011 + getNewSuffixCount();
120+
int dbPort = getNextFreePort();
122121
logger.info("Start DB and for namespace: {0}, "
123122
+ "dbImage: {2}, fmwImage: {3}, dbPort: {4} ", dbNamespace,
124123
DB_IMAGE_TO_USE_IN_SPEC, FMWINFRA_IMAGE_TO_USE_IN_SPEC, dbPort);
@@ -275,11 +274,8 @@ private static void setupSample() {
275274
}
276275

277276
private void updateDomainInputsFile(String domainUid, Path sampleBase, String script) {
278-
// in general the node port range has to be between 30,100 to 32,767
279-
// to avoid port conflict because of the delay in using it, the port here
280-
// starts with 30172
281-
final int t3ChannelPort = getNextFreePort(30172, 32767);
282-
final int adminNodePort = getNextFreePort(30701, 32767);
277+
final int t3ChannelPort = getNextFreePort();
278+
final int adminNodePort = getNextFreePort();
283279

284280
// change namespace from default to custom, domain name, and t3PublicAddress
285281
assertDoesNotThrow(() -> {

integration-tests/src/test/java/oracle/weblogic/kubernetes/ItFmwDomainInPVUsingWDT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ public static void initAll(@Namespaces(3) List<String> namespaces) {
153153
public void testFmwDomainOnPVUsingWdt() {
154154
final String pvName = domainUid + "-" + domainNamespace + "-pv";
155155
final String pvcName = domainUid + "-" + domainNamespace + "-pvc";
156-
final int t3ChannelPort = getNextFreePort(30000, 32767);
156+
final int t3ChannelPort = getNextFreePort();
157157

158158
// create FMW domain credential secret
159159
createSecretWithUsernamePassword(wlSecretName, domainNamespace,

integration-tests/src/test/java/oracle/weblogic/kubernetes/ItFmwDomainInPVUsingWLST.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ public void testFmwDomainInPvUsingWlst() {
151151
final int managedServerPort = 8001;
152152
final String managedServerPodNamePrefix = domainUid + "-" + managedServerNameBase;
153153
final int replicaCount = 2;
154-
final int t3ChannelPort = getNextFreePort(30000, 32767);
154+
final int t3ChannelPort = getNextFreePort();
155155

156156
final String pvName = domainUid + "-pv";
157157
final String pvcName = domainUid + "-pvc";
@@ -281,7 +281,7 @@ public void testFmwDomainInPvUsingWlst() {
281281

282282
// verify the admin server service created
283283
checkServiceExists(adminServerPodName, jrfDomainNamespace);
284-
284+
285285
// verify admin server pod is ready
286286
checkPodReady(adminServerPodName, domainUid, jrfDomainNamespace);
287287

integration-tests/src/test/java/oracle/weblogic/kubernetes/ItFmwDynamicDomainInPV.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ public void testFmwDynamicDomainInPV() {
158158
private void createFmwDomainAndVerify() {
159159
final String pvName = domainUid + "-" + domainNamespace + "-pv";
160160
final String pvcName = domainUid + "-" + domainNamespace + "-pvc";
161-
final int t3ChannelPort = getNextFreePort(30000, 32767);
161+
final int t3ChannelPort = getNextFreePort();
162162

163163
// create pull secrets for domainNamespace when running in non Kind Kubernetes cluster
164164
// this secret is used only for non-kind cluster

integration-tests/src/test/java/oracle/weblogic/kubernetes/ItFmwSample.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.createSecretWithUsernamePassword;
4646
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.getExternalServicePodName;
4747
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.installAndVerifyOperator;
48-
import static oracle.weblogic.kubernetes.utils.DbUtils.getNewSuffixCount;
4948
import static oracle.weblogic.kubernetes.utils.FileUtils.replaceStringInFile;
5049
import static oracle.weblogic.kubernetes.utils.TestUtils.callWebAppAndWaitTillReady;
5150
import static oracle.weblogic.kubernetes.utils.TestUtils.getNextFreePort;
@@ -118,7 +117,7 @@ public static void initAll(@Namespaces(3) List<String> namespaces) {
118117
assertNotNull(namespaces.get(2), "Namespace is null");
119118
domainNamespace = namespaces.get(2);
120119

121-
int dbPort = 30011 + getNewSuffixCount();
120+
int dbPort = getNextFreePort();
122121
logger.info("Start DB and for namespace: {0}, "
123122
+ "dbImage: {2}, fmwImage: {3}, dbPort: {4} ", dbNamespace,
124123
DB_IMAGE_TO_USE_IN_SPEC, FMWINFRA_IMAGE_TO_USE_IN_SPEC, dbPort);
@@ -358,8 +357,8 @@ private void updateDomainInputsFile(String domainUid, Path sampleBase) {
358357
// in general the node port range has to be between 30,100 to 32,767
359358
// to avoid port conflict because of the delay in using it, the port here
360359
// starts with 30172
361-
final int t3ChannelPort = getNextFreePort(30172, 32767);
362-
final int adminNodePort = getNextFreePort(30701, 32767);
360+
final int t3ChannelPort = getNextFreePort();
361+
final int adminNodePort = getNextFreePort();
363362

364363
// change namespace from default to custom, domain name, and t3PublicAddress
365364
assertDoesNotThrow(() -> {

integration-tests/src/test/java/oracle/weblogic/kubernetes/ItIntrospectVersion.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,8 @@ public static void initAll(@Namespaces(3) List<String> namespaces) {
185185
installAndVerifyOperator(opNamespace, introDomainNamespace);
186186

187187
// get a free node port for NGINX
188-
nodeportshttp = getNextFreePort(30109, 30405);
189-
int nodeportshttps = getNextFreePort(30143, 30543);
188+
nodeportshttp = getNextFreePort();
189+
int nodeportshttps = getNextFreePort();
190190

191191
// install and verify NGINX
192192
nginxHelmParams = installAndVerifyNginx(nginxNamespace, nodeportshttp, nodeportshttps);
@@ -230,10 +230,7 @@ public void testDomainIntrospectVersionNotRolling() {
230230

231231
int replicaCount = 2;
232232

233-
// in general the node port range has to be between 30,000 to 32,767
234-
// to avoid port conflict because of the delay in using it, the port here
235-
// starts with 30100
236-
final int t3ChannelPort = getNextFreePort(30172, 32767);
233+
final int t3ChannelPort = getNextFreePort();
237234

238235
final String pvName = domainUid + "-pv"; // name of the persistent volume
239236
final String pvcName = domainUid + "-pvc"; // name of the persistent volume claim

integration-tests/src/test/java/oracle/weblogic/kubernetes/ItIstioDomainInPV.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ public static void initAll(@Namespaces(2) List<String> namespaces) {
147147

148148
/**
149149
* Create a WebLogic domain using WLST in a persistent volume.
150-
* Add istio configuration.
150+
* Add istio configuration.
151151
* Deploy istio gateways and virtual service.
152152
* Verify domain pods runs in ready state and services are created.
153153
* Verify login to WebLogic console is successful thru istio ingress Port.
@@ -161,7 +161,7 @@ public void testIstioDomainHomeInPv() {
161161
final String managedServerNameBase = "wlst-ms-";
162162
String managedServerPodNamePrefix = domainUid + "-" + managedServerNameBase;
163163
final int replicaCount = 2;
164-
final int t3ChannelPort = getNextFreePort(31000, 32767);
164+
final int t3ChannelPort = getNextFreePort();
165165

166166
final String pvName = domainUid + "-pv"; // name of the persistent volume
167167
final String pvcName = domainUid + "-pvc"; // name of the persistent volume claim
@@ -221,7 +221,7 @@ public void testIstioDomainHomeInPv() {
221221
.namespace(domainNamespace))
222222
.spec(new DomainSpec()
223223
.domainUid(domainUid)
224-
.domainHome("/shared/domains/" + domainUid)
224+
.domainHome("/shared/domains/" + domainUid)
225225
.domainHomeSourceType("PersistentVolume")
226226
.image(WEBLOGIC_IMAGE_TO_USE_IN_SPEC)
227227
.imagePullPolicy("IfNotPresent")
@@ -308,24 +308,24 @@ public void testIstioDomainHomeInPv() {
308308
int istioIngressPort = getIstioHttpIngressPort();
309309
logger.info("Istio http ingress Port is {0}", istioIngressPort);
310310

311-
// We can not verify Rest Management console thru Adminstration NodePort
311+
// We can not verify Rest Management console thru Adminstration NodePort
312312
// in istio, as we can not enable Adminstration NodePort
313313
if (!WEBLOGIC_SLIM) {
314314
String consoleUrl = "http://" + K8S_NODEPORT_HOST + ":" + istioIngressPort + "/console/login/LoginForm.jsp";
315-
boolean checkConsole =
315+
boolean checkConsole =
316316
checkAppUsingHostHeader(consoleUrl, domainNamespace + ".org");
317317
assertTrue(checkConsole, "Failed to access WebLogic console");
318318
logger.info("WebLogic console is accessible");
319319
} else {
320320
logger.info("Skipping WebLogic console in WebLogic slim image");
321321
}
322-
322+
323323
Path archivePath = Paths.get(ITTESTS_DIR, "../operator/integration-tests/apps/testwebapp.war");
324324
ExecResult result = null;
325325
for (int i = 1; i <= 10; i++) {
326-
result = deployToClusterUsingRest(K8S_NODEPORT_HOST,
326+
result = deployToClusterUsingRest(K8S_NODEPORT_HOST,
327327
String.valueOf(istioIngressPort),
328-
ADMIN_USERNAME_DEFAULT, ADMIN_PASSWORD_DEFAULT,
328+
ADMIN_USERNAME_DEFAULT, ADMIN_PASSWORD_DEFAULT,
329329
clusterName, archivePath, domainNamespace + ".org", "testwebapp");
330330
assertNotNull(result, "Application deployment failed");
331331
logger.info("(Loop:{0}) Application deployment returned {1}", i, result.toString());
@@ -393,7 +393,7 @@ private void createDomainOnPVUsingWlst(Path wlstScriptFile, Path domainPropertie
393393
logger.info("Creating a config map to hold domain creation scripts");
394394
String domainScriptConfigMapName = "create-domain-scripts-cm";
395395
assertDoesNotThrow(
396-
() -> CommonTestUtils.createConfigMapForDomainCreation(domainScriptConfigMapName, domainScriptFiles,
396+
() -> CommonTestUtils.createConfigMapForDomainCreation(domainScriptConfigMapName, domainScriptFiles,
397397
namespace, this.getClass().getSimpleName()),
398398
"Create configmap for domain creation failed");
399399

integration-tests/src/test/java/oracle/weblogic/kubernetes/ItIstioMonitoringExporter.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050
import static oracle.weblogic.kubernetes.utils.IstioUtils.deployIstioDestinationRule;
5151
import static oracle.weblogic.kubernetes.utils.IstioUtils.deployIstioPrometheus;
5252
import static oracle.weblogic.kubernetes.utils.IstioUtils.getIstioHttpIngressPort;
53-
import static oracle.weblogic.kubernetes.utils.IstioUtils.getIstioHttpIngressPort;
5453
import static oracle.weblogic.kubernetes.utils.MonitoringUtils.checkMetricsViaPrometheus;
5554
import static oracle.weblogic.kubernetes.utils.MonitoringUtils.downloadMonitoringExporterApp;
5655
import static oracle.weblogic.kubernetes.utils.TestUtils.getNextFreePort;
@@ -129,7 +128,7 @@ public static void initAll(@Namespaces(2) List<String> namespaces) {
129128
+ "it can monitor Weblogic domain via weblogic exporter webapp")
130129
public void testIstioPrometheus() {
131130
assertDoesNotThrow(() -> setupIstioModelInImageDomain(), "setup for istio based domain failed");
132-
int prometheusPort = getNextFreePort(30510, 30600);
131+
int prometheusPort = getNextFreePort();
133132
assertTrue(deployIstioPrometheus(domainNamespace, domainUid,
134133
String.valueOf(prometheusPort)), "failed to install istio prometheus");
135134

integration-tests/src/test/java/oracle/weblogic/kubernetes/ItMonitoringExporter.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -813,7 +813,7 @@ private void installPrometheusGrafana(String promChartVersion,
813813
Path fileTemp = Paths.get(RESULTS_ROOT, "ItMonitoringExporter", "createTempValueFile");
814814
FileUtils.deleteDirectory(fileTemp.toFile());
815815
Files.createDirectories(fileTemp);
816-
816+
817817
logger.info("copy the promvalue.yaml to staging location");
818818
Path srcPromFile = Paths.get(RESOURCE_DIR, "exporter", "promvalues.yaml");
819819
Path targetPromFile = Paths.get(fileTemp.toString(), "promvalues.yaml");
@@ -827,16 +827,16 @@ private void installPrometheusGrafana(String promChartVersion,
827827
"webhook.webhook.svc.cluster.local",
828828
String.format("webhook.%s.svc.cluster.local", webhookNS));
829829

830-
831-
nodeportserver = getNextFreePort(32400, 32600);
832-
int nodeportalertmanserver = getNextFreePort(30400, 30600);
830+
831+
nodeportserver = getNextFreePort();
832+
int nodeportalertmanserver = getNextFreePort();
833833
promHelmParams = installAndVerifyPrometheus("prometheus",
834834
monitoringNS,
835835
targetPromFile.toString(),
836836
promChartVersion,
837837
nodeportserver,
838838
nodeportalertmanserver);
839-
839+
840840
prometheusDomainRegexValue = prometheusRegexValue;
841841
}
842842
//if prometheus already installed change CM for specified domain
@@ -1560,7 +1560,7 @@ private static String createAndVerifyDomainInImage() {
15601560
appList.add(app1Path);
15611561
appList.add(app2Path);
15621562

1563-
int t3ChannelPort = getNextFreePort(31600, 32767); // the port range has to be between 31,000 to 32,767
1563+
int t3ChannelPort = getNextFreePort();
15641564

15651565
Properties p = new Properties();
15661566
p.setProperty("ADMIN_USER", ADMIN_USERNAME_DEFAULT);
@@ -1693,7 +1693,7 @@ private static void createDomainCrAndVerify(String adminSecretName,
16931693
int replicaCount,
16941694
boolean twoClusters,
16951695
String monexpConfig) {
1696-
int t3ChannelPort = getNextFreePort(31570, 32767);
1696+
int t3ChannelPort = getNextFreePort();
16971697
// create the domain CR
16981698
Domain domain = new Domain()
16991699
.apiVersion(DOMAIN_API_VERSION)

0 commit comments

Comments
 (0)