-
Notifications
You must be signed in to change notification settings - Fork 210
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support complex domain host for datasource
- Loading branch information
1 parent
8d5a17d
commit ceeb300
Showing
7 changed files
with
140 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ | |
package com.qlangtech.tis.db.parser; | ||
|
||
import com.qlangtech.tis.common.utils.Assert; | ||
import com.qlangtech.tis.db.parser.ScannerPatterns.TokenTypes; | ||
import com.qlangtech.tis.plugin.ds.DBConfig; | ||
import junit.framework.TestCase; | ||
import org.apache.commons.collections.MapUtils; | ||
|
@@ -29,6 +30,8 @@ | |
import java.text.DecimalFormat; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.regex.Matcher; | ||
import java.util.regex.Pattern; | ||
|
||
/** | ||
* @author 百岁([email protected]) | ||
|
@@ -45,8 +48,25 @@ public void testJustParseDBHost() throws Exception { | |
validateDbEnum(dbName, dbEnum); | ||
} | ||
|
||
public void testK8SReplicaSetDomain() { | ||
String mysqlHost = "mysql-0.mysql-svc.default"; | ||
String dbName = "dbname"; | ||
Pattern hostPattern = TokenTypes.TT_HOST.createPattern(); | ||
Matcher matcher = hostPattern.matcher(mysqlHost); | ||
Assert.assertTrue(String.valueOf(hostPattern), matcher.matches()); | ||
|
||
Map<String, List<String>> dbname = DBConfigParser.parseDBEnum(dbName, mysqlHost); | ||
Assert.assertEquals(1, dbname.size()); | ||
List<String> dbs = dbname.get(mysqlHost); | ||
Assert.assertEquals(1, dbs.size()); | ||
Assert.assertTrue(dbs.contains(dbName)); | ||
} | ||
|
||
public void testParserErrorDBNodeDesc() throws Exception { | ||
Map<String, List<String>> dbname = DBConfigParser.parseDBEnum("dbname", "192.168.28。200"); | ||
|
||
TokenTypes.TT_IP.createPattern(); | ||
|
||
Assert.assertNotNull(dbname); | ||
Assert.assertTrue("dbname shall be empty", MapUtils.isEmpty(dbname)); | ||
} | ||
|