Skip to content

Add artifact naming service #6586

@nohwnd

Description

@nohwnd

Summary

Add attachment/artifact naming service that will allow users to achieve:

  • consistent naming for their artifact
  • consistent placement for their artifacts
  • allow us to do the minimum of work to distinguish artifacts

Background and Motivation

Each extension has it's own standards and needs to save files. Add a service that internal and external extension take dependency on to name their files, so we have a consistent way to distinguish and place files.

Below we focus just on hang dump, but each extension the produces artifacts should support this.

Naming

Hang dump creates a dump file, currently we take the name pattern and replace just %p for PID.

Instead user should be able to say <process-name>_<pid>_<id>_hang.dmp, to get file named with the process-name, process id (pid), and short random id.

Placement

user should also be able to say:

<root>/artifacts/<os>/<assembly>/dumps/<process-name>_<pid>_<tfm>_<time>.dmp

and get:

c:/myproject/artifacts/linux/MyTests/dumps/my-child-process_10001_net9.0_2025-09-22T13:49:34.dmp

The root is determined based on the solution / git / working dir (there should be a documented root finding service honestly).

os is one of linux / macos / windows.

assembly, tfm - is determined from the running source

process-name, pid is the actual process-name and pid of the dumped process

time is time with precision to 1 second to give rough info of when the dump was taken.

Future

When user finds out that e.g. re-runs cause the dumps to be mixed they can either rely on a new template <attempt>, if we add it, or they can add <id> to generate random id.

Non-existing template fields and volatile fields

Not all fields are available for all scenarios, in this case the field should simply be kept as is, so user can see it in the final name, and research why it is unusable in their scenario.

Calls to the replacement service should be able to provide a dictionary of replacements that will customize the available fields when these fields change meaning in the extension.

E.g. when we are running in process MyTests 123, but dumping process Notepad 1111, we should provide:

<process-name> = Notepad
<pid> = 1111

Backward compatibility

Service should provide a way to add custom names for current templates for backwards compatibility, e.g. to accomodate %p in hang dump which stands for <pid>.

Alternative Designs

Related to: #4130

Metadata

Metadata

Assignees

Labels

Area: MTPBelongs to the Microsoft.Testing.Platform core library

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions