Skip to content

Commit

Permalink
[release_4.0] Set the inproc net8 executable name based on operating …
Browse files Browse the repository at this point in the history
…system. (#3730) (#3733)

* Set the inproc net8 executable name based on operating system. (#3730)

* adding more increased timeouts

* increasing the timeout of node test because 'npm install' is taking longer

---------

Co-authored-by: azfuncgh <azfuncgh@github.com>
  • Loading branch information
kshyju and azfuncgh authored Jun 27, 2024
1 parent 48f2705 commit 807e897
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 35 deletions.
18 changes: 15 additions & 3 deletions src/Azure.Functions.Cli/Actions/HostActions/StartHostAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ internal class StartHostAction : BaseAction
private const int DefaultPort = 7071;
private const int DefaultTimeout = 20;
private const string Net6FrameworkDescriptionPrefix = ".NET 6.0";
private const string WindowsExecutableName = "func.exe";
private const string LinuxExecutableName = "func";
private const string InProc8DirectoryName = "in-proc8";
private readonly ISecretsManager _secretsManager;
private readonly IProcessManager _processManager;
private IConfigurationRoot _hostJsonConfig;
Expand Down Expand Up @@ -472,7 +475,8 @@ public override async Task RunAsync()
// Checking if in Limelight - it should have a `AzureDevSessionsRemoteHostName` value in local.settings.json.
var forwardedHttpUrl = _secretsManager.GetSecrets().FirstOrDefault(
s => s.Key.Equals(Constants.AzureDevSessionsRemoteHostName, StringComparison.OrdinalIgnoreCase)).Value;
if (forwardedHttpUrl != null){
if (forwardedHttpUrl != null)
{
var baseUrl = forwardedHttpUrl.Replace(Constants.AzureDevSessionsPortSuffixPlaceholder, Port.ToString(), StringComparison.OrdinalIgnoreCase);
baseUri = new Uri(baseUrl);
}
Expand All @@ -486,6 +490,14 @@ public override async Task RunAsync()
await runTask;
}

private static string GetInProcNet8ExecutablePath()
{
var funcExecutableDirectory = Path.GetDirectoryName(typeof(StartHostAction).Assembly.Location)!;
var executableName = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? WindowsExecutableName : LinuxExecutableName;

return Path.Combine(funcExecutableDirectory, InProc8DirectoryName, executableName);
}

private Task StartInProc8AsChildProcessAsync()
{
if (VerboseLogging == true)
Expand All @@ -495,8 +507,8 @@ private Task StartInProc8AsChildProcessAsync()

var commandLineArguments = string.Join(" ", Environment.GetCommandLineArgs().Skip(1));
var tcs = new TaskCompletionSource();
var funcExecutableDirectory = Path.GetDirectoryName(typeof(StartHostAction).Assembly.Location)!;
var inProc8FuncExecutablePath = Path.Combine(funcExecutableDirectory, "in-proc8", "func.exe");

var inProc8FuncExecutablePath = GetInProcNet8ExecutablePath();

EnsureNet8FuncExecutablePresent(inProc8FuncExecutablePath);

Expand Down
12 changes: 6 additions & 6 deletions test/Azure.Functions.Cli.Tests/E2E/CreateFunctionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ await CliTester.Run(new RunConfiguration
{
"Authorization level is applicable to templates that use Http trigger, Allowed values: [function, anonymous, admin]. Authorization level is not enforced when running functions from core tools"
},
CommandTimeout = TimeSpan.FromSeconds(120)
CommandTimeout = TimeSpan.FromSeconds(300)
}, _output);
}

Expand Down Expand Up @@ -157,7 +157,7 @@ await CliTester.Run(new RunConfiguration
"\\src\\functions\\testfunc.js",
"The function \"testfunc\" was created successfully from the \"http trigger\" template."
},
CommandTimeout = TimeSpan.FromSeconds(120)
CommandTimeout = TimeSpan.FromSeconds(300)
}, _output);
}

Expand Down Expand Up @@ -210,7 +210,7 @@ await CliTester.Run(new RunConfiguration
"\\src\\functions\\testfunc.js",
"The function \"testfunc\" was created successfully from the \"httptrigger\" template."
},
CommandTimeout = TimeSpan.FromSeconds(120)
CommandTimeout = TimeSpan.FromSeconds(300)
}, _output);
}

Expand All @@ -229,7 +229,7 @@ await CliTester.Run(new RunConfiguration
"\\src\\functions\\testfunc.js",
"The function \"testfunc\" was created successfully from the \"httptrigger\" template."
},
CommandTimeout = TimeSpan.FromSeconds(120)
CommandTimeout = TimeSpan.FromSeconds(300)
}, _output);
}

Expand Down Expand Up @@ -296,7 +296,7 @@ await CliTester.Run(new RunConfiguration
"\\src\\functions\\testfunc.ts",
"The function \"testfunc\" was created successfully from the \"http trigger\" template."
},
CommandTimeout = TimeSpan.FromSeconds(120)
CommandTimeout = TimeSpan.FromSeconds(300)
}, _output);
}

Expand Down Expand Up @@ -364,7 +364,7 @@ await CliTester.Run(new RunConfiguration
"\\src\\functions\\testfunc.ts",
"The function \"testfunc\" was created successfully from the \"azure Blob Storage trigger\" template."
},
CommandTimeout = TimeSpan.FromSeconds(120)
CommandTimeout = TimeSpan.FromSeconds(300)
}, _output);
}

Expand Down
13 changes: 7 additions & 6 deletions test/Azure.Functions.Cli.Tests/E2E/InitTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public Task init_with_worker_runtime_and_model(string workerRuntime, string prog
$".vscode{Path.DirectorySeparatorChar}extensions.json",
},
OutputDoesntContain = new[] { "Initialized empty Git repository" },
CommandTimeout = TimeSpan.FromSeconds(120)
CommandTimeout = TimeSpan.FromSeconds(300)
}, _output);
}

Expand Down Expand Up @@ -278,6 +278,7 @@ public Task init_with_no_source_control()
{
new DirectoryResult { Name = ".git", Exists = false }
},
CommandTimeout = TimeSpan.FromSeconds(300)
}, _output);
}

Expand All @@ -298,7 +299,7 @@ public Task init_with_Dockerfile(string workerRuntime, string version)
ContentContains = new[] { $"FROM mcr.microsoft.com/azure-functions/{workerRuntime}:{version}" }
}
},
CommandTimeout = TimeSpan.FromSeconds(120),
CommandTimeout = TimeSpan.FromSeconds(300),
OutputContains = new[] { "Dockerfile" }
}, _output);
}
Expand Down Expand Up @@ -480,7 +481,7 @@ public Task init_ts_app_using_lang(string initCommand)
"Writing Dockerfile",
"Writing .dockerignore"
},
CommandTimeout = TimeSpan.FromSeconds(120)
CommandTimeout = TimeSpan.FromSeconds(300)
}, _output);
}

Expand Down Expand Up @@ -510,7 +511,7 @@ public Task javascript_adds_packagejson()
"Writing local.settings.json",
$".vscode{Path.DirectorySeparatorChar}extensions.json",
},
CommandTimeout = TimeSpan.FromSeconds(120)
CommandTimeout = TimeSpan.FromSeconds(300)
}, _output);
}

Expand Down Expand Up @@ -581,7 +582,7 @@ public Task init_docker_only_for_existing_project(string workerRuntime, string v
}
},
OutputContains = new[] { "Dockerfile" },
CommandTimeout = TimeSpan.FromSeconds(120)
CommandTimeout = TimeSpan.FromSeconds(300)
}, _output);
}

Expand Down Expand Up @@ -714,7 +715,7 @@ public Task init_function_app_contains_logging_config()
{
"Writing host.json"
},
CommandTimeout = TimeSpan.FromSeconds(120)
CommandTimeout = TimeSpan.FromSeconds(300)
}, _output);
}

Expand Down
4 changes: 2 additions & 2 deletions test/Azure.Functions.Cli.Tests/E2E/SettingsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ await CliTester.Run(new RunConfiguration
}
}
},
CommandTimeout = TimeSpan.FromSeconds(120)
CommandTimeout = TimeSpan.FromSeconds(300)
}, _output);
}

Expand Down Expand Up @@ -66,7 +66,7 @@ await CliTester.Run(new RunConfiguration[]
}
}
},
CommandTimeout = TimeSpan.FromSeconds(120)
CommandTimeout = TimeSpan.FromSeconds(300)
},
new RunConfiguration
{
Expand Down
32 changes: 18 additions & 14 deletions test/Azure.Functions.Cli.Tests/E2E/StartTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ await CliTester.Run(new RunConfiguration
result.Should().Be("Hello, Test!", because: "response from default function should be 'Hello, {name}!'");
}
},
CommandTimeout = TimeSpan.FromSeconds(120),
CommandTimeout = TimeSpan.FromSeconds(300),
}, _output);
}

Expand Down Expand Up @@ -93,7 +93,7 @@ await CliTester.Run(new RunConfiguration
result.Should().Be("Hello, Test. This HTTP triggered function executed successfully.", because: "response from default function should be 'Hello, {name}. This HTTP triggered function executed successfully.'");
}
},
CommandTimeout = TimeSpan.FromSeconds(120),
CommandTimeout = TimeSpan.FromSeconds(300),
}, _output);
}

Expand All @@ -118,7 +118,7 @@ await CliTester.Run(new RunConfiguration
await Task.Delay(TimeSpan.FromSeconds(15));
p.Kill();
},
CommandTimeout = TimeSpan.FromSeconds(120)
CommandTimeout = TimeSpan.FromSeconds(300)
}, _output);

}
Expand All @@ -145,7 +145,7 @@ await CliTester.Run(new RunConfiguration
await Task.Delay(TimeSpan.FromSeconds(15));
p.Kill();
},
CommandTimeout = TimeSpan.FromSeconds(120),
CommandTimeout = TimeSpan.FromSeconds(300),
}, _output);
}

Expand Down Expand Up @@ -257,6 +257,7 @@ await CliTester.Run(new RunConfiguration[]
string hostJsonContent = "{\"version\": \"2.0\",\"logging\": {\"logLevel\": {\"Default\": \"None\"}}}";
await File.WriteAllTextAsync(filePath, hostJsonContent);
},
CommandTimeout = TimeSpan.FromSeconds(300),
},
new RunConfiguration
{
Expand All @@ -278,7 +279,8 @@ await CliTester.Run(new RunConfiguration[]
// give the host time to load functions and print any errors
await Task.Delay(TimeSpan.FromSeconds(10));
p.Kill();
}
},
CommandTimeout = TimeSpan.FromSeconds(300),
},
}, _output, startHost: true);
}
Expand Down Expand Up @@ -307,7 +309,7 @@ await CliTester.Run(new RunConfiguration
result.Should().Be("Hello, Test. This HTTP triggered function executed successfully.", because: "response from default function should be 'Hello, {name}. This HTTP triggered function executed successfully.'");
}
},
CommandTimeout = TimeSpan.FromSeconds(120),
CommandTimeout = TimeSpan.FromSeconds(300),
}, _output);
}

Expand Down Expand Up @@ -342,7 +344,7 @@ await CliTester.Run(new RunConfiguration
}
}
},
CommandTimeout = TimeSpan.FromSeconds(120),
CommandTimeout = TimeSpan.FromSeconds(300),
}, _output);
}

Expand All @@ -366,7 +368,8 @@ await CliTester.Run(new RunConfiguration[]
var functionJson = await File.ReadAllTextAsync(filePath);
functionJson = functionJson.Replace("\"type\": \"http\"", "\"type\": \"http2\"");
await File.WriteAllTextAsync(filePath, functionJson);
}
},
CommandTimeout = TimeSpan.FromSeconds(300),
},
new RunConfiguration
{
Expand Down Expand Up @@ -478,7 +481,7 @@ await CliTester.Run(new RunConfiguration
ExpectExit = true,
ExitInError = true,
ErrorContains = new[] { "Port 8081 is unavailable" },
CommandTimeout = TimeSpan.FromSeconds(120),
CommandTimeout = TimeSpan.FromSeconds(300),
}, _output);
}
finally
Expand Down Expand Up @@ -506,7 +509,8 @@ await CliTester.Run(new RunConfiguration[]
var content = File.ReadAllText(settingsFile);
content = content.Replace("EMPTY_VALUE", "");
File.WriteAllText(settingsFile,content);
}
},
CommandTimeout = TimeSpan.FromSeconds(300),
},
new RunConfiguration
{
Expand Down Expand Up @@ -540,7 +544,7 @@ await CliTester.Run(new RunConfiguration[]
{
"Skipping 'emptySetting' from local settings as it's already defined in current environment variables."
},
CommandTimeout = TimeSpan.FromSeconds(120),
CommandTimeout = TimeSpan.FromSeconds(300),
}
}, _output);
}
Expand Down Expand Up @@ -603,7 +607,7 @@ await CliTester.Run(new RunConfiguration
p.Kill();
}
},
CommandTimeout = TimeSpan.FromSeconds(120)
CommandTimeout = TimeSpan.FromSeconds(300)
}, _output);
}

Expand Down Expand Up @@ -669,7 +673,7 @@ await CliTester.Run(new RunConfiguration[]
{
"Using for user secrets file configuration."
},
CommandTimeout = TimeSpan.FromSeconds(120),
CommandTimeout = TimeSpan.FromSeconds(300),
Test = async (workingDir, p) =>
{
using (var client = new HttpClient() { BaseAddress = new Uri("http://localhost:7071/") })
Expand Down Expand Up @@ -743,7 +747,7 @@ await CliTester.Run(new RunConfiguration[]
{
"start --functions http1 --csharp",
},
CommandTimeout = TimeSpan.FromSeconds(120),
CommandTimeout = TimeSpan.FromSeconds(300),
ExpectExit = true,
ExitInError = true,
ErrorContains = new[] { "Missing value for AzureWebJobsStorage in local.settings.json and User Secrets. This is required for all triggers other than httptrigger, kafkatrigger. You can run 'func azure functionapp fetch-app-settings <functionAppName>' or specify a connection string in local.settings.json or User Secrets." },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public Task BundleConfiguredByDefault_no_action()
{
"No action performed"
},
CommandTimeout = TimeSpan.FromMinutes(3)
CommandTimeout = TimeSpan.FromMinutes(300)
}, _output);
}

Expand All @@ -47,7 +47,7 @@ public Task BundleConfiguredByDefault_findsBundlePath()
{
bundlePath
},
CommandTimeout = TimeSpan.FromMinutes(3)
CommandTimeout = TimeSpan.FromMinutes(300)
}, _output);
}

Expand All @@ -66,7 +66,7 @@ public Task BundleNotConfiguredByDefault_showsErrorMessage()
{
"Extension bundle not configured."
},
CommandTimeout = TimeSpan.FromMinutes(3)
CommandTimeout = TimeSpan.FromMinutes(300)
}, _output);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public Task try_install_with_no_valid_trigger()
Exists = false
}
},
CommandTimeout = TimeSpan.FromSeconds(120)
CommandTimeout = TimeSpan.FromSeconds(300)
}, _output);
}

Expand Down

0 comments on commit 807e897

Please sign in to comment.