sukumaar commented on a change in pull request #5614:
URL: https://github.com/apache/shardingsphere/pull/5614#discussion_r428700878
##########
File path:
sharding-orchestration/sharding-orchestration-core/sharding-orchestration-core-configcenter/src/test/java/org/apache/shardingsphere/orchestration/core/configcenter/ConfigCenterTest.java
##########
@@ -552,4 +465,13 @@ private void
assertDataSourceConfigurationWithConnectionInitSqls(final DataSourc
assertThat(actual.getProperties().get("password"),
is(expected.getProperties().get("password")));
assertThat(actual.getProperties().get("connectionInitSqls"),
is(expected.getProperties().get("connectionInitSqls")));
}
+
+ private static String readYamlFileIntoString(final String fileName) {
+ try {
+ return (new
String(Files.readAllBytes(Paths.get(ClassLoader.getSystemResource(fileName).toURI())))).replaceAll("#.*\n",
"");
Review comment:
Hey I referred to the PR you had asked me to refer.
if I use
```
@SneakyThrows
private String readYAML(final String yamlFile) {
return
Files.readAllLines(Paths.get(ClassLoader.getSystemResource(yamlFile).toURI())).stream().map(each
-> each + System.lineSeparator()).collect(Collectors.joining());
}
```
or
```
@SneakyThrows
private static String readYamlFileIntoString(final String fileName) {
return new
String(Files.readAllBytes(Paths.get(ClassLoader.getSystemResource(fileName).toURI())));
}
```
then getting this error:
```
Argument(s) are different! Wanted:
configCenterRepository.persist(
"/test/config/schema/sharding_db/rule",
"#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
rules:
-
!!org.apache.shardingsphere.sharding.yaml.config.YamlShardingRuleConfiguration
tables:
t_order:
actualDataNodes: ds_${0..1}.t_order_${0..1}
logicTable: t_order
tableStrategy:
standard:
shardingAlgorithm:
props:
algorithm.expression: t_order_${order_id % 2}
type: INLINE
shardingColumn: order_id
"
);
-> at
org.apache.shardingsphere.orchestration.core.configcenter.ConfigCenterTest.assertPersistConfigurationForShardingRuleWithoutAuthenticationAndIsOverwrite(ConfigCenterTest.java:144)
Actual invocation has different arguments:
configCenterRepository.persist(
"/test/config/schema/sharding_db/rule",
"rules:
-
!!org.apache.shardingsphere.sharding.yaml.config.YamlShardingRuleConfiguration
tables:
t_order:
actualDataNodes: ds_${0..1}.t_order_${0..1}
logicTable: t_order
tableStrategy:
standard:
shardingAlgorithm:
props:
algorithm.expression: t_order_${order_id % 2}
type: INLINE
shardingColumn: order_id
"
);
```
I guess configCenterRepository.persist("someFilePath","some YAML string") is
expecting YAML string without Licence comments.
that is why I earlier used:
```
"some yaml string".replaceAll("#.*\n", "")
```
but you have pointed out to use snake YAML instead of the above code.
And when I use snake YAML then I am getting an error which I have mentioned
in the previous comment
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]