forked from feast-dev/feast
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Expand Go and Java SDK Test Coverage (feast-dev#720)
* Added TestGetOnlineFeatures() client_test to test client.GetOnlineFeatures() * Added unit test for Java SDK's FeastClient * Make Python SDK's client.get_online_features() unit test more comprehensive * Remove code added to debug the Python SDK tests * Change repo referenced in go.mod to mrzzy fork to test modules retrieval * Fix python sdk lint * Revert "Change repo referenced in go.mod to mrzzy fork to test modules retrieval" This reverts commit 13008ccef6b6cbee6299029589b5e9e864eee7ae. * Optmisation: Init stripFields map to expected size in client.GetOnlineFeatures() * Make the name of the client test case more descriptive * Add missing mock files * Fix rebase markers in project root go mod * Fix compilation issue cause by downgrade to java 8 * Revert row count in python SDK client test to 300 Co-authored-by: Zhu Zhanyan <zhu.zhanyan@gojek.com>
- Loading branch information
1 parent
9a42445
commit 9485546
Showing
11 changed files
with
435 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
package feast | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/feast-dev/feast/sdk/go/mocks" | ||
"github.com/feast-dev/feast/sdk/go/protos/feast/serving" | ||
"github.com/feast-dev/feast/sdk/go/protos/feast/types" | ||
"github.com/golang/mock/gomock" | ||
"github.com/google/go-cmp/cmp" | ||
"github.com/opentracing/opentracing-go" | ||
) | ||
|
||
func TestGetOnlineFeatures(t *testing.T) { | ||
tt := []struct { | ||
name string | ||
req OnlineFeaturesRequest | ||
recieve OnlineFeaturesResponse | ||
want OnlineFeaturesResponse | ||
wantErr bool | ||
err error | ||
}{ | ||
{ | ||
name: "Valid client Get Online Features call", | ||
req: OnlineFeaturesRequest{ | ||
Features: []string{ | ||
"driver:rating", | ||
"rating", | ||
}, | ||
Entities: []Row{ | ||
{"driver_id": Int64Val(1)}, | ||
}, | ||
Project: "driver_project", | ||
}, | ||
// check GetOnlineFeatures() should strip projects returned from serving | ||
recieve: OnlineFeaturesResponse{ | ||
RawResponse: &serving.GetOnlineFeaturesResponse{ | ||
FieldValues: []*serving.GetOnlineFeaturesResponse_FieldValues{ | ||
{ | ||
Fields: map[string]*types.Value{ | ||
"driver_project/driver:rating": Int64Val(1), | ||
"driver_project/rating": Int64Val(1), | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
want: OnlineFeaturesResponse{ | ||
RawResponse: &serving.GetOnlineFeaturesResponse{ | ||
FieldValues: []*serving.GetOnlineFeaturesResponse_FieldValues{ | ||
{ | ||
Fields: map[string]*types.Value{ | ||
"driver:rating": Int64Val(1), | ||
"rating": Int64Val(1), | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
for _, tc := range tt { | ||
t.Run(tc.name, func(t *testing.T) { | ||
// mock feast grpc client get online feature requestss | ||
ctrl := gomock.NewController(t) | ||
defer ctrl.Finish() | ||
cli := mock_serving.NewMockServingServiceClient(ctrl) | ||
ctx := context.Background() | ||
_, traceCtx := opentracing.StartSpanFromContext(ctx, "get_online_features") | ||
rawRequest, _ := tc.req.buildRequest() | ||
resp := tc.recieve.RawResponse | ||
cli.EXPECT().GetOnlineFeatures(traceCtx, rawRequest).Return(resp, nil).Times(1) | ||
|
||
client := &GrpcClient{ | ||
cli: cli, | ||
} | ||
got, err := client.GetOnlineFeatures(ctx, &tc.req) | ||
|
||
if err != nil && !tc.wantErr { | ||
t.Errorf("error = %v, wantErr %v", err, tc.wantErr) | ||
return | ||
} | ||
if tc.wantErr && err.Error() != tc.err.Error() { | ||
t.Errorf("error = %v, expected err = %v", err, tc.err) | ||
return | ||
} | ||
// TODO: compare directly once OnlineFeaturesResponse no longer embeds a rawResponse. | ||
if !cmp.Equal(got.RawResponse.String(), tc.want.RawResponse.String()) { | ||
t.Errorf("got: \n%v\nwant:\n%v", got.RawResponse.String(), tc.want.RawResponse.String()) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.