Skip to content

Commit

Permalink
Add integration test for create store over secure grpc channel
Browse files Browse the repository at this point in the history
  • Loading branch information
sushantmane committed Jan 16, 2025
1 parent f1c131d commit 4fc5200
Showing 1 changed file with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import static org.testng.Assert.assertNotNull;

import com.linkedin.venice.controllerapi.StoreResponse;
import com.linkedin.venice.grpc.GrpcUtils;
import com.linkedin.venice.integration.utils.ServiceFactory;
import com.linkedin.venice.integration.utils.VeniceClusterCreateOptions;
import com.linkedin.venice.integration.utils.VeniceClusterWrapper;
Expand All @@ -18,8 +19,11 @@
import com.linkedin.venice.protocols.controller.LeaderControllerGrpcResponse;
import com.linkedin.venice.protocols.controller.VeniceControllerGrpcServiceGrpc;
import com.linkedin.venice.protocols.controller.VeniceControllerGrpcServiceGrpc.VeniceControllerGrpcServiceBlockingStub;
import com.linkedin.venice.security.SSLFactory;
import com.linkedin.venice.utils.SslUtils;
import com.linkedin.venice.utils.TestUtils;
import com.linkedin.venice.utils.Utils;
import io.grpc.ChannelCredentials;
import io.grpc.Grpc;
import io.grpc.InsecureChannelCredentials;
import io.grpc.ManagedChannel;
Expand All @@ -31,9 +35,11 @@

public class TestControllerGrpcEndpoints {
private VeniceClusterWrapper veniceCluster;
private SSLFactory sslFactory;

@BeforeClass(alwaysRun = true)
public void setUp() {
sslFactory = SslUtils.getVeniceLocalSslFactory();
Properties properties = new Properties();
properties.put(CONTROLLER_GRPC_SERVER_ENABLED, true);
VeniceClusterCreateOptions options = new VeniceClusterCreateOptions.Builder().numberOfControllers(1)
Expand Down Expand Up @@ -97,4 +103,35 @@ public void testGrpcEndpointsWithGrpcClient() {
assertEquals(discoverClusterGrpcResponse.getStoreName(), storeName);
assertEquals(discoverClusterGrpcResponse.getClusterName(), veniceCluster.getClusterName());
}

@Test
public void testCreateStoreOverSecureGrpcChannel() {
String storeName = Utils.getUniqueString("test_grpc_store");
String controllerSecureGrpcUrl = veniceCluster.getLeaderVeniceController().getControllerSecureGrpcUrl();
ChannelCredentials credentials = GrpcUtils.buildChannelCredentials(sslFactory);
ManagedChannel channel = Grpc.newChannelBuilder(controllerSecureGrpcUrl, credentials).build();
VeniceControllerGrpcServiceBlockingStub blockingStub = VeniceControllerGrpcServiceGrpc.newBlockingStub(channel);

CreateStoreGrpcRequest createStoreGrpcRequest = CreateStoreGrpcRequest.newBuilder()
.setClusterStoreInfo(
ClusterStoreGrpcInfo.newBuilder()
.setClusterName(veniceCluster.getClusterName())
.setStoreName(storeName)
.build())
.setOwner("owner")
.setKeySchema(DEFAULT_KEY_SCHEMA)
.setValueSchema("\"string\"")
.build();

CreateStoreGrpcResponse response = blockingStub.createStore(createStoreGrpcRequest);
assertNotNull(response, "Response should not be null");
assertNotNull(response.getClusterStoreInfo(), "ClusterStoreInfo should not be null");
assertEquals(response.getClusterStoreInfo().getClusterName(), veniceCluster.getClusterName());
assertEquals(response.getClusterStoreInfo().getStoreName(), storeName);

veniceCluster.useControllerClient(controllerClient -> {
StoreResponse storeResponse = TestUtils.assertCommand(controllerClient.getStore(storeName));
assertNotNull(storeResponse.getStore(), "Store should not be null");
});
}
}

0 comments on commit 4fc5200

Please sign in to comment.