public Upstream choose(final String serviceId, final String selectorId,
                           final String ip, final String loadbalancer) {
        // load service instance by serviceId
        List<ServiceInstance> available = this.getServiceInstance(serviceId);
        if (CollectionUtils.isEmpty(available)) {
            LOG.info("choose return 1");
            return null;
        }
        final SpringCloudSelectorHandle springCloudSelectorHandle = SpringCloudPluginDataHandler.SELECTOR_CACHED.get().obtainHandle(selectorId);
        // not gray flow
        if (!springCloudSelectorHandle.getGray()) {
            // load service from register center
            return this.doSelect(serviceId, ip, loadbalancer);
        }
        List<Upstream> divideUpstreams = UpstreamCacheManager.getInstance().findUpstreamListBySelectorId(selectorId);
        // gray flow,but upstream is null
        if (CollectionUtils.isEmpty(divideUpstreams)) {
            return this.doSelect(serviceId, ip, loadbalancer);
        }
        // select server from available to choose
        final List<Upstream> choose = new ArrayList<>(available.size());
        for (ServiceInstance serviceInstance : available) {
            divideUpstreams.stream()
                    .filter(Upstream::isStatus)
                    .filter(upstream -> Objects.equals(upstream.getUrl(), serviceInstance.getUri().getRawAuthority()))
                    .findFirst().ifPresent(choose::add);
        }
        if (CollectionUtils.isEmpty(choose)) {
            return this.doSelect(serviceId, ip, loadbalancer);
        }
        // select by divideUpstreams
        return this.doSelect(choose, loadbalancer, ip);
    }
@Test
    public void testLoadBalancer() {
        final List<DefaultServiceInstance> serviceInstances = new ArrayList<>();
        DefaultServiceInstance defaultServiceInstance = new DefaultServiceInstance();
        defaultServiceInstance.setServiceId("serviceId");
        defaultServiceInstance.setUri(URI.create("http://localhost:8081"));
        defaultServiceInstance.setInstanceId("serviceId");
        defaultServiceInstance.setPort(8081);
        defaultServiceInstance.setHost("localhost");

        DefaultServiceInstance defaultServiceInstance2 = new DefaultServiceInstance();
        defaultServiceInstance2.setServiceId("serviceId");
        defaultServiceInstance2.setUri(URI.create("http://localhost:8080"));
        defaultServiceInstance2.setInstanceId("serviceId");
        defaultServiceInstance2.setPort(8080);
        defaultServiceInstance2.setHost("localhost");
        serviceInstances.add(defaultServiceInstance);
        serviceInstances.add(defaultServiceInstance2);

        SimpleDiscoveryProperties simpleDiscoveryProperties = new SimpleDiscoveryProperties();
        Map<String, List<DefaultServiceInstance>> serviceInstanceMap = new HashMap<>();
        serviceInstanceMap.put(defaultServiceInstance.getInstanceId(), serviceInstances);
        simpleDiscoveryProperties.setInstances(serviceInstanceMap);
        final SimpleDiscoveryClient simpleDiscoveryClient = new SimpleDiscoveryClient(simpleDiscoveryProperties);
        final ShenyuSpringCloudServiceChooser shenyuServiceChoose = new ShenyuSpringCloudServiceChooser(simpleDiscoveryClient);

        final String ip = "0.0.0.0";
        final String selectorId = "1";
        final String loadbalancer = "roundRobin";
        final SpringCloudSelectorHandle springCloudSelectorHandle = SpringCloudSelectorHandle.builder()
                .serviceId("serviceId")
                .gray(false)
                .build();
        final SelectorData selectorData = SelectorData.builder()
                .handle(GsonUtils.getInstance().toJson(springCloudSelectorHandle))
                .id("1")
                .build();
        springCloudPluginDataHandler.handlerSelector(selectorData);
        Upstream upstream1 = shenyuServiceChoose.choose("serviceId", selectorId, ip, loadbalancer);
        Upstream upstream2 = shenyuServiceChoose.choose("serviceId", selectorId, ip, loadbalancer);
        // if roundRobin, upstream1 not equals upstream2
        Assertions.assertNotEquals(upstream1, upstream2);
    }