Skip to content

Commit 807e897

Browse files
kshyjuazfuncgh
and
azfuncgh
authored
[release_4.0] Set the inproc net8 executable name based on operating 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 <[email protected]>
1 parent 48f2705 commit 807e897

File tree

7 files changed

+52
-35
lines changed

7 files changed

+52
-35
lines changed

src/Azure.Functions.Cli/Actions/HostActions/StartHostAction.cs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ internal class StartHostAction : BaseAction
4141
private const int DefaultPort = 7071;
4242
private const int DefaultTimeout = 20;
4343
private const string Net6FrameworkDescriptionPrefix = ".NET 6.0";
44+
private const string WindowsExecutableName = "func.exe";
45+
private const string LinuxExecutableName = "func";
46+
private const string InProc8DirectoryName = "in-proc8";
4447
private readonly ISecretsManager _secretsManager;
4548
private readonly IProcessManager _processManager;
4649
private IConfigurationRoot _hostJsonConfig;
@@ -472,7 +475,8 @@ public override async Task RunAsync()
472475
// Checking if in Limelight - it should have a `AzureDevSessionsRemoteHostName` value in local.settings.json.
473476
var forwardedHttpUrl = _secretsManager.GetSecrets().FirstOrDefault(
474477
s => s.Key.Equals(Constants.AzureDevSessionsRemoteHostName, StringComparison.OrdinalIgnoreCase)).Value;
475-
if (forwardedHttpUrl != null){
478+
if (forwardedHttpUrl != null)
479+
{
476480
var baseUrl = forwardedHttpUrl.Replace(Constants.AzureDevSessionsPortSuffixPlaceholder, Port.ToString(), StringComparison.OrdinalIgnoreCase);
477481
baseUri = new Uri(baseUrl);
478482
}
@@ -486,6 +490,14 @@ public override async Task RunAsync()
486490
await runTask;
487491
}
488492

493+
private static string GetInProcNet8ExecutablePath()
494+
{
495+
var funcExecutableDirectory = Path.GetDirectoryName(typeof(StartHostAction).Assembly.Location)!;
496+
var executableName = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? WindowsExecutableName : LinuxExecutableName;
497+
498+
return Path.Combine(funcExecutableDirectory, InProc8DirectoryName, executableName);
499+
}
500+
489501
private Task StartInProc8AsChildProcessAsync()
490502
{
491503
if (VerboseLogging == true)
@@ -495,8 +507,8 @@ private Task StartInProc8AsChildProcessAsync()
495507

496508
var commandLineArguments = string.Join(" ", Environment.GetCommandLineArgs().Skip(1));
497509
var tcs = new TaskCompletionSource();
498-
var funcExecutableDirectory = Path.GetDirectoryName(typeof(StartHostAction).Assembly.Location)!;
499-
var inProc8FuncExecutablePath = Path.Combine(funcExecutableDirectory, "in-proc8", "func.exe");
510+
511+
var inProc8FuncExecutablePath = GetInProcNet8ExecutablePath();
500512

501513
EnsureNet8FuncExecutablePresent(inProc8FuncExecutablePath);
502514

test/Azure.Functions.Cli.Tests/E2E/CreateFunctionTests.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ await CliTester.Run(new RunConfiguration
6161
{
6262
"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"
6363
},
64-
CommandTimeout = TimeSpan.FromSeconds(120)
64+
CommandTimeout = TimeSpan.FromSeconds(300)
6565
}, _output);
6666
}
6767

@@ -157,7 +157,7 @@ await CliTester.Run(new RunConfiguration
157157
"\\src\\functions\\testfunc.js",
158158
"The function \"testfunc\" was created successfully from the \"http trigger\" template."
159159
},
160-
CommandTimeout = TimeSpan.FromSeconds(120)
160+
CommandTimeout = TimeSpan.FromSeconds(300)
161161
}, _output);
162162
}
163163

@@ -210,7 +210,7 @@ await CliTester.Run(new RunConfiguration
210210
"\\src\\functions\\testfunc.js",
211211
"The function \"testfunc\" was created successfully from the \"httptrigger\" template."
212212
},
213-
CommandTimeout = TimeSpan.FromSeconds(120)
213+
CommandTimeout = TimeSpan.FromSeconds(300)
214214
}, _output);
215215
}
216216

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

@@ -296,7 +296,7 @@ await CliTester.Run(new RunConfiguration
296296
"\\src\\functions\\testfunc.ts",
297297
"The function \"testfunc\" was created successfully from the \"http trigger\" template."
298298
},
299-
CommandTimeout = TimeSpan.FromSeconds(120)
299+
CommandTimeout = TimeSpan.FromSeconds(300)
300300
}, _output);
301301
}
302302

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

test/Azure.Functions.Cli.Tests/E2E/InitTests.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ public Task init_with_worker_runtime_and_model(string workerRuntime, string prog
155155
$".vscode{Path.DirectorySeparatorChar}extensions.json",
156156
},
157157
OutputDoesntContain = new[] { "Initialized empty Git repository" },
158-
CommandTimeout = TimeSpan.FromSeconds(120)
158+
CommandTimeout = TimeSpan.FromSeconds(300)
159159
}, _output);
160160
}
161161

@@ -278,6 +278,7 @@ public Task init_with_no_source_control()
278278
{
279279
new DirectoryResult { Name = ".git", Exists = false }
280280
},
281+
CommandTimeout = TimeSpan.FromSeconds(300)
281282
}, _output);
282283
}
283284

@@ -298,7 +299,7 @@ public Task init_with_Dockerfile(string workerRuntime, string version)
298299
ContentContains = new[] { $"FROM mcr.microsoft.com/azure-functions/{workerRuntime}:{version}" }
299300
}
300301
},
301-
CommandTimeout = TimeSpan.FromSeconds(120),
302+
CommandTimeout = TimeSpan.FromSeconds(300),
302303
OutputContains = new[] { "Dockerfile" }
303304
}, _output);
304305
}
@@ -480,7 +481,7 @@ public Task init_ts_app_using_lang(string initCommand)
480481
"Writing Dockerfile",
481482
"Writing .dockerignore"
482483
},
483-
CommandTimeout = TimeSpan.FromSeconds(120)
484+
CommandTimeout = TimeSpan.FromSeconds(300)
484485
}, _output);
485486
}
486487

@@ -510,7 +511,7 @@ public Task javascript_adds_packagejson()
510511
"Writing local.settings.json",
511512
$".vscode{Path.DirectorySeparatorChar}extensions.json",
512513
},
513-
CommandTimeout = TimeSpan.FromSeconds(120)
514+
CommandTimeout = TimeSpan.FromSeconds(300)
514515
}, _output);
515516
}
516517

@@ -581,7 +582,7 @@ public Task init_docker_only_for_existing_project(string workerRuntime, string v
581582
}
582583
},
583584
OutputContains = new[] { "Dockerfile" },
584-
CommandTimeout = TimeSpan.FromSeconds(120)
585+
CommandTimeout = TimeSpan.FromSeconds(300)
585586
}, _output);
586587
}
587588

@@ -714,7 +715,7 @@ public Task init_function_app_contains_logging_config()
714715
{
715716
"Writing host.json"
716717
},
717-
CommandTimeout = TimeSpan.FromSeconds(120)
718+
CommandTimeout = TimeSpan.FromSeconds(300)
718719
}, _output);
719720
}
720721

test/Azure.Functions.Cli.Tests/E2E/SettingsTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ await CliTester.Run(new RunConfiguration
3333
}
3434
}
3535
},
36-
CommandTimeout = TimeSpan.FromSeconds(120)
36+
CommandTimeout = TimeSpan.FromSeconds(300)
3737
}, _output);
3838
}
3939

@@ -66,7 +66,7 @@ await CliTester.Run(new RunConfiguration[]
6666
}
6767
}
6868
},
69-
CommandTimeout = TimeSpan.FromSeconds(120)
69+
CommandTimeout = TimeSpan.FromSeconds(300)
7070
},
7171
new RunConfiguration
7272
{

test/Azure.Functions.Cli.Tests/E2E/StartTests.cs

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ await CliTester.Run(new RunConfiguration
5656
result.Should().Be("Hello, Test!", because: "response from default function should be 'Hello, {name}!'");
5757
}
5858
},
59-
CommandTimeout = TimeSpan.FromSeconds(120),
59+
CommandTimeout = TimeSpan.FromSeconds(300),
6060
}, _output);
6161
}
6262

@@ -93,7 +93,7 @@ await CliTester.Run(new RunConfiguration
9393
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.'");
9494
}
9595
},
96-
CommandTimeout = TimeSpan.FromSeconds(120),
96+
CommandTimeout = TimeSpan.FromSeconds(300),
9797
}, _output);
9898
}
9999

@@ -118,7 +118,7 @@ await CliTester.Run(new RunConfiguration
118118
await Task.Delay(TimeSpan.FromSeconds(15));
119119
p.Kill();
120120
},
121-
CommandTimeout = TimeSpan.FromSeconds(120)
121+
CommandTimeout = TimeSpan.FromSeconds(300)
122122
}, _output);
123123

124124
}
@@ -145,7 +145,7 @@ await CliTester.Run(new RunConfiguration
145145
await Task.Delay(TimeSpan.FromSeconds(15));
146146
p.Kill();
147147
},
148-
CommandTimeout = TimeSpan.FromSeconds(120),
148+
CommandTimeout = TimeSpan.FromSeconds(300),
149149
}, _output);
150150
}
151151

@@ -257,6 +257,7 @@ await CliTester.Run(new RunConfiguration[]
257257
string hostJsonContent = "{\"version\": \"2.0\",\"logging\": {\"logLevel\": {\"Default\": \"None\"}}}";
258258
await File.WriteAllTextAsync(filePath, hostJsonContent);
259259
},
260+
CommandTimeout = TimeSpan.FromSeconds(300),
260261
},
261262
new RunConfiguration
262263
{
@@ -278,7 +279,8 @@ await CliTester.Run(new RunConfiguration[]
278279
// give the host time to load functions and print any errors
279280
await Task.Delay(TimeSpan.FromSeconds(10));
280281
p.Kill();
281-
}
282+
},
283+
CommandTimeout = TimeSpan.FromSeconds(300),
282284
},
283285
}, _output, startHost: true);
284286
}
@@ -307,7 +309,7 @@ await CliTester.Run(new RunConfiguration
307309
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.'");
308310
}
309311
},
310-
CommandTimeout = TimeSpan.FromSeconds(120),
312+
CommandTimeout = TimeSpan.FromSeconds(300),
311313
}, _output);
312314
}
313315

@@ -342,7 +344,7 @@ await CliTester.Run(new RunConfiguration
342344
}
343345
}
344346
},
345-
CommandTimeout = TimeSpan.FromSeconds(120),
347+
CommandTimeout = TimeSpan.FromSeconds(300),
346348
}, _output);
347349
}
348350

@@ -366,7 +368,8 @@ await CliTester.Run(new RunConfiguration[]
366368
var functionJson = await File.ReadAllTextAsync(filePath);
367369
functionJson = functionJson.Replace("\"type\": \"http\"", "\"type\": \"http2\"");
368370
await File.WriteAllTextAsync(filePath, functionJson);
369-
}
371+
},
372+
CommandTimeout = TimeSpan.FromSeconds(300),
370373
},
371374
new RunConfiguration
372375
{
@@ -478,7 +481,7 @@ await CliTester.Run(new RunConfiguration
478481
ExpectExit = true,
479482
ExitInError = true,
480483
ErrorContains = new[] { "Port 8081 is unavailable" },
481-
CommandTimeout = TimeSpan.FromSeconds(120),
484+
CommandTimeout = TimeSpan.FromSeconds(300),
482485
}, _output);
483486
}
484487
finally
@@ -506,7 +509,8 @@ await CliTester.Run(new RunConfiguration[]
506509
var content = File.ReadAllText(settingsFile);
507510
content = content.Replace("EMPTY_VALUE", "");
508511
File.WriteAllText(settingsFile,content);
509-
}
512+
},
513+
CommandTimeout = TimeSpan.FromSeconds(300),
510514
},
511515
new RunConfiguration
512516
{
@@ -540,7 +544,7 @@ await CliTester.Run(new RunConfiguration[]
540544
{
541545
"Skipping 'emptySetting' from local settings as it's already defined in current environment variables."
542546
},
543-
CommandTimeout = TimeSpan.FromSeconds(120),
547+
CommandTimeout = TimeSpan.FromSeconds(300),
544548
}
545549
}, _output);
546550
}
@@ -603,7 +607,7 @@ await CliTester.Run(new RunConfiguration
603607
p.Kill();
604608
}
605609
},
606-
CommandTimeout = TimeSpan.FromSeconds(120)
610+
CommandTimeout = TimeSpan.FromSeconds(300)
607611
}, _output);
608612
}
609613

@@ -669,7 +673,7 @@ await CliTester.Run(new RunConfiguration[]
669673
{
670674
"Using for user secrets file configuration."
671675
},
672-
CommandTimeout = TimeSpan.FromSeconds(120),
676+
CommandTimeout = TimeSpan.FromSeconds(300),
673677
Test = async (workingDir, p) =>
674678
{
675679
using (var client = new HttpClient() { BaseAddress = new Uri("http://localhost:7071/") })
@@ -743,7 +747,7 @@ await CliTester.Run(new RunConfiguration[]
743747
{
744748
"start --functions http1 --csharp",
745749
},
746-
CommandTimeout = TimeSpan.FromSeconds(120),
750+
CommandTimeout = TimeSpan.FromSeconds(300),
747751
ExpectExit = true,
748752
ExitInError = true,
749753
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." },

test/Azure.Functions.Cli.Tests/ExtensionsTests/ExtensionBundleTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public Task BundleConfiguredByDefault_no_action()
2828
{
2929
"No action performed"
3030
},
31-
CommandTimeout = TimeSpan.FromMinutes(3)
31+
CommandTimeout = TimeSpan.FromMinutes(300)
3232
}, _output);
3333
}
3434

@@ -47,7 +47,7 @@ public Task BundleConfiguredByDefault_findsBundlePath()
4747
{
4848
bundlePath
4949
},
50-
CommandTimeout = TimeSpan.FromMinutes(3)
50+
CommandTimeout = TimeSpan.FromMinutes(300)
5151
}, _output);
5252
}
5353

@@ -66,7 +66,7 @@ public Task BundleNotConfiguredByDefault_showsErrorMessage()
6666
{
6767
"Extension bundle not configured."
6868
},
69-
CommandTimeout = TimeSpan.FromMinutes(3)
69+
CommandTimeout = TimeSpan.FromMinutes(300)
7070
}, _output);
7171
}
7272
}

test/Azure.Functions.Cli.Tests/ExtensionsTests/InstallExtensionsTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public Task try_install_with_no_valid_trigger()
4040
Exists = false
4141
}
4242
},
43-
CommandTimeout = TimeSpan.FromSeconds(120)
43+
CommandTimeout = TimeSpan.FromSeconds(300)
4444
}, _output);
4545
}
4646

0 commit comments

Comments
 (0)