forked from strimzi/strimzi-kafka-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ST: Check that messages are not available in local storage when tiere…
…d storage is used (strimzi#10351) Signed-off-by: Jakub Stejskal <xstejs24@gmail.com>
- Loading branch information
Showing
6 changed files
with
184 additions
and
53 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
90 changes: 90 additions & 0 deletions
90
systemtest/src/main/java/io/strimzi/systemtest/utils/specific/MinioUtils.java
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 |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/* | ||
* Copyright Strimzi authors. | ||
* License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html). | ||
*/ | ||
package io.strimzi.systemtest.utils.specific; | ||
|
||
import io.strimzi.systemtest.TestConstants; | ||
import io.strimzi.systemtest.resources.ResourceManager; | ||
import io.strimzi.systemtest.resources.minio.SetupMinio; | ||
import io.strimzi.test.TestUtils; | ||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
|
||
import java.util.Map; | ||
import java.util.regex.Matcher; | ||
import java.util.regex.Pattern; | ||
|
||
public class MinioUtils { | ||
private static final Logger LOGGER = LogManager.getLogger(SetupMinio.class); | ||
|
||
private MinioUtils() { | ||
|
||
} | ||
|
||
/** | ||
* Collect data from Minio about usage of a specific bucket | ||
* @param namespace | ||
* @param bucketName | ||
* @return Overall statistics about the bucket in String format | ||
*/ | ||
public static String getBucketSizeInfo(String namespace, String bucketName) { | ||
final String minioPod = ResourceManager.kubeClient().listPods(namespace, Map.of(TestConstants.APP_POD_LABEL, SetupMinio.MINIO)).get(0).getMetadata().getName(); | ||
|
||
return ResourceManager.cmdKubeClient().namespace(namespace).execInPod(minioPod, | ||
"mc", | ||
"stat", | ||
"local/" + bucketName).out(); | ||
|
||
} | ||
|
||
/** | ||
* Parse out total size of bucket from the information about usage. | ||
* @param bucketInfo String containing all stat info about bucket | ||
* @return Map consists of parsed size and it's unit | ||
*/ | ||
private static Map<String, Object> parseTotalSize(String bucketInfo) { | ||
Pattern pattern = Pattern.compile("Total size:\\s*(?<size>[\\d.]+)\\s*(?<unit>.*)"); | ||
Matcher matcher = pattern.matcher(bucketInfo); | ||
|
||
if (matcher.find()) { | ||
return Map.of("size", Double.parseDouble(matcher.group("size")), "unit", matcher.group("unit")); | ||
} else { | ||
throw new IllegalArgumentException("Total size not found in the provided string"); | ||
} | ||
} | ||
|
||
/** | ||
* Wait until size of the bucket is not 0 B. | ||
* @param namespace Minio location | ||
* @param bucketName bucket name | ||
*/ | ||
public static void waitForDataInMinio(String namespace, String bucketName) { | ||
TestUtils.waitFor("data sync from Kafka to Minio", TestConstants.GLOBAL_POLL_INTERVAL_MEDIUM, TestConstants.GLOBAL_TIMEOUT_LONG, () -> { | ||
String bucketSizeInfo = getBucketSizeInfo(namespace, bucketName); | ||
Map<String, Object> parsedSize = parseTotalSize(bucketSizeInfo); | ||
double bucketSize = (Double) parsedSize.get("size"); | ||
LOGGER.info("Collected bucket size: {} {}", bucketSize, parsedSize.get("unit")); | ||
LOGGER.debug("Collected bucket info:\n{}", bucketSizeInfo); | ||
|
||
return bucketSize > 0; | ||
}); | ||
} | ||
|
||
/** | ||
* Wait until size of the bucket is 0 B. | ||
* @param namespace Minio location | ||
* @param bucketName bucket name | ||
*/ | ||
public static void waitForNoDataInMinio(String namespace, String bucketName) { | ||
TestUtils.waitFor("data deletion in Minio", TestConstants.GLOBAL_POLL_INTERVAL_MEDIUM, TestConstants.GLOBAL_TIMEOUT_LONG, () -> { | ||
String bucketSizeInfo = getBucketSizeInfo(namespace, bucketName); | ||
Map<String, Object> parsedSize = parseTotalSize(bucketSizeInfo); | ||
double bucketSize = (Double) parsedSize.get("size"); | ||
LOGGER.info("Collected bucket size: {} {}", bucketSize, parsedSize.get("unit")); | ||
LOGGER.debug("Collected bucket info:\n{}", bucketSizeInfo); | ||
|
||
return bucketSize == 0; | ||
}); | ||
} | ||
} |
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