Skip to content

Commit dae2e7f

Browse files
committed
[test] fix git context tests
We use UBP now, there is no more unleashed. Also, remove the "ff" feature flag code (which was for PVC). It was mutating the username, resulting in Code 460 errors on createWorkspace
1 parent 27325fd commit dae2e7f

File tree

1 file changed

+53
-78
lines changed

1 file changed

+53
-78
lines changed

test/tests/workspace/contexts_test.go

Lines changed: 53 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -111,102 +111,77 @@ func runContextTests(t *testing.T, tests []ContextTest) {
111111
f := features.New("context").
112112
WithLabel("component", "server").
113113
Assess("should run context tests", func(ctx context.Context, t *testing.T, cfg *envconf.Config) context.Context {
114-
ffs := []struct {
115-
Name string
116-
FF string
117-
}{
118-
{Name: "classic"},
119-
// {Name: "pvc", FF: "persistent_volume_claim"},
120-
}
121114

122-
for _, ff := range ffs {
123-
func() {
124-
sctx, scancel := context.WithTimeout(context.Background(), 5*time.Minute)
125-
defer scancel()
115+
sctx, scancel := context.WithTimeout(context.Background(), time.Duration(5*len(tests))*time.Minute)
116+
defer scancel()
126117

127-
api := integration.NewComponentAPI(sctx, cfg.Namespace(), kubeconfig, cfg.Client())
128-
defer api.Done(t)
118+
api := integration.NewComponentAPI(sctx, cfg.Namespace(), kubeconfig, cfg.Client())
119+
defer api.Done(t)
129120

130-
username := username + ff.Name
131-
userId, err := api.CreateUser(username, userToken)
132-
if err != nil {
133-
t.Fatal(err)
121+
for _, test := range tests {
122+
test := test
123+
t.Run(test.ContextURL, func(t *testing.T) {
124+
report.SetupReport(t, report.FeatureContentInit, fmt.Sprintf("Test to open %v", test.ContextURL))
125+
if test.Skip {
126+
t.SkipNow()
134127
}
135128

136-
if err := api.UpdateUserFeatureFlag(userId, ff.FF); err != nil {
137-
t.Fatal(err)
138-
}
139-
}()
140-
}
129+
t.Parallel()
141130

142-
for _, ff := range ffs {
143-
for _, test := range tests {
144-
test := test
145-
t.Run(test.ContextURL+"_"+ff.Name, func(t *testing.T) {
146-
report.SetupReport(t, report.FeatureContentInit, fmt.Sprintf("Test to open %v", test.ContextURL))
147-
if test.Skip {
148-
t.SkipNow()
149-
}
131+
ctx, cancel := context.WithTimeout(context.Background(), time.Duration(5*len(tests))*time.Minute)
132+
defer cancel()
150133

151-
t.Parallel()
134+
api := integration.NewComponentAPI(ctx, cfg.Namespace(), kubeconfig, cfg.Client())
135+
defer api.Done(t)
152136

153-
username := username + ff.Name
137+
nfo, stopWs, err := integration.LaunchWorkspaceFromContextURL(t, ctx, test.ContextURL, username, api)
138+
if err != nil {
139+
t.Fatal(err)
140+
}
154141

155-
ctx, cancel := context.WithTimeout(context.Background(), time.Duration(5*len(tests)*len(ffs))*time.Minute)
156-
defer cancel()
142+
t.Cleanup(func() {
143+
sctx, scancel := context.WithTimeout(context.Background(), 10*time.Minute)
144+
defer scancel()
157145

158-
api := integration.NewComponentAPI(ctx, cfg.Namespace(), kubeconfig, cfg.Client())
159-
defer api.Done(t)
146+
sapi := integration.NewComponentAPI(sctx, cfg.Namespace(), kubeconfig, cfg.Client())
147+
defer sapi.Done(t)
160148

161-
nfo, stopWs, err := integration.LaunchWorkspaceFromContextURL(t, ctx, test.ContextURL, username, api)
149+
_, err := stopWs(true, sapi)
162150
if err != nil {
163151
t.Fatal(err)
164152
}
153+
})
165154

166-
t.Cleanup(func() {
167-
sctx, scancel := context.WithTimeout(context.Background(), 10*time.Minute)
168-
defer scancel()
169-
170-
sapi := integration.NewComponentAPI(sctx, cfg.Namespace(), kubeconfig, cfg.Client())
171-
defer sapi.Done(t)
172-
173-
_, err := stopWs(true, sapi)
174-
if err != nil {
175-
t.Fatal(err)
176-
}
177-
})
178-
179-
rsa, closer, err := integration.Instrument(integration.ComponentWorkspace, "workspace", cfg.Namespace(), kubeconfig, cfg.Client(), integration.WithInstanceID(nfo.LatestInstance.ID))
180-
if err != nil {
181-
t.Fatal(err)
182-
}
183-
defer rsa.Close()
184-
integration.DeferCloser(t, closer)
155+
rsa, closer, err := integration.Instrument(integration.ComponentWorkspace, "workspace", cfg.Namespace(), kubeconfig, cfg.Client(), integration.WithInstanceID(nfo.LatestInstance.ID))
156+
if err != nil {
157+
t.Fatal(err)
158+
}
159+
defer rsa.Close()
160+
integration.DeferCloser(t, closer)
185161

186-
if test.ExpectedBranch == "" && test.ExpectedBranchFunc == nil {
187-
return
188-
}
162+
if test.ExpectedBranch == "" && test.ExpectedBranchFunc == nil {
163+
return
164+
}
189165

190-
// get actual from workspace
191-
git := integration.Git(rsa)
192-
err = git.ConfigSafeDirectory()
193-
if err != nil {
194-
t.Fatal(err)
195-
}
196-
actBranch, err := git.GetBranch(test.WorkspaceRoot, test.IgnoreError)
197-
if err != nil {
198-
t.Fatal(err)
199-
}
166+
// get actual from workspace
167+
git := integration.Git(rsa)
168+
err = git.ConfigSafeDirectory()
169+
if err != nil {
170+
t.Fatal(err)
171+
}
172+
actBranch, err := git.GetBranch(test.WorkspaceRoot, test.IgnoreError)
173+
if err != nil {
174+
t.Fatal(err)
175+
}
200176

201-
expectedBranch := test.ExpectedBranch
202-
if test.ExpectedBranchFunc != nil {
203-
expectedBranch = test.ExpectedBranchFunc(username)
204-
}
205-
if actBranch != expectedBranch {
206-
t.Fatalf("expected branch '%s', got '%s'!", expectedBranch, actBranch)
207-
}
208-
})
209-
}
177+
expectedBranch := test.ExpectedBranch
178+
if test.ExpectedBranchFunc != nil {
179+
expectedBranch = test.ExpectedBranchFunc(username)
180+
}
181+
if actBranch != expectedBranch {
182+
t.Fatalf("expected branch '%s', got '%s'!", expectedBranch, actBranch)
183+
}
184+
})
210185
}
211186
return ctx
212187
}).

0 commit comments

Comments
 (0)