This is an automated email from the ASF dual-hosted git repository.

adoroszlai pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hadoop-ozone.git


The following commit(s) were added to refs/heads/master by this push:
     new 30ec0e2  HDDS-3990. Test Kubernetes examples with acceptance tests 
(#1223)
30ec0e2 is described below

commit 30ec0e2d0e04e23b3ac59d14be25c87411100802
Author: Elek, Márton <[email protected]>
AuthorDate: Thu Jul 30 14:23:04 2020 +0200

    HDDS-3990. Test Kubernetes examples with acceptance tests (#1223)
---
 .github/workflows/post-commit.yml                  |  66 ++++++++++
 hadoop-ozone/dev-support/checks/kubernetes.sh      |  36 ++++++
 .../dist/dev-support/bin/dist-layout-stitching     |   1 +
 hadoop-ozone/dist/src/main/k8s/.gitignore          |  15 +++
 .../src/main/k8s/definitions/ozone/config.yaml     |   1 +
 .../k8s/definitions/ozone/definitions/onenode.yaml |   2 +-
 .../{pv-test => test-webserver}/flekszible.yaml    |   0
 .../webserver-deployment.yaml                      |   0
 .../webserver-service.yaml                         |   0
 .../webserver-volume.yaml                          |   0
 .../examples/getting-started/config-configmap.yaml |   1 +
 .../getting-started/datanode-statefulset.yaml      |  10 --
 .../getting-started/test.sh}                       |  34 +++--
 .../k8s/examples/minikube/config-configmap.yaml    |   1 +
 .../minikube/test.sh}                              |  34 +++--
 .../src/main/k8s/examples/ozone-dev/Flekszible     |   4 +-
 .../k8s/examples/ozone-dev/config-configmap.yaml   |   1 +
 .../examples/ozone-dev/datanode-statefulset.yaml   |  10 --
 .../ozone-dev/test.sh}                             |  34 +++--
 .../dist/src/main/k8s/examples/ozone/Flekszible    |   2 +-
 .../main/k8s/examples/ozone/config-configmap.yaml  |   1 +
 .../ozone/test.sh}                                 |  34 +++--
 .../webserver-volume.yaml => examples/test-all.sh} |  41 ++++--
 hadoop-ozone/dist/src/main/k8s/examples/testlib.sh | 137 +++++++++++++++++++++
 hadoop-ozone/dist/src/test/shell/k8s_testlib.bats  |  55 +++++++++
 25 files changed, 431 insertions(+), 89 deletions(-)

diff --git a/.github/workflows/post-commit.yml 
b/.github/workflows/post-commit.yml
index 992715f..e872884 100644
--- a/.github/workflows/post-commit.yml
+++ b/.github/workflows/post-commit.yml
@@ -258,3 +258,69 @@ jobs:
            name: coverage
            path: target/coverage
          continue-on-error: true
+  kubernetes:
+    name: kubernetes
+    runs-on: ubuntu-18.04
+    steps:
+      - name: Cache for maven dependencies
+        uses: actions/cache@v2
+        with:
+          path: ~/.m2/repository
+          key: maven-repo-${{ hashFiles('**/pom.xml') }}
+      - name: Cache for npm dependencies
+        uses: actions/cache@v2
+        with:
+          path: |
+            ~/.pnpm-store
+            **/node_modules
+          key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
+          restore-keys: |
+            ${{ runner.os }}-pnpm-
+      - name: Checkout to /mnt/ozone
+        run: |
+          sudo chmod 777 /mnt
+          git clone 'https://github.com/${{ github.repository }}.git' 
/mnt/ozone
+          cd /mnt/ozone
+          if [[ '${{ github.event_name }}' == 'pull_request' ]]; then
+            git fetch --verbose origin '${{ github.ref }}'
+          else
+            git fetch --verbose origin '${{ github.sha }}'
+          fi
+          git checkout FETCH_HEAD
+          git reset --hard
+      - name: Install robotframework
+        run: sudo pip install robotframework
+      - name: Install k3s
+        run: curl -sfL https://get.k3s.io | sh -
+      - name: Copy Kubernetes config file
+        run: |
+          sudo mkdir ~/.kube
+          sudo cp /etc/rancher/k3s/k3s.yaml ~/.kube/config
+          sudo chown $(id -u) ~/.kube/config
+      - name: Install flekszible
+        run: |
+          cd /tmp
+          wget 
https://github.com/elek/flekszible/releases/download/v1.8.1/flekszible_1.8.1_Linux_x86_64.tar.gz
 -O - | tar -zx
+          chmod +x flekszible
+          sudo mv flekszible /usr/bin/flekszible
+      - name: Run a full build
+        run: |
+          cd /mnt/ozone
+          hadoop-ozone/dev-support/checks/build.sh -Pcoverage
+      - name: Execute tests
+        run: |
+          cd /mnt/ozone/hadoop-ozone/dist/target/ozone-* && sudo mkdir .aws && 
sudo chmod 777 .aws && sudo chown 1000 .aws
+          cd /mnt/ozone && hadoop-ozone/dev-support/checks/kubernetes.sh
+      - name: Archive build results
+        uses: actions/upload-artifact@master
+        if: always()
+        with:
+          name: kubernetes
+          path: /mnt/ozone/target/kubernetes
+        continue-on-error: true
+      - name: Delete temporary build artifacts before caching
+        run: |
+          #Never cache local artifacts
+          rm -rf ~/.m2/repository/org/apache/hadoop/hdds
+          rm -rf ~/.m2/repository/org/apache/hadoop/ozone
+        if: always()
\ No newline at end of file
diff --git a/hadoop-ozone/dev-support/checks/kubernetes.sh 
b/hadoop-ozone/dev-support/checks/kubernetes.sh
new file mode 100755
index 0000000..a23aa83
--- /dev/null
+++ b/hadoop-ozone/dev-support/checks/kubernetes.sh
@@ -0,0 +1,36 @@
+#!/usr/bin/env bash
+# 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.
+DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
+cd "$DIR/../../.." || exit 1
+
+REPORT_DIR=${OUTPUT_DIR:-"$DIR/../../../target/kubernetes"}
+
+OZONE_VERSION=$(grep "<ozone.version>" "pom.xml" | sed 's/<[^>]*>//g'|  sed 
's/^[ \t]*//')
+DIST_DIR="$DIR/../../dist/target/ozone-$OZONE_VERSION"
+
+if [ ! -d "$DIST_DIR" ]; then
+    echo "Distribution dir is missing. Doing a full build"
+    "$DIR/build.sh" -Pcoverage
+fi
+
+mkdir -p "$REPORT_DIR"
+
+cd "$DIST_DIR/kubernetes/examples" || exit 1
+./test-all.sh
+RES=$?
+cp result/* "$REPORT_DIR/"
+cp "$REPORT_DIR/log.html" "$REPORT_DIR/summary.html"
+exit $RES
diff --git a/hadoop-ozone/dist/dev-support/bin/dist-layout-stitching 
b/hadoop-ozone/dist/dev-support/bin/dist-layout-stitching
index 80455a6..370d4de 100755
--- a/hadoop-ozone/dist/dev-support/bin/dist-layout-stitching
+++ b/hadoop-ozone/dist/dev-support/bin/dist-layout-stitching
@@ -131,3 +131,4 @@ run cp -p -r "${ROOT}/hadoop-ozone/dist/target/Dockerfile" .
 
 #workaround for https://issues.apache.org/jira/browse/MRESOURCES-236
 find ./compose -name "*.sh" -exec chmod 755 {} \;
+find ./kubernetes -name "*.sh" -exec chmod 755 {} \;
diff --git a/hadoop-ozone/dist/src/main/k8s/.gitignore 
b/hadoop-ozone/dist/src/main/k8s/.gitignore
new file mode 100644
index 0000000..bb9ee60
--- /dev/null
+++ b/hadoop-ozone/dist/src/main/k8s/.gitignore
@@ -0,0 +1,15 @@
+# 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.
+result
diff --git a/hadoop-ozone/dist/src/main/k8s/definitions/ozone/config.yaml 
b/hadoop-ozone/dist/src/main/k8s/definitions/ozone/config.yaml
index 6e63891..124f72f 100644
--- a/hadoop-ozone/dist/src/main/k8s/definitions/ozone/config.yaml
+++ b/hadoop-ozone/dist/src/main/k8s/definitions/ozone/config.yaml
@@ -26,6 +26,7 @@ data:
   OZONE-SITE.XML_ozone.om.address: "om-0.om"
   OZONE-SITE.XML_ozone.scm.client.address: "scm-0.scm"
   OZONE-SITE.XML_ozone.scm.names: "scm-0.scm"
+  OZONE-SITE.XML_hdds.scm.safemode.min.datanode: "3"
   LOG4J.PROPERTIES_log4j.rootLogger: "INFO, stdout"
   LOG4J.PROPERTIES_log4j.appender.stdout: "org.apache.log4j.ConsoleAppender"
   LOG4J.PROPERTIES_log4j.appender.stdout.layout: 
"org.apache.log4j.PatternLayout"
diff --git 
a/hadoop-ozone/dist/src/main/k8s/definitions/ozone/definitions/onenode.yaml 
b/hadoop-ozone/dist/src/main/k8s/definitions/ozone/definitions/onenode.yaml
index 8824779..19a3e1d 100644
--- a/hadoop-ozone/dist/src/main/k8s/definitions/ozone/definitions/onenode.yaml
+++ b/hadoop-ozone/dist/src/main/k8s/definitions/ozone/definitions/onenode.yaml
@@ -19,7 +19,7 @@ description: remove scheduling rules to make it possible to 
run multiple datanod
 - type: Remove
   trigger:
     metadata:
-      name: ozone-datanode
+      name: datanode
   path:
     - spec
     - template
diff --git a/hadoop-ozone/dist/src/main/k8s/definitions/pv-test/flekszible.yaml 
b/hadoop-ozone/dist/src/main/k8s/definitions/test-webserver/flekszible.yaml
similarity index 100%
rename from hadoop-ozone/dist/src/main/k8s/definitions/pv-test/flekszible.yaml
rename to 
hadoop-ozone/dist/src/main/k8s/definitions/test-webserver/flekszible.yaml
diff --git 
a/hadoop-ozone/dist/src/main/k8s/definitions/pv-test/webserver-deployment.yaml 
b/hadoop-ozone/dist/src/main/k8s/definitions/test-webserver/webserver-deployment.yaml
similarity index 100%
rename from 
hadoop-ozone/dist/src/main/k8s/definitions/pv-test/webserver-deployment.yaml
rename to 
hadoop-ozone/dist/src/main/k8s/definitions/test-webserver/webserver-deployment.yaml
diff --git 
a/hadoop-ozone/dist/src/main/k8s/definitions/pv-test/webserver-service.yaml 
b/hadoop-ozone/dist/src/main/k8s/definitions/test-webserver/webserver-service.yaml
similarity index 100%
rename from 
hadoop-ozone/dist/src/main/k8s/definitions/pv-test/webserver-service.yaml
rename to 
hadoop-ozone/dist/src/main/k8s/definitions/test-webserver/webserver-service.yaml
diff --git 
a/hadoop-ozone/dist/src/main/k8s/definitions/pv-test/webserver-volume.yaml 
b/hadoop-ozone/dist/src/main/k8s/definitions/test-webserver/webserver-volume.yaml
similarity index 100%
copy from 
hadoop-ozone/dist/src/main/k8s/definitions/pv-test/webserver-volume.yaml
copy to 
hadoop-ozone/dist/src/main/k8s/definitions/test-webserver/webserver-volume.yaml
diff --git 
a/hadoop-ozone/dist/src/main/k8s/examples/getting-started/config-configmap.yaml 
b/hadoop-ozone/dist/src/main/k8s/examples/getting-started/config-configmap.yaml
index 00fb72b..f02fb56 100644
--- 
a/hadoop-ozone/dist/src/main/k8s/examples/getting-started/config-configmap.yaml
+++ 
b/hadoop-ozone/dist/src/main/k8s/examples/getting-started/config-configmap.yaml
@@ -26,6 +26,7 @@ data:
   OZONE-SITE.XML_ozone.om.address: om-0.om
   OZONE-SITE.XML_ozone.scm.client.address: scm-0.scm
   OZONE-SITE.XML_ozone.scm.names: scm-0.scm
+  OZONE-SITE.XML_hdds.scm.safemode.min.datanode: "3"
   LOG4J.PROPERTIES_log4j.rootLogger: INFO, stdout
   LOG4J.PROPERTIES_log4j.appender.stdout: org.apache.log4j.ConsoleAppender
   LOG4J.PROPERTIES_log4j.appender.stdout.layout: org.apache.log4j.PatternLayout
diff --git 
a/hadoop-ozone/dist/src/main/k8s/examples/getting-started/datanode-statefulset.yaml
 
b/hadoop-ozone/dist/src/main/k8s/examples/getting-started/datanode-statefulset.yaml
index c393ead..db91864 100644
--- 
a/hadoop-ozone/dist/src/main/k8s/examples/getting-started/datanode-statefulset.yaml
+++ 
b/hadoop-ozone/dist/src/main/k8s/examples/getting-started/datanode-statefulset.yaml
@@ -37,16 +37,6 @@ spec:
         prometheus.io/port: "9882"
         prometheus.io/path: /prom
     spec:
-      affinity:
-        podAntiAffinity:
-          requiredDuringSchedulingIgnoredDuringExecution:
-          - labelSelector:
-              matchExpressions:
-              - key: component
-                operator: In
-                values:
-                - datanode
-            topologyKey: kubernetes.io/hostname
       securityContext:
         fsGroup: 1000
       containers:
diff --git 
a/hadoop-ozone/dist/src/main/k8s/definitions/pv-test/webserver-volume.yaml 
b/hadoop-ozone/dist/src/main/k8s/examples/getting-started/test.sh
old mode 100644
new mode 100755
similarity index 70%
copy from 
hadoop-ozone/dist/src/main/k8s/definitions/pv-test/webserver-volume.yaml
copy to hadoop-ozone/dist/src/main/k8s/examples/getting-started/test.sh
index 4b1e44b..dabe394
--- a/hadoop-ozone/dist/src/main/k8s/definitions/pv-test/webserver-volume.yaml
+++ b/hadoop-ozone/dist/src/main/k8s/examples/getting-started/test.sh
@@ -1,3 +1,4 @@
+#!/usr/bin/env bash
 # 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
@@ -14,16 +15,23 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-apiVersion: v1
-kind: PersistentVolumeClaim
-metadata:
-  name: ozone-csi-test-webserver
-  labels: {}
-  annotations: {}
-spec:
-  accessModes:
-  - ReadWriteOnce
-  resources:
-    requests:
-      storage: 1Gi
-  storageClassName: ozone
+export K8S_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && 
pwd )"
+
+cd "$K8S_DIR"
+
+# shellcheck source=/dev/null
+source "../testlib.sh"
+
+rm -rf result
+
+regenerate_resources
+
+start_k8s_env
+
+execute_robot_test scm-0 smoketest/basic/basic.robot
+
+combine_reports
+
+stop_k8s_env
+
+revert_resources
diff --git 
a/hadoop-ozone/dist/src/main/k8s/examples/minikube/config-configmap.yaml 
b/hadoop-ozone/dist/src/main/k8s/examples/minikube/config-configmap.yaml
index 00fb72b..f02fb56 100644
--- a/hadoop-ozone/dist/src/main/k8s/examples/minikube/config-configmap.yaml
+++ b/hadoop-ozone/dist/src/main/k8s/examples/minikube/config-configmap.yaml
@@ -26,6 +26,7 @@ data:
   OZONE-SITE.XML_ozone.om.address: om-0.om
   OZONE-SITE.XML_ozone.scm.client.address: scm-0.scm
   OZONE-SITE.XML_ozone.scm.names: scm-0.scm
+  OZONE-SITE.XML_hdds.scm.safemode.min.datanode: "3"
   LOG4J.PROPERTIES_log4j.rootLogger: INFO, stdout
   LOG4J.PROPERTIES_log4j.appender.stdout: org.apache.log4j.ConsoleAppender
   LOG4J.PROPERTIES_log4j.appender.stdout.layout: org.apache.log4j.PatternLayout
diff --git 
a/hadoop-ozone/dist/src/main/k8s/definitions/pv-test/webserver-volume.yaml 
b/hadoop-ozone/dist/src/main/k8s/examples/minikube/test.sh
old mode 100644
new mode 100755
similarity index 70%
copy from 
hadoop-ozone/dist/src/main/k8s/definitions/pv-test/webserver-volume.yaml
copy to hadoop-ozone/dist/src/main/k8s/examples/minikube/test.sh
index 4b1e44b..dabe394
--- a/hadoop-ozone/dist/src/main/k8s/definitions/pv-test/webserver-volume.yaml
+++ b/hadoop-ozone/dist/src/main/k8s/examples/minikube/test.sh
@@ -1,3 +1,4 @@
+#!/usr/bin/env bash
 # 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
@@ -14,16 +15,23 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-apiVersion: v1
-kind: PersistentVolumeClaim
-metadata:
-  name: ozone-csi-test-webserver
-  labels: {}
-  annotations: {}
-spec:
-  accessModes:
-  - ReadWriteOnce
-  resources:
-    requests:
-      storage: 1Gi
-  storageClassName: ozone
+export K8S_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && 
pwd )"
+
+cd "$K8S_DIR"
+
+# shellcheck source=/dev/null
+source "../testlib.sh"
+
+rm -rf result
+
+regenerate_resources
+
+start_k8s_env
+
+execute_robot_test scm-0 smoketest/basic/basic.robot
+
+combine_reports
+
+stop_k8s_env
+
+revert_resources
diff --git a/hadoop-ozone/dist/src/main/k8s/examples/ozone-dev/Flekszible 
b/hadoop-ozone/dist/src/main/k8s/examples/ozone-dev/Flekszible
index 350ea73..3d9bfcd 100644
--- a/hadoop-ozone/dist/src/main/k8s/examples/ozone-dev/Flekszible
+++ b/hadoop-ozone/dist/src/main/k8s/examples/ozone-dev/Flekszible
@@ -37,11 +37,11 @@ import:
     - type: Image
       image: "@docker.image@"
     - type: ozone/tracing
-  - path: pv-test
+  - path: test-webserver
     destination: pv-test
   - path: ozone-csi
     destination: csi
-  - path: pv-test
+  - path: test-webserver
     destination: pv-test
 transformations:
   - type: Namespace
diff --git 
a/hadoop-ozone/dist/src/main/k8s/examples/ozone-dev/config-configmap.yaml 
b/hadoop-ozone/dist/src/main/k8s/examples/ozone-dev/config-configmap.yaml
index 82f303f..5807630 100644
--- a/hadoop-ozone/dist/src/main/k8s/examples/ozone-dev/config-configmap.yaml
+++ b/hadoop-ozone/dist/src/main/k8s/examples/ozone-dev/config-configmap.yaml
@@ -26,6 +26,7 @@ data:
   OZONE-SITE.XML_ozone.om.address: om-0.om
   OZONE-SITE.XML_ozone.scm.client.address: scm-0.scm
   OZONE-SITE.XML_ozone.scm.names: scm-0.scm
+  OZONE-SITE.XML_hdds.scm.safemode.min.datanode: "3"
   LOG4J.PROPERTIES_log4j.rootLogger: INFO, stdout
   LOG4J.PROPERTIES_log4j.appender.stdout: org.apache.log4j.ConsoleAppender
   LOG4J.PROPERTIES_log4j.appender.stdout.layout: org.apache.log4j.PatternLayout
diff --git 
a/hadoop-ozone/dist/src/main/k8s/examples/ozone-dev/datanode-statefulset.yaml 
b/hadoop-ozone/dist/src/main/k8s/examples/ozone-dev/datanode-statefulset.yaml
index 475ce69..b22212f 100644
--- 
a/hadoop-ozone/dist/src/main/k8s/examples/ozone-dev/datanode-statefulset.yaml
+++ 
b/hadoop-ozone/dist/src/main/k8s/examples/ozone-dev/datanode-statefulset.yaml
@@ -37,16 +37,6 @@ spec:
         prometheus.io/port: "9882"
         prometheus.io/path: /prom
     spec:
-      affinity:
-        podAntiAffinity:
-          requiredDuringSchedulingIgnoredDuringExecution:
-          - labelSelector:
-              matchExpressions:
-              - key: component
-                operator: In
-                values:
-                - datanode
-            topologyKey: kubernetes.io/hostname
       securityContext:
         fsGroup: 1000
       containers:
diff --git 
a/hadoop-ozone/dist/src/main/k8s/definitions/pv-test/webserver-volume.yaml 
b/hadoop-ozone/dist/src/main/k8s/examples/ozone-dev/test.sh
old mode 100644
new mode 100755
similarity index 70%
copy from 
hadoop-ozone/dist/src/main/k8s/definitions/pv-test/webserver-volume.yaml
copy to hadoop-ozone/dist/src/main/k8s/examples/ozone-dev/test.sh
index 4b1e44b..dabe394
--- a/hadoop-ozone/dist/src/main/k8s/definitions/pv-test/webserver-volume.yaml
+++ b/hadoop-ozone/dist/src/main/k8s/examples/ozone-dev/test.sh
@@ -1,3 +1,4 @@
+#!/usr/bin/env bash
 # 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
@@ -14,16 +15,23 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-apiVersion: v1
-kind: PersistentVolumeClaim
-metadata:
-  name: ozone-csi-test-webserver
-  labels: {}
-  annotations: {}
-spec:
-  accessModes:
-  - ReadWriteOnce
-  resources:
-    requests:
-      storage: 1Gi
-  storageClassName: ozone
+export K8S_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && 
pwd )"
+
+cd "$K8S_DIR"
+
+# shellcheck source=/dev/null
+source "../testlib.sh"
+
+rm -rf result
+
+regenerate_resources
+
+start_k8s_env
+
+execute_robot_test scm-0 smoketest/basic/basic.robot
+
+combine_reports
+
+stop_k8s_env
+
+revert_resources
diff --git a/hadoop-ozone/dist/src/main/k8s/examples/ozone/Flekszible 
b/hadoop-ozone/dist/src/main/k8s/examples/ozone/Flekszible
index 2fb527c..ec6d745 100644
--- a/hadoop-ozone/dist/src/main/k8s/examples/ozone/Flekszible
+++ b/hadoop-ozone/dist/src/main/k8s/examples/ozone/Flekszible
@@ -31,7 +31,7 @@ import:
     destination: pv-test
   - path: ozone-csi
     destination: csi
-  - path: pv-test
+  - path: test-webserver
     destination: pv-test
 transformations:
   - type: Namespace
diff --git 
a/hadoop-ozone/dist/src/main/k8s/examples/ozone/config-configmap.yaml 
b/hadoop-ozone/dist/src/main/k8s/examples/ozone/config-configmap.yaml
index c7e8f48..820c197 100644
--- a/hadoop-ozone/dist/src/main/k8s/examples/ozone/config-configmap.yaml
+++ b/hadoop-ozone/dist/src/main/k8s/examples/ozone/config-configmap.yaml
@@ -26,6 +26,7 @@ data:
   OZONE-SITE.XML_ozone.om.address: om-0.om
   OZONE-SITE.XML_ozone.scm.client.address: scm-0.scm
   OZONE-SITE.XML_ozone.scm.names: scm-0.scm
+  OZONE-SITE.XML_hdds.scm.safemode.min.datanode: "3"
   LOG4J.PROPERTIES_log4j.rootLogger: INFO, stdout
   LOG4J.PROPERTIES_log4j.appender.stdout: org.apache.log4j.ConsoleAppender
   LOG4J.PROPERTIES_log4j.appender.stdout.layout: org.apache.log4j.PatternLayout
diff --git 
a/hadoop-ozone/dist/src/main/k8s/definitions/pv-test/webserver-volume.yaml 
b/hadoop-ozone/dist/src/main/k8s/examples/ozone/test.sh
old mode 100644
new mode 100755
similarity index 70%
copy from 
hadoop-ozone/dist/src/main/k8s/definitions/pv-test/webserver-volume.yaml
copy to hadoop-ozone/dist/src/main/k8s/examples/ozone/test.sh
index 4b1e44b..dabe394
--- a/hadoop-ozone/dist/src/main/k8s/definitions/pv-test/webserver-volume.yaml
+++ b/hadoop-ozone/dist/src/main/k8s/examples/ozone/test.sh
@@ -1,3 +1,4 @@
+#!/usr/bin/env bash
 # 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
@@ -14,16 +15,23 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-apiVersion: v1
-kind: PersistentVolumeClaim
-metadata:
-  name: ozone-csi-test-webserver
-  labels: {}
-  annotations: {}
-spec:
-  accessModes:
-  - ReadWriteOnce
-  resources:
-    requests:
-      storage: 1Gi
-  storageClassName: ozone
+export K8S_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && 
pwd )"
+
+cd "$K8S_DIR"
+
+# shellcheck source=/dev/null
+source "../testlib.sh"
+
+rm -rf result
+
+regenerate_resources
+
+start_k8s_env
+
+execute_robot_test scm-0 smoketest/basic/basic.robot
+
+combine_reports
+
+stop_k8s_env
+
+revert_resources
diff --git 
a/hadoop-ozone/dist/src/main/k8s/definitions/pv-test/webserver-volume.yaml 
b/hadoop-ozone/dist/src/main/k8s/examples/test-all.sh
old mode 100644
new mode 100755
similarity index 52%
rename from 
hadoop-ozone/dist/src/main/k8s/definitions/pv-test/webserver-volume.yaml
rename to hadoop-ozone/dist/src/main/k8s/examples/test-all.sh
index 4b1e44b..1d763ff
--- a/hadoop-ozone/dist/src/main/k8s/definitions/pv-test/webserver-volume.yaml
+++ b/hadoop-ozone/dist/src/main/k8s/examples/test-all.sh
@@ -1,3 +1,4 @@
+#!/usr/bin/env bash
 # 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
@@ -14,16 +15,30 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-apiVersion: v1
-kind: PersistentVolumeClaim
-metadata:
-  name: ozone-csi-test-webserver
-  labels: {}
-  annotations: {}
-spec:
-  accessModes:
-  - ReadWriteOnce
-  resources:
-    requests:
-      storage: 1Gi
-  storageClassName: ozone
+
+#
+# Test executor to test all the compose/*/test.sh test scripts.
+#
+SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )
+
+set -ex
+
+ALL_RESULT_DIR="$SCRIPT_DIR/result"
+rm "$ALL_RESULT_DIR/*" || true
+mkdir -p "$ALL_RESULT_DIR"
+
+RESULT=0
+IFS=$'\n'
+# shellcheck disable=SC2044
+for test in $(find "$SCRIPT_DIR" -name test.sh | grep 
"${OZONE_TEST_SELECTOR:-""}" |sort); do
+  echo ""
+  echo "#### Executing tests of $(dirname "$test") #####"
+  echo ""
+  TEST_DIR="$(dirname $test)"
+  cd "$TEST_DIR" || continue
+  ./test.sh
+  cp "$TEST_DIR"/result/output.xml "$ALL_RESULT_DIR"/"$(basename 
"$TEST_DIR")".xml
+done
+
+rebot -N "smoketests" -d "$ALL_RESULT_DIR/" "$ALL_RESULT_DIR/*.xml"
+
diff --git a/hadoop-ozone/dist/src/main/k8s/examples/testlib.sh 
b/hadoop-ozone/dist/src/main/k8s/examples/testlib.sh
new file mode 100644
index 0000000..d33194d
--- /dev/null
+++ b/hadoop-ozone/dist/src/main/k8s/examples/testlib.sh
@@ -0,0 +1,137 @@
+#!/usr/bin/env bash
+# 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.
+
+retry() {
+   n=0
+   until [ $n -ge 30 ]
+   do
+      "$@" && break
+      n=$[$n+1]
+      echo "$n '$@' is failed..."
+      sleep ${RETRY_SLEEP:-3}
+   done
+   if [ $n -eq 30 ]; then
+      return 255
+   fi
+}
+
+grep_log() {
+   CONTAINER="$1"
+   PATTERN="$2"
+   kubectl logs "$1"  | grep "$PATTERN"
+}
+
+wait_for_startup(){
+   print_phase "Waiting until the k8s cluster is running"
+   retry all_pods_are_running
+   retry grep_log scm-0 "SCM exiting safe mode."
+   retry grep_log om-0 "HTTP server of ozoneManager listening"
+   print_phase "Cluster is up and running"
+}
+
+all_pods_are_running() {
+   RUNNING_COUNT=$(kubectl get pod --field-selector status.phase=Running | wc 
-l)
+   ALL_COUNT=$(kubectl get pod | wc -l)
+   RUNNING_COUNT=$((RUNNING_COUNT - 1))
+   ALL_COUNT=$((ALL_COUNT - 1))
+   if [ "$RUNNING_COUNT" -lt "3" ]; then
+      echo "$RUNNING_COUNT pods are running. Waiting for more."
+      return 1
+   elif [ "$RUNNING_COUNT" -ne "$ALL_COUNT" ]; then
+      echo "$RUNNING_COUNT pods are running out from the $ALL_COUNT"
+      return 2
+   else
+      STARTED=true
+      return 0
+   fi
+}
+
+start_k8s_env() {
+   print_phase "Deleting existing k8s resources"
+   #reset environment
+   kubectl delete statefulset --all
+   kubectl delete daemonset --all
+   kubectl delete deployment --all
+   kubectl delete service --all
+   kubectl delete configmap --all
+   kubectl delete pod --all
+   kubectl delete pvc --all
+   kubectl delete pv --all
+
+   print_phase "Applying k8s resources from $1"
+   kubectl apply -f .
+   wait_for_startup
+}
+
+stop_k8s_env() {
+   if [ ! "$KEEP_RUNNING" ]; then
+     kubectl delete -f .
+   fi
+}
+
+regenerate_resources() {
+  print_phase "Modifying Kubernetes resources file for test"
+  echo "   (mounting current Ozone directory to the containers, scheduling 
containers to one node, ...)"
+  echo ""
+  echo "WARNING: this test can be executed only with local Kubernetes cluster"
+  echo "   (source dir should be available from K8s nodes)"
+  echo ""
+
+  PARENT_OF_PARENT=$(realpath ../..)
+
+  if [ $(basename $PARENT_OF_PARENT) == "k8s" ]; then
+    #running from src dir
+    OZONE_ROOT=$(realpath ../../../../../target/ozone-0.6.0-SNAPSHOT)
+  else
+    #running from dist
+    OZONE_ROOT=$(realpath ../../..)
+  fi
+
+  flekszible generate -t mount:hostPath="$OZONE_ROOT",path=/opt/hadoop -t 
image:image=apache/ozone-runner:20200420-1 -t ozone/onenode
+}
+
+revert_resources() {
+   print_phase "Regenerating original Kubernetes resource files"
+   flekszible generate
+}
+
+execute_robot_test() {
+   print_phase "Executing robot tests $@"
+   mkdir -p result
+
+   CONTAINER="$1"
+   shift 1 #Remove first argument which was the container name
+
+   # shellcheck disable=SC2206
+   ARGUMENTS=($@)
+
+   kubectl exec -it "${CONTAINER}" -- bash -c 'rm -rf /tmp/report'
+   kubectl exec -it "${CONTAINER}" -- bash -c 'mkdir -p  /tmp/report'
+   kubectl exec -it "${CONTAINER}" -- robot --nostatusrc -d /tmp/report 
${ARGUMENTS[@]} || true
+   kubectl cp "${CONTAINER}":/tmp/report/output.xml 
"result/$CONTAINER-$RANDOM.xml" || true
+}
+
+combine_reports() {
+  rm result/output.xml || true
+  rebot -d result --nostatusrc -o output.xml -N $(basename "$(pwd)") 
result/*.xml
+}
+
+print_phase() {
+   echo ""
+   echo "**** $1 ****"
+   echo ""
+}
diff --git a/hadoop-ozone/dist/src/test/shell/k8s_testlib.bats 
b/hadoop-ozone/dist/src/test/shell/k8s_testlib.bats
new file mode 100644
index 0000000..4558a1e
--- /dev/null
+++ b/hadoop-ozone/dist/src/test/shell/k8s_testlib.bats
@@ -0,0 +1,55 @@
+#!/usr/bin/env bash
+# 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.
+
+export COUNTER=1
+
+pass_after_three_failures() {
+   if [ $COUNTER -eq 3 ]; then
+      return 0
+   fi 
+   COUNTER=$(( COUNTER + 1))
+   return 255
+}
+
+pass_first() {
+   echo "pass"
+}
+
+pass_never() {
+   return 255
+}
+
+load ../../main/k8s/examples/testlib.sh
+
+@test "Test retry with passing function" {
+   retry pass_first
+}
+
+@test "Test retry with 3 failures" {
+   export RETRY_SLEEP=0 
+   retry pass_after_three_failures
+}
+
+@test "Test retry always failure" {
+   export RETRY_SLEEP=0 
+   run retry pass_never
+   [ "$status" -eq 255 ]
+}
+
+
+
+
+


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to