Skip to content

Commit

Permalink
tests: корректировака скрипта локального тестирования
Browse files Browse the repository at this point in the history
  • Loading branch information
alkoleft committed Jan 12, 2025
1 parent 829b893 commit 05ea59a
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 28 deletions.
16 changes: 9 additions & 7 deletions tools/local-test/scripts/lib/prepare-db.sh
Original file line number Diff line number Diff line change
@@ -1,29 +1,31 @@
CONNECTION_STRING=$1
JOB_NAME=$2

BASE_ARGUMENTS="$CONNECTION_STRING /DisableStartupDialogs /DisableStartupMessages /Out $TMP_PATH/$JOB_NAME.log"
. $LIB_PATH/print.sh

BASE_ARGUMENTS="$CONNECTION_STRING /DisableStartupDialogs /DisableStartupMessages /Out $LOGS_PATH/$JOB_NAME.log"
DESIGNER_COMMAND="$ONEC_PATH/1cv8 DESIGNER $BASE_ARGUMENTS"

echo "=========== Загрузка конфигурации ($JOB_NAME)"
$DESIGNER_COMMAND /LoadCfg $BINARY_PATH/configuration.cf /UpdateDBCfg >&- 2>&-
$DESIGNER_COMMAND /LoadCfg $BINARY_PATH/configuration.cf /UpdateDBCfg >> $LOGS_PATH/$JOB_NAME.log 2>&1
SUCCESS=$?
print_state "Загрузка конфигурации в ${BOLD}$JOB_NAME${RESET}"
# cat $TMP_PATH/$JOB_NAME.log

EXTENSIONS_SET=("smoke" "tests" "yaxunit")

for key in "${EXTENSIONS_SET[@]}";do
if [[ $SUCCESS -eq 0 ]]; then
echo "=========== Загрузка расширения $key ($JOB_NAME)"
$DESIGNER_COMMAND /LoadCfg $BINARY_PATH/$key.cfe -Extension $key /UpdateDBCfg >&- 2>&-
$DESIGNER_COMMAND /LoadCfg $BINARY_PATH/$key.cfe -Extension $key /UpdateDBCfg >> $LOGS_PATH/$JOB_NAME.log 2>&1
SUCCESS=$?
print_state "Загрузка расширения $key в ${BOLD}$JOB_NAME${RESET}"
# cat $TMP_PATH/$JOB_NAME.log
fi
done

if [[ $SUCCESS -eq 0 ]]; then
echo "=========== Снятие безопасного режима ($JOB_NAME)"
$ONEC_PATH/1cv8 ENTERPRISE $BASE_ARGUMENTS /Execute $LIB_PATH/DisableSafeMode.epf >&- 2>&-
$ONEC_PATH/1cv8 ENTERPRISE $BASE_ARGUMENTS /Execute $LIB_PATH/DisableSafeMode.epf >> $LOGS_PATH/$JOB_NAME.log 2>&1
SUCCESS=$?
print_state "Снятие безопасного режима ${BOLD}$JOB_NAME${RESET}"
# cat $TMP_PATH/$JOB_NAME.log
fi

Expand Down
25 changes: 18 additions & 7 deletions tools/local-test/scripts/lib/print.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,31 @@
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
RED=$(tput setaf 1)
GREEN=$(tput setaf 2)
YELLOW=$(tput setaf 3)
BLUE=$(tput setaf 4)
NC='\033[0m'
RESET=$(tput sgr0)
BOLD=$(tput bold)

function print_state {
if [[ $? -eq 0 ]]; then
echo -e " ${GREEN}${RESET} $1. ${GREEN}Успешно${RESET}"
else
echo -e " ${RED}× ${RESET} $1. ${RED}Не удалось${RESET}"
fi
}

function print_success {
echo -e " ${GREEN}🟢 ${NC} $1"
echo -e " ${GREEN}🟢 ${RESET} $1"
}

function print_error {
echo -e " ${RED}🔴 ${NC} $1 "
echo -e " ${RED}🔴 ${RESET} $1 "
}

function print_info {
echo -e " ${GREEN}🛈 ${NC} $1"
echo -e " ${BLUE}🛈 ${RESET} $1"
}

function print_warn {
echo -e " ${YELLOW}🟠 ${NC} $1"
echo -e " ${YELLOW}🟠 ${RESET} $1"
}
8 changes: 4 additions & 4 deletions tools/local-test/scripts/lib/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ cat >$CONFIG <<EOL
}
EOL

echo "=========== Тестирование $JOB_NAME"
$ONEC_PATH/$APP ENTERPRISE $CONNECTION_STRING /DisableSplash /DisableStartupDialogs /DisableStartupMessages $RUN_MODE /C "RunUnitTests=$CONFIG" > /dev/null
echo "=========== Тестирование ${BOLD}$JOB_NAME${RESET}"
$ONEC_PATH/$APP ENTERPRISE $CONNECTION_STRING /DisableSplash /DisableStartupDialogs /DisableStartupMessages $RUN_MODE /C "RunUnitTests=$CONFIG" >> $LOGS_PATH/$JOB_NAME.log 2>&1

RESULT=$(head -n 1 $RESULT_PATH/exit-code-$JOB_NAME.txt)
RESULT=${RESULT:1:1}

if [[ "$RESULT" == "0" ]]; then
print_success "Тестирование $JOB_NAME завершилось успешно"
print_success "Тестирование ${BOLD}$JOB_NAME${RESET} завершилось успешно"
else
print_error "Тестирование $JOB_NAME завершилось с ошибкой"
print_error "Тестирование ${BOLD}$JOB_NAME${RESET} завершилось с ошибкой"
fi
2 changes: 2 additions & 0 deletions tools/local-test/scripts/steps/build-artifacts.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
TEMP_DB_PATH=$TMP_PATH/file-db
. $LIB_PATH/print.sh

rm -rf $TEMP_DB_PATH/*

extensions=("smoke" "tests" "yaxunit")
Expand Down
4 changes: 2 additions & 2 deletions tools/local-test/scripts/steps/clean-outdated.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ if [ -f $hash_file_name ]; then
fi

if [[ "$current_hash" != "$old_hash" ]]; then
print_warn "$PROJECT_NAME, исходники изменены. Будет выполнена сборка"
print_warn "$PROJECT_NAME, исходники ${BOLD}изменены${RESET}. Будет выполнена сборка"
rm -rf $EXPORT_PATH/$PROJECT_NAME
rm -rf $BINARY_PATH/$PROJECT_NAME.*
echo $current_hash > $hash_file_name
else
print_success "$PROJECT_NAME, исходники не изменены. Будут использованы существующие артефакты"
print_success "$PROJECT_NAME, исходники ${BOLD}не изменены${RESET}. Будут использованы существующие артефакты"
fi
4 changes: 2 additions & 2 deletions tools/local-test/scripts/steps/convert-to-xml.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ PROJECT_PATH=$2
. $LIB_PATH/print.sh

if [[ -d $EXPORT_PATH/$PROJECT_NAME ]]; then
print_info "Конвертация $PROJECT_NAME не требуется"
print_info "Конвертация ${BOLD}$PROJECT_NAME${RESET} не требуется"
else
print_info "Конвертация $PROJECT_NAME"
print_info "Конвертация ${BOLD}$PROJECT_NAME${RESET}"
$EDT_PATH/1cedtcli -data $TMP_PATH/ws -timeout 300 -v -command export --configuration-files $EXPORT_PATH/$PROJECT_NAME --project $ROOT_PATH/$PROJECT_PATH > $LOGS_PATH/$PROJECT_NAME.log 2>&1
fi
17 changes: 14 additions & 3 deletions tools/local-test/scripts/steps/run-filedb-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,23 @@ JOB_NAME=${MODE}Application-File
TEST_DB_PATH=$DB_PATH/$MODE
CONNECTION_STRING=/F$TEST_DB_PATH

. $LIB_PATH/print.sh

rm -rf $TEST_DB_PATH

echo "=========== Создание информационной базы ($JOB_NAME)"
$ONEC_PATH/1cv8 CREATEINFOBASE File=$TEST_DB_PATH /DisableStartupDialogs /DisableStartupMessages /Out $TMP_PATH/$JOB_NAME.log >&- 2>&-
# cat $TMP_PATH/$JOB_NAME.log
echo "=========== Подготовка информационной базы ${BOLD}$JOB_NAME${RESET}"
$ONEC_PATH/1cv8 CREATEINFOBASE File=$TEST_DB_PATH /DisableStartupDialogs /DisableStartupMessages /Out $LOGS_PATH/$JOB_NAME.log >> $LOGS_PATH/$JOB_NAME.log 2>&1
SUCCESS=$?
print_state "Создание информационной базы ${BOLD}$JOB_NAME${RESET}"

if [ $SUCCESS -ne 0 ]; then
print_error "Не удалось создать базу ${BOLD}$JOB_NAME${RESET}"
exit 0
fi

if $LIB_PATH/prepare-db.sh $CONNECTION_STRING $JOB_NAME; then
print_info "Подготовлена база ${BOLD}$JOB_NAME${RESET}"
$LIB_PATH/run-tests.sh $MODE $CONNECTION_STRING $JOB_NAME
else
print_error "Не удалось подготовить базу ${BOLD}$JOB_NAME${RESET}"
fi
17 changes: 14 additions & 3 deletions tools/local-test/scripts/steps/run-serverdb-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,21 @@ JOB_NAME=${MODE}Application-Server
DB_NAME=DB_${MODE}Application
CONNECTION_STRING=/S\"localhost\\$DB_NAME\"

echo "=========== Создание информационной базы ($JOB_NAME)"
$ONEC_PATH/1cv8 CREATEINFOBASE Srvr=localhost\;Ref=$DB_NAME\;DBMS=PostgreSQL\;DBSrvr=localhost\;DB=$DB_NAME\;DBUID=postgres\;CrSQLDB=Y\;SchJobDn=Y /DisableStartupDialogs /DisableStartupMessages /Out $TMP_PATH/$JOB_NAME.log >&- 2>&-
# cat $TMP_PATH/$JOB_NAME.log
. $LIB_PATH/print.sh

echo "=========== Подготовка информационной базы ${BOLD}$JOB_NAME${RESET}"
$ONEC_PATH/1cv8 CREATEINFOBASE Srvr=localhost\;Ref=$DB_NAME\;DBMS=PostgreSQL\;DBSrvr=localhost\;DB=$DB_NAME\;DBUID=postgres\;CrSQLDB=Y\;SchJobDn=Y /DisableStartupDialogs /DisableStartupMessages /Out $LOGS_PATH/$JOB_NAME.log >> $LOGS_PATH/$JOB_NAME.log 2>&1
SUCCESS=$?
print_state "Создание информационной базы ${BOLD}$JOB_NAME${RESET}"

if [ $SUCCESS -ne 0 ]; then
print_error "Не удалось создать базу ${BOLD}$JOB_NAME${RESET}"
exit 0
fi

if $LIB_PATH/prepare-db.sh $CONNECTION_STRING $JOB_NAME; then
print_info "Подготовлена база для ${BOLD}$JOB_NAME${RESET}"
$LIB_PATH/run-tests.sh $MODE $CONNECTION_STRING $JOB_NAME
else
print_error "Не удалось создать базу для ${BOLD}$JOB_NAME${RESET}"
fi

0 comments on commit 05ea59a

Please sign in to comment.