Seddryck / NBi

NBi is a testing framework (add-on to NUnit) for Business Intelligence and Data Access. The main goal of this framework is to let users create tests with a declarative approach based on an Xml syntax. By the means of NBi, you don't need to develop C# or Java code to specify your tests! Either, you don't need Visual Studio or Eclipse to compile your test suite. Just create an Xml file and let the framework interpret it and play your tests. The framework is designed as an add-on of NUnit but with the possibility to port it easily to other testing frameworks.
http://www.nbi.io
Apache License 2.0
107 stars 37 forks source link

Wait for Power BI to Get Going #638

Closed saviourofdp closed 3 years ago

saviourofdp commented 3 years ago

currently I think the PBI support checks for the existence of the msmdsrv process before throwing if it can't find it.

https://github.com/Seddryck/NBi/blob/620544d23c0f52eb606c0c6dfcd67548fce538df/NBi.Core/PowerBiDesktop/PowerBiDesktopConnectionStringBuilder.cs

protected virtual string BuildLocalConnectionString(string name)
  {
      var processes = System.Diagnostics.Process.GetProcessesByName("msmdsrv");
      if (processes==null || processes.Count()==0)
      {
          throw new ConnectionException
                  (
                      new InvalidOperationException("No process found with the name 'msmdsrv'. Are you sure your Power BI desktop solution is running?")
                      , string.Format("PBIX = {0}", name)
                  );
      }

 // ...
 }

If NBi is configured to start the PBIDesktop.exe in <setup />, the current version takes a while to get going which means this is very likely to fail. Would it be possible to poll until the process is up, only failing after a timeout? Something like this perhaps:

private static async Task DelayUntilServerIsRunningAsync(int delay = 2000, int timeout = 10000)
{
   var end = DateTime.Now.AddMilliseconds(timeout);
    var processes = System.Diagnostics.Process.GetProcessesByName("msmdsrv");
    while (!processes.Any() && DateTime.Now < end)
    {
        await Task.Delay(delay);
        processes = System.Diagnostics.Process.GetProcessesByName("msmdsrv");
    }
    if(!processes.Any()) {
         throw new ConnectionException
                  (
                      new InvalidOperationException("No process found with the name 'msmdsrv'. Are you sure your Power BI desktop solution is running?")
                 );
    }
}

Also I have noticed that Power BI accepts a /diagnosticsPort command line parameter which allows you to specify the port of the AS server.

Seddryck commented 3 years ago

Thanks for the feedback and the contribution. Sounds great, will add that to the next release.

Seddryck commented 3 years ago

Code added and bug fix available in 1.23.0-beta0167