Compare commits
10 commits
7d6750151b
...
2b952d5bb2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2b952d5bb2 | ||
|
|
83d417c250 | ||
|
|
afffa7ec1f | ||
|
|
df52226861 | ||
|
|
5019a079ac | ||
|
|
8d6b8dfa2a | ||
|
|
a7596f1108 | ||
|
|
2d152ce12f | ||
|
|
71677e1d97 | ||
|
|
47c0d30604 |
7 changed files with 101 additions and 7 deletions
|
|
@ -17,7 +17,7 @@ preflight:
|
||||||
stage: preflight
|
stage: preflight
|
||||||
script:
|
script:
|
||||||
- pwd
|
- pwd
|
||||||
- git clone -b for_state_machine "http://gitlab-ci-token:$ACCESS_TOKEN@git.mfd.msk/mfd/clearing_test.git"
|
- git clone -b successful_set "http://gitlab-ci-token:$ACCESS_TOKEN@git.mfd.msk/mfd/clearing_test.git"
|
||||||
artifacts:
|
artifacts:
|
||||||
name: "$CI_COMMIT_REF_NAME"
|
name: "$CI_COMMIT_REF_NAME"
|
||||||
expire_in: 1 day
|
expire_in: 1 day
|
||||||
|
|
@ -63,8 +63,8 @@ test:
|
||||||
- ls -al
|
- ls -al
|
||||||
- docker run --rm -v clr_test_logs_volume:/logs alpine tar -C /logs -cf - . | tar -C artifacts/logs -xf -
|
- docker run --rm -v clr_test_logs_volume:/logs alpine tar -C /logs -cf - . | tar -C artifacts/logs -xf -
|
||||||
- ls -la artifacts/logs
|
- ls -la artifacts/logs
|
||||||
# - echo "Cleaning up log volume"
|
- echo "Cleaning up log volume"
|
||||||
# - docker volume rm clr_test_logs_volume
|
- docker volume rm clr_test_logs_volume
|
||||||
artifacts:
|
artifacts:
|
||||||
expire_in: 1 day
|
expire_in: 1 day
|
||||||
when: always
|
when: always
|
||||||
|
|
|
||||||
|
|
@ -183,9 +183,9 @@ public class PaymentInstructionOutboundService {
|
||||||
log.debug("PIClearingOutbondActionNewRequest.id={} a__f asset id={}",
|
log.debug("PIClearingOutbondActionNewRequest.id={} a__f asset id={}",
|
||||||
req.getId(),
|
req.getId(),
|
||||||
assets.map(AssetTrio::a__f).map(Registry::getId).orElse(null));
|
assets.map(AssetTrio::a__f).map(Registry::getId).orElse(null));
|
||||||
if (assets.isEmpty() || balanceChecker.insufficientBalance(assets.get().a__f(),
|
if (assets.isEmpty() || balanceChecker.insufficientBalance2(assets.get().a__f(),
|
||||||
tcr.getId(), //never null because validation
|
tcr.getId(), //never null because validation
|
||||||
accCred.getCurrency(),
|
currency,
|
||||||
amount)) {
|
amount)) {
|
||||||
pmt.setTransactionStatus(TransactionStatus.cher.getKey());
|
pmt.setTransactionStatus(TransactionStatus.cher.getKey());
|
||||||
pmt.setUpdated(now);
|
pmt.setUpdated(now);
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
import ru.clearing.classes.statics.data.misc.Currency;
|
||||||
import ru.clearing.classes.statics.data.registry.Registry;
|
import ru.clearing.classes.statics.data.registry.Registry;
|
||||||
import ru.clearing.classes.statics.data.security.CurrencyPairSecurity;
|
import ru.clearing.classes.statics.data.security.CurrencyPairSecurity;
|
||||||
import ru.clearing.classes.statics.data.security.Rates;
|
import ru.clearing.classes.statics.data.security.Rates;
|
||||||
|
|
@ -21,7 +22,9 @@ import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||||
import static ru.spcex.clearing.util.NumberUtils.safeCast;
|
import static ru.spcex.clearing.util.NumberUtils.safeCast;
|
||||||
import ru.spcex.platform.classes.base.SpcexObjectBase;
|
import ru.spcex.platform.classes.base.SpcexObjectBase;
|
||||||
import ru.spcex.platform.enumeration.RegistryStatus;
|
import ru.spcex.platform.enumeration.RegistryStatus;
|
||||||
|
import ru.spcex.platform.enumeration.RegistryTradingParams;
|
||||||
import static ru.spcex.platform.enumeration.RegistryTradingParams.OM_T;
|
import static ru.spcex.platform.enumeration.RegistryTradingParams.OM_T;
|
||||||
|
import static ru.spcex.platform.enumeration.RegistryTradingParams.TM_T;
|
||||||
import ru.spcex.platform.enumeration.WorkflowStatus;
|
import ru.spcex.platform.enumeration.WorkflowStatus;
|
||||||
import ru.spcex.platform.imdg.api.Imdg;
|
import ru.spcex.platform.imdg.api.Imdg;
|
||||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||||
|
|
@ -53,6 +56,73 @@ public class BalanceChecker {
|
||||||
this.balanceCheckOmts = settings.isBalanceCheckOmt();
|
this.balanceCheckOmts = settings.isBalanceCheckOmt();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean insufficientBalance2(Registry a__f,
|
||||||
|
Long tcrId,
|
||||||
|
Currency currency,
|
||||||
|
BigDecimal amount) {
|
||||||
|
if (!balanceCheckOmts || currency == null) {
|
||||||
|
if (currency == null) {
|
||||||
|
log.error("{}#id={}#balance={} check for amount {}; currency is null",
|
||||||
|
a__f.getRegistryCode(), a__f.getId(), a__f.getBalance(), amount);
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
log.info("{}#id={}#balance={}#currency={} check for amount {}; OM*T/TM*T checks disabled",
|
||||||
|
a__f.getRegistryCode(), a__f.getId(), a__f.getBalance(), currency.getCurrencyCode(), amount);
|
||||||
|
}
|
||||||
|
return safeBD(a__f.getBalance()).compareTo(safeBD(amount)) < 0;
|
||||||
|
}
|
||||||
|
log.info("{}#id={}#balance={}#currency={} check for amount {}; OM*T/TM*T checks enabled",
|
||||||
|
a__f.getRegistryCode(), a__f.getId(), a__f.getBalance(), currency.getCurrencyCode(), amount);
|
||||||
|
LocalDate today = LocalDate.now();
|
||||||
|
ImdgPredicateBuilder rgsPb = rgsImdg.predicateBuilder();
|
||||||
|
|
||||||
|
//для поиска ОМ*Т по tcrId, статусу И предикату
|
||||||
|
BiFunction<ImdgPredicate, RegistryTradingParams, ImdgPredicate> rgsAnd = (p, rgsCde) -> rgsPb.and(
|
||||||
|
rgsPb.sql(RegistryCodeSqlBuilder.getInstance(rgsCde).build()),
|
||||||
|
rgsPb.equals("tradingClearingRegistryId", tcrId),
|
||||||
|
rgsPb.or(
|
||||||
|
rgsPb.equals("registryStatus", RegistryStatus.PROC.getKey()),
|
||||||
|
rgsPb.equals("registryStatus", RegistryStatus.MNG.getKey())
|
||||||
|
),
|
||||||
|
rgsPb.equals("securityId", currency.getId()),
|
||||||
|
p
|
||||||
|
);
|
||||||
|
|
||||||
|
Collection<Registry> tmtToday;
|
||||||
|
{
|
||||||
|
ImdgPredicate tmtPrdct = rgsAnd.apply(
|
||||||
|
rgsPb.equals("settlementDate", today), TM_T
|
||||||
|
);
|
||||||
|
log.debug("searching tmt registries: {}", tmtPrdct);
|
||||||
|
tmtToday = rgsImdg.getCollectionObjectsByPredicate(tmtPrdct);
|
||||||
|
}
|
||||||
|
Collection<Registry> omtsNotToday;
|
||||||
|
{
|
||||||
|
ImdgPredicate omtPrdct = rgsAnd.apply(
|
||||||
|
rgsPb.not(rgsPb.equals("settlementDate", today)), OM_T
|
||||||
|
);
|
||||||
|
log.debug("searching omt registries: {}", omtPrdct);
|
||||||
|
omtsNotToday = rgsImdg.getCollectionObjectsByPredicate(omtPrdct);
|
||||||
|
}
|
||||||
|
log.debug("a__f.id={} balance checking; tmt today: {}, omt !today: {}",
|
||||||
|
a__f.getId(), tmtToday.size(), omtsNotToday.size());
|
||||||
|
|
||||||
|
BigDecimal tmtSum = tmtToday
|
||||||
|
.stream()
|
||||||
|
.map(tmt -> safeBD(tmt.getBalance()))
|
||||||
|
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||||
|
BigDecimal omtSum = omtsNotToday
|
||||||
|
.stream()
|
||||||
|
.map(omt -> safeBD(omt.getBalance()))
|
||||||
|
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||||
|
BigDecimal a__fBalance = safeBD(a__f.getBalance());
|
||||||
|
BigDecimal compareValue = tmtSum.subtract(omtSum).add(a__fBalance).max(a__fBalance);
|
||||||
|
log.info("{}#id={}#balance={} check; tmt sum: {}; omt sum {}; withdrawal amount: {}; check amount: {}",
|
||||||
|
a__f.getRegistryCode(), a__f.getId(), a__f.getBalance(), tmtSum, omtSum, amount, compareValue
|
||||||
|
);
|
||||||
|
return safeBD(amount).compareTo(compareValue) <= 0;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean insufficientBalance(Registry a__f,
|
public boolean insufficientBalance(Registry a__f,
|
||||||
Long tcrId,
|
Long tcrId,
|
||||||
String accCurrency,
|
String accCurrency,
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,9 @@ RUN mkdir -p $CLEARING_HOME/files/xml/importer/in
|
||||||
RUN mkdir -p $CLEARING_HOME/files/xml/importer/out
|
RUN mkdir -p $CLEARING_HOME/files/xml/importer/out
|
||||||
RUN mkdir -p $CLEARING_HOME/files/xml/importer/error
|
RUN mkdir -p $CLEARING_HOME/files/xml/importer/error
|
||||||
RUN mkdir -p $CLEARING_HOME/files/xml/exporter
|
RUN mkdir -p $CLEARING_HOME/files/xml/exporter
|
||||||
|
#ARG CLR_TEST_NAME
|
||||||
|
#RUN mkdir -p $CLEARING_HOME_BIN/log/$CLR_TEST_NAME
|
||||||
|
RUN mkdir -p $CLEARING_HOME_BIN/log_artifacts
|
||||||
|
|
||||||
WORKDIR $CLEARING_HOME
|
WORKDIR $CLEARING_HOME
|
||||||
RUN sed -i 's/\r$//' $CLEARING_HOME/*.sh
|
RUN sed -i 's/\r$//' $CLEARING_HOME/*.sh
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,18 @@ sleep 30
|
||||||
echo Run clearing-tester
|
echo Run clearing-tester
|
||||||
sh ./clearing_testing_utils/clearing-tester/clearing-tester.sh
|
sh ./clearing_testing_utils/clearing-tester/clearing-tester.sh
|
||||||
|
|
||||||
|
if [ -n "$CLR_TEST_NAME" ] && [ -d "./bin/log" ]; then
|
||||||
|
echo "Copying logs to ./bin/log_artifacts/${CLR_TEST_NAME}"
|
||||||
|
# Copy all contents from ./bin/log to tmp dir
|
||||||
|
mkdir -p "./bin/tmp_log_artifact"
|
||||||
|
cp -a ./bin/log/. "./bin/tmp_log_artifact/"
|
||||||
|
# Move the copied logs into the artifact location
|
||||||
|
mkdir -p "./bin/log_artifacts/${CLR_TEST_NAME}"
|
||||||
|
mv ./bin/tmp_log_artifact/* "./bin/log_artifacts/${CLR_TEST_NAME}"
|
||||||
|
else
|
||||||
|
echo "CLR_TEST_NAME is not set or ./bin/log does not exist. Skipping log copy."
|
||||||
|
fi
|
||||||
|
|
||||||
if [ $? -eq 0 ]
|
if [ $? -eq 0 ]
|
||||||
then
|
then
|
||||||
echo "Tests passed successfully"
|
echo "Tests passed successfully"
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,12 @@ services:
|
||||||
retries: 100
|
retries: 100
|
||||||
|
|
||||||
clearing_system:
|
clearing_system:
|
||||||
build: ./clearing-all
|
build:
|
||||||
|
context: ./clearing-all
|
||||||
|
args:
|
||||||
|
CLR_TEST_NAME: ${CLR_TEST_NAME}
|
||||||
|
environment:
|
||||||
|
- CLR_TEST_NAME=${CLR_TEST_NAME}
|
||||||
depends_on:
|
depends_on:
|
||||||
db:
|
db:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
|
|
@ -35,7 +40,7 @@ services:
|
||||||
- "8080:8080"
|
- "8080:8080"
|
||||||
volumes:
|
volumes:
|
||||||
- ./mnt/results:/opt/clearing/clearing_testing_utils/store/results
|
- ./mnt/results:/opt/clearing/clearing_testing_utils/store/results
|
||||||
- logs_volume:/opt/clearing/bin/log
|
- logs_volume:/opt/clearing/bin/log_artifacts
|
||||||
- ./mnt/logs/tester:/opt/clearing/clearing_testing_utils/clearing-tester/logs
|
- ./mnt/logs/tester:/opt/clearing/clearing_testing_utils/clearing-tester/logs
|
||||||
- ./mnt/logs/converter:/opt/clearing/clearing_testing_utils/clearing-converter/logs
|
- ./mnt/logs/converter:/opt/clearing/clearing_testing_utils/clearing-converter/logs
|
||||||
# - ./mnt/dbfout:/opt/clearing/files/dbf/exporter/
|
# - ./mnt/dbfout:/opt/clearing/files/dbf/exporter/
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ RESULT_FILES_DIR = os.environ['RESULT_FILES_DIR']
|
||||||
|
|
||||||
def run_docker(folder_name):
|
def run_docker(folder_name):
|
||||||
logging.info(f"Running docker-compose for {folder_name}")
|
logging.info(f"Running docker-compose for {folder_name}")
|
||||||
|
os.environ['CLR_TEST_NAME'] = folder_name
|
||||||
os.chdir("clr_test")
|
os.chdir("clr_test")
|
||||||
subprocess.call('docker rm -f $(docker ps --all -q --filter ancestor=clr_test-db)', shell=True)
|
subprocess.call('docker rm -f $(docker ps --all -q --filter ancestor=clr_test-db)', shell=True)
|
||||||
subprocess.call('docker rm -f $(docker ps --all -q --filter ancestor=clr_test-clearing_system)', shell=True)
|
subprocess.call('docker rm -f $(docker ps --all -q --filter ancestor=clr_test-clearing_system)', shell=True)
|
||||||
|
|
@ -107,6 +108,9 @@ def main():
|
||||||
change_date(folder)
|
change_date(folder)
|
||||||
run_docker(folder)
|
run_docker(folder)
|
||||||
|
|
||||||
|
os.chdir("clr_test")
|
||||||
|
subprocess.call('docker compose down', shell=True)
|
||||||
|
os.chdir("..")
|
||||||
|
|
||||||
if __name__=='__main__':
|
if __name__=='__main__':
|
||||||
main()
|
main()
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue