sanjay-awatramani commented on code in PR #14552:
URL: https://github.com/apache/kafka/pull/14552#discussion_r1377537216


##########
docker/test/docker_sanity_test.py:
##########
@@ -0,0 +1,193 @@
+# 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.
+
+import unittest
+import subprocess
+import time
+from HTMLTestRunner import HTMLTestRunner
+import constants
+import argparse
+
+class DockerSanityTestCommon(unittest.TestCase):
+    CONTAINER_NAME="broker"
+    IMAGE="apache/kafka"
+    
+    def resumeImage(self):
+        subprocess.run(["docker", "start", self.CONTAINER_NAME])
+
+    def stopImage(self) -> None:
+        subprocess.run(["docker", "stop", self.CONTAINER_NAME])
+
+    def startCompose(self, filename) -> None:
+        old_string="image: {$IMAGE}"
+        new_string=f"image: {self.IMAGE}"
+
+        with open(filename) as f:
+            s = f.read()
+            if old_string not in s:
+                print('"{old_string}" not found in 
{filename}.'.format(**locals()))
+
+        with open(filename, 'w') as f:
+            print('Changing "{old_string}" to "{new_string}" in 
{filename}'.format(**locals()))
+            s = s.replace(old_string, new_string)
+            f.write(s)
+
+        subprocess.run(["docker-compose", "-f", filename, "up", "-d"])
+        time.sleep(25)

Review Comment:
   `sleep` is not the best way to wait for an application to be ready. We could 
check for something that indicates the app is ready (for e.g. checking if 9092 
is ready to accept connections) and then maybe sleep a few seconds if required.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to