public SmokeTestsOnNanoServerUsingSharedRuntime(
     DotnetRuntimeSetupTestFixture dotnetRuntimeSetupTestFixture, ITestOutputHelper output)
 {
     _remoteDeploymentConfig = RemoteDeploymentConfigHelper.GetConfiguration();
     _remoteDeploymentConfig.DotnetRuntimePathOnShare = dotnetRuntimeSetupTestFixture.DotnetRuntimePathOnShare;
     _smokeTestsOnNanoServer = new SmokeTestsOnNanoServer(output, _remoteDeploymentConfig);
 }
            public DotnetRuntimeSetupTestFixture()
            {
                var runNanoServerTests = Environment.GetEnvironmentVariable("RUN_TESTS_ON_NANO");

                if (string.IsNullOrWhiteSpace(runNanoServerTests) ||
                    string.IsNullOrEmpty(runNanoServerTests) ||
                    runNanoServerTests.ToLowerInvariant() == "false")
                {
                    return;
                }

                RemoteDeploymentConfig = RemoteDeploymentConfigHelper.GetConfiguration();

                DotnetRuntimePathOnShare = Path.Combine(RemoteDeploymentConfig.FileSharePath, "dotnet_" + Guid.NewGuid());

                // Prefer copying the zip file to fileshare and extracting on file share over copying the extracted
                // dotnet runtime folder from source to file share as the size could be significantly huge.
                if (!string.IsNullOrEmpty(RemoteDeploymentConfig.DotnetRuntimeZipFilePath))
                {
                    if (!File.Exists(RemoteDeploymentConfig.DotnetRuntimeZipFilePath))
                    {
                        throw new InvalidOperationException(
                                  $"Expected dotnet runtime zip file at '{RemoteDeploymentConfig.DotnetRuntimeFolderPath}', but didn't find one.");
                    }

                    ZippedDotnetRuntimePathOnShare = Path.Combine(
                        RemoteDeploymentConfig.FileSharePath,
                        Path.GetFileName(RemoteDeploymentConfig.DotnetRuntimeZipFilePath));

                    if (!File.Exists(ZippedDotnetRuntimePathOnShare))
                    {
                        File.Copy(RemoteDeploymentConfig.DotnetRuntimeZipFilePath, ZippedDotnetRuntimePathOnShare, overwrite: true);
                        Console.WriteLine($"Copied the local dotnet zip folder '{RemoteDeploymentConfig.DotnetRuntimeZipFilePath}' " +
                                          $"to the file share path '{RemoteDeploymentConfig.FileSharePath}'");
                    }

                    if (Directory.Exists(DotnetRuntimePathOnShare))
                    {
                        Directory.Delete(DotnetRuntimePathOnShare, recursive: true);
                    }

                    ZipFile.ExtractToDirectory(ZippedDotnetRuntimePathOnShare, DotnetRuntimePathOnShare);
                    copiedDotnetRuntime = true;
                    Console.WriteLine($"Extracted dotnet runtime to folder '{DotnetRuntimePathOnShare}'");
                }
                else if (!string.IsNullOrEmpty(RemoteDeploymentConfig.DotnetRuntimeFolderPath))
                {
                    if (!Directory.Exists(RemoteDeploymentConfig.DotnetRuntimeFolderPath))
                    {
                        throw new InvalidOperationException(
                                  $"Expected dotnet runtime folder at '{RemoteDeploymentConfig.DotnetRuntimeFolderPath}', but didn't find one.");
                    }

                    Console.WriteLine($"Copying dotnet runtime folder from '{RemoteDeploymentConfig.DotnetRuntimeFolderPath}' to '{DotnetRuntimePathOnShare}'.");
                    Console.WriteLine("This could take some time.");

                    DirectoryCopy(RemoteDeploymentConfig.DotnetRuntimeFolderPath, DotnetRuntimePathOnShare, copySubDirs: true);
                    copiedDotnetRuntime = true;
                }
                else
                {
                    throw new InvalidOperationException("Dotnet runtime is required to be copied for testing portable apps scenario. " +
                                                        $"Either supply '{nameof(RemoteDeploymentConfig.DotnetRuntimeFolderPath)}' containing the unzipped dotnet runtime content or " +
                                                        $"supply the dotnet runtime zip file path via '{nameof(RemoteDeploymentConfig.DotnetRuntimeZipFilePath)}'.");
                }
            }
 public SmokeTestsOnNanoServerUsingStandaloneRuntime(ITestOutputHelper output)
 {
     _remoteDeploymentConfig = RemoteDeploymentConfigHelper.GetConfiguration();
     _smokeTestsOnNanoServer = new SmokeTestsOnNanoServer(output, _remoteDeploymentConfig);
 }
Beispiel #4
0
 public SmokeTestsOnNanoServerUsingStandaloneRuntime(ITestOutputHelper output)
 {
     _logger = new XunitLogger(output, LogLevel.Information);
     _remoteDeploymentConfig = RemoteDeploymentConfigHelper.GetConfiguration();
     _smokeTestsOnNanoServer = new SmokeTestsOnNanoServer(output, _remoteDeploymentConfig, _logger);
 }