@Test
    public void testWarmup() throws UnsupportedEncodingException, InterruptedException {

        long now = System.currentTimeMillis();

        ProviderInfo providerInfo = new ProviderInfo()
            .setWeight(200)
            .setStaticAttr(ProviderInfoAttrs.ATTR_WEIGHT, "200")
            .setStaticAttr(ProviderInfoAttrs.ATTR_START_TIME, String.valueOf(now))
            .setStaticAttr(ProviderInfoAttrs.ATTR_WARMUP_TIME, String.valueOf(200))
            .setStaticAttr(ProviderInfoAttrs.ATTR_WARMUP_WEIGHT, String.valueOf(700));

        ZookeeperRegistryHelper.processWarmUpWeight(providerInfo);

        Assert.assertEquals("200", providerInfo.getStaticAttr(ProviderInfoAttrs.ATTR_WEIGHT));
        Assert.assertEquals(now + "", providerInfo.getStaticAttr(ProviderInfoAttrs.ATTR_START_TIME));
        Assert.assertEquals(null, providerInfo.getStaticAttr(ProviderInfoAttrs.ATTR_WARMUP_TIME));
        Assert.assertEquals(null, providerInfo.getStaticAttr(ProviderInfoAttrs.ATTR_WARMUP_WEIGHT));

        Assert.assertEquals(now + 200, providerInfo.getDynamicAttr(ProviderInfoAttrs.ATTR_WARM_UP_END_TIME));
        Assert.assertEquals(700, providerInfo.getDynamicAttr(ProviderInfoAttrs.ATTR_WARMUP_WEIGHT));
        Assert.assertEquals(ProviderStatus.WARMING_UP, providerInfo.getStatus());
        Assert.assertEquals(700, providerInfo.getWeight());

        long elapsed = System.currentTimeMillis() - now;
        LOGGER.info("elapsed time: " + elapsed + "ms");

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

        Assert.assertEquals(ProviderStatus.AVAILABLE, providerInfo.getStatus());
        Assert.assertEquals(200, providerInfo.getWeight());
    }
@author <a href="mailto:lw111072@antfin.com">LiWei.Liangen</a>
registry/registry-zk/src/test/java/com/alipay/sofa/rpc/registry/zk/ZookeeperRegistryHelperTest.java