|
38 | 38 | import org.apache.doris.datasource.iceberg.IcebergExternalCatalog;
|
39 | 39 | import org.apache.doris.datasource.maxcompute.MaxComputeExternalCatalog;
|
40 | 40 | import org.apache.doris.datasource.property.constants.CosProperties;
|
| 41 | +import org.apache.doris.datasource.property.constants.DLFProperties; |
41 | 42 | import org.apache.doris.datasource.property.constants.GCSProperties;
|
| 43 | +import org.apache.doris.datasource.property.constants.GlueProperties; |
42 | 44 | import org.apache.doris.datasource.property.constants.HMSProperties;
|
43 | 45 | import org.apache.doris.datasource.property.constants.MinioProperties;
|
44 | 46 | import org.apache.doris.datasource.property.constants.ObsProperties;
|
@@ -677,4 +679,103 @@ public void testS3PropertiesConvertor() {
|
677 | 679 | Assertions.assertEquals("region", beProperties.get(S3Properties.Env.REGION));
|
678 | 680 | Assertions.assertEquals("false", beProperties.get(PropertyConverter.USE_PATH_STYLE));
|
679 | 681 | }
|
| 682 | + |
| 683 | + @Test |
| 684 | + public void testMetaPropertiesConvertor() { |
| 685 | + // test region parser |
| 686 | + Assertions.assertNull(S3Properties.getRegionOfEndpoint("http://192.168.2.30:9099/com.region.test/dir")); |
| 687 | + Assertions.assertEquals("cn-beijing", |
| 688 | + S3Properties.getRegionOfEndpoint("http://dlf.cn-beijing.aliyuncs.com/com.region.test/dir")); |
| 689 | + Assertions.assertEquals("oss-cn-beijing", |
| 690 | + S3Properties.getRegionOfEndpoint("http://oss-cn-beijing.aliyuncs.com/com.region.test/dir")); |
| 691 | + Assertions.assertEquals("us-east-1", |
| 692 | + S3Properties.getRegionOfEndpoint("http://s3.us-east-1.amazonaws.com/com.region.test/dir")); |
| 693 | + |
| 694 | + //1. dlf |
| 695 | + Map<String, String> props = new HashMap<>(); |
| 696 | + // iceberg.catalog.type |
| 697 | + props.put("type", "hms"); |
| 698 | + props.put("hive.metastore.type", "dlf"); |
| 699 | + props.put(DLFProperties.PROXY_MODE, "DLF_ONLY"); |
| 700 | + props.put(DLFProperties.ENDPOINT, "dlf.cn-beijing.aliyuncs.com"); |
| 701 | + props.put(DLFProperties.UID, "20239444"); |
| 702 | + props.put(DLFProperties.ACCESS_KEY, "akk"); |
| 703 | + props.put(DLFProperties.SECRET_KEY, "skk"); |
| 704 | + props.put(DLFProperties.REGION, "cn-beijing"); |
| 705 | + props.put(DLFProperties.ACCESS_PUBLIC, "false"); |
| 706 | + Map<String, String> res = PropertyConverter.convertToMetaProperties(new HashMap<>(props)); |
| 707 | + Assertions.assertEquals(25, res.size()); |
| 708 | + Assertions.assertEquals("akk", res.get(S3Properties.Env.ACCESS_KEY)); |
| 709 | + Assertions.assertEquals("skk", res.get(S3Properties.Env.SECRET_KEY)); |
| 710 | + Assertions.assertEquals("akk", res.get(DataLakeConfig.CATALOG_ACCESS_KEY_ID)); |
| 711 | + Assertions.assertEquals("skk", res.get(DataLakeConfig.CATALOG_ACCESS_KEY_SECRET)); |
| 712 | + Assertions.assertEquals("dlf.cn-beijing.aliyuncs.com", res.get(DataLakeConfig.CATALOG_ENDPOINT)); |
| 713 | + Assertions.assertEquals("oss-cn-beijing-internal.aliyuncs.com", res.get(S3Properties.Env.ENDPOINT)); |
| 714 | + Assertions.assertEquals("cn-beijing", res.get(DataLakeConfig.CATALOG_REGION_ID)); |
| 715 | + Assertions.assertEquals("oss-cn-beijing", res.get(S3Properties.Env.REGION)); |
| 716 | + |
| 717 | + props.put(DLFProperties.ACCESS_PUBLIC, "true"); |
| 718 | + res = PropertyConverter.convertToMetaProperties(new HashMap<>(props)); |
| 719 | + Assertions.assertEquals(25, res.size()); |
| 720 | + Assertions.assertEquals("oss-cn-beijing.aliyuncs.com", res.get(S3Properties.Env.ENDPOINT)); |
| 721 | + Assertions.assertEquals("oss-cn-beijing", res.get(S3Properties.Env.REGION)); |
| 722 | + |
| 723 | + props.put(OssProperties.OSS_HDFS_ENABLED, "true"); |
| 724 | + res = PropertyConverter.convertToMetaProperties(new HashMap<>(props)); |
| 725 | + Assertions.assertEquals(28, res.size()); |
| 726 | + Assertions.assertEquals("com.aliyun.jindodata.oss.JindoOssFileSystem", res.get("fs.oss.impl")); |
| 727 | + Assertions.assertEquals("com.aliyun.jindodata.oss.OSS", res.get("fs.AbstractFileSystem.oss.impl")); |
| 728 | + Assertions.assertEquals("false", res.get(DataLakeConfig.CATALOG_CREATE_DEFAULT_DB)); |
| 729 | + Assertions.assertEquals("cn-beijing", res.get(S3Properties.Env.REGION)); |
| 730 | + |
| 731 | + // 2. glue |
| 732 | + Map<String, String> props2 = new HashMap<>(); |
| 733 | + props2.put("hive.metastore.type", "glue"); |
| 734 | + props2.put("aws.glue.endpoint", "glue.us-east-1.amazonaws.com"); |
| 735 | + props2.put("aws.glue.access-key", "akk"); |
| 736 | + props2.put("aws.glue.secret-key", "skk"); |
| 737 | + props2.put("aws.region", "us-east-1"); |
| 738 | + res = PropertyConverter.convertToMetaProperties(props2); |
| 739 | + Assertions.assertEquals(16, res.size()); |
| 740 | + Assertions.assertEquals("akk", res.get(S3Properties.Env.ACCESS_KEY)); |
| 741 | + Assertions.assertEquals("skk", res.get(S3Properties.Env.SECRET_KEY)); |
| 742 | + Assertions.assertEquals("s3.us-east-1.amazonaws.com", res.get(S3Properties.Env.ENDPOINT)); |
| 743 | + Assertions.assertEquals("us-east-1", res.get(S3Properties.Env.REGION)); |
| 744 | + |
| 745 | + Map<String, String> props3 = new HashMap<>(); |
| 746 | + props3.put("hive.metastore.type", "glue"); |
| 747 | + props3.put(GlueProperties.ENDPOINT, "glue.us-east-1.amazonaws.com"); |
| 748 | + props3.put(GlueProperties.ACCESS_KEY, "akk"); |
| 749 | + props3.put(GlueProperties.SECRET_KEY, "skk"); |
| 750 | + res = PropertyConverter.convertToMetaProperties(props3); |
| 751 | + Assertions.assertEquals(16, res.size()); |
| 752 | + Assertions.assertEquals("akk", res.get(S3Properties.Env.ACCESS_KEY)); |
| 753 | + Assertions.assertEquals("skk", res.get(S3Properties.Env.SECRET_KEY)); |
| 754 | + Assertions.assertEquals("s3.us-east-1.amazonaws.com", res.get(S3Properties.Env.ENDPOINT)); |
| 755 | + Assertions.assertEquals("us-east-1", res.get(S3Properties.Env.REGION)); |
| 756 | + |
| 757 | + // 3. s3 env |
| 758 | + Map<String, String> props4 = new HashMap<>(); |
| 759 | + props4.put("hive.metastore.type", "hms"); |
| 760 | + props4.put(S3Properties.Env.ENDPOINT, "s3.us-west-2.amazonaws.com"); |
| 761 | + props4.put(S3Properties.Env.ACCESS_KEY, "akk"); |
| 762 | + props4.put(S3Properties.Env.SECRET_KEY, "skk"); |
| 763 | + res = PropertyConverter.convertToMetaProperties(new HashMap<>(props4)); |
| 764 | + Assertions.assertEquals(9, res.size()); |
| 765 | + Assertions.assertEquals("akk", res.get(S3Properties.Env.ACCESS_KEY)); |
| 766 | + Assertions.assertEquals("skk", res.get(S3Properties.Env.SECRET_KEY)); |
| 767 | + Assertions.assertEquals("s3.us-west-2.amazonaws.com", res.get(S3Properties.Env.ENDPOINT)); |
| 768 | + Assertions.assertEquals("us-west-2", res.get(S3Properties.Env.REGION)); |
| 769 | + |
| 770 | + props4.put(S3Properties.Env.ENDPOINT, "http://172.23.56.19:9033"); |
| 771 | + res = PropertyConverter.convertToMetaProperties(new HashMap<>(props4)); |
| 772 | + Assertions.assertEquals(9, res.size()); |
| 773 | + Assertions.assertEquals("http://172.23.56.19:9033", res.get(S3Properties.Env.ENDPOINT)); |
| 774 | + Assertions.assertEquals("us-east-1", res.get(S3Properties.Env.REGION)); |
| 775 | + |
| 776 | + props4.put(S3Properties.Env.REGION, "north"); |
| 777 | + res = PropertyConverter.convertToMetaProperties(new HashMap<>(props4)); |
| 778 | + Assertions.assertEquals(9, res.size()); |
| 779 | + Assertions.assertEquals("north", res.get(S3Properties.Env.REGION)); |
| 780 | + } |
680 | 781 | }
|
0 commit comments