@Test
    public void testWarmUp() throws InterruptedException {

        RegistryConfig registryConfig = new RegistryConfig()
            .setProtocol(RpcConstants.REGISTRY_PROTOCOL_ZK)
            .setAddress("127.0.0.1:2181");

        ServerConfig serverConfig = new ServerConfig()
            .setPort(22222)
            .setProtocol(RpcConstants.PROTOCOL_TYPE_BOLT);
        ProviderConfig<WarmUpService> providerConfig = new ProviderConfig<WarmUpService>()
            .setInterfaceId(WarmUpService.class.getName())
            .setRef(new WarmUpServiceImpl(22222))
            .setServer(serverConfig)
            .setRegistry(registryConfig)
            .setParameter(ProviderInfoAttrs.ATTR_WARMUP_TIME, "2000")
            .setParameter(ProviderInfoAttrs.ATTR_WARMUP_WEIGHT, "100")
            .setWeight(0);

        ServerConfig serverConfig2 = new ServerConfig()
            .setPort(22111)
            .setProtocol(RpcConstants.PROTOCOL_TYPE_BOLT);
        ProviderConfig<WarmUpService> providerConfig2 = new ProviderConfig<WarmUpService>()
            .setInterfaceId(WarmUpService.class.getName())
            .setRef(new WarmUpServiceImpl(22111))
            .setServer(serverConfig2)
            .setRegistry(registryConfig)
            .setRepeatedExportLimit(-1)
            .setWeight(0);

        providerConfig.export();
        providerConfig2.export();

        long startTime = System.currentTimeMillis();
        ConsumerConfig<WarmUpService> consumerConfig = new ConsumerConfig<WarmUpService>()
            .setInterfaceId(WarmUpService.class.getName())
            .setRegistry(registryConfig)
            .setProtocol(RpcConstants.PROTOCOL_TYPE_BOLT);
        WarmUpService warmUpService = consumerConfig.refer();

        // Before the 2000 ms, all the traffic goes to 22222.
        for (int i = 0; i < 10; i++) {
            Assert.assertEquals(22222, warmUpService.getPort());
        }

        long elapsed = System.currentTimeMillis() - startTime;
        LOGGER.info("elapsed " + elapsed + "ms");

        long sleepTime = 2100 - elapsed;
        if (sleepTime >= 0) {
            Thread.sleep(sleepTime);
        }

        // After 2000 ms, all the traffic goes to 22222 && 22111.
        int cnt = 0;
        for (int i = 0; i < 100; i++) {
            if (warmUpService.getPort() == 22111) {
                cnt++;
            }
        }
        Assert.assertTrue(cnt > 0);
    }
@author <a href="mailto:lw111072@antfin.com">LiWei.Liangen</a>
test/test-integration-3rd/src/test/java/com/alipay/sofa/rpc/registry/zk/WarmUpTest.java