@@ -21,6 +21,7 @@ import (
2121
2222 "github.com/cscetbon/casskop/controllers/common"
2323 "github.com/cscetbon/casskop/pkg/k8s"
24+ "github.com/jarcoal/httpmock"
2425 "k8s.io/apimachinery/pkg/runtime"
2526 "k8s.io/client-go/kubernetes/scheme"
2627 "sigs.k8s.io/controller-runtime/pkg/client/fake"
@@ -375,6 +376,10 @@ func assertRackStatus(assert *assert.Assertions, cc *api.CassandraCluster, dcRac
375376
376377func TestCassandraClusterReconciler (t * testing.T ) {
377378
379+ // tests speed-up
380+ httpmock .Activate ()
381+ defer httpmock .DeactivateAndReset ()
382+
378383 // Mock request to simulate Reconcile() being called on an event for a
379384 // watched resource .
380385 rcc , req := helperCreateCassandraCluster (context .TODO (), t , "cassandracluster-2DC.yaml" )
@@ -393,6 +398,14 @@ func TestCassandraClusterReconciler(t *testing.T) {
393398
394399func TestCassandraClusterReconcilerMultiNodePerRack (t * testing.T ) {
395400
401+ // override delay wait to speed up tests
402+ overrideDelayWaitWithNoDelay ()
403+ defer restoreDefaultDelayWait ()
404+
405+ // tests speed-up
406+ httpmock .Activate ()
407+ defer httpmock .DeactivateAndReset ()
408+
396409 // Mock request to simulate Reconcile() being called on an event for a
397410 // watched resource .
398411 rcc , req := helperCreateCassandraCluster (context .TODO (), t , "cassandracluster-2DC-2racksEach-2nodesPerRack.yaml" )
@@ -411,6 +424,11 @@ func TestCassandraClusterReconcilerMultiNodePerRack(t *testing.T) {
411424
412425// test that we detect an addition of a configmap
413426func TestUpdateStatusIfconfigMapHasChangedWithNoConfigMap (t * testing.T ) {
427+
428+ // tests speed-up
429+ httpmock .Activate ()
430+ defer httpmock .DeactivateAndReset ()
431+
414432 // Mock request to simulate Reconcile() being called on an event for a
415433 // watched resource .
416434 rcc , req := helperCreateCassandraCluster (context .TODO (), t , "cassandracluster-2DC.yaml" )
@@ -464,6 +482,11 @@ func TestUpdateStatusIfconfigMapHasChangedWithNoConfigMap(t *testing.T) {
464482
465483// test that we detect a change in a configmap
466484func TestUpdateStatusIfconfigMapHasChangedWithConfigMap (t * testing.T ) {
485+
486+ // tests speed-up
487+ httpmock .Activate ()
488+ defer httpmock .DeactivateAndReset ()
489+
467490 // Mock request to simulate Reconcile() being called on an event for a
468491 // watched resource .
469492 rcc , req := helperCreateCassandraCluster (context .TODO (), t , "cassandracluster-2DC-configmap.yaml" )
@@ -535,6 +558,11 @@ func TestUpdateStatusIfconfigMapHasChangedWithConfigMap(t *testing.T) {
535558
536559// test that we detect a change in a the docker image
537560func TestUpdateStatusIfDockerImageHasChanged (t * testing.T ) {
561+
562+ // tests speed-up
563+ httpmock .Activate ()
564+ defer httpmock .DeactivateAndReset ()
565+
538566 // Mock request to simulate Reconcile() being called on an event for a
539567 // watched resource .
540568 rcc , req := helperCreateCassandraCluster (context .TODO (), t , "cassandracluster-2DC-configmap.yaml" )
@@ -611,8 +639,12 @@ func overrideDelayWaitWithNoDelay() {
611639 delayWait = func () time.Duration {
612640 return 0
613641 }
642+ retryInterval = func () time.Duration {
643+ return time .Millisecond
644+ }
614645}
615646
616647func restoreDefaultDelayWait () {
617648 delayWait = defaultDelayWait
649+ retryInterval = defaultRetryInterval
618650}
0 commit comments