Skip to content

Commit

Permalink
Remove hook, Run ahead of everything else
Browse files Browse the repository at this point in the history
  • Loading branch information
adreed-msft committed Oct 16, 2024
1 parent 06c07fd commit 295237c
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 28 deletions.
28 changes: 24 additions & 4 deletions e2etest/newe2e_suite_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ import (
)

type SuiteManager struct {
testingT *testing.T
Suites map[string]any
testingT *testing.T
Suites map[string]any
EarlyRunSuites map[string]any
}

var suiteManager = &SuiteManager{Suites: make(map[string]any)}
Expand All @@ -19,14 +20,25 @@ func (sm *SuiteManager) RegisterSuite(Suite any) {
sm.Suites[suiteName] = Suite
}

// Early runs do not run in parallel, and run before anything else.
func (sm *SuiteManager) RegisterEarlyRunSuite(Suite any) {
suiteName := reflect.ValueOf(Suite).Elem().Type().Name()

sm.EarlyRunSuites[suiteName] = Suite
}

func (sm *SuiteManager) RunSuites(t *testing.T) {
defer func() {
NewFrameworkAsserter(t).AssertNow("Suite runner panicked (fatal)", IsNil{}, recover())
}()

sm.testingT = t

for sName, v := range sm.Suites {
tgt := sm.EarlyRunSuites
early := true
runAllSuites:

for sName, v := range tgt {
sVal := reflect.ValueOf(v)
sTyp := reflect.TypeOf(v)
mCount := sVal.NumMethod()
Expand Down Expand Up @@ -59,7 +71,9 @@ func (sm *SuiteManager) RunSuites(t *testing.T) {
}

t.Run(sName, func(t *testing.T) {
t.Parallel() // todo: env var
if early { // Early runners must run now.
t.Parallel() // todo: env var
}

if setupIdx != -1 {
// todo: call setup with suite manager
Expand Down Expand Up @@ -102,4 +116,10 @@ func (sm *SuiteManager) RunSuites(t *testing.T) {
}
})
}

if early { // Jump back and run the remaining suites.
early = false
tgt = sm.Suites
goto runAllSuites
}
}
22 changes: 0 additions & 22 deletions e2etest/newe2e_workload_identity_hook.go

This file was deleted.

1 change: 0 additions & 1 deletion e2etest/zt_aanewe2e_testmain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
//}

var FrameworkHooks = []TestFrameworkHook{
{HookName: "Workload Identity Setup", SetupHook: WorkloadIdentitySetup},
{HookName: "Config", SetupHook: LoadConfigHook},
{HookName: "OAuth Cache", SetupHook: SetupOAuthCache},
{HookName: "ARM Client", SetupHook: SetupArmClient, TeardownHook: TeardownArmClient},
Expand Down
2 changes: 1 addition & 1 deletion e2etest/zt_newe2e_workload_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
)

func init() {
suiteManager.RegisterSuite(&WorkloadIdentitySuite{})
suiteManager.RegisterEarlyRunSuite(&WorkloadIdentitySuite{})
}

type WorkloadIdentitySuite struct{}
Expand Down

0 comments on commit 295237c

Please sign in to comment.