Skip to content

Commit e57448d

Browse files
committed
seeing if vs artifacts work now
1 parent e76fc5e commit e57448d

File tree

6 files changed

+40
-15
lines changed

6 files changed

+40
-15
lines changed

eng/scripts/ArtifactAssemblerHelpers/testVsArtifacts.ps1

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ $runtimeSettings = ".\test\Cli\Func.E2E.Tests\.runsettings\start_tests\artifact_
1414
[System.Environment]::SetEnvironmentVariable("FUNCTIONS_WORKER_RUNTIME", "dotnet", "Process")
1515

1616
# Path for Visual Studio test projects (convert to absolute paths)
17-
$net8VsProjectPath = ".\test\Cli\Func.E2ETests\VisualStudioTestProjects\TestNet8InProcProject"
18-
$net6VsProjectPath = ".\test\Cli\Func.E2ETests\VisualStudioTestProjects\TestNet6InProcProject"
17+
$net8VsProjectPath = ".\test\TestFunctionApps\VisualStudioTestProjects\TestNet8InProcProject"
18+
$net6VsProjectPath = ".\test\TestFunctionApps\VisualStudioTestProjects\TestNet6InProcProject"
1919

2020
# Resolve paths to absolute paths
2121
$absoluteNet8VsProjectPath = (Resolve-Path -Path $net8VsProjectPath -ErrorAction SilentlyContinue).Path

test/Cli/Func.E2E.Tests/Commands/FuncStart/Core/BaseMissingConfigTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public async Task RunMissingLocalSettingsJsonTest(string language, string runtim
8989

9090
funcStartCommand.ProcessStartedHandler = async (process) =>
9191
{
92-
// Wait for host to start up if param is set, otherwise just wait 5 seconds for logs and kill the process
92+
// Wait for host to start up if param is set, otherwise just wait 1 second for logs and kill the process
9393
if (shouldWaitForHost)
9494
{
9595
await ProcessHelper.ProcessStartedHandlerHelper(port, process, funcStartCommand.FileWriter ?? throw new ArgumentNullException(nameof(funcStartCommand.FileWriter)), "HttpTriggerFunc");

test/Cli/Func.E2E.Tests/Commands/FuncStart/TestsWithFixtures/DotnetIsolatedTests.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public void Start_DotnetIsolated_WithRuntimeSpecified_SuccessfulFunctionExecutio
6767
var result = funcStartCommand
6868
.WithWorkingDirectory(_fixture.WorkingDirectory)
6969
.WithEnvironmentVariable(Common.Constants.FunctionsWorkerRuntime, "dotnet-isolated")
70-
.Execute(new[] { "start", "--verbose", "--runtime", "default", "--port", port.ToString() });
70+
.Execute(["start", "--verbose", "--runtime", "default", "--port", port.ToString()]);
7171

7272
// Validate that getting http endpoint works
7373
capturedContent.Should().Be(
@@ -96,7 +96,7 @@ public void Start_DotnetIsolated_WithoutRuntimeSpecified_SuccessfulFunctionExecu
9696
var result = funcStartCommand
9797
.WithWorkingDirectory(_fixture.WorkingDirectory)
9898
.WithEnvironmentVariable(Common.Constants.FunctionsWorkerRuntime, "dotnet-isolated")
99-
.Execute(new[] { "--verbose", "--port", port.ToString() });
99+
.Execute(["--verbose", "--port", port.ToString()]);
100100

101101
// Validate that getting http endpoint works
102102
capturedContent.Should().Be(
@@ -116,7 +116,7 @@ public void Start_DotnetIsolatedApp_With_InProc8AsRuntime_ShouldFail()
116116
var result = new FuncStartCommand(_fixture.FuncPath, nameof(Start_DotnetIsolatedApp_With_InProc8AsRuntime_ShouldFail), _fixture.Log)
117117
.WithWorkingDirectory(_fixture.WorkingDirectory)
118118
.WithEnvironmentVariable(Common.Constants.FunctionsWorkerRuntime, "dotnet-isolated")
119-
.Execute(new[] { "--verbose", "--runtime", "inproc6", "--port", port.ToString() });
119+
.Execute(["--verbose", "--runtime", "inproc6", "--port", port.ToString()]);
120120

121121
// Validate error message
122122
result.Should().ExitWith(1);
@@ -132,7 +132,7 @@ public void Start_DotnetIsolatedApp_With_InProc6AsRuntime_ShouldFail()
132132
var result = new FuncStartCommand(_fixture.FuncPath, nameof(Start_DotnetIsolatedApp_With_InProc6AsRuntime_ShouldFail), _fixture.Log)
133133
.WithWorkingDirectory(_fixture.WorkingDirectory)
134134
.WithEnvironmentVariable(Common.Constants.FunctionsWorkerRuntime, "dotnet-isolated")
135-
.Execute(new[] { "--verbose", "--runtime", "inproc8", "--port", port.ToString() });
135+
.Execute(["--verbose", "--runtime", "inproc8", "--port", port.ToString()]);
136136

137137
// Validate error message
138138
result.Should().ExitWith(1);

test/Cli/Func.E2E.Tests/Commands/FuncStart/TestsWithFixtures/NodeV3Tests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public void Start_NodeJsApp_V3_SuccessfulFunctionExecution()
4040
var result = funcStartCommand
4141
.WithWorkingDirectory(_fixture.WorkingDirectory)
4242
.WithEnvironmentVariable(Common.Constants.FunctionsWorkerRuntime, "node")
43-
.Execute(new[] { "--verbose", "--port", port.ToString() });
43+
.Execute(["--verbose", "--port", port.ToString()]);
4444

4545
capturedContent.Should().Be("This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response.");
4646
}

test/Cli/Func.E2E.Tests/Commands/FuncStart/TestsWithFixtures/NodeV4Tests.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public void Start_WithoutSpecifyingDefaultHost_SuccessfulFunctionExecution()
4242
var result = funcStartCommand
4343
.WithWorkingDirectory(_fixture.WorkingDirectory)
4444
.WithEnvironmentVariable(Common.Constants.FunctionsWorkerRuntime, "node")
45-
.Execute(new[] { "--verbose", "--port", port.ToString() });
45+
.Execute(["--verbose", "--port", port.ToString()]);
4646

4747
capturedContent.Should().Be("Hello, Test!");
4848

@@ -70,7 +70,7 @@ public void Start_WithSpecifyingDefaultHost_SuccessfulFunctionExecution()
7070
var result = funcStartCommand
7171
.WithWorkingDirectory(_fixture.WorkingDirectory)
7272
.WithEnvironmentVariable(Common.Constants.FunctionsWorkerRuntime, "node")
73-
.Execute(new[] { "--verbose", "--port", port.ToString(), "--runtime", "default" });
73+
.Execute(["--verbose", "--port", port.ToString(), "--runtime", "default"]);
7474

7575
capturedContent.Should().Be("Hello, Test!");
7676

@@ -97,7 +97,7 @@ public void Start_WithInspect_DebuggerIsStarted()
9797
var result = funcStartCommand
9898
.WithWorkingDirectory(_fixture.WorkingDirectory)
9999
.WithEnvironmentVariable(Common.Constants.FunctionsWorkerRuntime, "node")
100-
.Execute(new[] { "--port", port.ToString(), "--verbose", "--language-worker", "--", $"\"--inspect={debugPort}\"" });
100+
.Execute(["--port", port.ToString(), "--verbose", "--language-worker", "--", $"\"--inspect={debugPort}\""]);
101101

102102
// Validate debugger started
103103
result.Should().HaveStdOutContaining($"Debugger listening on ws://127.0.0.1:{debugPort}");
@@ -120,7 +120,7 @@ public void Start_PortInUse_FailsWithExpectedError()
120120
var result = funcStartCommand
121121
.WithWorkingDirectory(_fixture.WorkingDirectory)
122122
.WithEnvironmentVariable(Common.Constants.FunctionsWorkerRuntime, "node")
123-
.Execute(new[] { "--port", port.ToString() });
123+
.Execute(["--port", port.ToString()]);
124124

125125
funcStartCommand.ProcessStartedHandler = async (process) =>
126126
{
@@ -150,7 +150,7 @@ public void Start_NonDotnetApp_With_InProc6Runtime_ShouldFail()
150150
var result = funcStartCommand
151151
.WithWorkingDirectory(_fixture.WorkingDirectory)
152152
.WithEnvironmentVariable(Common.Constants.FunctionsWorkerRuntime, "node")
153-
.Execute(new[] { "--verbose", "--runtime", "inproc6", "--port", port.ToString() });
153+
.Execute(["--verbose", "--runtime", "inproc6", "--port", port.ToString()]);
154154

155155
// Validate failure message
156156
result.Should().ExitWith(1);

test/Cli/Func.E2E.Tests/README.md

+27-2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ There are two main types of tests for the `func start` command:
3636
**Dotnet isolated templates and dotnet in-proc templates CANNOT be run in parallel**
3737

3838
- Use traits to distinguish between dotnet-isolated and dotnet-inproc tests
39+
- Refer to TestTraits.cs for trait names and explanations on when they should be used
3940
- This ensures they run sequentially rather than in parallel
4041

4142
### Node.js Tests
@@ -154,9 +155,17 @@ else
154155
}
155156
```
156157

158+
You may also create a custom condition and then call the method like so:
159+
160+
```csharp
161+
// Validate inproc6 host was started
162+
result.Should().StartInProc6Host();
163+
164+
```
165+
157166
## Testing with Fixtures
158167

159-
The steps are similar for creating a `func start` test with a fixture, except you can skip the setup logic that calls `func init` and `func new` as the fixture handles this for you.
168+
The steps are similar for creating a `func start` test with a fixture, except you can skip the setup logic that calls `func init` and `func new` as the fixture handles this for you. Please ensure that the test that are being added to the fixture DO NOT change the environment or add any extra variables or config, as that may cause problems with the existing tests.
160169

161170
## Complete Example
162171

@@ -202,4 +211,20 @@ public async Task Start_DotnetIsolated_Test_EnableAuthFeature(
202211
result.Should().HaveStdOutContaining("Selected out-of-process host.");
203212
}
204213
}
205-
```
214+
```
215+
216+
## How to Build and Run Tests Locally
217+
218+
## How to Build and Run Tests Locally
219+
220+
1. Run `dotnet build` on `Azure.Functions.Cli.E2E.Tests.csproj`.
221+
222+
2. Navigate to `CORE_TOOLS_REPO_ROOT\out\bin\Azure.Functions.Cli.E2E.Tests\debug` and add a `templates` file if it doesn't already exist. Copy the existing templates file from the core tools installation on your local machine to the debug directory.
223+
224+
3. To test in-proc artifacts, copy the `inproc6` and `inproc8` directories by either:
225+
- Building the `inproc` branch locally and manually copying the folders into the debug folder, or
226+
- Copying these folders from the core tools installation on your local machine to the debug folder.
227+
228+
4. Execute the tests using the `dotnet test` command or Visual Studio Test Explorer. Note that only tests requiring default artifacts (not in-proc artifacts) will run by default.
229+
230+
5. To run a specific test with runtime settings, use: `dotnet test {PATH_TO_E2E_TEST_PROJECT} --filter "TestCategory=InProc"`.`

0 commit comments

Comments
 (0)