@@ -31,6 +31,9 @@ import (
31
31
"testing"
32
32
"time"
33
33
34
+ "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/util/slice"
35
+ "k8s.io/klog/v2"
36
+
34
37
"github.com/GoogleCloudPlatform/k8s-config-connector/config/tests/samples/create"
35
38
opcorev1beta1 "github.com/GoogleCloudPlatform/k8s-config-connector/operator/pkg/apis/core/v1beta1"
36
39
"github.com/GoogleCloudPlatform/k8s-config-connector/pkg/test"
@@ -146,8 +149,21 @@ func testFixturesInSeries(ctx context.Context, t *testing.T, testPause bool, can
146
149
fixtures := resourcefixture .Load (t )
147
150
for _ , fixture := range fixtures {
148
151
fixture := fixture
152
+ group := fixture .GVK .Group
153
+ if s := os .Getenv ("SKIP_TEST_APIGROUP" ); s != "" {
154
+ skippedGroups := strings .Split (s , "," )
155
+ if slice .StringSliceContains (skippedGroups , group ) {
156
+ klog .Infof ("skipping test %s because group %q matched entries in SKIP_TEST_APIGROUP=%s" , fixture .Name , group , s )
157
+ continue
158
+ }
159
+ }
160
+ if s := os .Getenv ("ONLY_TEST_APIGROUP" ); s != "" {
161
+ if group != s {
162
+ klog .Infof ("skipping test %s because group %q did not match ONLY_TEST_APIGROUP=%s" , fixture .Name , group , s )
163
+ continue
164
+ }
165
+ }
149
166
// TODO(b/259496928): Randomize the resource names for parallel execution when/if needed.
150
-
151
167
t .Run (fixture .Name , func (t * testing.T ) {
152
168
ctx := addTestTimeout (ctx , t , subtestTimeout )
153
169
@@ -192,20 +208,13 @@ func runScenario(ctx context.Context, t *testing.T, testPause bool, fixture reso
192
208
193
209
// Quickly load the fixture with a dummy project, just to see if we should skip it
194
210
{
195
- primaryObject , opt := loadFixture (testgcp.GCPProject {ProjectID : "test-skip" , ProjectNumber : 123456789 }, uniqueID )
211
+ _ , opt := loadFixture (testgcp.GCPProject {ProjectID : "test-skip" , ProjectNumber : 123456789 }, uniqueID )
196
212
create .MaybeSkip (t , fixture .Name , opt .Create )
197
213
if testPause && containsCCOrCCC (opt .Create ) {
198
214
t .Skipf ("test case %q contains ConfigConnector or ConfigConnectorContext object(s): " +
199
215
"pause test should not run against test cases already contain ConfigConnector " +
200
216
"or ConfigConnectorContext objects" , fixture .Name )
201
217
}
202
-
203
- if s := os .Getenv ("ONLY_TEST_APIGROUP" ); s != "" {
204
- group := primaryObject .GroupVersionKind ().Group
205
- if group != s {
206
- t .Skipf ("skipping test because group %q did not match ONLY_TEST_APIGROUP=%s" , group , s )
207
- }
208
- }
209
218
}
210
219
211
220
// Create test harness
0 commit comments