Skip to content

Commit

Permalink
Remove Config Backwards Compatibility: Enable GZIP (#3125)
Browse files Browse the repository at this point in the history
  • Loading branch information
bsardo authored Sep 27, 2023
1 parent 0c8f79b commit fc36944
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 90 deletions.
18 changes: 0 additions & 18 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,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 @@ -1068,7 +1067,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 @@ -1109,8 +1107,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##")
v.SetDefault("account_defaults.events.enabled", false)
Expand All @@ -1130,20 +1126,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 @@ -179,7 +179,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 @@ -384,7 +383,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 @@ -585,7 +583,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 @@ -2566,74 +2563,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

0 comments on commit fc36944

Please sign in to comment.