test-cli: add smoke tests for recommendation service
Signed-off-by: Ahmet Alp Balkan <ahmetb@google.com>
This commit is contained in:
parent
2d4f4f884a
commit
cc8ef35006
1 changed files with 26 additions and 0 deletions
|
@ -24,6 +24,10 @@ var (
|
||||||
envs: []string{"SHIPPING_SERVICE_ADDR"},
|
envs: []string{"SHIPPING_SERVICE_ADDR"},
|
||||||
f: testShippingService,
|
f: testShippingService,
|
||||||
},
|
},
|
||||||
|
"recommendationservice": {
|
||||||
|
envs: []string{"RECOMMENDATION_SERVICE_ADDR"},
|
||||||
|
f: testRecommendationService,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -126,3 +130,25 @@ func testShippingService() error {
|
||||||
log.Printf("--> quote: %+v", shipResp)
|
log.Printf("--> quote: %+v", shipResp)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func testRecommendationService() error {
|
||||||
|
addr := os.Getenv("RECOMMENDATION_SERVICE_ADDR")
|
||||||
|
conn, err := grpc.Dial(addr, grpc.WithInsecure())
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer conn.Close()
|
||||||
|
cl := pb.NewRecommendationServiceClient(conn)
|
||||||
|
|
||||||
|
log.Println("--- rpc ShipOrder()")
|
||||||
|
resp, err := cl.ListRecommendations(context.TODO(), &pb.ListRecommendationsRequest{
|
||||||
|
UserId: "foo",
|
||||||
|
ProductIds: []string{"1", "2", "3", "4", "5"},
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
log.Printf("--> returned %d recommendations", len(resp.GetProductIds()))
|
||||||
|
log.Printf("--> ids: %v", resp.GetProductIds())
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue