Skip to content
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

Remove Config Backwards Compatibility: Enable GZIP #3125

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ type Configuration struct {
Client HTTPClient `mapstructure:"http_client"`
CacheClient HTTPClient `mapstructure:"http_client_cache"`
AdminPort int `mapstructure:"admin_port"`
EnableGzip bool `mapstructure:"enable_gzip"`
Compression Compression `mapstructure:"compression"`
// GarbageCollectorThreshold allocates virtual memory (in bytes) which is not used by PBS but
// serves as a hack to trigger the garbage collector only when the heap reaches at least this size.
Expand Down Expand Up @@ -1073,7 +1072,6 @@ func SetupViper(v *viper.Viper, filename string, bidderInfos BidderInfos) {
migrateConfigSpecialFeature1(v)
migrateConfigTCF2PurposeFlags(v)
migrateConfigDatabaseConnection(v)
migrateConfigCompression(v)

// These defaults must be set after the migrate functions because those functions look for the presence of these
// config fields and there isn't a way to detect presence of a config field using the viper package if a default
Expand Down Expand Up @@ -1114,8 +1112,6 @@ func SetupViper(v *viper.Viper, filename string, bidderInfos BidderInfos) {
v.SetDefault("gdpr.tcf2.special_feature1.vendor_exceptions", []openrtb_ext.BidderName{})
v.SetDefault("price_floors.enabled", false)

v.SetDefault("enable_gzip", false)

// Defaults for account_defaults.events.default_url
v.SetDefault("account_defaults.events.default_url", "https://PBS_HOST/event?t=##PBS-EVENTTYPE##&vtype=##PBS-VASTEVENT##&b=##PBS-BIDID##&f=i&a=##PBS-ACCOUNTID##&ts=##PBS-TIMESTAMP##&bidder=##PBS-BIDDER##&int=##PBS-INTEGRATION##&mt=##PBS-MEDIATYPE##&ch=##PBS-CHANNEL##&aid=##PBS-AUCTIONID##&l=##PBS-LINEID##")

Expand All @@ -1134,20 +1130,6 @@ func SetupViper(v *viper.Viper, filename string, bidderInfos BidderInfos) {
}
}

func migrateConfigCompression(v *viper.Viper) {
oldField := "enable_gzip"
newField := "compression.response.enable_gzip"
if v.IsSet(oldField) {
oldConfig := v.GetBool(oldField)
if v.IsSet(newField) {
glog.Warningf("using %s and ignoring deprecated %s", newField, oldField)
} else {
glog.Warningf("%s is deprecated and should be changed to %s", oldField, newField)
v.Set(newField, oldConfig)
}
}
}

func migrateConfigPurposeOneTreatment(v *viper.Viper) {
if oldConfig, ok := v.Get("gdpr.tcf2.purpose_one_treatement").(map[string]interface{}); ok {
if v.IsSet("gdpr.tcf2.purpose_one_treatment") {
Expand Down
71 changes: 0 additions & 71 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ func TestDefaults(t *testing.T) {
cmpBools(t, "price_floors.enabled", false, cfg.PriceFloors.Enabled)

// Assert compression related defaults
cmpBools(t, "enable_gzip", false, cfg.EnableGzip)
cmpBools(t, "compression.request.enable_gzip", false, cfg.Compression.Request.GZIP)
cmpBools(t, "compression.response.enable_gzip", false, cfg.Compression.Response.GZIP)

Expand Down Expand Up @@ -386,7 +385,6 @@ external_url: http://prebid-server.prebid.org/
host: prebid-server.prebid.org
port: 1234
admin_port: 5678
enable_gzip: false
compression:
request:
enable_gzip: true
Expand Down Expand Up @@ -589,7 +587,6 @@ func TestFullConfig(t *testing.T) {
cmpInts(t, "account_defaults.privacy.ipv4.anon_keep_bits", 20, cfg.AccountDefaults.Privacy.IPv4Config.AnonKeepBits)

// Assert compression related defaults
cmpBools(t, "enable_gzip", false, cfg.EnableGzip)
cmpBools(t, "compression.request.enable_gzip", true, cfg.Compression.Request.GZIP)
cmpBools(t, "compression.response.enable_gzip", false, cfg.Compression.Response.GZIP)

Expand Down Expand Up @@ -2570,74 +2567,6 @@ func TestMigrateConfigDatabaseQueryParams(t *testing.T) {
assert.Equal(t, want_queries.poll_for_updates_amp_query, v.GetString("stored_responses.database.poll_for_updates.amp_query"))
}

func TestMigrateConfigCompression(t *testing.T) {
testCases := []struct {
desc string
config []byte
wantEnableGZIP bool
wantReqGZIPEnabled bool
wantRespGZIPEnabled bool
}{

{
desc: "New config and old config not set",
config: []byte{},
wantEnableGZIP: false,
wantReqGZIPEnabled: false,
wantRespGZIPEnabled: false,
},
{
desc: "Old config set, new config not set",
config: []byte(`
enable_gzip: true
`),
wantEnableGZIP: true,
wantRespGZIPEnabled: true,
wantReqGZIPEnabled: false,
},
{
desc: "Old config not set, new config set",
config: []byte(`
compression:
response:
enable_gzip: true
request:
enable_gzip: false
`),
wantEnableGZIP: false,
wantRespGZIPEnabled: true,
wantReqGZIPEnabled: false,
},
{
desc: "Old config set and new config set",
config: []byte(`
enable_gzip: true
compression:
response:
enable_gzip: false
request:
enable_gzip: true
`),
wantEnableGZIP: true,
wantRespGZIPEnabled: false,
wantReqGZIPEnabled: true,
},
}

for _, test := range testCases {
v := viper.New()
v.SetConfigType("yaml")
err := v.ReadConfig(bytes.NewBuffer(test.config))
assert.NoError(t, err)

migrateConfigCompression(v)

assert.Equal(t, test.wantEnableGZIP, v.GetBool("enable_gzip"), test.desc)
assert.Equal(t, test.wantReqGZIPEnabled, v.GetBool("compression.request.enable_gzip"), test.desc)
assert.Equal(t, test.wantRespGZIPEnabled, v.GetBool("compression.response.enable_gzip"), test.desc)
}
}

func TestIsConfigInfoPresent(t *testing.T) {
configPrefix1Field2Only := []byte(`
prefix1:
Expand Down
1 change: 0 additions & 1 deletion server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ func TestListen(t *testing.T) {
Port: 8000,
UnixSocketEnable: false,
UnixSocketName: "prebid_socket",
EnableGzip: false,
}
)

Expand Down
Loading