Skip to content
This repository has been archived by the owner on Aug 16, 2024. It is now read-only.

Commit

Permalink
Next try #18
Browse files Browse the repository at this point in the history
Signed-off-by: Ihor Okhrimenko <[email protected]>
  • Loading branch information
Ohrimenko1988 committed May 21, 2020
1 parent a9276e6 commit 6b16335
Show file tree
Hide file tree
Showing 3 changed files with 145 additions and 124 deletions.
37 changes: 37 additions & 0 deletions .ci/che-util.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash
# shellcheck disable=SC2046,SC2164,SC2086,SC1090,SC2154

# Copyright (c) 2012-2020 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#
# Contributors:
# Red Hat, Inc. - initial API and implementation



function createTestWorkspaceAndRunTest() {
CHE_URL=$(oc get checluster eclipse-che -o jsonpath='{.status.cheURL}')

### Create directory for report
cd /root/payload
mkdir report
REPORT_FOLDER=$(pwd)/report
### Run tests
docker run --shm-size=1g --net=host --ipc=host -v $REPORT_FOLDER:/tmp/e2e/report:Z \
-e TS_SELENIUM_BASE_URL="$CHE_URL" \
-e TS_SELENIUM_LOG_LEVEL=DEBUG \
-e TS_SELENIUM_MULTIUSER=true \
-e TS_SELENIUM_USERNAME="admin" \
-e TS_SELENIUM_PASSWORD="admin" \
-e TS_SELENIUM_DEFAULT_TIMEOUT=300000 \
-e TS_SELENIUM_WORKSPACE_STATUS_POLLING=20000 \
-e TS_SELENIUM_LOAD_PAGE_TIMEOUT=420000 \
-e TEST_SUITE="test-all-devfiles" \
-e NODE_TLS_REJECT_UNAUTHORIZED=0 \
quay.io/eclipse/che-e2e:nightly || IS_TESTS_FAILED=true
}

127 changes: 3 additions & 124 deletions .ci/cico-devfile-pr-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,6 @@
# Red Hat, Inc. - initial API and implementation


##############################################################
###################### Functions #############################
##############################################################


function installOC() {
OC_DIR_NAME=openshift-origin-client-tools-v3.11.0-0cbc58b-linux-64bit
curl -vL "https://github.com/openshift/origin/releases/download/v3.11.0/${OC_DIR_NAME}.tar.gz" --output ${OC_DIR_NAME}.tar.gz
tar -xvf ${OC_DIR_NAME}.tar.gz
cp ${OC_DIR_NAME}/oc /usr/local/bin
cp ${OC_DIR_NAME}/oc /tmp
}

function getOpenshiftLogs() {
echo "====== Che server logs ======"
oc logs $(oc get pods --selector=component=che -o jsonpath="{.items[].metadata.name}") || true
Expand All @@ -34,96 +21,6 @@ function getOpenshiftLogs() {
oc logs $(oc get pods --selector=app=che-operator -o jsonpath="{.items[].metadata.name}") || true
}

function installKVM() {
echo "======== Start to install KVM virtual machine ========"

yum install -y qemu-kvm libvirt libvirt-python libguestfs-tools virt-install

curl -L https://github.com/dhiltgen/docker-machine-kvm/releases/download/v0.10.0/docker-machine-driver-kvm-centos7 -o /usr/local/bin/docker-machine-driver-kvm
chmod +x /usr/local/bin/docker-machine-driver-kvm

systemctl enable libvirtd
systemctl start libvirtd

virsh net-list --all
echo "======== KVM has been installed successfully ========"
}

function installAndStartMinishift() {
echo "======== Start to install minishift ========"
curl -Lo minishift.tgz https://github.com/minishift/minishift/releases/download/v1.34.2/minishift-1.34.2-linux-amd64.tgz
tar -xvf minishift.tgz --strip-components=1
chmod +x ./minishift
mv ./minishift /usr/local/bin/minishift

#Setup GitHub token for minishift
if [ -z "$CHE_BOT_GITHUB_TOKEN" ]
then
echo "\$CHE_BOT_GITHUB_TOKEN is empty. Minishift start might fail with GitGub API rate limit reached."
else
echo "\$CHE_BOT_GITHUB_TOKEN is set, checking limits."
GITHUB_RATE_REMAINING=$(curl -slL "https://api.github.com/rate_limit?access_token=$CHE_BOT_GITHUB_TOKEN" | jq .rate.remaining)
if [ "$GITHUB_RATE_REMAINING" -gt 1000 ]
then
echo "Github rate greater than 1000. Using che-bot token for minishift startup."
export MINISHIFT_GITHUB_API_TOKEN=$CHE_BOT_GITHUB_TOKEN
else
echo "Github rate is lower than 1000. *Not* using che-bot for minishift startup."
echo "If minishift startup fails, please try again later."
fi
fi

minishift version
minishift config set memory 14GB
minishift config set cpus 4

echo "======== Launch minishift ========"
minishift start

oc login -u system:admin
oc adm policy add-cluster-role-to-user cluster-admin developer
oc login -u developer -p developer

. "${SCRIPT_DIR}"/che-cert-generation.sh

oc project default
oc delete secret router-certs

cat domain.crt domain.key > minishift.crt
oc create secret tls router-certs --key=domain.key --cert=minishift.crt
oc rollout status dc router
oc rollout latest router
oc rollout status dc router

oc create namespace che

cp rootCA.crt ca.crt
oc create secret generic self-signed-certificate --from-file=ca.crt -n=che
oc project che
}

function createTestWorkspaceAndRunTest() {
CHE_URL=$(oc get checluster eclipse-che -o jsonpath='{.status.cheURL}')

### Create directory for report
cd /root/payload
mkdir report
REPORT_FOLDER=$(pwd)/report
### Run tests
docker run --shm-size=1g --net=host --ipc=host -v $REPORT_FOLDER:/tmp/e2e/report:Z \
-e TS_SELENIUM_BASE_URL="$CHE_URL" \
-e TS_SELENIUM_LOG_LEVEL=DEBUG \
-e TS_SELENIUM_MULTIUSER=true \
-e TS_SELENIUM_USERNAME="admin" \
-e TS_SELENIUM_PASSWORD="admin" \
-e TS_SELENIUM_DEFAULT_TIMEOUT=300000 \
-e TS_SELENIUM_WORKSPACE_STATUS_POLLING=20000 \
-e TS_SELENIUM_LOAD_PAGE_TIMEOUT=420000 \
-e TEST_SUITE="test-all-devfiles" \
-e NODE_TLS_REJECT_UNAUTHORIZED=0 \
quay.io/eclipse/che-e2e:nightly || IS_TESTS_FAILED=true
}

function archiveArtifacts() {
JOB_NAME=$1
DATE=$(date +"%m-%d-%Y-%H-%M")
Expand All @@ -137,27 +34,6 @@ function archiveArtifacts() {
rsync --password-file=./artifacts.key -Hva --partial --relative ./che/${JOB_NAME}/${BUILD_NUMBER} [email protected]::devtools/
}

function installEpelRelease() {
if yum repolist | grep epel; then
echo "Epel already installed, skipping instalation."
else
#excluding mirror1.ci.centos.org
echo "exclude=mirror1.ci.centos.org" >>/etc/yum/pluginconf.d/fastestmirror.conf
echo "Installing epel..."
yum install -d1 --assumeyes epel-release
yum update --assumeyes -d1
fi
}

function installJQ() {
installEpelRelease
yum install --assumeyes -d1 jq
}

##############################################################
######################## Running #############################
##############################################################

set -x

export IS_TESTS_FAILED="false"
Expand All @@ -166,6 +42,9 @@ export FAIL_MESSAGE="Build failed."
SCRIPT_DIR=$(cd "$(dirname "$0")"; pwd)
export SCRIPT_DIR

. "${SCRIPT_DIR}"/che-util.sh
. "${SCRIPT_DIR}"/installation-util.sh

. "${SCRIPT_DIR}"/../cico_functions.sh

load_jenkins_vars
Expand Down
105 changes: 105 additions & 0 deletions .ci/installation-util.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
#!/bin/bash
# shellcheck disable=SC2046,SC2164,SC2086,SC1090,SC2154

# Copyright (c) 2012-2020 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#
# Contributors:
# Red Hat, Inc. - initial API and implementation

function installOC() {
OC_DIR_NAME=openshift-origin-client-tools-v3.11.0-0cbc58b-linux-64bit
curl -vL "https://github.com/openshift/origin/releases/download/v3.11.0/${OC_DIR_NAME}.tar.gz" --output ${OC_DIR_NAME}.tar.gz
tar -xvf ${OC_DIR_NAME}.tar.gz
cp ${OC_DIR_NAME}/oc /usr/local/bin
cp ${OC_DIR_NAME}/oc /tmp
}

function installKVM() {
echo "======== Start to install KVM virtual machine ========"

yum install -y qemu-kvm libvirt libvirt-python libguestfs-tools virt-install

curl -L https://github.com/dhiltgen/docker-machine-kvm/releases/download/v0.10.0/docker-machine-driver-kvm-centos7 -o /usr/local/bin/docker-machine-driver-kvm
chmod +x /usr/local/bin/docker-machine-driver-kvm

systemctl enable libvirtd
systemctl start libvirtd

virsh net-list --all
echo "======== KVM has been installed successfully ========"
}

function installEpelRelease() {
if yum repolist | grep epel; then
echo "Epel already installed, skipping instalation."
else
#excluding mirror1.ci.centos.org
echo "exclude=mirror1.ci.centos.org" >>/etc/yum/pluginconf.d/fastestmirror.conf
echo "Installing epel..."
yum install -d1 --assumeyes epel-release
yum update --assumeyes -d1
fi
}

function installJQ() {
installEpelRelease
yum install --assumeyes -d1 jq
}

function installAndStartMinishift() {
echo "======== Start to install minishift ========"
curl -Lo minishift.tgz https://github.com/minishift/minishift/releases/download/v1.34.2/minishift-1.34.2-linux-amd64.tgz
tar -xvf minishift.tgz --strip-components=1
chmod +x ./minishift
mv ./minishift /usr/local/bin/minishift

#Setup GitHub token for minishift
if [ -z "$CHE_BOT_GITHUB_TOKEN" ]
then
echo "\$CHE_BOT_GITHUB_TOKEN is empty. Minishift start might fail with GitGub API rate limit reached."
else
echo "\$CHE_BOT_GITHUB_TOKEN is set, checking limits."
GITHUB_RATE_REMAINING=$(curl -slL "https://api.github.com/rate_limit?access_token=$CHE_BOT_GITHUB_TOKEN" | jq .rate.remaining)
if [ "$GITHUB_RATE_REMAINING" -gt 1000 ]
then
echo "Github rate greater than 1000. Using che-bot token for minishift startup."
export MINISHIFT_GITHUB_API_TOKEN=$CHE_BOT_GITHUB_TOKEN
else
echo "Github rate is lower than 1000. *Not* using che-bot for minishift startup."
echo "If minishift startup fails, please try again later."
fi
fi

minishift version
minishift config set memory 14GB
minishift config set cpus 4

echo "======== Launch minishift ========"
minishift start

oc login -u system:admin
oc adm policy add-cluster-role-to-user cluster-admin developer
oc login -u developer -p developer

. "${SCRIPT_DIR}"/che-cert-generation.sh

oc project default
oc delete secret router-certs

cat domain.crt domain.key > minishift.crt
oc create secret tls router-certs --key=domain.key --cert=minishift.crt
oc rollout status dc router
oc rollout latest router
oc rollout status dc router

oc create namespace che

cp rootCA.crt ca.crt
oc create secret generic self-signed-certificate --from-file=ca.crt -n=che
oc project che
}

0 comments on commit 6b16335

Please sign in to comment.