Skip to content
This repository was archived by the owner on May 25, 2023. It is now read-only.

Commit 2cbe7ac

Browse files
committed
increase timeout for pod spinup
1 parent 8a08c82 commit 2cbe7ac

File tree

4 files changed

+34
-31
lines changed

4 files changed

+34
-31
lines changed

integrateion-test/src/sbt-test/bootstrap-demo/dns-kubernetes/build.sbt

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ lazy val root = (project in file("."))
5555
Process(s"$kubectl apply -f kubernetes/akka-cluster.yml").!(s.log)
5656

5757
waitForPods(3, 10, s.log)
58+
processAndLog(s"$kubectl describe pods --namespace reactivelibtest1", s.log)
5859
val p = findPodId(nm, s.log)
5960
checkMemberUp(p, 10, s.log)
6061
} else {
@@ -67,7 +68,8 @@ lazy val root = (project in file("."))
6768
s.log.info("applying openshift.yml")
6869
Process(s"$kubectl apply -f kubernetes/openshift.yml").!(s.log)
6970

70-
waitForPods(3, 10, s.log)
71+
waitForPods(3, 20, s.log)
72+
processAndLog(s"$kubectl describe pods --namespace reactivelibtest1", s.log)
7173
val p = findPodId(nm, s.log)
7274
checkMemberUp(p, 10, s.log)
7375
}
@@ -86,22 +88,12 @@ lazy val root = (project in file("."))
8688

8789
def waitForPods(expected: Int, attempt: Int, log: Logger): Unit = {
8890
if (attempt == 0) {
89-
val lines = try {
90-
Process(s"$kubectl describe pods --namespace reactivelibtest1").!!.lines.toList
91-
} catch {
92-
case NonFatal(_) => Nil
93-
}
94-
lines foreach { log.info(_: String) }
91+
processAndLog(s"$kubectl describe pods --namespace reactivelibtest1", log)
9592
sys.error("pods did not get ready in time")
9693
}
9794
else {
9895
log.info("waiting for pods to get ready...")
99-
val lines = try {
100-
Process(s"$kubectl get pods --namespace reactivelibtest1").!!.lines.toList
101-
} catch {
102-
case NonFatal(_) => Nil
103-
}
104-
lines foreach { log.info(_: String) }
96+
val lines = processAndLog(s"$kubectl get pods --namespace reactivelibtest1", log)
10597
if ((lines filter { _.contains("Running") }).size == expected) ()
10698
else {
10799
Thread.sleep(4000)
@@ -111,15 +103,24 @@ def waitForPods(expected: Int, attempt: Int, log: Logger): Unit = {
111103
}
112104

113105
def findPodId(nm: String, log: Logger): String = {
114-
val lines = Process(s"$kubectl get pods --namespace reactivelibtest1").!!.lines.toList
115-
lines foreach { log.info(_: String) }
106+
val lines = processAndLog(s"$kubectl get pods --namespace reactivelibtest1", log)
116107
val xs = lines filter { s => s.contains("Running") && s.contains(nm) }
117108
val firstRow = xs.headOption.getOrElse(sys.error("pods not found!"))
118109
val firstColumn = firstRow.trim.split(" ").toList
119110
.headOption.getOrElse(sys.error("pods not found!"))
120111
firstColumn
121112
}
122113

114+
def processAndLog(cmd: String, log: Logger): List[String] = {
115+
val lines = try {
116+
Process(cmd).!!.lines.toList
117+
} catch {
118+
case NonFatal(_) => Nil
119+
}
120+
lines foreach { log.info(_: String) }
121+
lines
122+
}
123+
123124
def checkMemberUp(p: String, attempt: Int, log: Logger): Unit = {
124125
if (attempt == 0) sys.error("3 MemberUp log events were not found")
125126
else {

integrateion-test/src/sbt-test/bootstrap-demo/dns-kubernetes/src/main/scala/foo/ClusterApp.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ object ClusterApp {
2525

2626
val cluster = Cluster(system)
2727
system.log.info("Starting Akka Management")
28+
system.log.info("something2")
2829
// AkkaManagement(system).start()
2930
// ClusterBootstrap(system).start()
3031

integrateion-test/src/sbt-test/bootstrap-demo/kubernetes-api/build.sbt

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ lazy val root = (project in file("."))
6161
Process(s"$kubectl apply -f kubernetes/rp.yml").!(s.log)
6262

6363
waitForPods(3, 10, s.log)
64+
processAndLog(s"$kubectl describe pods --namespace reactivelibtest1", s.log)
6465
val p = findPodId(nm, s.log)
6566
checkMemberUp(p, 10, s.log)
6667
} else {
@@ -74,7 +75,8 @@ lazy val root = (project in file("."))
7475
s.log.info("applying openshift.yml")
7576
Process(s"$kubectl apply -f kubernetes/openshift.yml").!(s.log)
7677

77-
waitForPods(3, 10, s.log)
78+
waitForPods(3, 20, s.log)
79+
processAndLog(s"$kubectl describe pods --namespace reactivelibtest1", s.log)
7880
val p = findPodId(nm, s.log)
7981
checkMemberUp(p, 10, s.log)
8082
}
@@ -93,21 +95,11 @@ def kubectl: String = {
9395

9496
def waitForPods(expected: Int, attempt: Int, log: Logger): Unit = {
9597
if (attempt == 0) {
96-
val lines = try {
97-
Process(s"$kubectl describe pods --namespace reactivelibtest1").!!.lines.toList
98-
} catch {
99-
case NonFatal(_) => Nil
100-
}
101-
lines foreach { log.info(_: String) }
98+
processAndLog(s"$kubectl describe pods --namespace reactivelibtest1", log)
10299
sys.error("pods did not get ready in time")
103100
} else {
104101
log.info("waiting for pods to get ready...")
105-
val lines = try {
106-
Process(s"$kubectl get pods --namespace reactivelibtest1").!!.lines.toList
107-
} catch {
108-
case NonFatal(_) => Nil
109-
}
110-
lines foreach { log.info(_: String) }
102+
val lines = processAndLog(s"$kubectl get pods --namespace reactivelibtest1", log)
111103
if ((lines filter { _.contains("Running") }).size == expected) ()
112104
else {
113105
Thread.sleep(4000)
@@ -117,15 +109,24 @@ def waitForPods(expected: Int, attempt: Int, log: Logger): Unit = {
117109
}
118110

119111
def findPodId(nm: String, log: Logger): String = {
120-
val lines = Process(s"$kubectl get pods --namespace reactivelibtest1").!!.lines.toList
121-
lines foreach { log.info(_: String) }
112+
val lines = processAndLog(s"$kubectl get pods --namespace reactivelibtest1", log)
122113
val xs = lines filter { s => s.contains("Running") && s.contains(nm) }
123114
val firstRow = xs.headOption.getOrElse(sys.error("pods not found!"))
124115
val firstColumn = firstRow.trim.split(" ").toList
125116
.headOption.getOrElse(sys.error("pods not found!"))
126117
firstColumn
127118
}
128119

120+
def processAndLog(cmd: String, log: Logger): List[String] = {
121+
val lines = try {
122+
Process(cmd).!!.lines.toList
123+
} catch {
124+
case NonFatal(_) => Nil
125+
}
126+
lines foreach { log.info(_: String) }
127+
lines
128+
}
129+
129130
def checkMemberUp(p: String, attempt: Int, log: Logger): Unit = {
130131
if (attempt == 0) sys.error("3 MemberUp log events were not found")
131132
else {

integrateion-test/src/sbt-test/bootstrap-demo/kubernetes-api/src/main/scala/foo/DemoApp.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ object DemoApp extends App {
2323
val cluster = Cluster(system)
2424

2525
log.info(s"Started [$system], cluster.selfAddress = ${cluster.selfAddress}")
26-
26+
log.info("something2")
2727
//#start-akka-management
2828
AkkaManagement(system).start()
2929
//#start-akka-management

0 commit comments

Comments
 (0)