summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorefiacor <fiachra.corcoran@est.tech>2022-11-24 15:54:58 +0000
committerefiacor <fiachra.corcoran@est.tech>2022-11-25 09:33:31 +0000
commit45fe8aec27a65fb4ce38bd71698b1dc2db904aa4 (patch)
tree2ea0cde2e93d78b0c06db42b922d3150cb7c247d
parent89701dc6483800daef21eac3feafd4f74553f238 (diff)
[DMAAP-MR] Set topic replica & partition from config1.4.4
Signed-off-by: efiacor <fiachra.corcoran@est.tech> Change-Id: Ie672075ca65ad4f24f0b163cd84d31c373e331c8 Issue-ID: DMAAP-1842
-rwxr-xr-xcsit/prepare-csit.sh10
-rwxr-xr-xcsit/run-csit.sh4
-rw-r--r--src/main/java/org/onap/dmaap/dmf/mr/service/impl/TopicServiceImpl.java17
-rw-r--r--src/test/java/org/onap/dmaap/dmf/mr/service/impl/TopicServiceImplTest.java53
4 files changed, 26 insertions, 58 deletions
diff --git a/csit/prepare-csit.sh b/csit/prepare-csit.sh
index a65368c..65c8351 100755
--- a/csit/prepare-csit.sh
+++ b/csit/prepare-csit.sh
@@ -24,15 +24,15 @@ fi
TESTPLANDIR=${WORKSPACE}/${TESTPLAN}
-# Assume that if ROBOT_VENV is set and virtualenv with system site packages can be activated,
+# Assume that if ROBOT3_VENV is set and virtualenv with system site packages can be activated,
# ci-management/jjb/integration/include-raw-integration-install-robotframework.sh has already
# been executed
if [ -f ${WORKSPACE}/env.properties ]; then
source ${WORKSPACE}/env.properties
fi
-if [ -f ${ROBOT_VENV}/bin/activate ]; then
- source ${ROBOT_VENV}/bin/activate
+if [ -f ${ROBOT3_VENV}/bin/activate ]; then
+ source ${ROBOT3_VENV}/bin/activate
else
rm -rf /tmp/ci-management
rm -f ${WORKSPACE}/env.properties
@@ -42,8 +42,8 @@ else
fi
# install eteutils
-mkdir -p ${ROBOT_VENV}/src/onap
-rm -rf ${ROBOT_VENV}/src/onap/testsuite
+mkdir -p ${ROBOT3_VENV}/src/onap
+rm -rf ${ROBOT3_VENV}/src/onap/testsuite
pip install --upgrade --extra-index-url="https://nexus3.onap.org/repository/PyPi.staging/simple" 'robotframework-onap==0.5.1.*' --pre
pip freeze
diff --git a/csit/run-csit.sh b/csit/run-csit.sh
index b987e60..038c55c 100755
--- a/csit/run-csit.sh
+++ b/csit/run-csit.sh
@@ -154,13 +154,13 @@ TESTPLANDIR="${WORKSPACE}/${TESTPLAN}"
source_safely "${WORKSPACE}/prepare-csit.sh"
# Activate the virtualenv containing all the required libraries installed by prepare-csit.sh
-source_safely "${ROBOT_VENV}/bin/activate"
+source_safely "${ROBOT3_VENV}/bin/activate"
WORKDIR=$(mktemp -d --suffix=-robot-workdir)
cd "${WORKDIR}"
# Add csit scripts to PATH
-export PATH="${PATH}:${WORKSPACE}/docker/scripts:${WORKSPACE}/scripts:${ROBOT_VENV}/bin"
+export PATH="${PATH}:${WORKSPACE}/docker/scripts:${WORKSPACE}/scripts:${ROBOT3_VENV}/bin"
export SCRIPTS="${WORKSPACE}/scripts"
export ROBOT_VARIABLES=
diff --git a/src/main/java/org/onap/dmaap/dmf/mr/service/impl/TopicServiceImpl.java b/src/main/java/org/onap/dmaap/dmf/mr/service/impl/TopicServiceImpl.java
index 386fb97..69c1414 100644
--- a/src/main/java/org/onap/dmaap/dmf/mr/service/impl/TopicServiceImpl.java
+++ b/src/main/java/org/onap/dmaap/dmf/mr/service/impl/TopicServiceImpl.java
@@ -198,8 +198,9 @@ public class TopicServiceImpl implements TopicService {
LOGGER.info("Creating topic {}",topicName);
String key = authorizeClient(dmaapContext, topicName, TOPIC_CREATE_OP);
try {
- final int partitions = getValueOrDefault(topicBean.getPartitionCount(), "default.partitions");
- final int replicas = getValueOrDefault(topicBean.getReplicationCount(), "default.replicas");
+ final int partitions = getIntValueOrDefault("default.partitions");
+ final int replicas = getIntValueOrDefault("default.replicas");
+ LOGGER.info("Attempting to create topic {} with replicas={}, partitions={}", topicName, replicas, partitions);
final Topic t = getMetaBroker(dmaapContext).createTopic(topicName, topicBean.getTopicDescription(),
key, partitions, replicas, topicBean.isTransactionEnabled());
LOGGER.info("Topic {} created successfully. Sending response", topicName);
@@ -258,13 +259,11 @@ public class TopicServiceImpl implements TopicService {
return enfTopicNamespace != null && topicName.startsWith(enfTopicNamespace);
}
- int getValueOrDefault(int value, String defaultProperty) {
- int returnValue = value;
- if (returnValue <= 0) {
- String defaultValue = getPropertyFromAJSCmap(defaultProperty);
- returnValue = StringUtils.isNotEmpty(defaultValue) ? NumberUtils.toInt(defaultValue) : 1;
- returnValue = (returnValue <= 0) ? 1 : returnValue;
- }
+ int getIntValueOrDefault(String defaultProperty) {
+ int returnValue;
+ String defaultValue = getPropertyFromAJSCmap(defaultProperty);
+ returnValue = StringUtils.isNotEmpty(defaultValue) ? NumberUtils.toInt(defaultValue) : 1;
+ returnValue = (returnValue <= 0) ? 1 : returnValue;
return returnValue;
}
diff --git a/src/test/java/org/onap/dmaap/dmf/mr/service/impl/TopicServiceImplTest.java b/src/test/java/org/onap/dmaap/dmf/mr/service/impl/TopicServiceImplTest.java
index 4424aa9..90c379e 100644
--- a/src/test/java/org/onap/dmaap/dmf/mr/service/impl/TopicServiceImplTest.java
+++ b/src/test/java/org/onap/dmaap/dmf/mr/service/impl/TopicServiceImplTest.java
@@ -290,73 +290,42 @@ public class TopicServiceImplTest {
}
@Test
- public void getValueOrDefault_shouldParseDeafultAndReturnIt_whenGivenValueIsZero() {
+ public void getIntValueOrDefault_shouldReturnOne_whenDefaultNotProvided() {
//given
- int value = 0;
String defaultPropertyName = "propertyName";
- when(topicService.getPropertyFromAJSCmap(defaultPropertyName)).thenReturn("6");
-
- //when
- int extracted = topicService.getValueOrDefault(value, defaultPropertyName);
-
- //then
- assertEquals(6, extracted);
- }
-
- @Test
- public void getValueOrDefault_shouldReturnGivenValue_whenGreaterThanZero() {
- //given
- int value = 3;
- String defaultPropertyName = "propertyName";
-
- //when
- int extracted = topicService.getValueOrDefault(value, defaultPropertyName);
-
- //then
- assertEquals(value, extracted);
- verify(topicService, never()).getPropertyFromAJSCmap(defaultPropertyName);
- }
-
- @Test
- public void getValueOrDefault_shouldParseDeafultAndReturnIt_whenGivenValueIsNegative() {
- //given
- int value = -3;
- String defaultPropertyName = "propertyName";
- when(topicService.getPropertyFromAJSCmap(defaultPropertyName)).thenReturn("6");
+ when(topicService.getPropertyFromAJSCmap(defaultPropertyName)).thenReturn("");
//when
- int extracted = topicService.getValueOrDefault(value, defaultPropertyName);
+ int extracted = topicService.getIntValueOrDefault(defaultPropertyName);
//then
- assertEquals(6, extracted);
+ assertEquals(1, extracted);
}
@Test
- public void getValueOrDefault_shouldReturnOne_whenGivenValueIsZero_andDefaultNotProvided() {
+ public void getIntValueOrDefault_shouldReturnOne_whenValueIsNegative() {
//given
- int value = 0;
String defaultPropertyName = "propertyName";
- when(topicService.getPropertyFromAJSCmap(defaultPropertyName)).thenReturn("");
+ when(topicService.getPropertyFromAJSCmap(defaultPropertyName)).thenReturn("-1");
//when
- int extracted = topicService.getValueOrDefault(value, defaultPropertyName);
+ int extracted = topicService.getIntValueOrDefault(defaultPropertyName);
//then
assertEquals(1, extracted);
}
@Test
- public void getValueOrDefault_shouldReturnOne_whenGivenValueIsZero_andDefaultNaN() {
+ public void getIntValueOrDefault_shouldParseDefaultAndReturnIt_whenGivenValueIsPositive() {
//given
- int value = 0;
String defaultPropertyName = "propertyName";
- when(topicService.getPropertyFromAJSCmap(defaultPropertyName)).thenReturn("a");
+ when(topicService.getPropertyFromAJSCmap(defaultPropertyName)).thenReturn("3");
//when
- int extracted = topicService.getValueOrDefault(value, defaultPropertyName);
+ int extracted = topicService.getIntValueOrDefault(defaultPropertyName);
//then
- assertEquals(1, extracted);
+ assertEquals(3, extracted);
}
@Test(expected = TopicExistsException.class)