orenccl commented on code in PR #103:
URL: 
https://github.com/apache/gravitino-playground/pull/103#discussion_r1848343376


##########
playground.sh:
##########
@@ -18,186 +18,398 @@
 # under the License.
 #
 
-set -x
-
 playground_dir="$(dirname "${BASH_SOURCE-$0}")"
 playground_dir="$(
-  cd "${playground_dir}" >/dev/null
+  cd "${playground_dir}" >/dev/null || exit 1
   pwd
 )"
 
+playgroundRuntimeName="gravitino-playground"
+
+runtime=""
+dockerComposeCommand=""
+
+requiredDiskSpaceGB=25
+requiredRamGB=8
+requiredCpuCores=2
+requiredPorts=(8090 9001 3307 19000 19083 60070 13306 15342 18080 18888 19090 
13000)
+
 testDocker() {
-  echo "INFO: Testing Docker environment by running hello-world..."
-  docker run --pull always hello-world >/dev/null 2>&1
+  echo "[INFO] Testing Docker environment by running hello-world..."
+  # Use always to test network connection
+  docker run --rm --pull always hello-world:linux >/dev/null 2>&1
+
   if [ $? -eq 0 ]; then
-    echo "INFO: Docker is working correctly!"
+    echo "[INFO] Docker check passed: Docker is working correctly!"
   else
-    echo "ERROR: There was an issue running the hello-world container. Please 
check your Docker installation."
+    echo "[ERROR] Docker check failed: There was an issue running the 
hello-world container. Please check your Docker installation."
     exit 1
   fi
 }
 
-testK8s() {
-  echo "Testing K8s environment ..."
-  kubectl cluster-info
-  if [ $? -eq 0 ]; then
-    echo "INFO: K8s is working correctly!"
+detectDockerComposeCommand() {
+  dockerComposeCommand=""
+  if command -v docker >/dev/null 2>&1 && command -v docker compose >/dev/null 
2>&1; then
+    dockerComposeCommand="docker compose"
+  elif command -v docker-compose >/dev/null 2>&1; then
+    dockerComposeCommand="docker-compose"
+  fi
+}
+
+checkDockerCompose() {
+  detectDockerComposeCommand
+  if [ -n "${dockerComposeCommand}" ]; then
+    echo "[INFO] Docker compose check passed: Docker compose is working 
correctly using ${dockerComposeCommand} command!"
+  else
+    echo "[ERROR] Docker compose check failed: No docker service environment 
found. Please install docker compose."
+    exit 1
+  fi
+}
+
+checkDockerDisk() {
+  # Step 1: Get Docker Root Directory
+  local dockerRootDir="$(docker info 2>/dev/null | grep "Docker Root Dir" | 
awk '{print $NF}')"
+
+  # Step 2: Check if the Docker directory exists
+  if [ -z "${dockerRootDir}" ]; then
+    echo "[ERROR] Docker disk check failed: Docker is not running or Docker 
Root Directory not found."
+    exit 1
+  fi
+
+  local availableSpaceKB
+
+  if [ -d "${dockerRootDir}" ]; then
+    # Check available space in the Docker directory's partition
+    availableSpaceKB=$(df --output=avail "${dockerRootDir}" | awk 'NR==2 
{print $1}')
   else
-    echo "ERROR: There was an issue running kubectl cluster-info, please check 
you K8s cluster."
+    # Check available space in the root partition if the directory doesn't 
exist (special case for WSL)
+    availableSpaceKB=$(df --output=avail / | awk 'NR==2 {print $1}')

Review Comment:
   It seems that macOS does not support `--output=avail`. Refer to 
[https://ss64.com/mac/df.html](https://ss64.com/mac/df.html).
   
   Instead of using `--output=avail`, change it to `-k` so that it works on 
both macOS and Linux. Refer to 
[https://linuxcommand.org/lc3_man_pages/df1.html](https://linuxcommand.org/lc3_man_pages/df1.html).
   
   However, I don't have a macOS environment. Could you check this for me?
   



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to