public static void batchCheckInstanceIsLegal(List<Instance> instances) throws NacosException {
        Set<Instance> newInstanceSet = new HashSet<>(instances);
        for (Instance instance : newInstanceSet) {
            checkInstanceIsEphemeral(instance);
            checkInstanceIsLegal(instance);
        }
    }
@Test
    void testBatchCheckInstanceIsLegal() throws NacosException {
        // check invalid clusterName
        Instance instance = new Instance();
        instance.setClusterName("cluster1,cluster2");
        List<Instance> instanceList = new ArrayList<>();
        instanceList.add(instance);
        try {
            NamingUtils.batchCheckInstanceIsLegal(instanceList);
            assertTrue(false);
        } catch (Exception e) {
            assertTrue(e instanceof NacosException);
            assertEquals(
                    "Instance 'clusterName' should be characters with only 0-9a-zA-Z-. (current: cluster1,cluster2)",
                    e.getMessage());
        }
        instanceList.remove(instance);
        
        // TODO valid clusterName
        instance.setClusterName("cluster1");
        instanceList.add(instance);
        NamingUtils.batchCheckInstanceIsLegal(instanceList);
        assertTrue(true);
        
        instanceList.remove(instance);
        
        // check heartBeatTimeout, heartBeatInterval, ipDeleteTimeout
        Map<String, String> meta = new HashMap<>();
        meta.put(PreservedMetadataKeys.HEART_BEAT_TIMEOUT, "1");
        meta.put(PreservedMetadataKeys.HEART_BEAT_INTERVAL, "2");
        meta.put(PreservedMetadataKeys.IP_DELETE_TIMEOUT, "1");
        instance.setMetadata(meta);
        instanceList.add(instance);
        try {
            NamingUtils.batchCheckInstanceIsLegal(instanceList);
            assertTrue(false);
        } catch (Exception e) {
            assertTrue(e instanceof NacosException);
            assertEquals("Instance 'heart beat interval' must less than 'heart beat timeout' and 'ip delete timeout'.",
                    e.getMessage());
        }
        instanceList.remove(instance);
        
        meta.put(PreservedMetadataKeys.HEART_BEAT_TIMEOUT, "3");
        meta.put(PreservedMetadataKeys.HEART_BEAT_INTERVAL, "2");
        meta.put(PreservedMetadataKeys.IP_DELETE_TIMEOUT, "3");
        instance.setMetadata(meta);
        instanceList.add(instance);
        NamingUtils.batchCheckInstanceIsLegal(instanceList);
        assertTrue(true);
    }