-
Notifications
You must be signed in to change notification settings - Fork 372
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Run tests within a container * cleanup Co-authored-by: narrieta <narrieta>
- Loading branch information
Showing
13 changed files
with
163 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# | ||
# * Sample command to build the image: | ||
# | ||
# docker build -t waagenttests . | ||
# | ||
# * Sample command to execute a container interactively: | ||
# | ||
# docker run --rm -it -v /home/nam/src/WALinuxAgent:/home/waagent/WALinuxAgent waagenttests bash --login | ||
# | ||
FROM ubuntu:latest | ||
LABEL description="Test environment for WALinuxAgent" | ||
|
||
SHELL ["/bin/bash", "-c"] | ||
|
||
# | ||
# Install the required packages as root | ||
# | ||
USER root | ||
|
||
RUN \ | ||
apt-get update && \ | ||
\ | ||
# \ | ||
# Install basic dependencies \ | ||
# \ | ||
apt-get install -y git python3.10 python3.10-dev curl && \ | ||
ln /usr/bin/python3.10 /usr/bin/python3 && \ | ||
\ | ||
# \ | ||
# Install LISA dependencies \ | ||
# \ | ||
apt-get install -y git gcc libgirepository1.0-dev libcairo2-dev qemu-utils libvirt-dev python3-venv && \ | ||
\ | ||
# \ | ||
# Create user waagent, which is used to execute the tests \ | ||
# \ | ||
groupadd waagent && \ | ||
useradd --shell /bin/bash --create-home -g waagent waagent && \ | ||
: | ||
|
||
# | ||
# Do the Poetry and LISA setup as waagent | ||
# | ||
USER waagent | ||
|
||
RUN \ | ||
# \ | ||
# Install Poetry \ | ||
# \ | ||
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py | python3 - && \ | ||
export PATH="$HOME/.local/bin:$PATH" && \ | ||
\ | ||
# \ | ||
# Install LISA \ | ||
# \ | ||
cd $HOME && \ | ||
git clone https://github.com/microsoft/lisa.git && \ | ||
cd lisa && \ | ||
poetry config virtualenvs.in-project true && \ | ||
make setup && \ | ||
\ | ||
# \ | ||
# Install additional test dependencies \ | ||
# \ | ||
poetry add msrestazure && \ | ||
\ | ||
# \ | ||
# The setup for the tests depends on a couple of paths; add those to the profile \ | ||
# \ | ||
echo 'export PYTHONPATH="$HOME/WALinuxAgent"' >> $HOME/.bash_profile && \ | ||
echo 'export PATH="$HOME/.local/bin:$PATH"' >> $HOME/.bash_profile && \ | ||
: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,4 +10,3 @@ cryptography | |
distro | ||
junitparser | ||
msrestazure | ||
python-dotenv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Create a base class | ||
import logging | ||
|
||
|
||
def get_logger(name): | ||
return LoggingHandler(name).log | ||
|
||
|
||
class LoggingHandler: | ||
""" | ||
Base class for Logging | ||
""" | ||
def __init__(self, name=None): | ||
self.log = self.__setup_and_get_logger(name) | ||
|
||
def __setup_and_get_logger(self, name): | ||
logger = logging.getLogger(name if name is not None else self.__class__.__name__) | ||
if logger.hasHandlers(): | ||
# Logging module inherits from base loggers if already setup, if a base logger found, reuse that | ||
return logger | ||
|
||
# No handlers found for logger, set it up | ||
# This logging format is easier to read on the DevOps UI - | ||
# https://docs.microsoft.com/en-us/azure/devops/pipelines/scripts/logging-commands?view=azure-devops&tabs=bash#formatting-commands | ||
log_formatter = logging.Formatter("##[%(levelname)s] [%(asctime)s] [%(module)s] {%(pathname)s:%(lineno)d} %(message)s", | ||
datefmt="%Y-%m-%dT%H:%M:%S%z") | ||
console_handler = logging.StreamHandler() | ||
console_handler.setFormatter(log_formatter) | ||
logger.addHandler(console_handler) | ||
logger.setLevel(logging.INFO) | ||
|
||
return logger | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euxo pipefail | ||
|
||
az login --service-principal --username "$AZURE_CLIENT_ID" --password "$AZURE_CLIENT_SECRET" --tenant "$AZURE_TENANT_ID" > /dev/null | ||
|
||
az acr login --name waagenttests | ||
|
||
docker pull waagenttests.azurecr.io/waagenttests:latest | ||
|
||
# Logs will be placed in this location. Make waagent (UID 1000 in the container) the owner. | ||
mkdir "$HOME/logs" | ||
sudo chown 1000 "$HOME/logs" | ||
|
||
docker run --rm \ | ||
--volume "$BUILD_SOURCESDIRECTORY:/home/waagent/WALinuxAgent" \ | ||
--volume "$DOWNLOADSSHKEY_SECUREFILEPATH:/home/waagent/id_rsa" \ | ||
--volume "$HOME/logs:/home/waagent/logs" \ | ||
--env SUBSCRIPTION_ID \ | ||
--env AZURE_CLIENT_ID \ | ||
--env AZURE_CLIENT_SECRET \ | ||
--env AZURE_TENANT_ID \ | ||
waagenttests.azurecr.io/waagenttests \ | ||
bash --login -c '~/WALinuxAgent/tests_e2e/scripts/execute_tests.sh' | ||
|
||
ls -lR "$HOME/logs" | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters