@@ -78,7 +78,6 @@ var _ = Describe("Collector", Ordered, func() {
78
78
dataCollector telemetry.DataCollector
79
79
version string
80
80
expData telemetry.Data
81
- ctx context.Context
82
81
podNSName types.NamespacedName
83
82
ngfPod * v1.Pod
84
83
ngfReplicaSet * appsv1.ReplicaSet
@@ -90,7 +89,6 @@ var _ = Describe("Collector", Ordered, func() {
90
89
)
91
90
92
91
BeforeAll (func () {
93
- ctx = context .Background ()
94
92
version = "1.1"
95
93
96
94
ngfPod = & v1.Pod {
@@ -230,7 +228,7 @@ var _ = Describe("Collector", Ordered, func() {
230
228
231
229
Describe ("Normal case" , func () {
232
230
When ("collecting telemetry data" , func () {
233
- It ("collects all fields" , func () {
231
+ It ("collects all fields" , func (ctx SpecContext ) {
234
232
nodes := & v1.NodeList {
235
233
Items : []v1.Node {
236
234
{
@@ -396,7 +394,7 @@ var _ = Describe("Collector", Ordered, func() {
396
394
Describe ("cluster information collector" , func () {
397
395
When ("collecting cluster platform" , func () {
398
396
When ("it encounters an error while collecting data" , func () {
399
- It ("should error if the kubernetes client errored when getting the NamespaceList" , func () {
397
+ It ("should error if the kubernetes client errored when getting the NamespaceList" , func (ctx SpecContext ) {
400
398
expectedError := errors .New ("failed to get NamespaceList" )
401
399
k8sClientReader .ListCalls (mergeListCallsWithBase (
402
400
func (_ context.Context , object client.ObjectList , _ ... client.ListOption ) error {
@@ -415,7 +413,7 @@ var _ = Describe("Collector", Ordered, func() {
415
413
416
414
When ("collecting clusterID data" , func () {
417
415
When ("it encounters an error while collecting data" , func () {
418
- It ("should error if the kubernetes client errored when getting the namespace" , func () {
416
+ It ("should error if the kubernetes client errored when getting the namespace" , func (ctx SpecContext ) {
419
417
expectedError := errors .New ("there was an error getting clusterID" )
420
418
k8sClientReader .GetCalls (mergeGetCallsWithBase (
421
419
func (_ context.Context , _ types.NamespacedName , object client.Object , _ ... client.GetOption ) error {
@@ -434,7 +432,7 @@ var _ = Describe("Collector", Ordered, func() {
434
432
435
433
When ("collecting cluster version data" , func () {
436
434
When ("the kubelet version is missing" , func () {
437
- It ("should be report 'unknown'" , func () {
435
+ It ("should be report 'unknown'" , func (ctx SpecContext ) {
438
436
nodes := & v1.NodeList {
439
437
Items : []v1.Node {
440
438
{
@@ -463,7 +461,7 @@ var _ = Describe("Collector", Ordered, func() {
463
461
464
462
Describe ("node count collector" , func () {
465
463
When ("collecting node count data" , func () {
466
- It ("collects correct data for one node" , func () {
464
+ It ("collects correct data for one node" , func (ctx SpecContext ) {
467
465
k8sClientReader .ListCalls (createListCallsFunc (nodeList ))
468
466
469
467
expData .Data .ClusterNodeCount = 1
@@ -475,7 +473,7 @@ var _ = Describe("Collector", Ordered, func() {
475
473
})
476
474
477
475
When ("it encounters an error while collecting data" , func () {
478
- It ("should error when there are no nodes" , func () {
476
+ It ("should error when there are no nodes" , func (ctx SpecContext ) {
479
477
expectedError := errors .New ("failed to collect cluster information: NodeList length is zero" )
480
478
k8sClientReader .ListCalls (createListCallsFunc (nil ))
481
479
@@ -484,7 +482,7 @@ var _ = Describe("Collector", Ordered, func() {
484
482
Expect (err ).To (MatchError (expectedError ))
485
483
})
486
484
487
- It ("should error on kubernetes client api errors" , func () {
485
+ It ("should error on kubernetes client api errors" , func (ctx SpecContext ) {
488
486
expectedError := errors .New ("failed to get NodeList" )
489
487
k8sClientReader .ListCalls (
490
488
func (_ context.Context , object client.ObjectList , _ ... client.ListOption ) error {
@@ -593,7 +591,7 @@ var _ = Describe("Collector", Ordered, func() {
593
591
})
594
592
595
593
When ("collecting NGF resource counts" , func () {
596
- It ("collects correct data for graph with no resources" , func () {
594
+ It ("collects correct data for graph with no resources" , func (ctx SpecContext ) {
597
595
fakeGraphGetter .GetLatestGraphReturns (& graph.Graph {})
598
596
fakeConfigurationGetter .GetLatestConfigurationReturns (& dataplane.Configuration {})
599
597
@@ -605,7 +603,7 @@ var _ = Describe("Collector", Ordered, func() {
605
603
Expect (expData ).To (Equal (data ))
606
604
})
607
605
608
- It ("collects correct data for graph with one of each resource" , func () {
606
+ It ("collects correct data for graph with one of each resource" , func (ctx SpecContext ) {
609
607
fakeGraphGetter .GetLatestGraphReturns (graph1 )
610
608
fakeConfigurationGetter .GetLatestConfigurationReturns (config1 )
611
609
@@ -629,7 +627,7 @@ var _ = Describe("Collector", Ordered, func() {
629
627
Expect (expData ).To (Equal (data ))
630
628
})
631
629
632
- It ("ignores invalid and empty upstreams" , func () {
630
+ It ("ignores invalid and empty upstreams" , func (ctx SpecContext ) {
633
631
fakeGraphGetter .GetLatestGraphReturns (& graph.Graph {})
634
632
fakeConfigurationGetter .GetLatestConfigurationReturns (invalidUpstreamsConfig )
635
633
expData .NGFResourceCounts = telemetry.NGFResourceCounts {
@@ -659,15 +657,15 @@ var _ = Describe("Collector", Ordered, func() {
659
657
fakeGraphGetter .GetLatestGraphReturns (& graph.Graph {})
660
658
fakeConfigurationGetter .GetLatestConfigurationReturns (& dataplane.Configuration {})
661
659
})
662
- It ("should error on nil latest graph" , func () {
660
+ It ("should error on nil latest graph" , func (ctx SpecContext ) {
663
661
expectedError := errors .New ("latest graph cannot be nil" )
664
662
fakeGraphGetter .GetLatestGraphReturns (nil )
665
663
666
664
_ , err := dataCollector .Collect (ctx )
667
665
Expect (err ).To (MatchError (expectedError ))
668
666
})
669
667
670
- It ("should error on nil latest configuration" , func () {
668
+ It ("should error on nil latest configuration" , func (ctx SpecContext ) {
671
669
expectedError := errors .New ("latest configuration cannot be nil" )
672
670
fakeConfigurationGetter .GetLatestConfigurationReturns (nil )
673
671
@@ -681,7 +679,7 @@ var _ = Describe("Collector", Ordered, func() {
681
679
Describe ("NGF replica count collector" , func () {
682
680
When ("collecting NGF replica count" , func () {
683
681
When ("it encounters an error while collecting data" , func () {
684
- It ("should error if the kubernetes client errored when getting the Pod" , func () {
682
+ It ("should error if the kubernetes client errored when getting the Pod" , func (ctx SpecContext ) {
685
683
expectedErr := errors .New ("there was an error getting the Pod" )
686
684
k8sClientReader .GetCalls (mergeGetCallsWithBase (
687
685
func (_ context.Context , _ client.ObjectKey , object client.Object , _ ... client.GetOption ) error {
@@ -697,7 +695,7 @@ var _ = Describe("Collector", Ordered, func() {
697
695
Expect (err ).To (MatchError (expectedErr ))
698
696
})
699
697
700
- It ("should error if the Pod's owner reference is nil" , func () {
698
+ It ("should error if the Pod's owner reference is nil" , func (ctx SpecContext ) {
701
699
expectedErr := errors .New ("expected one owner reference of the NGF Pod, got 0" )
702
700
k8sClientReader .GetCalls (mergeGetCallsWithBase (createGetCallsFunc (
703
701
& v1.Pod {
@@ -712,7 +710,7 @@ var _ = Describe("Collector", Ordered, func() {
712
710
Expect (err ).To (MatchError (expectedErr ))
713
711
})
714
712
715
- It ("should error if the Pod has multiple owner references" , func () {
713
+ It ("should error if the Pod has multiple owner references" , func (ctx SpecContext ) {
716
714
expectedErr := errors .New ("expected one owner reference of the NGF Pod, got 2" )
717
715
k8sClientReader .GetCalls (mergeGetCallsWithBase (createGetCallsFunc (
718
716
& v1.Pod {
@@ -736,7 +734,7 @@ var _ = Describe("Collector", Ordered, func() {
736
734
Expect (err ).To (MatchError (expectedErr ))
737
735
})
738
736
739
- It ("should error if the Pod's owner reference is not a ReplicaSet" , func () {
737
+ It ("should error if the Pod's owner reference is not a ReplicaSet" , func (ctx SpecContext ) {
740
738
expectedErr := errors .New ("expected pod owner reference to be ReplicaSet, got Deployment" )
741
739
k8sClientReader .GetCalls (mergeGetCallsWithBase (createGetCallsFunc (
742
740
& v1.Pod {
@@ -757,7 +755,7 @@ var _ = Describe("Collector", Ordered, func() {
757
755
Expect (err ).To (MatchError (expectedErr ))
758
756
})
759
757
760
- It ("should error if the replica set's replicas is nil" , func () {
758
+ It ("should error if the replica set's replicas is nil" , func (ctx SpecContext ) {
761
759
expectedErr := errors .New ("replica set replicas was nil" )
762
760
k8sClientReader .GetCalls (mergeGetCallsWithBase (createGetCallsFunc (
763
761
& appsv1.ReplicaSet {
@@ -771,7 +769,7 @@ var _ = Describe("Collector", Ordered, func() {
771
769
Expect (err ).To (MatchError (expectedErr ))
772
770
})
773
771
774
- It ("should error if the kubernetes client errored when getting the ReplicaSet" , func () {
772
+ It ("should error if the kubernetes client errored when getting the ReplicaSet" , func (ctx SpecContext ) {
775
773
expectedErr := errors .New ("there was an error getting the ReplicaSet" )
776
774
k8sClientReader .GetCalls (mergeGetCallsWithBase (
777
775
func (_ context.Context , _ client.ObjectKey , object client.Object , _ ... client.GetOption ) error {
@@ -792,7 +790,7 @@ var _ = Describe("Collector", Ordered, func() {
792
790
Describe ("DeploymentID collector" , func () {
793
791
When ("collecting deploymentID" , func () {
794
792
When ("it encounters an error while collecting data" , func () {
795
- It ("should error if the replicaSet's owner reference is nil" , func () {
793
+ It ("should error if the replicaSet's owner reference is nil" , func (ctx SpecContext ) {
796
794
replicas := int32 (1 )
797
795
k8sClientReader .GetCalls (mergeGetCallsWithBase (createGetCallsFunc (
798
796
& appsv1.ReplicaSet {
@@ -807,7 +805,7 @@ var _ = Describe("Collector", Ordered, func() {
807
805
Expect (err ).To (MatchError (expectedErr ))
808
806
})
809
807
810
- It ("should error if the replicaSet's owner reference kind is not deployment" , func () {
808
+ It ("should error if the replicaSet's owner reference kind is not deployment" , func (ctx SpecContext ) {
811
809
replicas := int32 (1 )
812
810
k8sClientReader .GetCalls (mergeGetCallsWithBase (createGetCallsFunc (
813
811
& appsv1.ReplicaSet {
@@ -829,7 +827,7 @@ var _ = Describe("Collector", Ordered, func() {
829
827
_ , err := dataCollector .Collect (ctx )
830
828
Expect (err ).To (MatchError (expectedErr ))
831
829
})
832
- It ("should error if the replicaSet's owner reference has empty UID" , func () {
830
+ It ("should error if the replicaSet's owner reference has empty UID" , func (ctx SpecContext ) {
833
831
replicas := int32 (1 )
834
832
k8sClientReader .GetCalls (mergeGetCallsWithBase (createGetCallsFunc (
835
833
& appsv1.ReplicaSet {
0 commit comments