@@ -35,7 +35,6 @@ import (
3535
3636 "github.com/Azure/ARO-HCP/internal/utils"
3737 "github.com/Azure/ARO-HCP/test/util/timing"
38- "github.com/Azure/ARO-HCP/tooling/templatize/pkg/pipeline"
3938)
4039
4140//go:embed artifacts/*.tmpl
@@ -78,7 +77,6 @@ type ValidatedOptions struct {
7877
7978// completedOptions is a private wrapper that enforces a call of Complete() before config generation can be invoked.
8079type completedOptions struct {
81- Steps []pipeline.NodeInfo
8280 TimingInputDir string
8381 OutputDir string
8482}
@@ -124,9 +122,17 @@ type LinkDetails struct {
124122
125123type QueryInfo struct {
126124 ResourceGroupName string
125+ StartTime string
126+ EndTime string
127127 Database string
128128}
129129
130+ type TimingInfo struct {
131+ StartTime string
132+ EndTime string
133+ ResourceGroupNames []string
134+ }
135+
130136func createQueryURL (templatePath string , info QueryInfo ) string {
131137 currURL := url.URL {
132138 Scheme : "https" ,
@@ -178,20 +184,8 @@ func encodeKustoQuery(query string) string {
178184}
179185
180186func (o * ValidatedOptions ) Complete (logger logr.Logger ) (* Options , error ) {
181- // we consume steps.yaml (output of templatize and stored for us by the visualization) to determine the cluster name
182- stepsYamlBytes , err := os .ReadFile (path .Join (o .TimingInputDir , "steps.yaml" ))
183- if err != nil {
184- return nil , utils .TrackError (err )
185- }
186-
187- var steps []pipeline.NodeInfo
188- if err := yaml .Unmarshal (stepsYamlBytes , & steps ); err != nil {
189- return nil , fmt .Errorf ("failed to unmarshal timing input file: %w" , err )
190- }
191-
192187 return & Options {
193188 completedOptions : & completedOptions {
194- Steps : steps ,
195189 OutputDir : o .OutputDir ,
196190 TimingInputDir : o .TimingInputDir ,
197191 },
@@ -201,27 +195,32 @@ func (o *ValidatedOptions) Complete(logger logr.Logger) (*Options, error) {
201195func (o Options ) Run (ctx context.Context ) error {
202196 allTestRows := []TestRow {}
203197
204- deploymentResourceGroups , err := gatherResourceGroups (o .TimingInputDir )
198+ timingInfo , err := gatherTimingInfo (o .TimingInputDir )
205199 if err != nil {
206200 return utils .TrackError (err )
207201 }
208202
209- for testName , rgs := range deploymentResourceGroups {
210- for _ , rg := range rgs {
203+ for testName , timing := range timingInfo {
204+ for _ , rg := range timing . ResourceGroupNames {
211205 allTestRows = append (allTestRows , TestRow {
212206 TestName : testName ,
213207 ResourceGroupName : rg ,
214208 Links : []LinkDetails {
215209 createLinkForTest ("Hosted Control Plane Logs" , "hosted-controlplane.kql.tmpl" , QueryInfo {
216210 ResourceGroupName : rg ,
217211 Database : "HostedControlPlaneLogs" ,
212+ StartTime : timing .StartTime ,
213+ EndTime : timing .EndTime ,
218214 }),
219215 createLinkForTest ("Service Logs" , "service-logs.kql.tmpl" , QueryInfo {
220216 ResourceGroupName : rg ,
221217 Database : "ServiceLogs" ,
218+ StartTime : timing .StartTime ,
219+ EndTime : timing .EndTime ,
222220 }),
223221 },
224222 Database : "HostedControlPlaneLogs" ,
223+ Status : "tbd" ,
225224 })
226225 }
227226 }
@@ -259,7 +258,7 @@ func (o Options) Run(ctx context.Context) error {
259258 return nil
260259}
261260
262- func gatherResourceGroups (timingInputDir string ) (map [string ][] string , error ) {
261+ func gatherTimingInfo (timingInputDir string ) (map [string ]TimingInfo , error ) {
263262 timingDir , err := os .Stat (path .Join (timingInputDir , "test-timing/" ))
264263 if err != nil {
265264 return nil , err
@@ -269,7 +268,7 @@ func gatherResourceGroups(timingInputDir string) (map[string][]string, error) {
269268 }
270269
271270 var allTimingFiles []string
272- filepath .Walk (path .Join (timingInputDir , "test-timing/" ), func (path string , info os.FileInfo , err error ) error {
271+ err = filepath .Walk (path .Join (timingInputDir , "test-timing/" ), func (path string , info os.FileInfo , err error ) error {
273272 if err != nil {
274273 return err
275274 }
@@ -278,8 +277,11 @@ func gatherResourceGroups(timingInputDir string) (map[string][]string, error) {
278277 }
279278 return nil
280279 })
280+ if err != nil {
281+ return nil , err
282+ }
281283
282- var allResourceGroups map [ string ][] string = make (map [string ][] string )
284+ var allTimingInfo = make (map [string ]TimingInfo )
283285
284286 for _ , timingFile := range allTimingFiles {
285287 timingFileBytes , err := os .ReadFile (timingFile )
@@ -293,18 +295,24 @@ func gatherResourceGroups(timingInputDir string) (map[string][]string, error) {
293295 }
294296 deployment := strings .Join (timing .Identifier , " " )
295297
296- var rgNames map [ string ] bool = make (map [string ]bool )
298+ var rgNames = make (map [string ]bool )
297299 for resourceGroup := range timing .Deployments {
298300 rgNames [resourceGroup ] = true
299301 }
300302
303+ rgNameList := make ([]string , 0 )
301304 for rgName := range rgNames {
302305 if rgName == "" {
303306 continue
304307 }
305- allResourceGroups [deployment ] = append (allResourceGroups [deployment ], rgName )
308+ rgNameList = append (rgNameList , rgName )
309+ }
310+ allTimingInfo [deployment ] = TimingInfo {
311+ StartTime : timing .StartedAt ,
312+ EndTime : timing .FinishedAt ,
313+ ResourceGroupNames : rgNameList ,
306314 }
307315 }
308316
309- return allResourceGroups , nil
317+ return allTimingInfo , nil
310318}
0 commit comments