Question

I want to build up a load test rig in azure. I created 2 projects for 2 roles and let the instances download and setup the TestAgent and TestController. That works greatly for the test agent!

But it does not work for the Controller-setup: I created a startup task that runs a .cmd file, which downloads and installs the TestController. The weird thing is: The cmd file is executed (proofed by logs into outfile), but it does not install the TestController. Now when ich RDP on the instance and start the cmd file manually everything works fine!

This is my startup task definition:

  <WorkerRole name="TestController" vmsize="ExtraSmall">
    <Startup>
      <Task executionContext="elevated" taskType="simple" commandLine="setupController.cmd"></Task>

I also tried it with taskType background, nothing different.

And this is my command file:

powershell $command = "set-executionpolicy Unrestricted"
powershell $command = ".\setupController.ps1" -NonInteractive >; out.txt
echo Setup TestController >> out.txt
.\testcontroller.exe /full /q >> out.txt
echo Setup was executed! >> out.txt
net user vstestagent password! /add
net localgroup Administrators vstestagent /add
REM Create a task that will run with full network privileges.
net start Schedule
schtasks /CREATE /TN "Configure Test Controller Service" /SC ONCE /SD 01/01/2020 /ST 00:00:00 /RL HIGHEST /RU vstestagent /RP password! /TR e:\approot\configcontroller.cmd /F
schtasks /RUN /TN "Configure Test Controller Service"

Does anyone know this problem? I thought it could be a privileges problem, but executionContext="elevated" rins with administrative privileges...

Best regards Sebastian

Edit: I searched Windows Event Log and found that my CMD is executed, but nothing about testcontroller.rexe being installed.

pic1 pic2

Was it helpful?

Solution 2

I still don't know WHY it is that way, but the installation works, if you do it via a scheduled task.

Because I thought the only difference is maybe the account installing the software, I first tried to install the test controller via runas command, but I could not pass a password along with the command. So I created a scheduled task for installing the test controller and was able to pass user credentials along with the command. Now my setupController.cmd looks like this:

powershell $command = "set-executionpolicy Unrestricted"
powershell $command = ".\setupController.ps1" -NonInteractive >; out.txt
echo Setup TestController >> %~dp0out.txt
cd E:\approot
echo Setup has been executed! >> %~dp0out.txt
net user vstestagent MyPassword! /add
net localgroup Administrators vstestagent /add
REM Create a task that will run with full network privileges.
net start Schedule
schtasks /CREATE /TN "Install Test Controller Service" /SC ONCE /SD 01/01/2020 /ST 00:00:00 /RL HIGHEST /RU vstestagent /RP MyPassword! /TR "E:\approot\testcontroller.exe /full /q /Log %~dp0install.log" /F
schtasks /RUN /TN "Install Test Controller Service"
timeout /T 120
schtasks /CREATE /TN "Configure Test Controller Service" /SC ONCE /SD 01/01/2020 /ST 00:00:00 /RL HIGHEST /RU vstestagent /RP MyPassword! /TR e:\approot\configcontroller.cmd /F
schtasks /RUN /TN "Configure Test Controller Service"

Hope it helps somebody else also.

OTHER TIPS

Based on above I can think off one problem is that when your batch file is executed, the testcontroller.exe is not in correct path so it is not found to be executed. Once you setup elevated option your app should run exactly.

I just put together a quick test scenario to launch an a console application which just return a string which can be saved through redirection and launched from Startup task.

Step 1: Created a simple ConsoleApp as below:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Todays date & time is {0}", DateTime.Now);
        }
    }
}

Step 2: Created a Startup folder to place ConsoleApp.exe and Startup.cmd as below. I also set the files properties to "copy always" so they are part of the package.

enter image description here

Step 3: Here is my Statup.cmd:

 @ECHO ON
 @ECHO "Launcher"
 md C:\temp
 Startup\ConsoleApp.exe  >> C:\temp\out.log
 exit /b 0

Step 4: Now when I deployed the application and remote into the my machine, I could see that a temp folder is created my drive C: and inside there is out.log along with time stamp when the file was created.

You can try exactly same to see if your console app TestController is executed first and then modify your batch file for more functions.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top