Skip to content

Commit bb217af

Browse files
committed
feat: review
Signed-off-by: Ondrej Pokorny <[email protected]>
1 parent 4bada1b commit bb217af

12 files changed

+756
-644
lines changed

insights/v1alpha2/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
.PHONY: test
22
test:
3-
make -C ../../tests test GINKGO_EXTRA_ARGS=--focus="insights.openshift.io/v1alpha2"
3+
make -C ../../tests test GINKGO_EXTRA_ARGS=--focus="insights.openshift.io/v1alpha2"

insights/v1alpha2/doc.go

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// +k8s:defaulter-gen=TypeMeta
33
// +k8s:openapi-gen=true
44

5-
// +kubebuilder:validation:Optional
65
// +groupName=insights.openshift.io
76
// Package v1alpha2 is the v1alpha2 version of the API.
87
package v1alpha2

insights/v1alpha2/tests/datagathers.insights.openshift.io/InsightsOnDemandDataGather.yaml

+80-156
Original file line numberDiff line numberDiff line change
@@ -356,95 +356,7 @@ tests:
356356
resource: "pods"
357357
namespace: "openshift-insights"
358358
expectedStatusError: 'status: Invalid value: "object": cannot remove finishTime attribute from status'
359-
- name: dataGatherState cannot be removed from status
360-
initial: |
361-
apiVersion: insights.openshift.io/v1alpha2
362-
kind: DataGather
363-
spec: {} # No spec is required for a DataGather
364-
status:
365-
dataGatherState: Running
366-
updated: |
367-
apiVersion: insights.openshift.io/v1alpha2
368-
kind: DataGather
369-
spec: {} # No spec is required for a DataGather
370-
status:
371-
relatedObjects:
372-
- name: periodic-job-xyz
373-
group: ""
374-
resource: "pods"
375-
namespace: "openshift-insights"
376-
expectedStatusError: 'status: Invalid value: "object": cannot remove dataGatherState attribute from status'
377-
- name: dataGatherState cannot transition from Running to Pending
378-
initial: |
379-
apiVersion: insights.openshift.io/v1alpha2
380-
kind: DataGather
381-
spec: {} # No spec is required for a DataGather
382-
status:
383-
dataGatherState: Running
384-
updated: |
385-
apiVersion: insights.openshift.io/v1alpha2
386-
kind: DataGather
387-
spec: {} # No spec is required for a DataGather
388-
status:
389-
dataGatherState: Pending
390-
expectedStatusError: 'status.dataGatherState: Invalid value: "string": dataGatherState cannot transition from Running to Pending'
391-
- name: dataGatherState cannot transition from Completed to Pending
392-
initial: |
393-
apiVersion: insights.openshift.io/v1alpha2
394-
kind: DataGather
395-
spec: {} # No spec is required for a DataGather
396-
status:
397-
dataGatherState: Completed
398-
updated: |
399-
apiVersion: insights.openshift.io/v1alpha2
400-
kind: DataGather
401-
spec: {} # No spec is required for a DataGather
402-
status:
403-
dataGatherState: Pending
404-
expectedStatusError: 'status.dataGatherState: Invalid value: "string": dataGatherState cannot transition from Completed to Pending'
405-
- name: dataGatherState cannot transition from Failed to Pending
406-
initial: |
407-
apiVersion: insights.openshift.io/v1alpha2
408-
kind: DataGather
409-
spec: {} # No spec is required for a DataGather
410-
status:
411-
dataGatherState: Failed
412-
updated: |
413-
apiVersion: insights.openshift.io/v1alpha2
414-
kind: DataGather
415-
spec: {} # No spec is required for a DataGather
416-
status:
417-
dataGatherState: Pending
418-
expectedStatusError: 'status.dataGatherState: Invalid value: "string": dataGatherState cannot transition from Failed to Pending'
419-
- name: dataGatherState cannot transition from Completed to Running
420-
initial: |
421-
apiVersion: insights.openshift.io/v1alpha2
422-
kind: DataGather
423-
spec: {} # No spec is required for a DataGather
424-
status:
425-
dataGatherState: Completed
426-
updated: |
427-
apiVersion: insights.openshift.io/v1alpha2
428-
kind: DataGather
429-
spec: {} # No spec is required for a DataGather
430-
status:
431-
dataGatherState: Running
432-
expectedStatusError: 'status.dataGatherState: Invalid value: "string": dataGatherState cannot transition from Completed to Running'
433-
- name: dataGatherState cannot transition from Failed to Running
434-
initial: |
435-
apiVersion: insights.openshift.io/v1alpha2
436-
kind: DataGather
437-
spec: {} # No spec is required for a DataGather
438-
status:
439-
dataGatherState: Failed
440-
updated: |
441-
apiVersion: insights.openshift.io/v1alpha2
442-
kind: DataGather
443-
spec: {} # No spec is required for a DataGather
444-
status:
445-
dataGatherState: Running
446-
expectedStatusError: 'status.dataGatherState: Invalid value: "string": dataGatherState cannot transition from Failed to Running'
447-
- name: lastGatherDuration can be updated with a trailing zero value
359+
- name: lastGatherSeconds must be integer
448360
initial: |
449361
apiVersion: insights.openshift.io/v1alpha2
450362
kind: DataGather
@@ -456,28 +368,35 @@ tests:
456368
status:
457369
gatherers:
458370
- name: testGatherer
459-
lastGatherDuration: 1m0s
371+
lastGatherSeconds: 1.1
460372
conditions:
461373
- type: Gathered
462374
status: "True"
463375
reason: OK
464376
message: "test message"
465377
lastTransitionTime: "2024-12-01T08:04:21Z"
466-
expected: |
378+
expectedStatusError: "gatherers[0].lastGatherSeconds in body must be of type integer"
379+
- name: lastGatherSeconds cannot be updated with an invalid value
380+
initial: |
381+
apiVersion: insights.openshift.io/v1alpha2
382+
kind: DataGather
383+
spec: {} # No spec is required for a DataGather
384+
updated: |
467385
apiVersion: insights.openshift.io/v1alpha2
468386
kind: DataGather
469387
spec: {} # No spec is required for a DataGather
470388
status:
471389
gatherers:
472390
- name: testGatherer
473-
lastGatherDuration: 1m0s
391+
lastGatherSeconds: 1d2h
474392
conditions:
475393
- type: Gathered
476394
status: "True"
477395
reason: OK
478396
message: "test message"
479397
lastTransitionTime: "2024-12-01T08:04:21Z"
480-
- name: lastGatherDuration can be updated with a leading zero value
398+
expectedStatusError: 'Invalid value: "string": gatherers[0].lastGatherSeconds in body must be of type integer'
399+
- name: lastGatherSeconds cannot be updated with a negative value
481400
initial: |
482401
apiVersion: insights.openshift.io/v1alpha2
483402
kind: DataGather
@@ -489,28 +408,28 @@ tests:
489408
status:
490409
gatherers:
491410
- name: testGatherer
492-
lastGatherDuration: 0m11s
411+
lastGatherSeconds: -5
493412
conditions:
494413
- type: Gathered
495414
status: "True"
496415
reason: OK
497416
message: "test message"
498417
lastTransitionTime: "2024-12-01T08:04:21Z"
499-
expected: |
418+
expectedStatusError: "lastGatherSeconds in body should be greater than or equal to 0"
419+
- name: should not be updated with URL that is not HTTPS
420+
initial: |
421+
apiVersion: insights.openshift.io/v1alpha2
422+
kind: DataGather
423+
spec: {} # No spec is required for a DataGather
424+
updated: |
500425
apiVersion: insights.openshift.io/v1alpha2
501426
kind: DataGather
502427
spec: {} # No spec is required for a DataGather
503428
status:
504-
gatherers:
505-
- name: testGatherer
506-
lastGatherDuration: 0m11s
507-
conditions:
508-
- type: Gathered
509-
status: "True"
510-
reason: OK
511-
message: "test message"
512-
lastTransitionTime: "2024-12-01T08:04:21Z"
513-
- name: lastGatherDuration can be updated with a decimal number value
429+
insightsReport:
430+
uri: http://example.com
431+
expectedStatusError: 'status.insightsReport.uri: Invalid value: "string": URI must be a valid HTTPS URL (e.g., https://example.com)'
432+
- name: should be updated with a valid HTTPS URL
514433
initial: |
515434
apiVersion: insights.openshift.io/v1alpha2
516435
kind: DataGather
@@ -520,30 +439,16 @@ tests:
520439
kind: DataGather
521440
spec: {} # No spec is required for a DataGather
522441
status:
523-
gatherers:
524-
- name: testGatherer
525-
lastGatherDuration: 1m0.77s
526-
conditions:
527-
- type: Gathered
528-
status: "True"
529-
reason: OK
530-
message: "test message"
531-
lastTransitionTime: "2024-12-01T08:04:21Z"
442+
insightsReport:
443+
uri: https://example.com
532444
expected: |
533445
apiVersion: insights.openshift.io/v1alpha2
534446
kind: DataGather
535447
spec: {} # No spec is required for a DataGather
536448
status:
537-
gatherers:
538-
- name: testGatherer
539-
lastGatherDuration: 1m0.77s
540-
conditions:
541-
- type: Gathered
542-
status: "True"
543-
reason: OK
544-
message: "test message"
545-
lastTransitionTime: "2024-12-01T08:04:21Z"
546-
- name: lastGatherDuration cannot be updated with an invalid value
449+
insightsReport:
450+
uri: https://example.com
451+
- name: should be updated with a valid totalRisk
547452
initial: |
548453
apiVersion: insights.openshift.io/v1alpha2
549454
kind: DataGather
@@ -553,37 +458,22 @@ tests:
553458
kind: DataGather
554459
spec: {} # No spec is required for a DataGather
555460
status:
556-
gatherers:
557-
- name: testGatherer
558-
lastGatherDuration: 1d2h
559-
conditions:
560-
- type: Gathered
561-
status: "True"
562-
reason: OK
563-
message: "test message"
564-
lastTransitionTime: "2024-12-01T08:04:21Z"
565-
expectedStatusError: "Invalid value: \"1d2h\": gatherers[0].lastGatherDuration in body should match '^(([0-9]+(?:\\.[0-9]+)?(ns|us|µs|μs|ms|s|m|h))+)$'"
566-
- name: lastGatherDuration cannot be updated with a negative value
567-
initial: |
568-
apiVersion: insights.openshift.io/v1alpha2
569-
kind: DataGather
570-
spec: {} # No spec is required for a DataGather
571-
updated: |
461+
insightsReport:
462+
healthChecks:
463+
- description: Low risk update test
464+
totalRisk: Low
465+
advisorURI: https://example.com
466+
expected: |
572467
apiVersion: insights.openshift.io/v1alpha2
573468
kind: DataGather
574469
spec: {} # No spec is required for a DataGather
575470
status:
576-
gatherers:
577-
- name: testGatherer
578-
lastGatherDuration: -0m5s
579-
conditions:
580-
- type: Gathered
581-
status: "True"
582-
reason: OK
583-
message: "test message"
584-
lastTransitionTime: "2024-12-01T08:04:21Z"
585-
expectedStatusError: "Invalid value: \"-0m5s\": gatherers[0].lastGatherDuration in body should match '^(([0-9]+(?:\\.[0-9]+)?(ns|us|µs|μs|ms|s|m|h))+)$'"
586-
- name: should not be updated with URL that is not HTTPS
471+
insightsReport:
472+
healthChecks:
473+
- description: Low risk update test
474+
totalRisk: Low
475+
advisorURI: https://example.com
476+
- name: should not be updated with invalid totalRisk value
587477
initial: |
588478
apiVersion: insights.openshift.io/v1alpha2
589479
kind: DataGather
@@ -594,9 +484,12 @@ tests:
594484
spec: {} # No spec is required for a DataGather
595485
status:
596486
insightsReport:
597-
uri: http://example.com
598-
expectedStatusError: 'status.insightsReport.uri: Invalid value: "string": URI must be a valid HTTPS URL (e.g., https://example.com)'
599-
- name: should be updated with a valid HTTPS URL
487+
healthChecks:
488+
- description: NoRisk update test
489+
totalRisk: NoRisk
490+
advisorURI: https://example.com
491+
expectedStatusError: 'totalRisk: Unsupported value: "NoRisk": supported values: "Low", "Moderate", "Important", "Critical"'
492+
- name: should pass
600493
initial: |
601494
apiVersion: insights.openshift.io/v1alpha2
602495
kind: DataGather
@@ -607,11 +500,42 @@ tests:
607500
spec: {} # No spec is required for a DataGather
608501
status:
609502
insightsReport:
610-
uri: https://example.com
503+
healthChecks:
504+
- description: NoRisk update test
505+
totalRisk: Low
506+
advisorURI: https://example.com
507+
- description: NoRisk update test
508+
totalRisk: Important
509+
advisorURI: https://example.com
611510
expected: |
612511
apiVersion: insights.openshift.io/v1alpha2
613512
kind: DataGather
614513
spec: {} # No spec is required for a DataGather
615514
status:
616515
insightsReport:
617-
uri: https://example.com
516+
healthChecks:
517+
- description: NoRisk update test
518+
totalRisk: Low
519+
advisorURI: https://example.com
520+
- description: NoRisk update test
521+
totalRisk: Important
522+
advisorURI: https://example.com
523+
- name: no duplicates
524+
initial: |
525+
apiVersion: insights.openshift.io/v1alpha2
526+
kind: DataGather
527+
spec: {} # No spec is required for a DataGather
528+
updated: |
529+
apiVersion: insights.openshift.io/v1alpha2
530+
kind: DataGather
531+
spec: {} # No spec is required for a DataGather
532+
status:
533+
insightsReport:
534+
healthChecks:
535+
- description: Low risk update test
536+
totalRisk: Low
537+
advisorURI: https://example.com
538+
- description: Low risk update test
539+
totalRisk: Low
540+
advisorURI: https://example.com
541+
expectedStatusError: "invalid: status.insightsReport.healthChecks[1]: Duplicate value"

0 commit comments

Comments
 (0)