@@ -9,6 +9,7 @@ namespace VirtualClient.Actions
9
9
using System . IO . Abstractions ;
10
10
using System . Linq ;
11
11
using System . Runtime . InteropServices ;
12
+ using System . Text ;
12
13
using System . Text . RegularExpressions ;
13
14
using System . Threading ;
14
15
using System . Threading . Tasks ;
@@ -29,8 +30,11 @@ namespace VirtualClient.Actions
29
30
public class SpecViewExecutor : VirtualClientComponent
30
31
{
31
32
private const string VisualStudioCRuntimePackageName = "visualstudiocruntime" ;
33
+ private const string RenamePrefix = "hist_" ;
34
+
32
35
private IFileSystem fileSystem ;
33
36
private ISystemManagement systemManagement ;
37
+ private string historyResultsPath ;
34
38
35
39
/// <summary>
36
40
/// Constructor for <see cref="SpecViewExecutor"/>
@@ -62,7 +66,8 @@ public string Viewset
62
66
{
63
67
get
64
68
{
65
- return this . Parameters . GetValue < string > ( nameof ( SpecViewExecutor . Viewset ) ) ;
69
+ // Remove whitespaces in the argument (e.g. "3dsmax, catia" -> "3dsmax,catia")
70
+ return this . Parameters . GetValue < string > ( nameof ( SpecViewExecutor . Viewset ) ) . Replace ( " " , string . Empty ) ;
66
71
}
67
72
}
68
73
@@ -113,8 +118,34 @@ protected override async Task ExecuteAsync(EventContext telemetryContext, Cancel
113
118
process . ThrowIfWorkloadFailed ( ) ;
114
119
this . CaptureMetrics ( process , commandArguments , relatedContext ) ;
115
120
}
116
- }
117
-
121
+ }
122
+
123
+ if ( this . TryGetContentStoreManager ( out IBlobManager blobManager ) )
124
+ {
125
+ // specview logs are distributed in subdirectories corresponding to the viewsets
126
+ string [ ] viewsetArray = this . Viewset . Split ( new [ ] { "," } , StringSplitOptions . RemoveEmptyEntries ) ;
127
+ string specviewOriginalLogPath ;
128
+ string specviewRenamedLogPath ;
129
+ List < Task > tasks = new List < Task > ( ) ;
130
+ foreach ( string viewset in viewsetArray )
131
+ {
132
+ // log file is inside a folder that starts with the viewset name e.g. 3dsmax-07
133
+ string ? viewsetLogDir = this . fileSystem . Directory . GetDirectories ( this . historyResultsPath , $ "{ viewset } *", SearchOption . TopDirectoryOnly ) . FirstOrDefault ( ) ;
134
+ if ( viewsetLogDir == null )
135
+ {
136
+ throw new WorkloadResultsException (
137
+ $ "The expected SPECviewperf viewset log directory was not found in '{ this . historyResultsPath } '.",
138
+ ErrorReason . WorkloadResultsNotFound ) ;
139
+ }
140
+
141
+ specviewOriginalLogPath = this . PlatformSpecifics . Combine ( viewsetLogDir , "log.txt" ) ;
142
+ specviewRenamedLogPath = this . PlatformSpecifics . Combine ( viewsetLogDir , viewset + "-" + Path . GetFileName ( specviewOriginalLogPath ) ) ;
143
+ this . fileSystem . Directory . Move ( specviewOriginalLogPath , specviewRenamedLogPath ) ;
144
+ tasks . Add ( this . UploadSpecviewLogAsync ( blobManager , specviewRenamedLogPath , DateTime . UtcNow , cancellationToken ) ) ;
145
+ }
146
+
147
+ await Task . WhenAll ( tasks ) ;
148
+ }
118
149
}
119
150
120
151
/// <summary>
@@ -180,8 +211,8 @@ private void CaptureMetrics(IProcessProxy workloadProcess, string commandArgumen
180
211
telemetryContext ) ;
181
212
182
213
// rename the result file to avoid confusions on future runs
183
- string historyResultsDir = this . PlatformSpecifics . Combine ( this . Package . Path , "hist_" + Path . GetFileName ( resultsFileDir ) ) ;
184
- this . fileSystem . Directory . Move ( resultsFileDir , historyResultsDir ) ;
214
+ this . historyResultsPath = this . PlatformSpecifics . Combine ( this . Package . Path , RenamePrefix + Path . GetFileName ( resultsFileDir ) ) ;
215
+ this . fileSystem . Directory . Move ( resultsFileDir , this . historyResultsPath ) ;
185
216
}
186
217
catch ( SchemaException exc )
187
218
{
@@ -223,5 +254,24 @@ private async Task SetUpEnvironmentVariable()
223
254
string visualStudioCRuntimeDllPath = this . PlatformSpecifics . ToPlatformSpecificPath ( visualStudioCRuntimePackage , this . Platform , this . CpuArchitecture ) . Path ;
224
255
this . SetEnvironmentVariable ( EnvironmentVariable . PATH , visualStudioCRuntimeDllPath , EnvironmentVariableTarget . Machine , append : true ) ;
225
256
}
257
+
258
+ private Task UploadSpecviewLogAsync ( IBlobManager blobManager , string specviewLogPath , DateTime logTime , CancellationToken cancellationToken )
259
+ {
260
+ // Example Blob Store Structure:
261
+ // 9ed58814-435b-4900-8eb2-af86393e0059/my-vc/specview/specviewperf/2023-10-11T22-07-41-73235Z-log.txt
262
+ FileUploadDescriptor descriptor = this . CreateFileUploadDescriptor (
263
+ new FileContext (
264
+ this . fileSystem . FileInfo . New ( specviewLogPath ) ,
265
+ HttpContentType . PlainText ,
266
+ Encoding . UTF8 . WebName ,
267
+ this . ExperimentId ,
268
+ this . AgentId ,
269
+ "specview" ,
270
+ this . Scenario ,
271
+ null ,
272
+ this . Roles ? . FirstOrDefault ( ) ) ) ;
273
+
274
+ return this . UploadFileAsync ( blobManager , this . fileSystem , descriptor , cancellationToken , deleteFile : false ) ;
275
+ }
226
276
}
227
277
}
0 commit comments