11package ps
22
33import (
4- "context"
54 "strings"
65 "testing"
76
@@ -53,7 +52,7 @@ func TestReconcileMySQLAutoConfig(t *testing.T) {
5352 t .Helper ()
5453 cm := new (corev1.ConfigMap )
5554 nn := types.NamespacedName {Name : mysql .AutoConfigMapName (cr ), Namespace : cr .Namespace }
56- require .NoError (t , r .Client . Get (context . Background (), nn , cm ))
55+ require .NoError (t , r .Get (t . Context (), nn , cm ))
5756 return cm .Data [mysql .CustomConfigKey ]
5857 }
5958
@@ -102,7 +101,7 @@ func TestReconcileMySQLAutoConfig(t *testing.T) {
102101 cr := newCR (tt .enabled , tt .version )
103102 r := newReconciler (t , cr )
104103
105- require .NoError (t , r .reconcileMySQLAutoConfig (context . Background (), cr ))
104+ require .NoError (t , r .reconcileMySQLAutoConfig (t . Context (), cr ))
106105
107106 config := autoConfig (t , r , cr )
108107 assert .Contains (t , config , "innodb_buffer_pool_size=" , "both paths size the buffer pool" )
@@ -111,12 +110,8 @@ func TestReconcileMySQLAutoConfig(t *testing.T) {
111110 })
112111 }
113112
114- // The redo log the calculator sizes from memory is preallocated on the data
115- // volume at startup, and a node joining by clone needs free space for the
116- // donor's estimate on top of its own. The reconcile trims it to fit rather
117- // than leaving a cluster that cannot bootstrap.
118113 t .Run ("a data volume smaller than the calculated redo log trims it" , func (t * testing.T ) {
119- ctx := context . Background ()
114+ ctx := t . Context ()
120115 cr := newCR (true , "8.4" )
121116 withDataVolume (cr , "2Gi" )
122117 r := newReconciler (t , cr )
@@ -126,10 +121,8 @@ func TestReconcileMySQLAutoConfig(t *testing.T) {
126121 assert .Contains (t , autoConfig (t , r , cr ), "innodb_redo_log_capacity=536870912" )
127122 })
128123
129- // Trimming stops at the smallest redo log MySQL accepts, so a volume below
130- // that leaves nothing to write: the reconcile fails until the user resizes.
131124 t .Run ("a data volume too small for the minimum redo log fails the reconcile" , func (t * testing.T ) {
132- ctx := context . Background ()
125+ ctx := t . Context ()
133126 cr := newCR (true , "8.4" )
134127 withDataVolume (cr , "16Mi" )
135128 r := newReconciler (t , cr )
@@ -143,14 +136,12 @@ func TestReconcileMySQLAutoConfig(t *testing.T) {
143136 // No autotune fallback was written in its place.
144137 cm := new (corev1.ConfigMap )
145138 nn := types.NamespacedName {Name : mysql .AutoConfigMapName (cr ), Namespace : cr .Namespace }
146- assert .True (t , k8serrors .IsNotFound (r .Client . Get (ctx , nn , cm )),
139+ assert .True (t , k8serrors .IsNotFound (r .Get (ctx , nn , cm )),
147140 "no ConfigMap should be written when the calculated configuration does not fit" )
148141 })
149142
150- // The ConfigMap is rebuilt from the spec on every pass, so a wrong version
151- // costs nothing more than the fallback it caused.
152143 t .Run ("correcting the version restores the calculated configuration" , func (t * testing.T ) {
153- ctx := context . Background ()
144+ ctx := t . Context ()
154145 cr := newCR (true , "5.7" )
155146 r := newReconciler (t , cr )
156147
@@ -163,7 +154,7 @@ func TestReconcileMySQLAutoConfig(t *testing.T) {
163154 })
164155
165156 t .Run ("correcting the version leaves no parameter of the wrong one behind" , func (t * testing.T ) {
166- ctx := context . Background ()
157+ ctx := t . Context ()
167158 // Removed in MySQL 8.4, still emitted for 8.0 — and emitted bare, so
168159 // mysqld would refuse to boot on it.
169160 const removedIn84 = "innodb_log_file_size="
0 commit comments