Skip to content

Commit

Permalink
Added functionality for e2e files
Browse files Browse the repository at this point in the history
  • Loading branch information
axsaucedo committed Oct 25, 2019
1 parent f2d2aef commit 222efb7
Show file tree
Hide file tree
Showing 6 changed files with 227 additions and 40 deletions.
73 changes: 66 additions & 7 deletions core-builder/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
FROM openjdk:8u141-jdk

ENV PYTHON_VERSION "3.6.0"

# install docker
RUN \
apt-get update && \
Expand All @@ -17,6 +19,23 @@ RUN \
apt-get update && \
apt-get install -y docker-ce

# Installing source to image (s2i)
RUN wget https://github.com/openshift/source-to-image/releases/download/v1.1.14/source-to-image-v1.1.14-874754de-linux-386.tar.gz && \
tar -zxvf source-to-image-v1.1.14-874754de-linux-386.tar.gz && \
rm source-to-image-v1.1.14-874754de-linux-386.tar.gz && \
mv ./s2i /bin && \
mv ./sti /bin

# Installing KIND
RUN wget https://github.com/kubernetes-sigs/kind/releases/download/v0.5.1/kind-linux-amd64 && \
chmod +x kind-linux-amd64 && \
mv ./kind-linux-amd64 /bin/kind

# Installing Kubectl
RUN wget https://storage.googleapis.com/kubernetes-release/release/v1.16.2/bin/linux/amd64/kubectl && \
chmod +x ./kubectl && \
mv ./kubectl /bin

RUN \
apt-get update -y && \
apt-get install -y vim && \
Expand All @@ -25,13 +44,53 @@ RUN \
update-alternatives --set java /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java && \
apt-get remove -y --auto-remove && apt-get clean -y && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

# dependencies for release script
RUN \
# install env for python3
apt-get update -y && \
apt-get install -y python3-pip && \
pip3 install pyyaml && \
apt-get remove -y --auto-remove && apt-get clean -y && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# ZLIB1G required for installation python
RUN apt-get upgrade && \
apt-get update && \
apt-get install zlib1g -y && \
apt-get install zlib1g-dev -y && \
apt-get install libssl-dev -y

RUN curl -SLO https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tgz \
&& tar xvf Python-${PYTHON_VERSION}.tgz \
&& cd Python-${PYTHON_VERSION} \
&& ./configure --prefix=/usr/local --with-openssl \
&& make \
&& make altinstall \
&& cd / \
&& rm -rf Python-${PYTHON_VERSION}*

# Ensure python3 and pip3 are default
RUN curl -sS https://bootstrap.pypa.io/get-pip.py >>setup.py && \
python setup.py
RUN update-alternatives --install /usr/bin/python python /usr/local/bin/python3.6 1
RUN rm -rf /usr/local/bin/pip && \
ln -s /usr/local/bin/pip3.6 /usr/local/bin/pip

RUN pip install --upgrade pip
RUN pip install --upgrade setuptools
RUN pip install pyyaml
RUN pip install grpcio
RUN pip install grpcio-tools
RUN apt-get remove -y --auto-remove && apt-get clean -y && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

# INSTALL GO
ENV PATH /usr/local/go/bin:$PATH
RUN wget https://dl.google.com/go/go1.13.3.linux-amd64.tar.gz && \
tar -zxvf go1.13.3.linux-amd64.tar.gz && \
mv go/ /usr/local/go
RUN curl -sL https://go.kubebuilder.io/dl/2.0.1/linux/amd64 | tar -xz -C /tmp/ && \
mv /tmp/kubebuilder_2.0.1_linux_amd64 /usr/local/kubebuilder/
ENV PATH /usr/local/kubebuilder/bin:$PATH

# DOWNLOAD HELM
RUN curl -L https://git.io/get_helm.sh | bash

# DOWNLOAD KUSTOMIZE
RUN wget https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2Fv3.2.3/kustomize_kustomize.v3.2.3_linux_amd64 && \
chmod +x kustomize_kustomize.v3.2.3_linux_amd64 && \
mv kustomize_kustomize.v3.2.3_linux_amd64 /usr/local/bin/kustomize


WORKDIR /work

Expand Down
2 changes: 1 addition & 1 deletion core-builder/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
DOCKER_IMAGE_NAME=seldonio/core-builder
DOCKER_IMAGE_VERSION=0.3
DOCKER_IMAGE_VERSION=0.4

build_docker_image:
docker build --force-rm=true -t $(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_VERSION) .
Expand Down
45 changes: 45 additions & 0 deletions jenkins-x-bdd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
buildPack: none
pipelineConfig:
pipelines:
pullRequest:
pipeline:
agent:
image: seldonio/core-builder:0.4
stages:
- name: end-to-end
steps:
- name: test-end-to-end
command: cd
args:
- testing/scripts &&
- bash
- kind_test_all.sh
options:
containerOptions:
volumeMounts:
- mountPath: /lib/modules
name: modules
readOnly: true
- mountPath: /sys/fs/cgroup
name: cgroup
- name: dind-storage
mountPath: /var/lib/docker
resources:
requests:
cpu: 2
memory: 4000Mi
securityContext:
privileged: true
imagePullPolicy: Always
volumes:
- name: modules
hostPath:
path: /lib/modules
type: Directory
- name: cgroup
hostPath:
path: /sys/fs/cgroup
type: Directory
- name: dind-storage
emptyDir: {}

69 changes: 38 additions & 31 deletions jenkins-x.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,42 @@ pipelineConfig:
pullRequest:
pipeline:
agent:
image: seldonio/core-builder:0.3
image: seldonio/core-builder:0.4
stages:
- name: build-and-test
parallel:
- name: seldon-python
agent:
image: seldonio/python-builder:0.2
steps:
- name: test-python
command: make
args:
- -C python
- update_package
- install
- test
- name: test-python-tf
command: make
args:
- -C python
- update_package
- install-tf
- test
- name: seldon-engine
agent:
image: seldonio/core-builder:0.3
steps:
- name: test-engine
command: make
args:
- -C engine
- -f Makefile.ci
- build_jar
- name: end-to-end
steps:
- name: test-end-to-end
command: cd
args:
- testing/scripts &&
- bash
- kind_test_all.sh
options:
containerOptions:
volumeMounts:
- mountPath: /lib/modules
name: modules
readOnly: true
- mountPath: /sys/fs/cgroup
name: cgroup
- name: dind-storage
mountPath: /var/lib/docker
resources:
requests:
cpu: 2
memory: 4000Mi
securityContext:
privileged: true
imagePullPolicy: Always
volumes:
- name: modules
hostPath:
path: /lib/modules
type: Directory
- name: cgroup
hostPath:
path: /sys/fs/cgroup
type: Directory
- name: dind-storage
emptyDir: {}

6 changes: 5 additions & 1 deletion testing/scripts/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ VERSION := $(shell cat ../../version.txt)
kind_create_cluster:
kind create cluster --config kind_config.yaml

kind_delete_cluster:
kind delete cluster

kind_build_engine:
cd ../../engine/ && make build_image
kind load docker-image seldonio/engine:$(VERSION) --loglevel trace
Expand Down Expand Up @@ -48,6 +51,7 @@ build_protos:
cp -vr ../../proto/tensorflow/tensorflow .
python -m grpc.tools.protoc -I. --python_out=. --grpc_python_out=. ./proto/prediction.proto
cd ../../notebooks && make build_protos
cd ../../proto/k8s && make create_protos

#requires mvn, helm, ks, python, s2i and an accessible k8s cluster (if minikube increase mem and cpu)
#tests will create namespaces, deploy seldon core and create examples
Expand All @@ -57,7 +61,7 @@ install:

.PHONY: test
test: build_protos install
pytest -s -W ignore > run.log 2>&1
pytest --verbose -s -W ignore 2>&1

.PHONY: clean
clean:
Expand Down
72 changes: 72 additions & 0 deletions testing/scripts/kind_test_all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#!/bin/bash

set -o errexit
set -o pipefail
set -o nounset

# FIRST WE START THE DOCKER DAEMON
service docker start
# the service can be started but the docker socket not ready, wait for ready
WAIT_N=0
while true; do
# docker ps -q should only work if the daemon is ready
docker ps -q > /dev/null 2>&1 && break
if [[ ${WAIT_N} -lt 5 ]]; then
WAIT_N=$((WAIT_N+1))
echo "[SETUP] Waiting for Docker to be ready, sleeping for ${WAIT_N} seconds ..."
sleep ${WAIT_N}
else
echo "[SETUP] Reached maximum attempts, not waiting any longer ..."
break
fi
done

#######################################
# AVOID EXIT ON ERROR FOR FOLLOWING CMDS
set +o errexit

# START CLUSTER
make kind_create_cluster
KIND_EXIT_VALUE=$?

# Ensure we reach the kubeconfig path
export KUBECONFIG=$(kind get kubeconfig-path)

# ONLY RUN THE FOLLOWING IF SUCCESS
if [[ ${KIND_EXIT_VALUE} -eq 0 ]]; then
# BUILD S2I BASE IMAGES
make s2i_build_base_images
S2I_EXIT_VALUE=$?

# CREATE PROTOS
make build_protos
PROTOS_EXIT_VALUE=$?

# KIND CLUSTER SETUP
make kind_setup
SETUP_EXIT_VALUE=$?

## INSTALL ALL REQUIRED DEPENDENCIES
make -C ../../python install-dev
INSTALL_EXIT_VALUE=$?

## RUNNING TESTS AND CAPTURING ERROR
make test
TEST_EXIT_VALUE=$?
fi

# DELETE KIND CLUSTER
make kind_delete_cluster
DELETE_EXIT_VALUE=$?

#######################################
# EXIT STOPS COMMANDS FROM HERE ONWARDS
set -o errexit

# CLEANING DOCKER
docker ps -aq | xargs -r docker rm -f || true
service docker stop || true

# NOW THAT WE'VE CLEANED WE CAN EXIT ON TEST EXIT VALUE
exit ${TEST_EXIT_VALUE}

0 comments on commit 222efb7

Please sign in to comment.