Skip to content

Commit

Permalink
Merge pull request #753 from PubMatic-OpenWrap/ci
Browse files Browse the repository at this point in the history
Release 16th April 2024
  • Loading branch information
pm-nilesh-chate authored Apr 12, 2024
2 parents b604c88 + 19134d5 commit f8c11c2
Show file tree
Hide file tree
Showing 47 changed files with 1,940 additions and 1,535 deletions.
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,8 @@ mockgenmetrics:

mockgenlogger:
mkdir -p analytics/pubmatic/mhttp/mock
mockgen github.com/PubMatic-OpenWrap/prebid-server/analytics/pubmatic/mhttp HttpCallInterface,MultiHttpContextInterface > analytics/pubmatic/mhttp/mock/mock.go
mockgen github.com/PubMatic-OpenWrap/prebid-server/analytics/pubmatic/mhttp HttpCallInterface,MultiHttpContextInterface > analytics/pubmatic/mhttp/mock/mock.go

mockgenpublisherfeature:
mkdir -p modules/pubmatic/openwrap/publisherfeature
mockgen github.com/PubMatic-OpenWrap/prebid-server/modules/pubmatic/openwrap/publisherfeature Feature > modules/pubmatic/openwrap/publisherfeature/mock/mock.go
2 changes: 1 addition & 1 deletion modules/pubmatic/openwrap/auctionresponsehook.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ func (m OpenWrap) handleAuctionResponseHook(
addLostToDealBidNonBRCode(&rctx)
}

droppedBids, warnings := addPWTTargetingForBid(rctx, payload.BidResponse)
droppedBids, warnings := m.addPWTTargetingForBid(rctx, payload.BidResponse)
if len(droppedBids) != 0 {
rctx.DroppedBids = droppedBids
}
Expand Down
46 changes: 39 additions & 7 deletions modules/pubmatic/openwrap/auctionresponsehook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
mock_metrics "github.com/prebid/prebid-server/modules/pubmatic/openwrap/metrics/mock"
"github.com/prebid/prebid-server/modules/pubmatic/openwrap/models"
"github.com/prebid/prebid-server/modules/pubmatic/openwrap/models/nbr"
"github.com/prebid/prebid-server/modules/pubmatic/openwrap/tbf"
mock_feature "github.com/prebid/prebid-server/modules/pubmatic/openwrap/publisherfeature/mock"
"github.com/prebid/prebid-server/openrtb_ext"
"github.com/prebid/prebid-server/util/ptrutil"
"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -134,6 +134,7 @@ func TestSeatNonBidsInHandleAuctionResponseHook(t *testing.T) {
func TestNonBRCodesInHandleAuctionResponseHook(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
mockFeature := mock_feature.NewMockFeature(ctrl)

type args struct {
ctx context.Context
Expand Down Expand Up @@ -186,6 +187,8 @@ func TestNonBRCodesInHandleAuctionResponseHook(t *testing.T) {
mockEngine := mock_metrics.NewMockMetricsEngine(ctrl)
mockEngine.EXPECT().RecordPublisherResponseTimeStats("5890", gomock.Any())
mockEngine.EXPECT().RecordPlatformPublisherPartnerResponseStats("", "5890", "pubmatic")
mockFeature.EXPECT().IsTBFFeatureEnabled(gomock.Any(), gomock.Any()).Return(false).AnyTimes()
mockFeature.EXPECT().IsFscApplicable(gomock.Any(), gomock.Any(), gomock.Any()).Return(false)
return mockEngine
},
want: want{
Expand Down Expand Up @@ -270,6 +273,8 @@ func TestNonBRCodesInHandleAuctionResponseHook(t *testing.T) {
mockEngine.EXPECT().RecordPlatformPublisherPartnerResponseStats("", "5890", "pubmatic")
mockEngine.EXPECT().RecordPlatformPublisherPartnerResponseStats("", "5890", "appnexus")
mockEngine.EXPECT().RecordPlatformPublisherPartnerResponseStats("", "5890", "rubicon")
mockFeature.EXPECT().IsTBFFeatureEnabled(gomock.Any(), gomock.Any()).Return(false).AnyTimes()
mockFeature.EXPECT().IsFscApplicable(gomock.Any(), gomock.Any(), gomock.Any()).Return(false)
return mockEngine
},
want: want{
Expand Down Expand Up @@ -380,6 +385,8 @@ func TestNonBRCodesInHandleAuctionResponseHook(t *testing.T) {
mockEngine.EXPECT().RecordPlatformPublisherPartnerResponseStats("", "5890", "pubmatic")
mockEngine.EXPECT().RecordPlatformPublisherPartnerResponseStats("", "5890", "appnexus")
mockEngine.EXPECT().RecordPlatformPublisherPartnerResponseStats("", "5890", "rubicon")
mockFeature.EXPECT().IsTBFFeatureEnabled(gomock.Any(), gomock.Any()).Return(false).AnyTimes()
mockFeature.EXPECT().IsFscApplicable(gomock.Any(), gomock.Any(), gomock.Any()).Return(false)
return mockEngine
},
want: want{
Expand Down Expand Up @@ -470,6 +477,8 @@ func TestNonBRCodesInHandleAuctionResponseHook(t *testing.T) {
mockEngine := mock_metrics.NewMockMetricsEngine(ctrl)
mockEngine.EXPECT().RecordPublisherResponseTimeStats("5890", gomock.Any())
mockEngine.EXPECT().RecordPlatformPublisherPartnerResponseStats("", "5890", "pubmatic")
mockFeature.EXPECT().IsTBFFeatureEnabled(gomock.Any(), gomock.Any()).Return(false).AnyTimes()
mockFeature.EXPECT().IsFscApplicable(gomock.Any(), gomock.Any(), gomock.Any()).Return(false)
return mockEngine
},
want: want{
Expand Down Expand Up @@ -555,6 +564,8 @@ func TestNonBRCodesInHandleAuctionResponseHook(t *testing.T) {
mockEngine.EXPECT().RecordPlatformPublisherPartnerResponseStats("", "5890", "pubmatic")
mockEngine.EXPECT().RecordPlatformPublisherPartnerResponseStats("", "5890", "appnexus")
mockEngine.EXPECT().RecordPlatformPublisherPartnerResponseStats("", "5890", "rubicon")
mockFeature.EXPECT().IsTBFFeatureEnabled(gomock.Any(), gomock.Any()).Return(false).AnyTimes()
mockFeature.EXPECT().IsFscApplicable(gomock.Any(), gomock.Any(), gomock.Any()).Return(false)
return mockEngine
},
want: want{
Expand Down Expand Up @@ -666,6 +677,8 @@ func TestNonBRCodesInHandleAuctionResponseHook(t *testing.T) {
mockEngine.EXPECT().RecordPlatformPublisherPartnerResponseStats("", "5890", "pubmatic")
mockEngine.EXPECT().RecordPlatformPublisherPartnerResponseStats("", "5890", "appnexus")
mockEngine.EXPECT().RecordPlatformPublisherPartnerResponseStats("", "5890", "rubicon")
mockFeature.EXPECT().IsTBFFeatureEnabled(gomock.Any(), gomock.Any()).Return(false).AnyTimes()
mockFeature.EXPECT().IsFscApplicable(gomock.Any(), gomock.Any(), gomock.Any()).Return(false)
return mockEngine
},
want: want{
Expand Down Expand Up @@ -778,6 +791,8 @@ func TestNonBRCodesInHandleAuctionResponseHook(t *testing.T) {
mockEngine.EXPECT().RecordPlatformPublisherPartnerResponseStats("", "5890", "pubmatic")
mockEngine.EXPECT().RecordPlatformPublisherPartnerResponseStats("", "5890", "appnexus")
mockEngine.EXPECT().RecordPlatformPublisherPartnerResponseStats("", "5890", "rubicon")
mockFeature.EXPECT().IsTBFFeatureEnabled(gomock.Any(), gomock.Any()).Return(false).AnyTimes()
mockFeature.EXPECT().IsFscApplicable(gomock.Any(), gomock.Any(), gomock.Any()).Return(false)
return mockEngine
},
want: want{
Expand Down Expand Up @@ -890,6 +905,8 @@ func TestNonBRCodesInHandleAuctionResponseHook(t *testing.T) {
mockEngine.EXPECT().RecordPlatformPublisherPartnerResponseStats("", "5890", "pubmatic")
mockEngine.EXPECT().RecordPlatformPublisherPartnerResponseStats("", "5890", "appnexus")
mockEngine.EXPECT().RecordPlatformPublisherPartnerResponseStats("", "5890", "rubicon")
mockFeature.EXPECT().IsTBFFeatureEnabled(gomock.Any(), gomock.Any()).Return(false).AnyTimes()
mockFeature.EXPECT().IsFscApplicable(gomock.Any(), gomock.Any(), gomock.Any()).Return(false)
return mockEngine
},
want: want{
Expand Down Expand Up @@ -1002,6 +1019,8 @@ func TestNonBRCodesInHandleAuctionResponseHook(t *testing.T) {
mockEngine.EXPECT().RecordPlatformPublisherPartnerResponseStats("", "5890", "pubmatic")
mockEngine.EXPECT().RecordPlatformPublisherPartnerResponseStats("", "5890", "appnexus")
mockEngine.EXPECT().RecordPlatformPublisherPartnerResponseStats("", "5890", "rubicon")
mockFeature.EXPECT().IsTBFFeatureEnabled(gomock.Any(), gomock.Any()).Return(false).AnyTimes()
mockFeature.EXPECT().IsFscApplicable(gomock.Any(), gomock.Any(), gomock.Any()).Return(false)
return mockEngine
},
want: want{
Expand Down Expand Up @@ -1058,7 +1077,8 @@ func TestNonBRCodesInHandleAuctionResponseHook(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
o := OpenWrap{
metricEngine: tt.getMetricsEngine(),
metricEngine: tt.getMetricsEngine(),
featureConfig: mockFeature,
}
hookResult, _ := o.handleAuctionResponseHook(tt.args.ctx, tt.args.moduleCtx, tt.args.payload)
mutations := hookResult.ChangeSet.Mutations()
Expand All @@ -1073,6 +1093,7 @@ func TestNonBRCodesInHandleAuctionResponseHook(t *testing.T) {
func TestPrebidTargetingInHandleAuctionResponseHook(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
mockFeature := mock_feature.NewMockFeature(ctrl)

type args struct {
ctx context.Context
Expand Down Expand Up @@ -1150,6 +1171,8 @@ func TestPrebidTargetingInHandleAuctionResponseHook(t *testing.T) {
mockEngine.EXPECT().RecordPlatformPublisherPartnerResponseStats("", "5890", "pubmatic")
mockEngine.EXPECT().RecordPlatformPublisherPartnerResponseStats("", "5890", "appnexus")
mockEngine.EXPECT().RecordPlatformPublisherPartnerResponseStats("", "5890", "rubicon")
mockFeature.EXPECT().IsTBFFeatureEnabled(gomock.Any(), gomock.Any()).Return(false).AnyTimes()
mockFeature.EXPECT().IsFscApplicable(gomock.Any(), gomock.Any(), gomock.Any()).Return(false)
return mockEngine
},
want: want{
Expand Down Expand Up @@ -1273,6 +1296,8 @@ func TestPrebidTargetingInHandleAuctionResponseHook(t *testing.T) {
mockEngine.EXPECT().RecordPlatformPublisherPartnerResponseStats("", "5890", "pubmatic")
mockEngine.EXPECT().RecordPlatformPublisherPartnerResponseStats("", "5890", "appnexus")
mockEngine.EXPECT().RecordPlatformPublisherPartnerResponseStats("", "5890", "rubicon")
mockFeature.EXPECT().IsTBFFeatureEnabled(gomock.Any(), gomock.Any()).Return(false).AnyTimes()
mockFeature.EXPECT().IsFscApplicable(gomock.Any(), gomock.Any(), gomock.Any()).Return(false)
return mockEngine
},
want: want{
Expand Down Expand Up @@ -1335,7 +1360,8 @@ func TestPrebidTargetingInHandleAuctionResponseHook(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
o := OpenWrap{
metricEngine: tt.getMetricsEngine(),
metricEngine: tt.getMetricsEngine(),
featureConfig: mockFeature,
}
hookResult, _ := o.handleAuctionResponseHook(tt.args.ctx, tt.args.moduleCtx, tt.args.payload)
mutations := hookResult.ChangeSet.Mutations()
Expand Down Expand Up @@ -1419,7 +1445,6 @@ func TestResetBidIdtoOriginal(t *testing.T) {
func TestAuctionResponseHookForEndpointWebS2S(t *testing.T) {
ctrl := gomock.NewController(t)
mockCache := mock_cache.NewMockCache(ctrl)
tbf.SetAndResetTBFConfig(mockCache, nil)
defer ctrl.Finish()

type args struct {
Expand Down Expand Up @@ -1568,8 +1593,8 @@ func TestAuctionResponseHookForEndpointWebS2S(t *testing.T) {
func TestOpenWrap_handleAuctionResponseHook(t *testing.T) {
ctrl := gomock.NewController(t)
mockCache := mock_cache.NewMockCache(ctrl)
tbf.SetAndResetTBFConfig(mockCache, nil)
defer ctrl.Finish()
mockFeature := mock_feature.NewMockFeature(ctrl)

type want struct {
result hookstage.HookResult[hookstage.AuctionResponsePayload]
Expand Down Expand Up @@ -1684,6 +1709,8 @@ func TestOpenWrap_handleAuctionResponseHook(t *testing.T) {
mockEngine := mock_metrics.NewMockMetricsEngine(ctrl)
mockEngine.EXPECT().RecordNobidErrPrebidServerResponse("5890")
mockEngine.EXPECT().RecordPublisherResponseTimeStats("5890", gomock.Any())
mockFeature.EXPECT().IsTBFFeatureEnabled(gomock.Any(), gomock.Any()).Return(false).AnyTimes()
mockFeature.EXPECT().IsFscApplicable(gomock.Any(), gomock.Any(), gomock.Any()).Return(false)
return mockEngine
},
want: want{
Expand Down Expand Up @@ -1766,6 +1793,8 @@ func TestOpenWrap_handleAuctionResponseHook(t *testing.T) {
mockEngine.EXPECT().RecordPartnerResponseTimeStats("5890", "pubmatic", 8)
mockEngine.EXPECT().RecordPublisherResponseTimeStats("5890", gomock.Any())
mockEngine.EXPECT().RecordPublisherPartnerNoCookieStats("5890", gomock.Any()).AnyTimes()
mockFeature.EXPECT().IsTBFFeatureEnabled(gomock.Any(), gomock.Any()).Return(false).AnyTimes()
mockFeature.EXPECT().IsFscApplicable(gomock.Any(), gomock.Any(), gomock.Any()).Return(false)
return mockEngine
},
doMutate: true,
Expand Down Expand Up @@ -1858,6 +1887,8 @@ func TestOpenWrap_handleAuctionResponseHook(t *testing.T) {
mockEngine.EXPECT().RecordPartnerResponseTimeStats("5890", "pubmatic", 8)
mockEngine.EXPECT().RecordPublisherResponseTimeStats("5890", gomock.Any())
mockEngine.EXPECT().RecordPublisherPartnerNoCookieStats("5890", gomock.Any()).AnyTimes()
mockFeature.EXPECT().IsTBFFeatureEnabled(gomock.Any(), gomock.Any()).Return(false).AnyTimes()
mockFeature.EXPECT().IsFscApplicable(gomock.Any(), gomock.Any(), gomock.Any()).Return(false).AnyTimes()
return mockEngine
},
doMutate: true,
Expand All @@ -1875,8 +1906,9 @@ func TestOpenWrap_handleAuctionResponseHook(t *testing.T) {
mockEngine = tt.setup()
}
m := OpenWrap{
cache: mockCache,
metricEngine: mockEngine,
cache: mockCache,
metricEngine: mockEngine,
featureConfig: mockFeature,
}
moduleCtx, ok := tt.args.moduleCtx.ModuleContext["rctx"]
if ok {
Expand Down
4 changes: 3 additions & 1 deletion modules/pubmatic/openwrap/beforevalidationhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ func (m OpenWrap) handleBeforeValidationHook(
rCtx.DeviceCtx.Platform = getDevicePlatform(rCtx, payload.BidRequest)
populateDeviceContext(&rCtx.DeviceCtx, payload.BidRequest.Device)

rCtx.IsTBFFeatureEnabled = m.featureConfig.IsTBFFeatureEnabled(rCtx.PubID, rCtx.ProfileID)

if rCtx.UidCookie == nil {
m.metricEngine.RecordUidsCookieNotPresentErrorStats(rCtx.PubIDStr, rCtx.ProfileIDStr)
}
Expand Down Expand Up @@ -247,7 +249,7 @@ func (m OpenWrap) handleBeforeValidationHook(
}
}
videoAdUnitCtx = adunitconfig.UpdateVideoObjectWithAdunitConfig(rCtx, imp, div, payload.BidRequest.Device.ConnectionType)
if rCtx.Endpoint == models.EndpointAMP && isVideoEnabledForAMP(videoAdUnitCtx.AppliedSlotAdUnitConfig) {
if rCtx.Endpoint == models.EndpointAMP && m.featureConfig.IsAmpMultiformatEnabled(rCtx.PubID) && isVideoEnabledForAMP(videoAdUnitCtx.AppliedSlotAdUnitConfig) {
//Iniitalized local imp.Video object to update macros and get mappings in case of AMP request
rCtx.AmpVideoEnabled = true
imp.Video = &openrtb2.Video{}
Expand Down
Loading

0 comments on commit f8c11c2

Please sign in to comment.