Skip to content

Commit

Permalink
Merge branch 'main' into feat/coverage-ext
Browse files Browse the repository at this point in the history
# Conflicts:
#	pom.xml
  • Loading branch information
QizhengMo committed Sep 19, 2024
2 parents f772d04 + e2bd5dc commit b972af3
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,18 @@
import com.arextest.storage.model.Constants;
import com.arextest.storage.repository.ProviderNames;
import com.arextest.storage.repository.RepositoryProvider;
import com.arextest.storage.utils.TimeUtils;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ArrayUtils;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.core.query.Update;

/**
* The rolling provider used by default, which means auto deleted the records after TTL index
Expand Down Expand Up @@ -83,10 +80,6 @@ public Iterable<AREXQueryMocker> queryRecordList(MockCategoryType categoryType,
public Iterable<AREXQueryMocker> queryRecordList(MockCategoryType category, String recordId, String[] fieldNames) {
Criteria criteria = buildRecordIdFilter(category, recordId);

if (Objects.equals(this.providerName, ProviderNames.DEFAULT)) {
updateExpirationTime(criteria, getCollectionName(category));
}

Query query = new Query(criteria);
if (ArrayUtils.isNotEmpty(fieldNames)) {
String[] mappedFieldNames = Arrays.stream(fieldNames)
Expand All @@ -101,27 +94,6 @@ public Iterable<AREXQueryMocker> queryRecordList(MockCategoryType category, Stri
return new AttachmentCategoryIterable(category, iterable);
}

private void updateExpirationTime(Criteria criteria, String collectionName) {
long currentTimeMillis = System.currentTimeMillis();
long allowedLastMills = TimeUtils.getTodayFirstMills() +
properties.getAllowReRunDays() * TimeUtils.ONE_DAY;

Criteria finalCriteria = new Criteria().andOperator(
criteria,
new Criteria().orOperator(
Criteria.where(AbstractMocker.Fields.expirationTime).lt(new Date(allowedLastMills)),
Criteria.where(AbstractMocker.Fields.expirationTime).exists(false)
)
);

// Add different minutes to avoid the same expiration time
Update update = new Update();
update.set(AbstractMocker.Fields.expirationTime,
new Date(allowedLastMills + currentTimeMillis % TimeUtils.ONE_HOUR));
update.set(AbstractMocker.Fields.updateTime, new Date(currentTimeMillis));
mongoTemplate.updateMulti(new Query(finalCriteria), update, collectionName);
}

private Criteria buildRecordIdFilter(MockCategoryType categoryType, String value) {
if (categoryType.isEntryPoint()) {
return Criteria.where(AbstractMocker.Fields.id).is(value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public List<ListResultHolder> queryReplayResult(String recordId, String replayRe
List<ListResultHolder> resultHolderList = new ArrayList<>(categoryTypes.size());
ListResultHolder listResultHolder;
for (MockCategoryType categoryType : categoryTypes) {
if (categoryType.isSkipComparison()) {
if (categoryType.isSkipComparison() && MockCategoryType.Q_MESSAGE_CONSUMER != categoryType) {
continue;
}
MDCTracer.addCategory(categoryType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,10 @@ private boolean getFromCompareRelation(String replayId) {
}

private boolean compareVersion(String replayAgentVersion) {
if (StringUtils.isEmpty(replayAgentVersion)) {
return false;
}

String agentVersion = applicationDefaultConfig.getConfigAsString(Constants.AGENT_VERSION, null);
if (StringUtils.isEmpty(agentVersion)) {
return false;
Expand Down
4 changes: 4 additions & 0 deletions arex-storage-web-api/src/main/resources/log4j2-dev.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
</Appenders>

<Loggers>
<Logger level="WARN" name="org.springframework.data.mongodb.core.convert.QueryMapper">
<AppenderRef ref="Mongo4"/>
<AppenderRef ref="Prometheus"/>
</Logger>
<Logger level="INFO" name="com.arextest">
<AppenderRef ref="Mongo4"/>
</Logger>
Expand Down
4 changes: 4 additions & 0 deletions arex-storage-web-api/src/main/resources/log4j2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
</Appenders>

<Loggers>
<Logger level="WARN" name="org.springframework.data.mongodb.core.convert.QueryMapper">
<AppenderRef ref="Mongo4"/>
<AppenderRef ref="Prometheus"/>
</Logger>
<Logger level="INFO" name="com.arextest.storage">
<AppenderRef ref="Mongo4"/>
<AppenderRef ref="Prometheus"/>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@
</profiles>

<properties>
<revision>1.3.3</revision>
<revision>1.3.5</revision>
<commons-lang3.version>3.3.2</commons-lang3.version>
<java.version>1.8</java.version>

Expand Down

0 comments on commit b972af3

Please sign in to comment.