Skip to content

Commit

Permalink
Add integration test for android CLI manual commands (#503)
Browse files Browse the repository at this point in the history
* add integration test for android CLI manual commands

* test android install comand

* fix job, add more commands and try with zipped apk

* Apply suggestions from code review

Co-authored-by: Přemek Vysoký <[email protected]>

* apply suggestions from code review

* apply suggestions from code review

* fixing arguments

* update device command

* move retrying device message into debug

* switch off warn logging for android device

* filter verbosity for android device

* override loglevel for android device command

* try set -ex

Co-authored-by: Přemek Vysoký <[email protected]>
  • Loading branch information
Katya Sokolova and premun authored Apr 7, 2021
1 parent f1c7f66 commit a1a2bc0
Show file tree
Hide file tree
Showing 3 changed files with 113 additions and 1 deletion.
41 changes: 41 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,47 @@ stages:
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
HelixAccessToken: ''

- stage: Test_CLI_Manual_Commands_In_Helix_Android
displayName: 'CLI Android Manual Commands Integration tests (Helix SDK)'
dependsOn: Build_OSX
jobs:
- template: /eng/common/templates/jobs/jobs.yml
parameters:
workspace:
clean: all
jobs:
- job: Linux
pool:
vmimage: ubuntu-latest
strategy:
matrix:
Build_Debug:
_BuildConfig: Debug
preSteps:
- checkout: self
clean: true
displayName: Submit Helix Job
steps:
- task: DownloadPipelineArtifact@2
inputs:
source: current
artifact: Microsoft.DotNet.XHarness.CLI.Debug
path: $(Build.SourcesDirectory)/artifacts/packages/$(_BuildConfig)/Shipping/

- script: eng/common/build.sh
--configuration $(_BuildConfig)
--prepareMachine
--ci
--restore
--test
--projects $(Build.SourcesDirectory)/tests/integration-tests/Android/Android.CLI.Commands.Tests.proj
/bl:$(Build.SourcesDirectory)/artifacts/log/$(_BuildConfig)/Android.CLI.Commands.Tests.binlog
/p:RestoreUsingNuGetTargets=false
displayName: Run Helix Tests
env:
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
HelixAccessToken: ''

- stage: Test_CLI_Package_In_Helix_Apple
displayName: 'CLI Apple Integration tests (Helix SDK)'
dependsOn: Build_OSX
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ namespace Microsoft.DotNet.XHarness.CLI.Commands.Android
{
internal class AndroidGetDeviceCommand : XHarnessCommand
{
private readonly AndroidGetDeviceCommandArguments _arguments = new();
private readonly AndroidGetDeviceCommandArguments _arguments = new()
{
Verbosity = LogLevel.Error
};

protected override XHarnessCommandArguments Arguments => _arguments;

Expand Down
68 changes: 68 additions & 0 deletions tests/integration-tests/Android/Android.CLI.Commands.Tests.proj
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<Project DefaultTargets="Test">
<Import Sdk="Microsoft.DotNet.Helix.Sdk" Project="Sdk.props"/>

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<!-- Workaround changes from newer MSBuild requiring additional properties, see https://github.com/dotnet/arcade/pull/5996 -->
<TargetFrameworkVersion>3.1</TargetFrameworkVersion>
<TargetFrameworkIdentifier>.NETCoreApp</TargetFrameworkIdentifier>
<HelixType>test/product/</HelixType>
<IncludeXHarnessCli>true</IncludeXHarnessCli>
<TestRunNamePrefix>$(AGENT_JOBNAME)</TestRunNamePrefix>
<EnableAzurePipelinesReporter>true</EnableAzurePipelinesReporter>
<HelixBaseUri>https://helix.dot.net</HelixBaseUri>
<!-- Pick up the nupkg from this repo for testing purposes -->
<MicrosoftDotNetXHarnessCLIVersion>1.0.0-ci</MicrosoftDotNetXHarnessCLIVersion>
<XHarnessNupkgPath>$(ArtifactsShippingPackagesDir)/Microsoft.DotNet.XHarness.CLI.$(MicrosoftDotNetXHarnessCLIVersion).nupkg</XHarnessNupkgPath>
</PropertyGroup>

<!-- For non-ci local runs -->
<PropertyGroup Condition=" '$(AGENT_JOBNAME)' == '' ">
<EnableAzurePipelinesReporter>false</EnableAzurePipelinesReporter>
<MicrosoftDotNetXHarnessCLIVersion>1.0.0-dev</MicrosoftDotNetXHarnessCLIVersion>
</PropertyGroup>

<!-- Required: Configuration that is already needed for the Helix SDK -->
<ItemGroup>
<HelixTargetQueue Include="ubuntu.1804.amd64.android.open"/>
</ItemGroup>

<PropertyGroup Condition=" '$(HelixAccessToken)' == '' ">
<IsExternal>true</IsExternal>
<Creator>$(BUILD_SOURCEVERSIONAUTHOR)</Creator>
<Creator Condition=" '$(Creator)' == '' ">anon</Creator>
</PropertyGroup>

<PropertyGroup>
<XHarnessX86TestApkUrl>https://netcorenativeassets.blob.core.windows.net/resource-packages/external/android/test-apk/x86/System.Numerics.Vectors.Tests-x86.zip</XHarnessX86TestApkUrl>
</PropertyGroup>

<!-- Useless stuff to make Arcade SDK happy -->
<PropertyGroup>
<Language>msbuild</Language>
</PropertyGroup>

<Target Name="TestAndroid" BeforeTargets="CoreTest">

<DownloadFile SourceUrl="$(XHarnessX86TestApkUrl)" DestinationFolder="$(ArtifactsTmpDir)apk" SkipUnchangedFiles="True" Retries="5">
<Output TaskParameter="DownloadedFile" ItemName="DownloadedApkFile" />
</DownloadFile>

<Message Text="Downloaded @(DownloadedApkFile) for XHarness Test purposes" Importance="High" />

<ItemGroup>
<HelixWorkItem Include="System.Numerics.Vectors.Tests">
<Command>
set -ex;
deviceId=`dotnet exec "$XHARNESS_CLI_PATH" android device --app="$HELIX_WORKITEM_PAYLOAD/System.Numerics.Vectors.Tests-x86.apk"`;
dotnet exec $XHARNESS_CLI_PATH android install --device-id="$deviceId" --output-directory="$HELIX_WORKITEM_UPLOAD_ROOT" --package-name="net.dot.System.Numerics.Vectors.Tests" --app="$HELIX_WORKITEM_PAYLOAD/System.Numerics.Vectors.Tests-x86.apk";
dotnet exec "$XHARNESS_CLI_PATH" android run --device-id="$deviceId" --output-directory="$HELIX_WORKITEM_UPLOAD_ROOT" --package-name="net.dot.System.Numerics.Vectors.Tests";
dotnet exec "$XHARNESS_CLI_PATH" android uninstall --device-id="$deviceId" --package-name="net.dot.System.Numerics.Vectors.Tests"
</Command>
<PayloadArchive>@(DownloadedApkFile)</PayloadArchive>
</HelixWorkItem>
</ItemGroup>
</Target>

<Import Sdk="Microsoft.DotNet.Helix.Sdk" Project="Sdk.targets"/>
</Project>

0 comments on commit a1a2bc0

Please sign in to comment.