@@ -55,29 +55,29 @@ func TestRegistry_EnableHAAirgap(t *testing.T) {
55
55
kclient := util .KubeClient (t , kubeconfig )
56
56
hcli := util .HelmClient (t , kubeconfig )
57
57
58
- t .Log ( " installing openebs" )
58
+ t .Logf ( "%s installing openebs", formattedTime () )
59
59
addon := & openebs.OpenEBS {
60
60
ProxyRegistryDomain : "proxy.replicated.com" ,
61
61
}
62
62
if err := addon .Install (ctx , kcli , hcli , nil , nil ); err != nil {
63
63
t .Fatalf ("failed to install openebs: %v" , err )
64
64
}
65
65
66
- t .Log ( " waiting for storageclass" )
66
+ t .Logf ( "%s waiting for storageclass", formattedTime () )
67
67
util .WaitForStorageClass (t , kubeconfig , "openebs-hostpath" , 30 * time .Second )
68
68
69
- t .Log ( " installing registry" )
69
+ t .Logf ( "%s installing registry", formattedTime () )
70
70
registryAddon := & registry.Registry {
71
71
ServiceCIDR : "10.96.0.0/12" ,
72
72
ProxyRegistryDomain : "proxy.replicated.com" ,
73
73
IsHA : false ,
74
74
}
75
75
require .NoError (t , registryAddon .Install (ctx , kcli , hcli , nil , nil ))
76
76
77
- t .Log ( " creating hostport service" )
77
+ t .Logf ( "%s creating hostport service", formattedTime () )
78
78
registryAddr := createHostPortService (t , clusterName , kubeconfig )
79
79
80
- t .Log ( " installing admin console" )
80
+ t .Logf ( "%s installing admin console", formattedTime () )
81
81
adminConsoleAddon := & adminconsole.AdminConsole {
82
82
IsAirgap : true ,
83
83
ServiceCIDR : "10.96.0.0/12" ,
@@ -86,13 +86,13 @@ func TestRegistry_EnableHAAirgap(t *testing.T) {
86
86
}
87
87
require .NoError (t , adminConsoleAddon .Install (ctx , kcli , hcli , nil , nil ))
88
88
89
- t .Log ( " pushing image to registry" )
89
+ t .Logf ( "%s pushing image to registry", formattedTime () )
90
90
copyImageToRegistry (t , registryAddr , "docker.io/library/busybox:1.36.1" )
91
91
92
- t .Log ( " running pod to validate image pull" )
92
+ t .Logf ( "%s running pod to validate image pull", formattedTime () )
93
93
runPodAndValidateImagePull (t , kubeconfig , "pod-1" , "pod1.yaml" )
94
94
95
- t .Log ( " creating installation with HA disabled" )
95
+ t .Logf ( "%s creating installation with HA disabled", formattedTime () )
96
96
util .EnsureInstallation (t , kcli , ecv1beta1.InstallationSpec {
97
97
HighAvailability : false ,
98
98
})
@@ -119,21 +119,21 @@ func TestRegistry_EnableHAAirgap(t *testing.T) {
119
119
require .NoError (t , err )
120
120
require .True (t , canEnable , "should be able to enable HA: %s" , reason )
121
121
122
- t .Log ( " enabling HA" )
122
+ t .Logf ( "%s enabling HA", formattedTime () )
123
123
loading := newTestingSpinner (t )
124
124
func () {
125
125
defer loading .Close ()
126
126
err = addons .EnableHA (ctx , kcli , kclient , hcli , true , "10.96.0.0/12" , nil , cfgSpec , loading )
127
127
require .NoError (t , err )
128
128
}()
129
129
130
- t .Log ( " pushing a second image to registry" )
130
+ t .Logf ( "%s pushing a second image to registry", formattedTime () )
131
131
copyImageToRegistry (t , registryAddr , "docker.io/library/busybox:1.37.0" )
132
132
133
- t .Log ( " running pod to validate image pull" )
133
+ t .Logf ( "%s running pod to validate image pull", formattedTime () )
134
134
runPodAndValidateImagePull (t , kubeconfig , "pod-1" , "pod1.yaml" )
135
135
136
- t .Log ( " running second pod to validate image pull" )
136
+ t .Logf ( "%s running second pod to validate image pull", formattedTime () )
137
137
runPodAndValidateImagePull (t , kubeconfig , "pod-2" , "pod2.yaml" )
138
138
}
139
139
@@ -175,7 +175,7 @@ func enableHAAndCancelContextOnMessage(
175
175
defer pr .Close ()
176
176
got := waitForMatchingMessage (t , pr , re )
177
177
if got {
178
- t .Log ( " cancelling context" )
178
+ t .Logf ( "%s cancelling context", formattedTime () )
179
179
cancel ()
180
180
}
181
181
io .Copy (io .Discard , pr ) // discard the rest of the output
@@ -184,19 +184,18 @@ func enableHAAndCancelContextOnMessage(
184
184
loading := newTestingSpinner (t )
185
185
defer loading .Close ()
186
186
187
- t .Log ( " enabling HA and cancelling context on message" )
187
+ t .Logf ( "%s enabling HA and cancelling context on message", formattedTime () )
188
188
err = addons .EnableHA (ctx , kcli , kclient , hcli , true , "10.96.0.0/12" , nil , cfgSpec , loading )
189
189
require .ErrorIs (t , err , context .Canceled , "expected context to be cancelled" )
190
- t .Logf ("cancelled context and got error: %v" , err )
190
+ t .Logf ("%s cancelled context and got error: %v" , formattedTime () , err )
191
191
}
192
192
193
193
func waitForMatchingMessage (t * testing.T , r io.Reader , re * regexp.Regexp ) bool {
194
194
scanner := bufio .NewScanner (r )
195
195
for scanner .Scan () {
196
196
b := scanner .Bytes ()
197
- // t.Logf("got message: %s", string(b))
198
197
if re .Match (b ) {
199
- t .Logf ("got matching message: %s" , string (b ))
198
+ t .Logf ("%s got matching message: %s" , formattedTime () , string (b ))
200
199
return true
201
200
}
202
201
}
@@ -212,7 +211,7 @@ func buildOperatorImage(t *testing.T) string {
212
211
operatorDir := filepath .Join (workspaceRoot , "operator" )
213
212
214
213
if os .Getenv ("SKIP_OPERATOR_IMAGE_BUILD" ) == "" {
215
- t .Log ( " building operator image" )
214
+ t .Logf ( "%s building operator image", formattedTime () )
216
215
217
216
cmd := exec .CommandContext (
218
217
t .Context (), "make" , "-C" , operatorDir , "build-ttl.sh" , "USE_CHAINGUARD=0" ,
@@ -253,7 +252,7 @@ func newTestingSpinner(t *testing.T) *spinner.MessageWriter {
253
252
spinner .WithWriter (func (format string , args ... any ) (int , error ) {
254
253
// discard the output
255
254
out := fmt .Sprintf (format , args ... )
256
- t .Log ( " [spinner]" , strings .TrimSpace (out ))
255
+ t .Logf ( "%s [spinner] %s" , formattedTime () , strings .TrimSpace (out ))
257
256
return len (out ), nil
258
257
}),
259
258
spinner .WithTTY (false ),
@@ -272,3 +271,7 @@ func (h *logrusHook) Fire(entry *logrus.Entry) error {
272
271
h .writer .Write ([]byte (entry .Message + "\n " ))
273
272
return nil
274
273
}
274
+
275
+ func formattedTime () string {
276
+ return time .Now ().Format ("2006-01-02 15:04:05" )
277
+ }
0 commit comments