-
Notifications
You must be signed in to change notification settings - Fork 1.1k
[testing] Remove dnsmock, lifecycle reorg, NewTest api #6875
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
… lifecycle into test.go
A JIRA Issue ID is missing from your branch name, PR title and PR description! 🦄 Your branch: testing/refactor-StartTest-scaffold Your PR title: [testing] lifecycle reorg, NewTest api Your PR description: null If this is your first time contributing to this repository - welcome! Please refer to jira-lint to get started. Without the JIRA Issue ID in your branch name you would lose out on automatic updates to JIRA via SCM; some GitHub status checks might fail. Valid sample branch names:‣ feature/shiny-new-feature--mojo-10' |
API Changes --- prev.txt 2025-02-16 16:43:23.356648986 +0000
+++ current.txt 2025-02-16 16:43:19.262599930 +0000
@@ -8102,10 +8102,6 @@
ErrSyncResourceNotKnown = errors.New("unknown resource to sync")
)
var (
- EnableTestDNSMock = false
- MockHandle *test.DnsMockHandle
-)
-var (
VERSION = build.Version
Commit = build.Commit
)
@@ -8178,6 +8174,7 @@
func NewPythonDispatcher(conf config.Config) (dispatcher coprocess.Dispatcher, err error)
NewPythonDispatcher wraps all the actions needed for this CP.
+func NewTestConfigOption(conf TestConfig) func(*Test)
func NormalisePath(a *analytics.AnalyticsRecord, globalConfig *config.Config)
func ParseRSAPublicKey(data []byte) (interface{}, error)
func ProtoMap(inputMap map[string][]string) map[string]string
@@ -10817,11 +10814,13 @@
Gw *Gateway `json:"-"`
HttpHandler *http.Server
TestServerRouter *mux.Router
- MockHandle *test.DnsMockHandle
+ Parent testing.TB
// Has unexported fields.
}
+func NewTest(tb testing.TB, genConf func(*config.Config), opts ...TestOption) *Test
+
func StartTest(genConf func(globalConf *config.Config), testConfig ...TestConfig) *Test
func (s *Test) AddDynamicHandler(path string, handlerFunc http.HandlerFunc)
@@ -10829,6 +10828,7 @@
func (s *Test) BundleHandleFunc(w http.ResponseWriter, r *http.Request)
func (s *Test) Close()
+ Close is the shutdown lifecycle for a gateway integration test w/ storage.
func (s *Test) CreatePolicy(pGen ...func(p *user.Policy)) string
@@ -10872,8 +10872,7 @@
Delay time.Duration
HotReload bool
- CoprocessConfig config.CoProcessConfig
- EnableTestDNSMock bool
+ CoprocessConfig config.CoProcessConfig
// Has unexported fields.
}
@@ -10887,6 +10886,8 @@
Form map[string]string
}
+type TestOption func(*Test)
+
type TraceMiddleware struct {
TykMiddleware
} |
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
|
PR Type
Enhancement, Tests
Description
Removed
dnsmock
dependency and related code from tests.Introduced
NewTest
API with functional options for test configuration.Refactored lifecycle management into a new
test.go
file.Simplified and streamlined test setup and teardown processes.
Changes walkthrough 📝
reverse_proxy_test.go
Remove `dnsmock` and update test setup
gateway/reverse_proxy_test.go
dnsmock
usage and related setup/teardown calls.flakySetupTestReverseProxyDnsCache
.test.go
Introduce `Test` struct and `NewTest` API
gateway/test.go
Test
struct for managing test lifecycle.NewTest
API with functional options for configuration.start
andClose
.testutil.go
Remove `dnsmock` and refactor test utilities
gateway/testutil.go
dnsmock
initialization and related configuration.Test
struct and lifecycle methods.StartTest
and removed unused fields.