Skip to content

Commit

Permalink
feature:expands grayscale publishing capabilities to support dimensio…
Browse files Browse the repository at this point in the history
…ns other than IP

fix apolloconfig#2932
  • Loading branch information
zcy1010 committed Oct 6, 2021
1 parent e7bcac9 commit 6e98ec6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ public class ConfigFileControllerIntegrationTest extends AbstractBaseIntegration
private String someDC;
private String someDefaultCluster;
private String grayClientIp;
private String grayClientLabel;
private String nonGrayClientIp;
private String nonGrayClientLabel;
private static final Gson GSON = new Gson();
private ExecutorService executorService;
private Type mapResponseType = new TypeToken<Map<String, String>>(){}.getType();
Expand All @@ -78,7 +80,9 @@ public void setUp() throws Exception {
somePublicNamespace = "somePublicNamespace";
someDC = "someDC";
grayClientIp = "1.1.1.1";
grayClientLabel = "myLabel";
nonGrayClientIp = "2.2.2.2";
nonGrayClientLabel = "appLabel";
executorService = Executors.newFixedThreadPool(1);
}

Expand Down Expand Up @@ -112,13 +116,13 @@ public void testQueryConfigAsPropertiesWithGrayRelease() throws Exception {

ResponseEntity<String> response =
restTemplate
.getForEntity("http://{baseurl}/configfiles/{appId}/{clusterName}/{namespace}?ip={clientIp}", String.class,
getHostUrl(), someAppId, someDefaultCluster, ConfigConsts.NAMESPACE_APPLICATION, grayClientIp);
.getForEntity("http://{baseurl}/configfiles/{appId}/{clusterName}/{namespace}?ip={clientIp}&label={clientLabel}", String.class,
getHostUrl(), someAppId, someDefaultCluster, ConfigConsts.NAMESPACE_APPLICATION, grayClientIp, grayClientLabel);

ResponseEntity<String> anotherResponse =
restTemplate
.getForEntity("http://{baseurl}/configfiles/{appId}/{clusterName}/{namespace}?ip={clientIp}", String.class,
getHostUrl(), someAppId, someDefaultCluster, ConfigConsts.NAMESPACE_APPLICATION, nonGrayClientIp);
.getForEntity("http://{baseurl}/configfiles/{appId}/{clusterName}/{namespace}?ip={clientIp}&label={clientLabel}", String.class,
getHostUrl(), someAppId, someDefaultCluster, ConfigConsts.NAMESPACE_APPLICATION, nonGrayClientIp, nonGrayClientLabel);

String result = response.getBody();
String anotherResult = anotherResponse.getBody();
Expand Down Expand Up @@ -235,16 +239,16 @@ public void testQueryPublicConfigAsJsonWithGrayRelease() throws Exception {
ResponseEntity<String> response =
restTemplate
.getForEntity(
"http://{baseurl}/configfiles/json/{appId}/{clusterName}/{namespace}?ip={clientIp}",
"http://{baseurl}/configfiles/json/{appId}/{clusterName}/{namespace}?ip={clientIp}&label={clientLabel}",
String.class,
getHostUrl(), someAppId, someDefaultCluster, somePublicNamespace, grayClientIp);
getHostUrl(), someAppId, someDefaultCluster, somePublicNamespace, grayClientIp, grayClientLabel);

ResponseEntity<String> anotherResponse =
restTemplate
.getForEntity(
"http://{baseurl}/configfiles/json/{appId}/{clusterName}/{namespace}?ip={clientIp}",
"http://{baseurl}/configfiles/json/{appId}/{clusterName}/{namespace}?ip={clientIp}&label={clientLabel}",
String.class,
getHostUrl(), someAppId, someDefaultCluster, somePublicNamespace, nonGrayClientIp);
getHostUrl(), someAppId, someDefaultCluster, somePublicNamespace, nonGrayClientIp, nonGrayClientLabel);

Map<String, String> configs = GSON.fromJson(response.getBody(), mapResponseType);
Map<String, String> anotherConfigs = GSON.fromJson(anotherResponse.getBody(), mapResponseType);
Expand Down Expand Up @@ -276,16 +280,16 @@ public void testQueryPublicConfigAsJsonWithGrayReleaseAndIncorrectCase() throws
ResponseEntity<String> response =
restTemplate
.getForEntity(
"http://{baseurl}/configfiles/json/{appId}/{clusterName}/{namespace}?ip={clientIp}",
"http://{baseurl}/configfiles/json/{appId}/{clusterName}/{namespace}?ip={clientIp}&label={clientLabel}",
String.class,
getHostUrl(), someAppId, someDefaultCluster, somePublicNamespace.toUpperCase(), grayClientIp);
getHostUrl(), someAppId, someDefaultCluster, somePublicNamespace.toUpperCase(), grayClientIp, grayClientLabel);

ResponseEntity<String> anotherResponse =
restTemplate
.getForEntity(
"http://{baseurl}/configfiles/json/{appId}/{clusterName}/{namespace}?ip={clientIp}",
"http://{baseurl}/configfiles/json/{appId}/{clusterName}/{namespace}?ip={clientIp}&label={clientLabel}",
String.class,
getHostUrl(), someAppId, someDefaultCluster, somePublicNamespace.toUpperCase(), nonGrayClientIp);
getHostUrl(), someAppId, someDefaultCluster, somePublicNamespace.toUpperCase(), nonGrayClientIp, nonGrayClientLabel);

Map<String, String> configs = GSON.fromJson(response.getBody(), mapResponseType);
Map<String, String> anotherConfigs = GSON.fromJson(anotherResponse.getBody(), mapResponseType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
--
INSERT INTO GrayReleaseRule (`Id`, `AppId`, `ClusterName`, `NamespaceName`, `BranchName`, `Rules`, `ReleaseId`, `BranchStatus`)
VALUES
(1, 'someAppId', 'default', 'application', 'gray-branch-1', '[{"clientAppId":"someAppId","clientIpList":["1.1.1.1"]}]', 986, 1);
(1, 'someAppId', 'default', 'application', 'gray-branch-1', '[{"clientAppId":"someAppId","clientIpList":["1.1.1.1"],"clientLabelList":["myLabel"]}]', 986, 1);
INSERT INTO GrayReleaseRule (`Id`, `AppId`, `ClusterName`, `NamespaceName`, `BranchName`, `Rules`, `ReleaseId`, `BranchStatus`)
VALUES
(2, 'somePublicAppId', 'default', 'somePublicNamespace', 'gray-branch-2', '[{"clientAppId":"someAppId","clientIpList":["1.1.1.1"]}]', 985, 1);
(2, 'somePublicAppId', 'default', 'somePublicNamespace', 'gray-branch-2', '[{"clientAppId":"someAppId","clientIpList":["1.1.1.1"],"clientLabelList":["myLabel"]}]', 985, 1);

0 comments on commit 6e98ec6

Please sign in to comment.