Skip to content

Commit

Permalink
bugfix: squash error, and cleanup code
Browse files Browse the repository at this point in the history
  • Loading branch information
bubbajoe committed Apr 30, 2024
1 parent 3989338 commit 08d7642
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 34 deletions.
4 changes: 3 additions & 1 deletion functional-tests/admin_tests/performance_test_prep.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,6 @@ curl -s --fail-with-body ${PROXY_URL}/svctest -H Host:dgate.dev

curl -s --fail-with-body ${PROXY_URL}/modtest -H Host:dgate.dev

curl -s ${PROXY_URL}/blank -H Host:dgate.dev
curl -s ${PROXY_URL}/blank -H Host:dgate.dev

echo "Performance Test Prep Done"
2 changes: 1 addition & 1 deletion internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ type (
}

DomainSpec struct {
*spec.Domain `koanf:",squash"`
spec.Domain `koanf:",squash"`
CertFile string `koanf:"cert_file"`
KeyFile string `koanf:"key_file"`
}
Expand Down
6 changes: 3 additions & 3 deletions internal/config/configtest/dgate_configs.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func NewTestDGateConfig_DomainAndNamespaces() *config.DGateConfig {
}
conf.ProxyConfig.InitResources.Domains = []config.DomainSpec{
{
Domain: &spec.Domain{
Domain: spec.Domain{
Name: "test-dm",
NamespaceName: "test",
Patterns: []string{"example.com"},
Expand All @@ -111,7 +111,7 @@ func NewTestDGateConfig_DomainAndNamespaces() *config.DGateConfig {
},
},
{
Domain: &spec.Domain{
Domain: spec.Domain{
Name: "test-dm2",
NamespaceName: "test2",
Patterns: []string{`*test.com`},
Expand All @@ -120,7 +120,7 @@ func NewTestDGateConfig_DomainAndNamespaces() *config.DGateConfig {
},
},
{
Domain: &spec.Domain{
Domain: spec.Domain{
Name: "test-dm3",
NamespaceName: "test3",
Patterns: []string{`/^(abc|cba).test.com$/`},
Expand Down
2 changes: 1 addition & 1 deletion internal/config/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func (resources *DGateResources) Validate() (int, error) {
if (dom.Cert == "") != (dom.Key == "") {
return 0, errors.New("domain cert (file) and key (file) must both be specified, or neither")
}
domains[key] = dom.Domain
domains[key] = &dom.Domain
}
numChanges += len(domains)

Expand Down
2 changes: 1 addition & 1 deletion internal/config/resources_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func TestValidate(t *testing.T) {
},
Domains: []DomainSpec{
{
Domain: &spec.Domain{
Domain: spec.Domain{
Name: "default",
NamespaceName: "default",
Tags: []string{"default"},
Expand Down
5 changes: 1 addition & 4 deletions internal/proxy/change_log.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,7 @@ func (ps *ProxyState) processChangeLog(
}
if store {
if err = ps.store.StoreChangeLog(cl); err != nil {
// TODO: Add config option to panic on persistent storage errors
// TODO: maybe revert change here
// add some in-memory queue for changes?
// add some retry mechanism?
// TODO: revert change here on error ??
ps.logger.Err(err).Msg("Error storing change log")
return
}
Expand Down
2 changes: 1 addition & 1 deletion internal/proxy/proxy_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ func (ps *ProxyState) initConfigResources(resources *config.DGateResources) erro
}
dom.Key = string(key)
}
cl := spec.NewChangeLog(dom.Domain, dom.NamespaceName, spec.AddDomainCommand)
cl := spec.NewChangeLog(&dom.Domain, dom.NamespaceName, spec.AddDomainCommand)
err := ps.processChangeLog(cl, false, false)
if err != nil {
return err
Expand Down
6 changes: 0 additions & 6 deletions internal/proxy/reverse_proxy/reverse_proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,6 @@ func testDGateProxyRewrite(
if params.newHost != "" && req.Host != params.newHost {
t.Errorf("FAIL: Expected Host %s, got %s", params.newHost, req.Host)
}
// if req.Header.Get("X-Testing") == "" {
// t.Errorf("FAIL: Expected X-Testing header, got empty")
// }
// if req.Header.Get("X-Testing-2") == "" {
// t.Errorf("FAIL: Expected X-Testing-2 header, got empty")
// }
if rewriteParams.xForwardedHeaders {
if req.Header.Get("X-Forwarded-For") == "" {
t.Errorf("FAIL: Expected X-Forwarded-For header, got empty")
Expand Down
26 changes: 13 additions & 13 deletions performance-tests/perf-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,25 @@ import { check } from 'k6';
const n = 10;
export let options = {
scenarios: {
// modtest: {
// executor: 'constant-vus',
// vus: n,
// duration: '20s',
// // same function as the scenario above, but with different env vars
// exec: 'dgatePath',
// env: { DGATE_PATH: '/modtest' },
// // startTime: '25s',
// gracefulStop: '5s',
// },
svctest: {
modtest: {
executor: 'constant-vus',
vus: n,
duration: '20s',
exec: 'dgatePath', // same function as the scenario above, but with different env vars
env: { DGATE_PATH: "/svctest" },
// same function as the scenario above, but with different env vars
exec: 'dgatePath',
env: { DGATE_PATH: '/modtest' },
// startTime: '25s',
gracefulStop: '5s',
},
// svctest: {
// executor: 'constant-vus',
// vus: n,
// duration: '20s',
// exec: 'dgatePath', // same function as the scenario above, but with different env vars
// env: { DGATE_PATH: "/svctest" },
// // startTime: '25s',
// gracefulStop: '5s',
// },
// blank: {
// executor: 'constant-vus',
// vus: n,
Expand Down
3 changes: 0 additions & 3 deletions pkg/storage/badger_logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ func (b *badgerLoggerAdapter) Debugf(format string, args ...any) {
}

func newBadgerLoggerAdapter(component string, logger zerolog.Logger) badger.Logger {
// logger := fsConfig.Logger.Hook(zerolog.HookFunc(func(e *zerolog.Event, level zerolog.Level, msg string) {
// e.Str("storage", "filestore::badger")
// }))
logger = logger.With().Str("component", component).Logger()
return &badgerLoggerAdapter{
logger: logger,
Expand Down

0 comments on commit 08d7642

Please sign in to comment.