From e8b0d7df9359dbad319f239728eca1a177b8fe4a Mon Sep 17 00:00:00 2001 From: Travis Glenn Hansen Date: Sun, 26 Sep 2021 22:17:33 -0600 Subject: [PATCH] initial attempt at csi-sanity ci test Signed-off-by: Travis Glenn Hansen --- .github/workflows/main.yml | 34 +++++++++++- bin/k8s-csi-cleaner | 2 +- ci/bin/launch-csi-sanity.sh | 39 ++++++++++++++ ci/bin/launch-server.sh | 24 +++++++++ ci/configs/synlogy-iscsi/default.yaml | 77 +++++++++++++++++++++++++++ docker/iscsiadm | 0 docker/mount | 0 docker/multipath | 0 docker/node-installer.sh | 9 ++-- docker/npm-install-wrapper.sh | 23 -------- docker/umount | 0 11 files changed, 179 insertions(+), 29 deletions(-) create mode 100755 ci/bin/launch-csi-sanity.sh create mode 100755 ci/bin/launch-server.sh create mode 100644 ci/configs/synlogy-iscsi/default.yaml mode change 100644 => 100755 docker/iscsiadm mode change 100644 => 100755 docker/mount mode change 100644 => 100755 docker/multipath mode change 100644 => 100755 docker/node-installer.sh delete mode 100644 docker/npm-install-wrapper.sh mode change 100644 => 100755 docker/umount diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ecda440..8a25a66 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -9,14 +9,44 @@ on: - next jobs: - build: + cancel-previous-runs: runs-on: ubuntu-latest - steps: - name: Cancel Previous Runs uses: styfle/cancel-workflow-action@0.6.0 with: access_token: ${{ github.token }} + + csi-sanity-synology: + strategy: + matrix: + config: + - synlogy-iscsi/default.yaml + runs-on: + - self-hosted + steps: + - uses: actions/checkout@v2 + - name: csi-sanity + run: | + export CI_BUILD_KEY=$(uuidgen) + sudo ci/bin/launch-server.sh & + # wait for server to launch + sleep 10 + sudo ci/bin/launch-csi-sanity.sh + env: + TEMPLATE_CONFIG_FILE: "./ci/configs/${{ matrix.config }}" + SYNOLOGY_HOST: ${{ secrets.SANITY_SYNOLOGY_HOST }} + SYNOLOGY_PORT: ${{ secrets.SANITY_SYNOLOGY_PORT }} + SYNOLOGY_USERNAME: ${{ secrets.SANITY_SYNOLOGY_USERNAME }} + SYNOLOGY_PASSWORD: ${{ secrets.SANITY_SYNOLOGY_PASSWORD }} + SYNOLOGY_VOLUME: ${{ secrets.SANITY_SYNOLOGY_VOLUME }} + TARGET_PORTAL: ${{ secrets.SANITY_SYNOLOGY_TARGET_PORTAL }} + + build: + needs: + - csi-sanity-synology + runs-on: ubuntu-latest + steps: - uses: actions/checkout@v2 - name: docker build run: | diff --git a/bin/k8s-csi-cleaner b/bin/k8s-csi-cleaner index b483fa0..e57c9db 100755 --- a/bin/k8s-csi-cleaner +++ b/bin/k8s-csi-cleaner @@ -31,7 +31,7 @@ const PROTO_PATH = __dirname + "/../csi_proto/csi-v1.5.0.proto"; //var grpc = require("grpc-uds"); var grpc = require("@grpc/grpc-js"); var protoLoader = require("@grpc/proto-loader"); -const { rsort } = require("semver"); + // Suggested options for similarity to existing grpc.load behavior var packageDefinition = protoLoader.loadSync(PROTO_PATH, { keepCase: true, diff --git a/ci/bin/launch-csi-sanity.sh b/ci/bin/launch-csi-sanity.sh new file mode 100755 index 0000000..2d82f89 --- /dev/null +++ b/ci/bin/launch-csi-sanity.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +set -e +set -x + +: ${CI_BUILD_KEY:="local"} +: ${CSI_ENDPOINT:=/tmp/csi-${CI_BUILD_KEY}.sock} +: ${CSI_SANITY_TEMP_DIR:=$(mktemp -d -t ci-csi-sanity-tmp-XXXXXXXX)} + +if [[ ! -S "${CSI_ENDPOINT}" ]];then + echo "csi socket: ${CSI_ENDPOINT} does not exist" + exit 1 +fi + +trap ctrl_c INT + +function ctrl_c() { + echo "Trapped CTRL-C" + exit 1 +} + +chmod g+w,o+w "${CSI_ENDPOINT}"; +mkdir -p "${CSI_SANITY_TEMP_DIR}"; +rm -rf "${CSI_SANITY_TEMP_DIR}"/*; +chmod -R 777 "${CSI_SANITY_TEMP_DIR}"; + +# https://github.com/kubernetes-csi/csi-test/tree/master/cmd/csi-sanity +# FOR DEBUG: --ginkgo.v +# --csi.secrets= +# expand size 2073741824 to have mis-alignments +# expand size 2147483648 to have everything line up nicely + +csi-sanity --csi.endpoint "unix://${CSI_ENDPOINT}" \ +--csi.mountdir "${CSI_SANITY_TEMP_DIR}/mnt" \ +--csi.stagingdir "${CSI_SANITY_TEMP_DIR}/stage" \ +--csi.testvolumeexpandsize 2147483648 \ +--csi.testvolumesize 1073741824 + +rm -rf "${CSI_SANITY_TEMP_DIR}" diff --git a/ci/bin/launch-server.sh b/ci/bin/launch-server.sh new file mode 100755 index 0000000..d59d2b1 --- /dev/null +++ b/ci/bin/launch-server.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +set -e +set -x + +: ${CI_BUILD_KEY:="local"} +: ${TEMPLATE_CONFIG_FILE:=${1}} +: ${CSI_MODE:=""} +: ${CSI_VERSION:="1.5.0"} +: ${CSI_ENDPOINT:=/tmp/csi-${CI_BUILD_KEY}.sock} + +if [[ "x${CONFIG_FILE}" == "x" ]];then + : ${CONFIG_FILE:=$(mktemp -t ci-csi-config-XXXXXXXX)} + + if [[ "x${TEMPLATE_CONFIG_FILE}" != "x" ]];then + envsubst < "${TEMPLATE_CONFIG_FILE}" > "${CONFIG_FILE}" + fi +fi + +if [[ "x${CSI_MODE}" != "x" ]];then + EXTRA_ARGS="--csi-mode ${CSI_MODE} ${EXTRA_ARGS}" +fi + +./bin/democratic-csi --log-level debug --driver-config-file "${CONFIG_FILE}" --csi-version "${CSI_VERSION}" --csi-name "driver-test" --server-socket "${CSI_ENDPOINT}" ${EXTRA_ARGS} diff --git a/ci/configs/synlogy-iscsi/default.yaml b/ci/configs/synlogy-iscsi/default.yaml new file mode 100644 index 0000000..6811247 --- /dev/null +++ b/ci/configs/synlogy-iscsi/default.yaml @@ -0,0 +1,77 @@ +driver: synology-iscsi +httpConnection: + protocol: http + host: ${SYNOLOGY_HOST} + port: ${SYNOLOGY_PORT} + username: ${SYNOLOGY_USERNAME} + password: ${SYNOLOGY_PASSWORD} + allowInsecure: true + session: "democratic-csi-${CI_BUILD_KEY}" + serialize: true + +synology: + volume: ${SYNOLOGY_VOLUME} + +iscsi: + targetPortal: ${TARGET_PORTAL} + targetPortals: [] + baseiqn: "iqn.2000-01.com.synology:XpenoDsm62x." + namePrefix: "csi-${CI_BUILD_KEY}" + nameSuffix: "-ci" + + lunTemplate: + # btrfs thin provisioning + type: "BLUN" + # tpws = Hardware-assisted zeroing + # caw = Hardware-assisted locking + # 3pc = Hardware-assisted data transfer + # tpu = Space reclamation + # can_snapshot = Snapshot + #dev_attribs: + #- dev_attrib: emulate_tpws + # enable: 1 + #- dev_attrib: emulate_caw + # enable: 1 + #- dev_attrib: emulate_3pc + # enable: 1 + #- dev_attrib: emulate_tpu + # enable: 0 + #- dev_attrib: can_snapshot + # enable: 1 + + # btfs thick provisioning + # only zeroing and locking supported + #type: "BLUN_THICK" + # tpws = Hardware-assisted zeroing + # caw = Hardware-assisted locking + #dev_attribs: + #- dev_attrib: emulate_tpws + # enable: 1 + #- dev_attrib: emulate_caw + # enable: 1 + + # ext4 thinn provisioning UI sends everything with enabled=0 + #type: "THIN" + + # ext4 thin with advanced legacy features set + # can only alter tpu (all others are set as enabled=1) + #type: "ADV" + #dev_attribs: + #- dev_attrib: emulate_tpu + # enable: 1 + + # ext4 thick + # can only alter caw + #type: "FILE" + #dev_attribs: + #- dev_attrib: emulate_caw + # enable: 1 + + lunSnapshotTemplate: + is_locked: true + # https://kb.synology.com/en-me/DSM/tutorial/What_is_file_system_consistent_snapshot + is_app_consistent: true + + targetTemplate: + auth_type: 0 + max_sessions: 0 diff --git a/docker/iscsiadm b/docker/iscsiadm old mode 100644 new mode 100755 diff --git a/docker/mount b/docker/mount old mode 100644 new mode 100755 diff --git a/docker/multipath b/docker/multipath old mode 100644 new mode 100755 diff --git a/docker/node-installer.sh b/docker/node-installer.sh old mode 100644 new mode 100755 index f7e34dd..c65c8bb --- a/docker/node-installer.sh +++ b/docker/node-installer.sh @@ -28,8 +28,11 @@ fi echo "I am installing node $NODE_VERSION $NODE_DISTRO" +if [[ "x${NODE_TARGET_DIR}" == "x" ]]; then + NODE_TARGET_DIR="/usr/local/lib/nodejs" +fi + wget https://nodejs.org/dist/${NODE_VERSION}/node-${NODE_VERSION}-${NODE_DISTRO}.tar.xz >/dev/null 2>&1 -mkdir -p /usr/local/lib/nodejs -tar -xJf node-${NODE_VERSION}-${NODE_DISTRO}.tar.xz -C /usr/local/lib/nodejs --strip-components=1 +mkdir -p ${NODE_TARGET_DIR} +tar -xJf node-${NODE_VERSION}-${NODE_DISTRO}.tar.xz -C ${NODE_TARGET_DIR} --strip-components=1 rm node-${NODE_VERSION}-${NODE_DISTRO}.tar.xz -rm -rf /var/lib/apt/lists/* diff --git a/docker/npm-install-wrapper.sh b/docker/npm-install-wrapper.sh deleted file mode 100644 index 4279e48..0000000 --- a/docker/npm-install-wrapper.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash - -set -e -set -x - -PLATFORM=$TARGETPLATFORM - -if [[ "x${PLATFORM}" == "x" ]]; then - PLATFORM="linux/amd64" -fi - -if [ "$PLATFORM" = "linux/amd64" ]; then - export NODE_ARCH="x64" -elif [ "$PLATFORM" = "linux/arm64" ]; then - export NODE_ARCH="arm64" -elif [ "$PLATFORM" = "linux/arm/v7" ]; then - export NODE_ARCH="armv7l" -else - echo "unsupported/unknown PLATFORM ${PLATFORM}" - exit 1 -fi - -npm install --target_arch="${NODE_ARCH}" diff --git a/docker/umount b/docker/umount old mode 100644 new mode 100755