HodorNV / ALOps

ALOps
59 stars 24 forks source link

ALOpsDockerCreate includetesttoolkit does not conclude #308

Closed lvanvugt closed 3 years ago

lvanvugt commented 3 years ago

I need to have the full standard test toolkit in my pipeline, so I have set includetesttoolkit for ALOpsDockerCreate to true (see below). But the ALOpsDockerCreate step does not do the job fully (see the full output below):

Publishing   C:\Applications\TestFramework\TestRunner\Microsoft_Test Runner.app
This Extension cannot be published as it has   the same Publisher, Name, and Version as a previously published Extension.

As can seen below the ALOpsDockerCreate step does stop installing (but does not throw an error. Consequence is that the major part of the test toolkit is not installed and the ALOpsAppCompiler task fails as it does not find the various test (library) apps it depends on. Have been trying various things (f.e. setting forcecreateimage: $(forceCreateImage) with $(forceCreateImage) set to true), but so far to no avail.

the used yaml

name: $(Build.BuildId)

trigger:
 branches:
   include:
     - master/TestFixtureInitializer

variables:
- group: 'PipelineVariables'

pool: TestAutomationExamples

jobs:
- job: default
  timeoutInMinutes: 600
  pool: TestAutomationExamples

  steps:
  - checkout: self
    clean: true 

  - task: ALOpsDockerCreate@1
    displayName: 'ALOPS - Create Docker Image' # It will reuse the image if already exists, or build one if it doesn't.
    inputs:
      artifacttype: 'Sandbox'
      forcecreateimage: $(forceCreateImage)
      licensefile: '$(LuxBeheerBcDevLicense)'
      includetesttoolkit: true

  - task: ALOpsDockerStart@1
    displayName: 'ALOPS - Start Docker Container' # No need to provide any details - it will get the details from previous step

  - task: ALOpsDockerWait@1
    displayName: 'ALOPS - Wait for Docker Container to start'
    inputs:
      search_string: 'Ready for connections!'

  - task: ALOpsAppCompiler@1
    displayName: 'ALOPS - Compile Extension: App'
    inputs:
      usedocker: true
      nav_app_version: '1.0.[yyyyWW].*'
      targetproject: 'TestFixtureInitializer/app/app.json'
      app_file_suffix: '_APP' 

  - task: ALOpsAppPublish@1
    displayName: 'ALOPS - Publish Extension'
    inputs:
      usedocker: true
      nav_artifact_app_filter: '*.app'
      skip_verification: true

  - task: ALOpsAppTest@1
    displayName: 'ALOPS - Run TestSuite'
    inputs:
      usedocker: true
      testfilter: '81000..'
      failed_test_action: 'Ignore'
    continueOnError: true
    timeoutInMinutes: 360

  - task: PublishTestResults@2
    displayName: 'Publish Test Results **/TestResults.xml'
    inputs:
      testResultsFormat: XUnit
      testResultsFiles: '**/TestResults.xml'
      failTaskOnFailedTests: true
      testRunTitle: 'BC Test Results: $(Build.BuildId)'

  - task: ALOpsDockerRemove@1
    displayName: 'ALOPS - Remove Docker Container'
    enabled: true
    condition: always()
    inputs:
      createsqlbackup: 'onfailure'

the output Also the complete output is necessary for us to see what is going on. Also use backtics:

##[section]Starting: ALOPS - Create Docker   Image
--
==============================================================================
Task           : ALOps Docker Create
Description    : Create Docker image from Business Central Artifacts
Version        : 1.438.2098
Author         : Hodor
Help           : Create Docker image based on NAV/BC Artifacts.
==============================================================================
*** Validate configuration
*** Task Inputs:
 
name                      value
----                      -----
artifactspecification     Specific
artifactversion
artifacttype              Sandbox
artifactcountry
versionselect             Latest
artifacthint
multitenant               False
memory                    8G
imageprefix               myImage
dockerregistry
dockerusername
dockerpassword
storageaccount
sastoken
forcecreateimage          True
myscripts
imagenametemplate           %IMAGE_PREFIX%:%ARTIFACT_TYPE%-%ARTIFACT_VERSION%-%ARTIFACT_COUNTRY%-%OS_VERSION%-%OS_LTSC%
licensefile                 https://luxadofiles.blob.core.windows.net/bcdevlicensefile/BC17%20Development%20License%20...
includetesttoolkit        True
includetestlibrariesonly  False
includetestframeworkonly  False
includeperformancetoolkit False
 
*** No ALOps License found. Set License with   the [alops-licenseid] or [alops_licenseid] variables.
*** To acquire a license, please visit:   https://www.alops.be/getlicense
*** For pricing options, please visit :   https://www.alops.be/pricing
*** For documentation, please visit   : https://www.alops.be/documentation
 
*** ALOps License:
* Trial Key  :   9e49a0a1-45c6-4038-b670-7f21fd35e892
* Licensed To: Public Project (Free License)
 
*** Importing required PS-Functions
*** Install/Update BCContainerHelper   [https://github.com/microsoft/navcontainerhelper]
*** Check BcContainerHelper
*** Load BcContainerHelper
BcContainerHelper version 1.0.14-dev
 
*** Get Artifact Url for Version [] /   Country [] / Type [Sandbox]: Latest
##[command]"Get-BCArtifactUrl"
Name                           Value
----                           -----
select                         Latest
type                           Sandbox
 
*** Artifact Url:   [https://bcartifacts.azureedge.net/sandbox/17.3.20469.21771/w1]
*** Build new Image based on   [https://bcartifacts.azureedge.net/sandbox/17.3.20469.21771/w1]
*** Artifact Type   : [sandbox]
*** Artifact Version: [17.3.20469.21771]
*** Artifact Country: [w1]
*** OS: [2019]
*** OS version: [10.0.17763.1577]
*** Image Template:   [%IMAGE_PREFIX%:%ARTIFACT_TYPE%-%ARTIFACT_VERSION%-%ARTIFACT_COUNTRY%-%OS_VERSION%-%OS_LTSC%]
*** ImageName:   [myimage:sandbox-17.3.20469.21771-w1-10.0.17763.1577-ltsc2019]
*** Set Pipeline variable $(ALOPS_BC_IMAGE)   = 'myimage:sandbox-17.3.20469.21771-w1-10.0.17763.1577-ltsc2019'
*** Forcing image creation.
*** No 'MyScripts' specified, skipping   parse.
*** Create Image:   myimage:sandbox-17.3.20469.21771-w1-10.0.17763.1577-ltsc2019
##[command]"New-BcImage"
Name                           Value
----                           -----
includePerformanceToolkit      False
artifactUrl                      https://bcartifacts.azureedge.net/sandbox/17.3.20469.21771/w1
licenseFile                      https://luxadofiles.blob.core.windows.net/bcdevlicensefile/BC17%20Development%20Licen...
includeTestToolkit             True
memory                         8G
includeTestFrameworkOnly       False
multitenant                    False
imageName                        myimage:sandbox-17.3.20469.21771-w1-10.0.17763.1577-ltsc2019
includeTestLibrariesOnly       False

Building image   myimage:sandbox-17.3.20469.21771-w1-10.0.17763.1577-ltsc2019 based on   mcr.microsoft.com/dynamicsnav:10.0.17763.1577-generic with   https://bcartifacts.azureedge.net/sandbox/17.3.20469.21771/w1
Pulling latest image   mcr.microsoft.com/dynamicsnav:10.0.17763.1577-generic
10.0.17763.1577-generic: Pulling from   dynamicsnav
Generic Tag: 0.1.0.24
Container OS Version: 10.0.17763.1577   (ltsc2019)
Host OS Version: 10.0.17763.1697 (ltsc2019)
Using hyperv isolation
Using license file ***
Downloading   c:\bcartifacts.cache\q1zml01g.kam\my\license.flf
Files in   c:\bcartifacts.cache\q1zml01g.kam\my:
-   license.flf
Copying Platform Artifacts
Copying Database
Copying Licensefile
Copying Extensions
Untagged:   myimage:sandbox-17.3.20469.21771-w1-10.0.17763.1577-ltsc2019
Deleted:   sha256:2cb0b94569784da5625152f21d85b8fd4204caf4b462ae503312dbb84784400e
Deleted:   sha256:c373ef4ee39bbc3e728415971d0d39af5a0bc4c14862b12009213ee8b38aa90c
Deleted:   sha256:4854aaceca4553f52d9a06c088d8d337152677b4b71ebbb420d6b979b39d769a
Deleted:   sha256:f0b61a2cb0eb7ceec17f5d626ffb27fe11b118fc0f126e3dab337df113cfefc2
Deleted:   sha256:3d539b64d516a3873a1b5f58b225a3d9adb2e8f01c38ab25a6c101f67096dfaf
Deleted:   sha256:35c278444aa5d29bb2561f9a6aa5d0aa00bba6f0aa2bb93077027a93640403c2
Deleted:   sha256:2096609fc1c08a71745718a56dc71331f225ddfc84590193911997daa828249c
Deleted:   sha256:116ca8fb49957e1e6728b5c3173df7ef477ffc1bacc84dbcd8cbe9349070db80
Deleted:   sha256:d827e6168f11547c201fda80e597a7848d37ee1543f9dfb6dfed7c134a48e0e2
Deleted:   sha256:78dd6bdd669b5f2ceda64e260607ec90538997b5896c5437485f45028284a154
c:\bcartifacts.cache\q1zml01g.kam
Sending build context to Docker daemon  1.566GB
 
Step 1/6 : FROM   mcr.microsoft.com/dynamicsnav:10.0.17763.1577-generic
---> 8e70404d55fc
Step 2/6 : ENV DatabaseServer=localhost   DatabaseInstance=SQLEXPRESS DatabaseName=CRONUS IsBcSandbox=Y   artifactUrl=https://bcartifacts.azureedge.net/sandbox/17.3.20469.21771/w1
---> Running in bc28bec736d7
Removing intermediate container bc28bec736d7
---> 87503867f5b1
Step 3/6 : COPY my /run/
---> a5998e4c19b6
Step 4/6 : COPY NAVDVD /NAVDVD/
---> ac4d9132248f
Step 5/6 : RUN \Run\start.ps1 -installOnly   -includeTestToolkit
---> Running in 11a2e045d54c
Using installer from C:\Run\150-new
Installing Business Central
Installing from DVD
Starting Local SQL Server
Starting Internet Information Server
Copying Service Tier Files
Copying PowerShell Scripts
Copying dependencies
Copying ReportBuilder
Importing PowerShell Modules
Determining Database Collation
Restoring CRONUS Demo Database
Modifying Business Central Service Tier   Config File for Docker
Creating Business Central Service Tier
Installing SIP crypto provider:   'C:\Windows\System32\NavSip.dll'
Copying Web Client Files
Copying Client Files
Copying ModernDev Files
Copying additional files
Copying ConfigurationPackages
Copying Test Assemblies
Copying Extensions
Copying Applications
Starting Business Central Service Tier
Importing CRONUS license file
Publishing   C:\Applications\TestFramework\TestLibraries\Any\Microsoft_Any.app
Synchronizing Any
Installing Any
Publishing   C:\Applications\TestFramework\TestLibraries\Assert\Microsoft_Library   Assert.app
Synchronizing Library Assert
Installing Library Assert
Publishing   C:\Applications\TestFramework\TestLibraries\Variable   Storage\Microsoft_Library Variable Storage.app
Synchronizing Library Variable Storage
Installing Library Variable Storage
Publishing   C:\Applications\TestFramework\TestRunner\Microsoft_Test Runner.app
This Extension cannot be published as it has   the same Publisher, Name, and Version as a previously published Extension.
Removing intermediate container 11a2e045d54c
---> ea45eddc9549
Step 6/6 : LABEL   legal="http://go.microsoft.com/fwlink/?LinkId=837447"       created="202102051713"       nav=""       cu=""       country="W1"         version="17.3.20469.21771"       platform="17.0.20458.21738"
---> Running in 9ff0cccf99d9
Removing intermediate container 9ff0cccf99d9
---> 2cb0564cfa26
Successfully built 2cb0564cfa26
Successfully tagged   myimage:sandbox-17.3.20469.21771-w1-10.0.17763.1577-ltsc2019
Building image took 416 seconds
*** Created Image:   myimage:sandbox-17.3.20469.21771-w1-10.0.17763.1577-ltsc2019
*** No Docker Registry specified
*** Docker Create Succeeded.
*** Cleanup VSTS Environment: True
##[section]Finishing: ALOPS - Create Docker   Image

expected behavior All standard test (library) apps installed in the image/container.

waldo1001 commented 3 years ago

Yes, we noticed this. The entire testtoolkit is a big mess on Microsoft's side. Depending on the versions of BC, they handle this differently. We're revising this - and this pipeline helps to mitigate the problem. So .. a solution is in the works!

lvanvugt commented 3 years ago

Hey, @waldo1001, good to know it's no me. Have been spending some hours trying to get this right. Is ALOps not making use of the BcContainerHelper? I am asking as that handles it right for any version, afaik.

Would be great if your solution comes fast as this is blocking part of my work right now.

lvanvugt commented 3 years ago

O, and BTW, why is the ALOpsDockerCreate step not failing on this? I would expect it to do, so it's clearly marked in my pipeline. Now it fails on the ALOpsAppCompiler step as it dependant apps are missing in the database.

lvanvugt commented 3 years ago

FYI: having my mind run I tried this workaround, which was successful. But of course it's a workaround as I would like the original issue to be solved so my image will contain the test apps saving a lot of time in my pipeline (approx. 5 minutes) as this workaround every time again will install the apps.

  - task: ALOpsAppPublish@1
    displayName: 'ALOPS - Install AL TestTool' # install necessary dependent apps for testability
    inputs:
      usedocker: true
      installaltesttool: true
      skip_verification: true
      install_al_app_names: |
        Any
        Tests-Bank
        Tests-Cash Flow
        Tests-Cost Accounting
        Tests-CRM integration
        Tests-Data Exchange
        Tests-Dimension
        Tests-ERM
        Tests-Fixed Asset
        Tests-General Journal
        Tests-Graph
        Tests-Integration
        Tests-Invoicing
        Tests-Job
        Tests-Local
        Tests-Marketing
        Tests-Misc
        Tests-Monitor Sensitive Fields
        Tests-Permissions
        Tests-Physical Inventory
        Tests-Prepayment
        Tests-Rapid Start
        Tests-Report
        Tests-Resource
        Tests-Reverse
        Tests-SCM
        Tests-SINGLESERVER
        Tests-SMB
        Tests-SMTP
        Tests-TestLibraries
        Tests-Upgrade
        Tests-User
        Tests-VAT
        Tests-Workflow
        Test Runner
        Library Assert
        Library Variable Storage
        System Application Test
        System Application Test Library

Note This workaround enabled the pipeline to continue, but it failed on the ALOpsAppTest step. Another issue has been created for this: #309.

waldo1001 commented 3 years ago

I see you're working with a dev-version of BcContainerVersion ... could you please install a released version - just to be sure?

waldo1001 commented 3 years ago

(latest, if possible)

lvanvugt commented 3 years ago

I see you're working with a dev-version of BcContainerVersion ... could you please install a released version - just to be sure?

Sure.

lvanvugt commented 3 years ago

The workaround pipeline is still running. Will check whether this fixed the original issue.

Update 20210207 @waldo1001: no difference.

waldo1001 commented 3 years ago

Hm,

Can you try to remove all images on your docker server with docker image prune --force? So that everything is clean again?

I copied your pipeline to my evironment, and I'm not getting your issues .. that's why I ask ..

lvanvugt commented 3 years ago

Busy right now.

lvanvugt commented 3 years ago

Seems to be working. Great.

image

waldo1001 commented 3 years ago

Great. You see what our challenge is with ALOps? A lot of issues are not even ALOps related ;-).

The above is also a reason why our DevOps agents are dedicated machines: it shouldn't be used for anything else then DevOps tasks .. and should be cleaned (pruned) regularly ..

lvanvugt commented 3 years ago

Right. The prune however did not clean up any of the images. Had to do them one by one. (Admitted: not a lot of experience with pruning so far)