Search in sources :

Example 26 with DataProvider

use of org.testng.annotations.DataProvider in project rest.li by linkedin.

the class TestRestLiRouting method nKeyAssociationRoutingBatch.

@DataProvider(name = TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "nKeyAssociationRoutingBatch")
public Object[][] nKeyAssociationRoutingBatch() {
    CompoundKey key1 = new CompoundKey();
    key1.append("foo", "1,1").append("bar", "1:2");
    CompoundKey key2 = new CompoundKey();
    key2.append("foo", "2,1").append("bar", "2;2");
    Set<CompoundKey> keys = new HashSet<CompoundKey>();
    keys.add(key1);
    keys.add(key2);
    return new Object[][] { { "/test?ids=bar%3D1%253A2%26foo%3D1%252C1&ids=bar%3D2%253B2%26foo%3D2%252C1", AllProtocolVersions.RESTLI_PROTOCOL_1_0_0.getProtocolVersion(), "GET", ResourceMethod.BATCH_GET, "batchGet", keys }, { "/test?ids=List((bar:1%3A2,foo:1%2C1),(bar:2;2,foo:2%2C1))", AllProtocolVersions.RESTLI_PROTOCOL_2_0_0.getProtocolVersion(), "GET", ResourceMethod.BATCH_GET, "batchGet", keys } };
}
Also used : CompoundKey(com.linkedin.restli.common.CompoundKey) HashSet(java.util.HashSet) DataProvider(org.testng.annotations.DataProvider)

Example 27 with DataProvider

use of org.testng.annotations.DataProvider in project rest.li by linkedin.

the class TestRestCompressionEcho method compressionEchoData.

@DataProvider
public Object[][] compressionEchoData() {
    EncodingType[] encodings = new EncodingType[] { EncodingType.GZIP, EncodingType.SNAPPY, EncodingType.IDENTITY };
    Object[][] args = new Object[4 * encodings.length * encodings.length][2];
    int cur = 0;
    for (EncodingType requestEncoding : encodings) {
        for (EncodingType acceptEncoding : encodings) {
            RestFilter clientCompressionFilter = new ClientCompressionFilter(requestEncoding, new CompressionConfig(THRESHOLD), new EncodingType[] { acceptEncoding }, new CompressionConfig(THRESHOLD), Arrays.asList(new String[] { "*" }));
            TransportClientFactory factory = new HttpClientFactory.Builder().setFilterChain(FilterChains.createRestChain(clientCompressionFilter)).build();
            Client http1Client = new TransportClientAdapter(factory.getClient(getHttp1ClientProperties()), REST_OVER_STREAM);
            Client http2Client = new TransportClientAdapter(factory.getClient(getHttp2ClientProperties()), REST_OVER_STREAM);
            args[cur][0] = http1Client;
            args[cur][1] = LARGE_BYTES_NUM;
            args[cur + 1][0] = http2Client;
            args[cur + 1][1] = LARGE_BYTES_NUM;
            cur += 2;
            _clientFactories.add(factory);
            _clients.add(http1Client);
            _clients.add(http2Client);
        }
    }
    // test data that won't trigger compression
    for (EncodingType requestEncoding : encodings) {
        for (EncodingType acceptEncoding : encodings) {
            RestFilter clientCompressionFilter = new ClientCompressionFilter(requestEncoding, new CompressionConfig(THRESHOLD), new EncodingType[] { acceptEncoding }, new CompressionConfig(THRESHOLD), Arrays.asList(new String[] { "*" }));
            TransportClientFactory factory = new HttpClientFactory.Builder().setFilterChain(FilterChains.createRestChain(clientCompressionFilter)).build();
            Client http1Client = new TransportClientAdapter(factory.getClient(getHttp1ClientProperties()), REST_OVER_STREAM);
            Client http2Client = new TransportClientAdapter(factory.getClient(getHttp2ClientProperties()), REST_OVER_STREAM);
            args[cur][0] = http1Client;
            args[cur][1] = SMALL_BYTES_NUM;
            args[cur + 1][0] = http2Client;
            args[cur + 1][1] = SMALL_BYTES_NUM;
            cur += 2;
            _clientFactories.add(factory);
            _clients.add(http1Client);
            _clients.add(http2Client);
        }
    }
    return args;
}
Also used : RestFilter(com.linkedin.r2.filter.message.rest.RestFilter) RestRequestBuilder(com.linkedin.r2.message.rest.RestRequestBuilder) TransportDispatcherBuilder(com.linkedin.r2.transport.common.bridge.server.TransportDispatcherBuilder) RestResponseBuilder(com.linkedin.r2.message.rest.RestResponseBuilder) EncodingType(com.linkedin.r2.filter.compression.EncodingType) TransportClientAdapter(com.linkedin.r2.transport.common.bridge.client.TransportClientAdapter) Client(com.linkedin.r2.transport.common.Client) TransportClientFactory(com.linkedin.r2.transport.common.TransportClientFactory) ClientCompressionFilter(com.linkedin.r2.filter.compression.ClientCompressionFilter) CompressionConfig(com.linkedin.r2.filter.CompressionConfig) DataProvider(org.testng.annotations.DataProvider)

Example 28 with DataProvider

use of org.testng.annotations.DataProvider in project rest.li by linkedin.

the class TestRequestCompression method requestCompressionData.

@DataProvider
public Object[][] requestCompressionData() {
    StreamEncodingType[] encodings = new StreamEncodingType[] { StreamEncodingType.GZIP, StreamEncodingType.DEFLATE, StreamEncodingType.SNAPPY_FRAMED, StreamEncodingType.BZIP2 };
    String[] protocols = new String[] { HttpProtocolVersion.HTTP_1_1.name(), HttpProtocolVersion.HTTP_2.name() };
    Object[][] args = new Object[encodings.length * protocols.length][2];
    int cur = 0;
    for (StreamEncodingType requestEncoding : encodings) {
        for (String protocol : protocols) {
            StreamFilter clientCompressionFilter = new ClientStreamCompressionFilter(requestEncoding, new CompressionConfig(THRESHOLD), null, new CompressionConfig(THRESHOLD), Arrays.asList(new String[] { "*" }), _executor);
            TransportClientFactory factory = new HttpClientFactory.Builder().setFilterChain(FilterChains.createStreamChain(clientCompressionFilter)).build();
            HashMap<String, String> properties = new HashMap<>();
            properties.put(HttpClientFactory.HTTP_PROTOCOL_VERSION, protocol);
            Client client = new TransportClientAdapter(factory.getClient(properties), true);
            args[cur][0] = client;
            args[cur][1] = URI.create("/" + requestEncoding.getHttpName());
            cur++;
            _clientFactories.add(factory);
            _clients.add(client);
        }
    }
    return args;
}
Also used : HashMap(java.util.HashMap) TransportDispatcherBuilder(com.linkedin.r2.transport.common.bridge.server.TransportDispatcherBuilder) StreamRequestBuilder(com.linkedin.r2.message.stream.StreamRequestBuilder) ByteString(com.linkedin.data.ByteString) StreamFilter(com.linkedin.r2.filter.message.stream.StreamFilter) StreamEncodingType(com.linkedin.r2.filter.compression.streaming.StreamEncodingType) ClientStreamCompressionFilter(com.linkedin.r2.filter.compression.ClientStreamCompressionFilter) TransportClientAdapter(com.linkedin.r2.transport.common.bridge.client.TransportClientAdapter) Client(com.linkedin.r2.transport.common.Client) TransportClientFactory(com.linkedin.r2.transport.common.TransportClientFactory) CompressionConfig(com.linkedin.r2.filter.CompressionConfig) DataProvider(org.testng.annotations.DataProvider)

Example 29 with DataProvider

use of org.testng.annotations.DataProvider in project rest.li by linkedin.

the class TestClientStreamCompressionFilter method provideRequestData.

@DataProvider(name = "requestData")
private Object[][] provideRequestData() {
    CompressionConfig smallThresholdConfig = new CompressionConfig(1);
    CompressionConfig largeThresholdConfig = new CompressionConfig(10000);
    return new Object[][] { { new CompressionConfig(Integer.MAX_VALUE), CompressionOption.FORCE_OFF, false, "" }, { new CompressionConfig(Integer.MAX_VALUE), CompressionOption.FORCE_ON, true, "" }, { new CompressionConfig(Integer.MAX_VALUE), null, false, "" }, { new CompressionConfig(0), CompressionOption.FORCE_OFF, false, "" }, { new CompressionConfig(0), CompressionOption.FORCE_ON, true, "" }, { new CompressionConfig(0), null, true, "" }, { smallThresholdConfig, CompressionOption.FORCE_OFF, false, "" }, { smallThresholdConfig, CompressionOption.FORCE_ON, true, "" }, { smallThresholdConfig, null, true, "" }, { largeThresholdConfig, CompressionOption.FORCE_OFF, false, "" }, { largeThresholdConfig, CompressionOption.FORCE_ON, true, "" }, { largeThresholdConfig, null, false, "" }, // The same tests, but with null instead of an empty string
    { new CompressionConfig(Integer.MAX_VALUE), CompressionOption.FORCE_OFF, false, null }, { new CompressionConfig(Integer.MAX_VALUE), CompressionOption.FORCE_ON, true, null }, { new CompressionConfig(Integer.MAX_VALUE), null, false, null }, { new CompressionConfig(0), CompressionOption.FORCE_OFF, false, null }, { new CompressionConfig(0), CompressionOption.FORCE_ON, true, null }, { new CompressionConfig(0), null, true, null }, { smallThresholdConfig, CompressionOption.FORCE_OFF, false, null }, { smallThresholdConfig, CompressionOption.FORCE_ON, true, null }, { smallThresholdConfig, null, true, null }, { largeThresholdConfig, CompressionOption.FORCE_OFF, false, null }, { largeThresholdConfig, CompressionOption.FORCE_ON, true, null }, { largeThresholdConfig, null, false, null } };
}
Also used : CompressionConfig(com.linkedin.r2.filter.CompressionConfig) DataProvider(org.testng.annotations.DataProvider)

Example 30 with DataProvider

use of org.testng.annotations.DataProvider in project rest.li by linkedin.

the class TestHttpClient method configs.

@DataProvider
public Object[][] configs() {
    Map<String, String> http1ClientProperties = new HashMap<>();
    http1ClientProperties.put(HttpClientFactory.HTTP_PROTOCOL_VERSION, HttpProtocolVersion.HTTP_1_1.name());
    http1ClientProperties.put(HttpClientFactory.HTTP_REQUEST_TIMEOUT, Integer.toString(REQUEST_TIMEOUT));
    Map<String, String> http2ClientProperties = new HashMap<>();
    http2ClientProperties.put(HttpClientFactory.HTTP_PROTOCOL_VERSION, HttpProtocolVersion.HTTP_2.name());
    http2ClientProperties.put(HttpClientFactory.HTTP_REQUEST_TIMEOUT, Integer.toString(REQUEST_TIMEOUT));
    TransportDispatcher dispatcher = new TransportDispatcherBuilder().addRestHandler(DISPATCHER_URI, new EchoHandler()).build();
    return new Object[][] { { new HttpServerFactory().createH2cServer(PORT, dispatcher, REST_OVER_STREAM), new TransportClientAdapter(_clientFactory.getClient(http1ClientProperties), REST_OVER_STREAM) }, { new HttpServerFactory().createH2cServer(PORT, dispatcher, REST_OVER_STREAM), new TransportClientAdapter(_clientFactory.getClient(http2ClientProperties), REST_OVER_STREAM) }, { new HttpServerFactory().createH2cServer(PORT, dispatcher, NOT_REST_OVER_STREAM), new TransportClientAdapter(_clientFactory.getClient(http1ClientProperties), NOT_REST_OVER_STREAM) }, { new HttpServerFactory().createH2cServer(PORT, dispatcher, NOT_REST_OVER_STREAM), new TransportClientAdapter(_clientFactory.getClient(http2ClientProperties), NOT_REST_OVER_STREAM) } };
}
Also used : HttpServerFactory(com.linkedin.r2.transport.http.server.HttpServerFactory) HashMap(java.util.HashMap) TransportClientAdapter(com.linkedin.r2.transport.common.bridge.client.TransportClientAdapter) TransportDispatcher(com.linkedin.r2.transport.common.bridge.server.TransportDispatcher) ByteString(com.linkedin.data.ByteString) TransportDispatcherBuilder(com.linkedin.r2.transport.common.bridge.server.TransportDispatcherBuilder) DataProvider(org.testng.annotations.DataProvider)

Aggregations

DataProvider (org.testng.annotations.DataProvider)391 SimpleInterval (org.broadinstitute.hellbender.utils.SimpleInterval)99 ArrayList (java.util.ArrayList)93 Test (org.testng.annotations.Test)85 File (java.io.File)74 List (java.util.List)72 Assert (org.testng.Assert)67 URIDetails (com.linkedin.restli.internal.testutils.URIDetails)65 Collectors (java.util.stream.Collectors)61 HashMap (java.util.HashMap)57 IntStream (java.util.stream.IntStream)54 Random (java.util.Random)50 RealMatrix (org.apache.commons.math3.linear.RealMatrix)44 BaseTest (org.broadinstitute.hellbender.utils.test.BaseTest)41 IOException (java.io.IOException)39 ByteString (com.linkedin.data.ByteString)37 Array2DRowRealMatrix (org.apache.commons.math3.linear.Array2DRowRealMatrix)34 Stream (java.util.stream.Stream)31 DoubleStream (java.util.stream.DoubleStream)29 HashSet (java.util.HashSet)28