@Override
    protected ServiceInstance doChoose(String serviceName, List<ServiceInstance> instances) {
        final int index = ThreadLocalRandom.current().nextInt(instances.size());
        return instances.get(index);
    }
@Test
    public void doChoose() {
        final RandomLoadbalancer randomLoadbalancer = new RandomLoadbalancer();
        int port1 = 9999;
        int port2 = 8888;
        String serviceName = "random";
        final List<ServiceInstance> serviceInstances = Arrays
                .asList(CommonUtils.buildInstance(serviceName, port1), CommonUtils.buildInstance(serviceName, port2));
        int lastPort = 0;
        int curPort;
        boolean isOver = false;
        for (int i = 0; i < 500; i++) {
            // Simulate whether there will be a contiguous port, and if it exists, it will take effect randomly
            final Optional<ServiceInstance> choose = randomLoadbalancer.choose(serviceName, serviceInstances);
            Assert.assertTrue(choose.isPresent());
            curPort = choose.get().getPort();
            if (curPort == lastPort) {
                isOver = true;
                break;
            }
            lastPort = curPort;
        }
        Assert.assertTrue(isOver);
    }