Skip to content
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
3 changes: 1 addition & 2 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@ source = ./libraries/
omit =
*/tests/*
setup.py
*/botbuilder-schema/*
*/functional-tests/*
*/botbuilder-schema/*
67 changes: 48 additions & 19 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,61 @@
schedules:
- cron: "0 0 * * *"
displayName: Daily midnight build
trigger:
branches:
include:
- daveta-python-functional
exclude:
- master

variables:
resourceGroupName: 'pyfuntest'
# Container registry service connection established during pipeline creation
dockerRegistryServiceConnection: 'NightlyE2E-Acr'
azureRmServiceConnection: 'NightlyE2E-RM'
dockerFilePath: 'libraries/functional-tests/functionaltestbot/Dockerfile'
buildIdTag: $(Build.BuildNumber)
webAppName: 'e2epython'
containerRegistry: 'nightlye2etest.azurecr.io'
imageRepository: 'functionaltestpy'




jobs:
- job: Doit
# Build and publish container
- job: Build
pool:
vmImage: 'Ubuntu-16.04'

displayName: Build and push bot image
continueOnError: false
steps:
- task: UsePythonVersion@0
displayName: Use Python 3.6
- task: Docker@2
displayName: Build and push bot image
inputs:
versionSpec: '3.6'
command: buildAndPush
repository: $(imageRepository)
dockerfile: $(dockerFilePath)
containerRegistry: $(dockerRegistryServiceConnection)
tags: $(buildIdTag)



- task: AzureCLI@2
displayName: Provision, Deploy and run tests
- job: Deploy
displayName: Provision bot container
pool:
vmImage: 'Ubuntu-16.04'
dependsOn:
- Build
steps:
- task: AzureRMWebAppDeployment@4
displayName: Python Functional E2E test.
inputs:
azureSubscription: 'FUSE Temporary (174c5021-8109-4087-a3e2-a1de20420569)'
scriptType: 'bash'
scriptLocation: 'inlineScript'
inlineScript: |
cd $(Build.SourcesDirectory)/libraries/functional-tests/functionaltestbot
chmod +x ./scripts/deploy_webapp.sh
./scripts/deploy_webapp.sh --appid $(botAppId) --password $(botAppPassword) -g $(resourceGroupName)
continueOnError: false
ConnectionType: AzureRM
ConnectedServiceName: $(azureRmServiceConnection)
appType: webAppContainer
WebAppName: $(webAppName)
DockerNamespace: $(containerRegistry)
DockerRepository: $(imageRepository)
DockerImageTag: $(buildIdTag)
AppSettings: '-MicrosoftAppId $(botAppId) -MicrosoftAppPassword $(botAppPassword) -FLASK_APP /functionaltestbot/app.py -FLASK_DEBUG 1'

#StartupCommand: 'flask run --host=0.0.0.0 --port=3978'


48 changes: 48 additions & 0 deletions libraries/functional-tests/functionaltestbot/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.

FROM tiangolo/uwsgi-nginx-flask:python3.6


RUN mkdir /functionaltestbot

EXPOSE 443
# EXPOSE 2222

COPY ./functionaltestbot /functionaltestbot
COPY setup.py /
COPY test.sh /
# RUN ls -ltr
# RUN cat prestart.sh
# RUN cat main.py

ENV FLASK_APP=/functionaltestbot/app.py
ENV LANG=C.UTF-8
ENV LC_ALL=C.UTF-8
ENV PATH ${PATH}:/home/site/wwwroot

WORKDIR /

# Initialize the bot
RUN pip3 install -e .

# ssh
ENV SSH_PASSWD "root:Docker!"
RUN apt-get update \
&& apt-get install -y --no-install-recommends dialog \
&& apt-get update \
&& apt-get install -y --no-install-recommends openssh-server \
&& echo "$SSH_PASSWD" | chpasswd \
&& apt install -y --no-install-recommends vim
COPY sshd_config /etc/ssh/
COPY init.sh /usr/local/bin/
RUN chmod u+x /usr/local/bin/init.sh

# For Debugging, uncomment the following:
# ENTRYPOINT ["python3.6", "-c", "import time ; time.sleep(500000)"]
ENTRYPOINT ["init.sh"]

# For Devops, they don't like entry points. This is now in the devops
# pipeline.
# ENTRYPOINT [ "flask" ]
# CMD [ "run", "--port", "3978", "--host", "0.0.0.0" ]
27 changes: 27 additions & 0 deletions libraries/functional-tests/functionaltestbot/Dockfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.

FROM python:3.7-slim as pkg_holder

ARG EXTRA_INDEX_URL
RUN pip config set global.extra-index-url "${EXTRA_INDEX_URL}"

COPY requirements.txt .
RUN pip download -r requirements.txt -d packages

FROM python:3.7-slim

ENV VIRTUAL_ENV=/opt/venv
RUN python3.7 -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"

COPY . /app
WORKDIR /app

COPY --from=pkg_holder packages packages

RUN pip install -r requirements.txt --no-index --find-links=packages && rm -rf packages

ENTRYPOINT ["python"]
EXPOSE 3978
CMD ["runserver.py"]
9 changes: 0 additions & 9 deletions libraries/functional-tests/functionaltestbot/README.md

This file was deleted.

98 changes: 0 additions & 98 deletions libraries/functional-tests/functionaltestbot/application.py

This file was deleted.

19 changes: 0 additions & 19 deletions libraries/functional-tests/functionaltestbot/bots/echo_bot.py

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Client Driver for Function E2E test

This contains the client code that drives the bot functional test.

It performs simple operations against the bot and validates results.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.

from .echo_bot import EchoBot
from .app import APP

__all__ = ["EchoBot"]
__all__ = ["APP"]
21 changes: 21 additions & 0 deletions libraries/functional-tests/functionaltestbot/flask_bot_app/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.

"""Bot app with Flask routing."""

from flask import Response

from .bot_app import BotApp


APP = BotApp()


@APP.flask.route("/api/messages", methods=["POST"])
def messages() -> Response:
return APP.messages()


@APP.flask.route("/api/test", methods=["GET"])
def test() -> Response:
return APP.test()
Loading