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

UOE-10950 : kgpv and kgpsv getting empty in logger for flag test=1 #877

Merged
merged 10 commits into from
Aug 30, 2024
11 changes: 1 addition & 10 deletions modules/pubmatic/openwrap/bidderparams/pubmatic.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,7 @@ func PreparePubMaticParamsV25(rctx models.RequestCtx, cache cache.Cache, bidRequ
isRegexKGP = true
}

if rctx.IsTestRequest == 1 {
matchedSlot, matchedPattern, isRegexSlot = getMatchingSlotAndPattern(rctx, cache, slots, slotMap, slotMappingInfo, isRegexKGP, isRegexSlot, partnerID, &extImpPubMatic, imp)
params, err := json.Marshal(extImpPubMatic)
return matchedSlot, matchedPattern, isRegexSlot, params, err
}

if rctx.IsTestRequest > 0 {
if len(slots) > 0 {
extImpPubMatic.AdSlot = slots[0]
}
if rctx.IsTestRequest == 2 {
pm-priyanka-bagade marked this conversation as resolved.
Show resolved Hide resolved
params, err := json.Marshal(extImpPubMatic)
return extImpPubMatic.AdSlot, "", false, params, err
pm-priyanka-bagade marked this conversation as resolved.
Show resolved Hide resolved
}
Expand Down
145 changes: 139 additions & 6 deletions modules/pubmatic/openwrap/bidderparams/pubmatic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ func TestPreparePubMaticParamsV25(t *testing.T) {
SlotMappings: map[string]interface{}{
"site": "12313",
"adtag": "45343",
"slotName": "/Test_Adunit1234@DIV1@200x300",
"slotName": "/Test_Adunit1234@Div1@200x300",
},
},
})
Expand Down Expand Up @@ -1046,7 +1046,7 @@ func TestPreparePubMaticParamsV25(t *testing.T) {
},
},
{
name: "For test value 1",
name: "For_test_value_1_for_regex",
pm-priyanka-bagade marked this conversation as resolved.
Show resolved Hide resolved
args: args{
rctx: models.RequestCtx{
IsTestRequest: 1,
Expand Down Expand Up @@ -1116,6 +1116,139 @@ func TestPreparePubMaticParamsV25(t *testing.T) {
wantErr: false,
},
},
{
name: "For_test_value_1_for_non_regex",
args: args{
rctx: models.RequestCtx{
IsTestRequest: 1,
PubID: 5890,
ProfileID: 123,
DisplayID: 1,
PartnerConfigMap: map[int]map[string]string{
1: {
models.PREBID_PARTNER_NAME: "pubmatic",
models.BidderCode: "pubmatic",
models.TIMEOUT: "200",
models.KEY_GEN_PATTERN: "_AU_@_W_x_H_",
models.SERVER_SIDE_FLAG: "1",
},
},
},
cache: mockCache,
impExt: models.ImpExtension{
Bidder: map[string]*models.BidderExtension{
"pubmatic": {
KeyWords: []models.KeyVal{
{
Key: "test_key1",
Values: []string{"test_value1", "test_value2"},
},
{
Key: "test_key2",
Values: []string{"test_value1", "test_value2"},
},
},
},
},
Wrapper: &models.ExtImpWrapper{
Div: "Div1",
},
},
imp: getTestImp("/Test_Adunit1234", false, false),
partnerID: 1,
},
setup: func() {
mockCache.EXPECT().GetMappingsFromCacheV25(gomock.Any(), gomock.Any()).Return(map[string]models.SlotMapping{
"/test_adunit1234@1x1": {
PartnerId: 1,
AdapterId: 1,
SlotName: "/Test_Adunit1234@1x1",
SlotMappings: map[string]interface{}{
"site": "12313",
"adtag": "45343",
models.KEY_OW_SLOT_NAME: "/Test_Adunit1234@1x1",
},
},
})
mockCache.EXPECT().GetSlotToHashValueMapFromCacheV25(gomock.Any(), gomock.Any()).Return(models.SlotMappingInfo{
OrderedSlotList: []string{"test", "test1"},
})
},
want: want{
matchedSlot: "/Test_Adunit1234@1x1",
matchedPattern: "",
isRegexSlot: false,
params: []byte(`{"publisherId":"5890","adSlot":"/Test_Adunit1234@1x1","wrapper":{"version":1,"profile":123},"keywords":[{"key":"test_key1","value":["test_value1","test_value2"]},{"key":"test_key2","value":["test_value1","test_value2"]}]}`),
wantErr: false,
},
},
{
name: "for_test_value_1_exact_matched_slot_found_adslot_updated_from_PubMatic_secondary_flow",
pm-isha-bharti marked this conversation as resolved.
Show resolved Hide resolved
args: args{
rctx: models.RequestCtx{
IsTestRequest: 1,
PubID: 5890,
ProfileID: 123,
DisplayID: 1,
PartnerConfigMap: map[int]map[string]string{
1: {
models.PREBID_PARTNER_NAME: "pubmatic",
models.BidderCode: "pubmatic",
models.TIMEOUT: "200",
models.KEY_GEN_PATTERN: "_AU_@_DIV_@_W_x_H_",
models.SERVER_SIDE_FLAG: "1",
models.KEY_PROFILE_ID: "1323",
},
},
},
cache: mockCache,
impExt: models.ImpExtension{
Bidder: map[string]*models.BidderExtension{
"pubmatic": {
KeyWords: []models.KeyVal{
{
Key: "test_key1",
Values: []string{"test_value1", "test_value2"},
},
{
Key: "test_key2",
Values: []string{"test_value1", "test_value2"},
},
},
},
},
Wrapper: &models.ExtImpWrapper{
Div: "Div1",
},
},
imp: getTestImp("/Test_Adunit1234", true, false),
partnerID: 1,
},
setup: func() {
mockCache.EXPECT().GetMappingsFromCacheV25(gomock.Any(), gomock.Any()).Return(map[string]models.SlotMapping{
"/test_adunit1234@div1@200x300": {
PartnerId: 1,
AdapterId: 1,
SlotName: "/Test_Adunit1234@Div1@200x300",
SlotMappings: map[string]interface{}{
"site": "12313",
"adtag": "45343",
"slotName": "/Test_Adunit1234@DIV1@200x300",
},
},
})
mockCache.EXPECT().GetSlotToHashValueMapFromCacheV25(gomock.Any(), gomock.Any()).Return(models.SlotMappingInfo{
OrderedSlotList: []string{"test", "test1"},
})
},
want: want{
matchedSlot: "/Test_Adunit1234@Div1@200x300",
matchedPattern: "",
isRegexSlot: false,
params: []byte(`{"publisherId":"5890","adSlot":"/Test_Adunit1234@DIV1@200x300","wrapper":{"version":0,"profile":1323},"keywords":[{"key":"test_key1","value":["test_value1","test_value2"]},{"key":"test_key2","value":["test_value1","test_value2"]}]}`),
wantErr: false,
},
},
{
name: "For_test_value_2_with_regex",
args: args{
Expand Down Expand Up @@ -1158,10 +1291,10 @@ func TestPreparePubMaticParamsV25(t *testing.T) {
partnerID: 1,
},
want: want{
matchedSlot: "/Test_Adunit1234@Div1@200x300",
matchedSlot: "",
matchedPattern: "",
isRegexSlot: false,
params: []byte(`{"publisherId":"5890","adSlot":"/Test_Adunit1234@Div1@200x300","wrapper":{"version":1,"profile":123},"keywords":[{"key":"test_key1","value":["test_value1","test_value2"]},{"key":"test_key2","value":["test_value1","test_value2"]}]}`),
params: []byte(`{"publisherId":"5890","adSlot":"","wrapper":{"version":1,"profile":123},"keywords":[{"key":"test_key1","value":["test_value1","test_value2"]},{"key":"test_key2","value":["test_value1","test_value2"]}]}`),
wantErr: false,
},
},
Expand Down Expand Up @@ -1207,10 +1340,10 @@ func TestPreparePubMaticParamsV25(t *testing.T) {
partnerID: 1,
},
want: want{
matchedSlot: "/Test_Adunit1234@200x300",
matchedSlot: "",
matchedPattern: "",
isRegexSlot: false,
params: []byte(`{"publisherId":"5890","adSlot":"/Test_Adunit1234@200x300","wrapper":{"version":1,"profile":123},"keywords":[{"key":"test_key1","value":["test_value1","test_value2"]},{"key":"test_key2","value":["test_value1","test_value2"]}]}`),
params: []byte(`{"publisherId":"5890","adSlot":"","wrapper":{"version":1,"profile":123},"keywords":[{"key":"test_key1","value":["test_value1","test_value2"]},{"key":"test_key2","value":["test_value1","test_value2"]}]}`),
wantErr: false,
},
},
Expand Down
Loading