Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge release/2.0 #5

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
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
42 changes: 29 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,43 @@
# Test Runner is an image built to execute a set of unit and integration tests for
# the 'demo' project.
#
FROM python:3
FROM python:3-buster

# Install our deps
RUN apt-get update -qq && apt-get install -y \
sudo \
jq \
python-pycurl \
rubygems
# Install dependencies
RUN apt-get update -y
RUN apt-get install -y jq git bash libcurl4 curl openssh-client

# Install pycurl
ENV PYCURL_SSL_LIBRARY=openssl
RUN apt-get install -y build-essential \
&& pip install pycurl

RUN pip install \
future \
jmespath \
jsonschema \
pyresttest \
shyaml

# TODO: (lkrcal) Enable these when kubectl tests are ready
# Set the Kubernetes version as found in the UCP Dashboard or API
RUN curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.11.5/bin/linux/amd64/kubectl && \
chmod +x ./kubectl && mv ./kubectl /usr/local/bin/kubectl
# RUN curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.11.5/bin/linux/amd64/kubectl && \
# chmod +x ./kubectl && mv ./kubectl /usr/local/bin/kubectl

RUN git clone https://github.com/sstephenson/bats.git && cd bats && ./install.sh /usr/local && cd .. && rm -rf bats

RUN git clone https://github.com/sstephenson/bats.git && cd bats && ./install.sh /usr/local
# Install iofogctl
RUN curl https://packagecloud.io/install/repositories/iofog/iofogctl/script.deb.sh | bash
RUN apt update -y
RUN apt install iofogctl=2.0.0 -y
RUN iofogctl version

# Install the pyresttest and deps (the basis of all our smoke tests)
RUN pip install pyresttest jsonschema future shyaml jmespath
# Make dir for test results
RUN mkdir -p /test-results

# Copy over all the files we need
COPY run.bash /
COPY tests /tests/

# Run our tests
ENTRYPOINT ["/bin/sh", "-c", "/run.bash"]
ENTRYPOINT ["/bin/sh", "-c", "/run.bash"]
26 changes: 16 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ The following test suites are available:

Note that some of additional test suites are automatically skipped as of this release of Test Runner.

## Prerequisites

You must have iofogctl configured with its default namespace pointing to the ECN you want to test

## Usage

| Test suite | Description | Required configuration |
Expand All @@ -20,27 +24,29 @@ Note that some of additional test suites are automatically skipped as of this re
| Basic microservice deployment integration tests | Sets up users and catalog entries, deploys and destroys microservices on each Agent | <ul><li>CONTROLLER</li><li>CONTROLLER_EMAIL</li><li>CONTROLLER_PASSWORD</li><li>AGENTS</li></ul> |


The format of the environment variables is the following:
Example usage of the test runner with iofogctl configuration:

* _CONTROLLER_ - IP:PORT format (e.g. "1.2.3.4:51121")
* _CONTROLLER_EMAIL_ - existing user identifier in Controller to use for testing (e.g. "[email protected]")
* _CONTROLLER_PASSWORD_ - login password for the user (e.g. "#Bugs4Fun")
* _AGENTS_ - comma separated URI with user and optional port (e.g. [email protected]:6451,[email protected])

Note that whenever _AGENTS_ is specified, you need to mount appropriate ssh keys to /root/.ssh of the test-runner containers. The keys can be in any default SSH position: ~/.ssh/id_dsa, ~/.ssh/id_ecdsa, ~/.ssh/id_ed25519 and ~/.ssh/id_rsa.
```bash
docker run --name test-runner \
-v ~/.iofog/:/root/.iofog/ \
iofog/test-runner:latest
```

Example usage of the test runner with full configuration:
Example usage of the test runner with endpoint configurations configuration:

```bash
docker run --name test-runner \
-v ~/.ssh/my_iofog_ssh_key:/root/.ssh/id_rsa \
-v ~/.ssh/my_iofog_agent_ssh_key:/root/.ssh/id_rsa \
-e CONTROLLER="1.2.3.4:51121" \
-e CONTROLLER_EMAIL="[email protected]" \
-e CONTROLLER_PASSWORD="#Bugs4Fun" \
-e AGENTS="[email protected]:6451,[email protected]" \
-e AGENT_USER="root" \
-e AGENT_KEY="/root/.ssh/id_rsa" \
iofog/test-runner:latest
```

Note that whenever AGENTS is specified, you need to mount appropriate ssh keys to /root/.ssh of the test-runner containers. The keys can be in any default SSH position: ~/.ssh/id_dsa, ~/.ssh/id_ecdsa, ~/.ssh/id_ed25519 and ~/.ssh/id_rsa.

## Test Results

The output of this test-suite currently is a single XML File that is Junit-XML compliant.
Expand Down
18 changes: 17 additions & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,28 @@ pr:

variables:
repository: 'focal-freedom-236620/test-runner'
ref: $(Build.SourceBranch)
buildTag: $(Build.BuildId)
imageTag:

jobs:
- job: TestRunner
pool:
vmImage: 'Ubuntu-16.04'

steps:
- script: |
if [[ $(ref) == refs/tags* ]]; then
TAG=$(echo $(ref) | sed "s|refs/tags/v||g")
echo "##vso[task.setvariable variable=imageTag]$TAG"
else
LATESTTAG=$(git tag | tail -1)
LATESTVERS=${LATESTTAG#?}
if [ -z "$LATESTVERS" ]; then LATESTVERS=0.0.0; fi
echo "##vso[task.setvariable variable=imageTag]$LATESTVERS-b$(buildTag)"
fi
echo $(imageTag)
displayName: 'Set image tag'
- task: Docker@2
displayName: 'Docker build'
inputs:
Expand All @@ -34,6 +48,7 @@ jobs:
Dockerfile: "Dockerfile"
tags: |
$(buildTag)
$(imageTag)
latest

- task: Docker@2
Expand All @@ -45,10 +60,11 @@ jobs:
Dockerfile: "Dockerfile"
tags: |
$(buildTag)
$(imageTag)
latest

- script: |
echo "gcr.io/${REPOSITORY}:${BUILDTAG}" > $(Build.ArtifactStagingDirectory)/docker-image.txt
echo "gcr.io/${REPOSITORY}:$(imageTag)" > $(Build.ArtifactStagingDirectory)/docker-image.txt
displayName: 'Save Docker image name to artifact'

- task: PublishPipelineArtifact@0
Expand Down
Loading