Skip to content
This repository has been archived by the owner on Feb 21, 2021. It is now read-only.

created test for packages #933

Merged
merged 1 commit into from
Oct 24, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions test/packages/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test_result.txt
20 changes: 20 additions & 0 deletions test/packages/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Package Tests
========
This directory contains all Tests for packages. They use dockers to test

# Install python docker api

```sh
$ pip install docker
```

# Run Tests

```sh
$ python run_test.py test_list.yml
```
in test_list.yml you can able or disable tests

# Edit Dockerfile

Follow [this link](https://docker-py.readthedocs.io/en/stable/) for more information
45 changes: 45 additions & 0 deletions test/packages/cameraview/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
FROM jderobot/jderobot


LABEL manteiner Aitor Martínez Fernández+aitor.martinez.fernandez@gmail.com

RUN apt-get update && apt-get -y install \
wget \
&& rm -rf /var/lib/apt/lists/*

########## setup Repositories ##############
## ROS ##
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116
RUN echo "deb http://packages.ros.org/ros/ubuntu xenial main" > /etc/apt/sources.list.d/ros-latest.list

## ZeroC ##
RUN sh -c 'echo deb http://zeroc.com/download/apt/ubuntu16.04 stable main > /etc/apt/sources.list.d/zeroc.list'
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv 5E6DA83306132997

## Gazebo ##
RUN echo "deb http://packages.osrfoundation.org/gazebo/ubuntu-stable xenial main" > /etc/apt/sources.list.d/gazebo-stable.list
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-key 67170598AF249743


## JdeRobot Test ##
RUN sh -c 'echo "deb http://jderobot.org/aptest xenial main" > /etc/apt/sources.list.d/jderobot.list'
RUN wget -qO - www.jderobot.org/aptest/aptest.key | apt-key add -


## JdeRobot ##
#RUN sh -c 'echo "deb http://jderobot.org/apt xenial main" > /etc/apt/sources.list.d/jderobot.list'
#RUN apt-key adv --keyserver keyserver.ubuntu.com --recv B0E7F58E82C8091DF945A0453DA08892EE69A25C

########## Install JdeRobot ##############
RUN apt-get update && apt-get -y install --only-upgrade\
jderobot-cameraview \
&& rm -rf /var/lib/apt/lists/*

COPY ./search_files.sh /
COPY ./files.txt /

RUN ./search_files.sh files.txt




3 changes: 3 additions & 0 deletions test/packages/cameraview/files.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/opt/jderobot/share/jderobot/glade/cameraview.glade
/opt/jderobot/share/jderobot/conf/cameraview.yml
/opt/jderobot/bin/cameraview
13 changes: 13 additions & 0 deletions test/packages/cameraview/search_files.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash


FILE_NOT_FONUD=64

while IFS='' read -r line || [[ -n "$line" ]]; do
if [ ! -f "$line" ]; then
echo "File Not Found!" 1>&2
exit $FILE_NOT_FONUD
fi
done < "$1"


39 changes: 39 additions & 0 deletions test/packages/install_test/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
FROM ubuntu:xenial


LABEL manteiner Aitor Martínez Fernández+aitor.martinez.fernandez@gmail.com

RUN apt-get update && apt-get -y install \
wget \
&& rm -rf /var/lib/apt/lists/*


########## setup Repositories ##############

## ROS ##
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116
RUN echo "deb http://packages.ros.org/ros/ubuntu xenial main" > /etc/apt/sources.list.d/ros-latest.list

## ZeroC ##
RUN sh -c 'echo deb http://zeroc.com/download/apt/ubuntu16.04 stable main > /etc/apt/sources.list.d/zeroc.list'
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv 5E6DA83306132997

## Gazebo ##
RUN echo "deb http://packages.osrfoundation.org/gazebo/ubuntu-stable xenial main" > /etc/apt/sources.list.d/gazebo-stable.list
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-key 67170598AF249743


## JdeRobot ##
RUN sh -c 'echo "deb http://jderobot.org/aptest xenial main" > /etc/apt/sources.list.d/jderobot.list'
RUN wget -qO - www.jderobot.org/aptest/aptest.key | apt-key add -

########## Install JdeRobot ##############
RUN apt-get update && apt-get -y install\
jderobot \
&& rm -rf /var/lib/apt/lists/*


########## Install JdeRobot ##############
RUN apt-get update && apt-get -y purge\
jderobot \
&& rm -rf /var/lib/apt/lists/*
60 changes: 60 additions & 0 deletions test/packages/run_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import docker
import yaml
import sys




yamlFile = sys.argv[1]
client = docker.from_env()
images={}

result = open('test_result.txt', 'w')


## Build Image ##
def build_image(ipath, itag):
try:
print "Building " + image
client.images.build(pull=True, path=ipath, tag=itag, rm=True, stream=True)
except docker.errors.BuildError as exc:
return "ERROR " + exc.__str__()
except docker.errors.APIError as exc:
return "ERROR " + exc.__str__()

return "OK"


## remove Image ##
def remove_image(itag):
try:
print "Removing " + image
client.images.remove(image=itag, force=True)
except docker.errors.BuildError as exc:
pass
except docker.errors.APIError as exc:
print (exc)



## Open File ##
with open(yamlFile, 'r') as stream:
try:
images=yaml.load(stream)
except yaml.YAMLError as exc:
print(exc)


for image in images:
if images[image]["run"]:

sol = build_image(images[image]["path"], image)
remove_image(image)

result.write(image + ": " + sol + "\n")

result.close()




11 changes: 11 additions & 0 deletions test/packages/test_list.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
install_test:
path: install_test
run: True

update_test:
path: update_test
run: True

cameraview:
path: cameraview
run: True
22 changes: 22 additions & 0 deletions test/packages/update_test/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM jderobot/jderobot


LABEL manteiner Aitor Martínez Fernández+aitor.martinez.fernandez@gmail.com

RUN apt-get update && apt-get -y install \
wget \
&& rm -rf /var/lib/apt/lists/*

########## setup Repositories ##############
## JdeRobot Test##
RUN sh -c 'echo "deb http://jderobot.org/aptest xenial main" > /etc/apt/sources.list.d/jderobot.list'
RUN wget -qO - www.jderobot.org/aptest/aptest.key | apt-key add -

########## Upgrade JdeRobot ##############
RUN apt-get update && apt-get -y install --only-upgrade \
jderobot \
&& rm -rf /var/lib/apt/lists/*