Skip to content

Commit

Permalink
Addressing Comments
Browse files Browse the repository at this point in the history
Signed-off-by: Ajay Kumar Movva <[email protected]>
  • Loading branch information
Ajay Kumar Movva committed Oct 18, 2023
1 parent 05720da commit 2759b70
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ protected Settings nodeSettings(int nodeOrdinal) {
return Settings.builder().put(super.nodeSettings(nodeOrdinal)).put(settings).build();
}

// TODO this integration test currently evaluating is admissionControl Interceptor is triggering as expected
// and registered controllers are applying for the requests or not. Will modify this in further PR's.
public void testAdmissionControlRejectionFlow() {
assertAcked(
prepareCreate(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public TransportInterceptorRegistry() {
*
* @param transportInterceptor new transport interceptor object
*/
public void registerTransportInterceptor(TransportInterceptor transportInterceptor){
public void addTransportInterceptor(TransportInterceptor transportInterceptor) {
this.transportInterceptors.add(transportInterceptor);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -426,8 +426,7 @@ private NetworkModule newNetworkModule(Settings settings, NetworkPlugin... plugi
null,
new NullDispatcher(),
new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS),
NoopTracer.INSTANCE,
null
NoopTracer.INSTANCE
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

package org.opensearch.transport;

import org.opensearch.test.OpenSearchTestCase;

import java.util.ArrayList;

import static org.mockito.Mockito.mock;

public class TransportInterceptorRegistryTests extends OpenSearchTestCase {

private TransportInterceptorRegistry transportInterceptorRegistry;

@Override
public void setUp() throws Exception {
super.setUp();
transportInterceptorRegistry = new TransportInterceptorRegistry();
}

@Override
public void tearDown() throws Exception {
super.tearDown();
}

public void testDefaultSettings() {
assertEquals(transportInterceptorRegistry.transportInterceptors, new ArrayList<>());
assertEquals(transportInterceptorRegistry.getTransportInterceptors().size(), 0);
}

public void testRegisterInterceptor() {
transportInterceptorRegistry.addTransportInterceptor(mock(TransportInterceptor.class));
assertEquals(transportInterceptorRegistry.getTransportInterceptors().size(), 1);
transportInterceptorRegistry.addTransportInterceptor(mock(TransportInterceptor.class));
assertEquals(transportInterceptorRegistry.getTransportInterceptors().size(), 2);
}

public void testGetAllInterceptor() {
transportInterceptorRegistry.addTransportInterceptor(mock(TransportInterceptor.class));
assertEquals(transportInterceptorRegistry.getTransportInterceptors().size(), 1);
transportInterceptorRegistry.addTransportInterceptor(mock(TransportInterceptor.class));
assertEquals(transportInterceptorRegistry.getTransportInterceptors().size(), 2);
transportInterceptorRegistry.getTransportInterceptors().forEach(transportInterceptor -> {
assertEquals(transportInterceptor.getClass(), mock(TransportInterceptor.class).getClass());
});
}
}

0 comments on commit 2759b70

Please sign in to comment.