Skip to content

Conversation

@ceciliaavila
Copy link

Proposed Changes

  • Enable echo controller in Microsoft.Bot.Builder.TestBot project by adding an environment variable with the name of the bot we want to use.
    image
    image
  • Add new DirectLineClientTests to FunctionalTests project to test sending a message to the TestBot deployed in Azure with ARM Templates and check its response.
    image

Steps to configure the Pipeline:

1- Define five environment variables: AppId, AppSecret, BotName, BotGroup and CHOSENBOT and mark the first two as Secrets.
image
image
2- Add a Dotnet Task to publish the Test Bot project and leave it as a zip in a folder named PublishedBot.
image
In Arguments we need to set:

--output $(System.DefaultWorkingDirectory)\tests\Microsoft.Bot.Builder.TestBot\PublishedBot

3- Configure one Azure CLI Task to:

  • Run az deployment create command to create the resources in Azure.
  • Run az webapp deployment command to deploy the TestBot sample.
  • Run az bot direcline create command to connect the bot to the DirectLine channel
    image
    The output goes into a json file from where we will recover the channel key later.

The script is:

call az deployment create --name "$(BotGroup)" --template-file "$(System.DefaultWorkingDirectory)\FunctionalTests\ExportedTemplate\template.json" --location "westus" --parameters appId=$(AppId) appSecret="$(AppSecret)" botId="$(BotName)" botSku=F0 newAppServicePlanName="$(BotName)" newWebAppName="$(BotName)" groupName="$(BotGroup)" groupLocation="westus" newAppServicePlanLocation="westus"

call az webapp deployment source config-zip --resource-group "$(BotGroup)" --name "$(BotName)" --src "$(System.DefaultWorkingDirectory)\tests\Microsoft.Bot.Builder.TestBot\PublishedBot\PublishedBot.zip"

call az bot directline create -n "$(BotName)" -g "$(BotGroup)" > "$(System.DefaultWorkingDirectory)\DirectLineCreate.json"

4- Add a new PowerShell Script Task to read the json file generated in the previous step and get the secret key to connect to the bot. It also sets an environment variable with this value.
image
The script is:

$json = Get-Content '$(System.DefaultWorkingDirectory)\DirectLineCreate.json' | Out-String | ConvertFrom-Json

$key = $json.properties.properties.sites.key
$botName = "$env:BotName"

echo "##vso[task.setvariable variable=DIRECTLINE;]$key"
echo "##vso[task.setvariable variable=BOTID;]$botName"

5- After the Tests run, add a new Azure CLI Task to delete the resource group we've created in the third step.
image
The script is:

call az group delete -n "$(BotGroup)" --yes

We strongly recommend setting this task to run Even if a previous task has failed, even if the build was canceled. With this setting, we will assure that the resources will be deleted from Azure even if the build fails at any step.

After running these steps, the Bot is deployed, tested and deleted.
image
image

@ceciliaavila ceciliaavila changed the title Add Test for TestBot in Functional Tests project Add test for TestBot in Functional Tests project Apr 26, 2019
Copy link

@gasper-az gasper-az left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. :shipit:

@ParadoxARG
Copy link

:shipit:

Copy link

@denscollo denscollo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@ParadoxARG
Copy link

Replaced by #1807

@ParadoxARG ParadoxARG closed this May 30, 2019
@gasper-az gasper-az deleted the feature/functional-test-bot-with-echo branch September 13, 2019 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants