mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-10-27 14:02:15 +08:00
feat: add test options
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
This commit is contained in:
parent
ab91f24fd1
commit
a7a880787b
4
.github/workflows/scripts-test.yml
vendored
4
.github/workflows/scripts-test.yml
vendored
@ -61,8 +61,8 @@ jobs:
|
|||||||
|
|
||||||
- name: Build all services
|
- name: Build all services
|
||||||
run: |
|
run: |
|
||||||
sudo chmod +x ./scripts/build_all_service.sh
|
sudo chmod +x ./scripts/build-all-service.sh
|
||||||
sudo ./scripts/build_all_service.sh
|
sudo ./scripts/build-all-service.sh
|
||||||
sudo cat logs/openIM.log 2>/dev/null
|
sudo cat logs/openIM.log 2>/dev/null
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
|
|||||||
@ -28,4 +28,4 @@ COPY --from=builder ${OPENIM_SERVER_CMDDIR} /openim/openim-server/scripts
|
|||||||
COPY --from=builder ${SERVER_WORKDIR}/config /openim/openim-server/config
|
COPY --from=builder ${SERVER_WORKDIR}/config /openim/openim-server/config
|
||||||
COPY --from=builder ${OPENIM_SERVER_BINDIR} /openim/openim-server/_output/bin
|
COPY --from=builder ${OPENIM_SERVER_BINDIR} /openim/openim-server/_output/bin
|
||||||
|
|
||||||
CMD ["bash","-c","${OPENIM_SERVER_CMDDIR}/docker-start-all-all.sh"]
|
CMD ["bash","-c","${OPENIM_SERVER_CMDDIR}/docker-start-all.sh"]
|
||||||
|
|||||||
5
Makefile
5
Makefile
@ -53,6 +53,11 @@ export USAGE_OPTIONS
|
|||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
# Targets
|
# Targets
|
||||||
|
|
||||||
|
## init: Initialize openim server project ✨
|
||||||
|
.PHONY: init
|
||||||
|
init:
|
||||||
|
@$(MAKE) gen.init
|
||||||
|
|
||||||
## demo: Run demo get started with Makefiles quickly ✨
|
## demo: Run demo get started with Makefiles quickly ✨
|
||||||
.PHONY: demo
|
.PHONY: demo
|
||||||
demo:
|
demo:
|
||||||
|
|||||||
@ -32,7 +32,7 @@ scripts/
|
|||||||
├── advertise.sh # Script for advertisement services
|
├── advertise.sh # Script for advertisement services
|
||||||
├── batch_start-all.sh # Script to start all services in batch
|
├── batch_start-all.sh # Script to start all services in batch
|
||||||
├── build.cmd # Windows build command script
|
├── build.cmd # Windows build command script
|
||||||
├── build_all_service.sh # Script to build all services
|
├── build-all-service.sh # Script to build all services
|
||||||
├── build_push_k8s_images.sh # Script to build and push images for Kubernetes
|
├── build_push_k8s_images.sh # Script to build and push images for Kubernetes
|
||||||
├── check_all.sh # Script to check status of all services
|
├── check_all.sh # Script to check status of all services
|
||||||
├── common.sh # Contains common functions used by other scripts
|
├── common.sh # Contains common functions used by other scripts
|
||||||
|
|||||||
@ -19,7 +19,7 @@
|
|||||||
# WHAT: Directory names to build. If any of these directories has a 'main'
|
# WHAT: Directory names to build. If any of these directories has a 'main'
|
||||||
# package, the build will produce executable files under $(OUT_DIR)/bin/platforms OR $(OUT_DIR)/bin—tools/platforms.
|
# package, the build will produce executable files under $(OUT_DIR)/bin/platforms OR $(OUT_DIR)/bin—tools/platforms.
|
||||||
# If not specified, "everything" will be built.
|
# If not specified, "everything" will be built.
|
||||||
# Usage: `scripts/build_all_service.sh`.
|
# Usage: `scripts/build-all-service.sh`.
|
||||||
# Example: `hack/build-go.sh WHAT=cmd/kubelet`.
|
# Example: `hack/build-go.sh WHAT=cmd/kubelet`.
|
||||||
|
|
||||||
set -o errexit
|
set -o errexit
|
||||||
@ -58,15 +58,15 @@ openim::color::echo $COLOR_CYAN "NOTE: $0 has been replaced by 'make multiarch'
|
|||||||
echo
|
echo
|
||||||
echo "The equivalent of this invocation is: "
|
echo "The equivalent of this invocation is: "
|
||||||
echo " make build ${ARGHELP}"
|
echo " make build ${ARGHELP}"
|
||||||
echo " ./scripts/build_all_service.sh ${ARGHELP}"
|
echo " ./scripts/build-all-service.sh ${ARGHELP}"
|
||||||
echo
|
echo
|
||||||
echo " Example: "
|
echo " Example: "
|
||||||
echo " Print a single binary:"
|
echo " Print a single binary:"
|
||||||
echo " make build BINS=openim-api"
|
echo " make build BINS=openim-api"
|
||||||
echo " ./scripts/build_all_service.sh BINS=openim-api"
|
echo " ./scripts/build-all-service.sh BINS=openim-api"
|
||||||
echo " Print : Enable debugging and logging"
|
echo " Print : Enable debugging and logging"
|
||||||
echo " make build BINS=openim-api V=1 DEBUG=1"
|
echo " make build BINS=openim-api V=1 DEBUG=1"
|
||||||
echo " ./scripts/build_all_service.sh BINS=openim-api V=1 DEBUG=1"
|
echo " ./scripts/build-all-service.sh BINS=openim-api V=1 DEBUG=1"
|
||||||
echo
|
echo
|
||||||
|
|
||||||
if [ -z "$*" ]; then
|
if [ -z "$*" ]; then
|
||||||
@ -17,53 +17,13 @@
|
|||||||
#fixme This scripts is the total startup scripts
|
#fixme This scripts is the total startup scripts
|
||||||
#fixme The full name of the shell scripts that needs to be started is placed in the need_to_start_server_shell array
|
#fixme The full name of the shell scripts that needs to be started is placed in the need_to_start_server_shell array
|
||||||
|
|
||||||
#Include shell font styles and some basic information
|
|
||||||
SCRIPTS_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
|
||||||
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
|
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
|
||||||
|
source "${OPENIM_ROOT}/scripts/install/common.sh"
|
||||||
|
|
||||||
trap 'openim::util::onCtrlC' INT
|
trap 'openim::util::onCtrlC' INT
|
||||||
|
|
||||||
#fixme Put the shell scripts name here
|
nohup ${OPENIM_ROOT}/scripts/start-all.sh > ${LOG_FILE} 2>&1 &
|
||||||
need_to_start_server_shell=(
|
|
||||||
${SCRIPTS_ROOT}/openim-rpc.sh
|
|
||||||
${SCRIPTS_ROOT}/openim-msggateway.sh
|
|
||||||
${SCRIPTS_ROOT}/openim-push.sh
|
|
||||||
${SCRIPTS_ROOT}/openim-msgtransfer.sh
|
|
||||||
${SCRIPTS_ROOT}/openim-crontask.sh
|
|
||||||
)
|
|
||||||
|
|
||||||
component_check=start_component_check.sh
|
nohup ${OPENIM_ROOT}/scripts/check-all.sh > ${LOG_FILE} 2>&1 &
|
||||||
chmod +x $SCRIPTS_ROOT/$component_check
|
|
||||||
$SCRIPTS_ROOT/$component_check
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
# Print error message and exit
|
|
||||||
echo "${BOLD_PREFIX}${RED_PREFIX}Error executing ${component_check}. Exiting...${COLOR_SUFFIX}"
|
|
||||||
exit -1
|
|
||||||
fi
|
|
||||||
|
|
||||||
#fixme The 10 second delay to start the project is for the docker-compose one-click to start openIM when the infrastructure dependencies are not started
|
tail -f ${LOG_FILE}
|
||||||
|
|
||||||
sleep 10
|
|
||||||
time=`date +"%Y-%m-%d %H:%M:%S"`
|
|
||||||
echo "==========================================================">>$OPENIM_ROOT/logs/openIM.log 2>&1 &
|
|
||||||
echo "==========================================================">>$OPENIM_ROOT/logs/openIM.log 2>&1 &
|
|
||||||
echo "==========================================================">>$OPENIM_ROOT/logs/openIM.log 2>&1 &
|
|
||||||
echo "==========server start time:${time}===========">>$OPENIM_ROOT/logs/openIM.log 2>&1 &
|
|
||||||
echo "==========================================================">>$OPENIM_ROOT/logs/openIM.log 2>&1 &
|
|
||||||
echo "==========================================================">>$OPENIM_ROOT/logs/openIM.log 2>&1 &
|
|
||||||
echo "==========================================================">>$OPENIM_ROOT/logs/openIM.log 2>&1 &
|
|
||||||
for i in ${need_to_start_server_shell[*]}; do
|
|
||||||
$i
|
|
||||||
done
|
|
||||||
|
|
||||||
sleep 15
|
|
||||||
|
|
||||||
#fixme prevents the openIM service exit after execution in the docker container
|
|
||||||
tail -f /dev/null
|
|
||||||
|
|
||||||
# nohup ./bin/seata-server.sh > ./logs/seata.log.out 2>&1 &
|
|
||||||
|
|
||||||
# # seata注册到nacos的ip和端口,不配置默认获取本机ip(docker容器ip)
|
|
||||||
# echo $SEATA_IP $SEATA_PORT
|
|
||||||
|
|
||||||
# tail -f logs/seata.log.out
|
|
||||||
@ -22,38 +22,52 @@
|
|||||||
# Makefile helper functions for generate necessary files
|
# Makefile helper functions for generate necessary files
|
||||||
#
|
#
|
||||||
|
|
||||||
|
## gen.init: Initialize openim server project ✨
|
||||||
|
.PHONY: gen.init
|
||||||
|
gen.init:
|
||||||
|
@echo "===========> Initializing openim server project"
|
||||||
|
@${ROOT_DIR}/scripts/init-config.sh
|
||||||
|
|
||||||
|
## gen.run: Generate necessary files and docs ✨
|
||||||
.PHONY: gen.run
|
.PHONY: gen.run
|
||||||
#gen.run: gen.errcode gen.docgo
|
#gen.run: gen.errcode gen.docgo
|
||||||
gen.run: gen.clean gen.errcode gen.docgo.doc
|
gen.run: gen.clean gen.errcode gen.docgo.doc
|
||||||
|
|
||||||
|
## gen.errcode: Generate necessary files and docs ✨
|
||||||
.PHONY: gen.errcode
|
.PHONY: gen.errcode
|
||||||
gen.errcode: gen.errcode.code gen.errcode.doc
|
gen.errcode: gen.errcode.code gen.errcode.doc
|
||||||
|
|
||||||
|
## gen.errcode.code: Generate openim error code go source files ✨
|
||||||
.PHONY: gen.errcode.code
|
.PHONY: gen.errcode.code
|
||||||
gen.errcode.code: tools.verify.codegen
|
gen.errcode.code: tools.verify.codegen
|
||||||
@echo "===========> Generating openim error code go source files"
|
@echo "===========> Generating openim error code go source files"
|
||||||
@codegen -type=int ${ROOT_DIR}/internal/pkg/code
|
@codegen -type=int ${ROOT_DIR}/internal/pkg/code
|
||||||
|
|
||||||
|
## gen.errcode.doc: Generate openim error code markdown documentation ✨
|
||||||
.PHONY: gen.errcode.doc
|
.PHONY: gen.errcode.doc
|
||||||
gen.errcode.doc: tools.verify.codegen
|
gen.errcode.doc: tools.verify.codegen
|
||||||
@echo "===========> Generating error code markdown documentation"
|
@echo "===========> Generating error code markdown documentation"
|
||||||
@codegen -type=int -doc \
|
@codegen -type=int -doc \
|
||||||
-output ${ROOT_DIR}/docs/guide/zh-CN/api/error_code_generated.md ${ROOT_DIR}/internal/pkg/code
|
-output ${ROOT_DIR}/docs/guide/zh-CN/api/error_code_generated.md ${ROOT_DIR}/internal/pkg/code
|
||||||
|
|
||||||
|
## gen.docgo: Generate missing doc.go for go packages ✨
|
||||||
.PHONY: gen.ca.%
|
.PHONY: gen.ca.%
|
||||||
gen.ca.%:
|
gen.ca.%:
|
||||||
$(eval CA := $(word 1,$(subst ., ,$*)))
|
$(eval CA := $(word 1,$(subst ., ,$*)))
|
||||||
@echo "===========> Generating CA files for $(CA)"
|
@echo "===========> Generating CA files for $(CA)"
|
||||||
@${ROOT_DIR}/scripts/gencerts.sh generate-openim-cert $(OUTPUT_DIR)/cert $(CA)
|
@${ROOT_DIR}/scripts/gencerts.sh generate-openim-cert $(OUTPUT_DIR)/cert $(CA)
|
||||||
|
|
||||||
|
## gen.ca: Generate CA files for all certificates ✨
|
||||||
.PHONY: gen.ca
|
.PHONY: gen.ca
|
||||||
gen.ca: $(addprefix gen.ca., $(CERTIFICATES))
|
gen.ca: $(addprefix gen.ca., $(CERTIFICATES))
|
||||||
|
|
||||||
|
## gen.docgo: Generate missing doc.go for go packages ✨
|
||||||
.PHONY: gen.docgo.doc
|
.PHONY: gen.docgo.doc
|
||||||
gen.docgo.doc:
|
gen.docgo.doc:
|
||||||
@echo "===========> Generating missing doc.go for go packages"
|
@echo "===========> Generating missing doc.go for go packages"
|
||||||
@${ROOT_DIR}/scripts/gendoc.sh
|
@${ROOT_DIR}/scripts/gendoc.sh
|
||||||
|
|
||||||
|
## gen.docgo.check: Check if there are untracked doc.go files ✨
|
||||||
.PHONY: gen.docgo.check
|
.PHONY: gen.docgo.check
|
||||||
gen.docgo.check: gen.docgo.doc
|
gen.docgo.check: gen.docgo.doc
|
||||||
@n="$$(git ls-files --others '*/doc.go' | wc -l)"; \
|
@n="$$(git ls-files --others '*/doc.go' | wc -l)"; \
|
||||||
@ -63,14 +77,17 @@ gen.docgo.check: gen.docgo.doc
|
|||||||
false ; \
|
false ; \
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
## gen.docgo.add: Add untracked doc.go files to git index ✨
|
||||||
.PHONY: gen.docgo.add
|
.PHONY: gen.docgo.add
|
||||||
gen.docgo.add:
|
gen.docgo.add:
|
||||||
@git ls-files --others '*/doc.go' | $(XARGS) -- git add
|
@git ls-files --others '*/doc.go' | $(XARGS) -- git add
|
||||||
|
|
||||||
|
## gen.docgo: Generate missing doc.go for go packages ✨
|
||||||
.PHONY: gen.defaultconfigs
|
.PHONY: gen.defaultconfigs
|
||||||
gen.defaultconfigs:
|
gen.defaultconfigs:
|
||||||
@${ROOT_DIR}/scripts/gen_default_config.sh
|
@${ROOT_DIR}/scripts/gen_default_config.sh
|
||||||
|
|
||||||
|
## gen.docgo: Generate missing doc.go for go packages ✨
|
||||||
.PHONY: gen.clean
|
.PHONY: gen.clean
|
||||||
gen.clean:
|
gen.clean:
|
||||||
@rm -rf ./api/client/{clientset,informers,listers}
|
@rm -rf ./api/client/{clientset,informers,listers}
|
||||||
|
|||||||
@ -205,12 +205,12 @@ go.format: tools.verify.golines tools.verify.goimports
|
|||||||
@$(FIND) -type f -name '*.go' -not -name '*pb*' | $(XARGS) $(TOOLS_DIR)/golines -w --max-len=200 --reformat-tags --shorten-comments --ignore-generated .
|
@$(FIND) -type f -name '*.go' -not -name '*pb*' | $(XARGS) $(TOOLS_DIR)/golines -w --max-len=200 --reformat-tags --shorten-comments --ignore-generated .
|
||||||
@$(GO) mod edit -fmt
|
@$(GO) mod edit -fmt
|
||||||
|
|
||||||
## imports: task to automatically handle import packages in Go files using goimports tool
|
## go.imports: task to automatically handle import packages in Go files using goimports tool
|
||||||
.PHONY: go.imports
|
.PHONY: go.imports
|
||||||
go.imports: tools.verify.goimports
|
go.imports: tools.verify.goimports
|
||||||
@$(TOOLS_DIR)/goimports -l -w $(SRC)
|
@$(TOOLS_DIR)/goimports -l -w $(SRC)
|
||||||
|
|
||||||
## verify: execute all verity scripts.
|
## go.verify: execute all verity scripts.
|
||||||
.PHONY: go.verify
|
.PHONY: go.verify
|
||||||
go.verify:
|
go.verify:
|
||||||
@echo "Starting verification..."
|
@echo "Starting verification..."
|
||||||
@ -234,7 +234,7 @@ go.clean:
|
|||||||
@-rm -vrf $(TMP_DIR) $(BIN_DIR) $(BIN_TOOLS_DIR) $(LOGS_DIR)
|
@-rm -vrf $(TMP_DIR) $(BIN_DIR) $(BIN_TOOLS_DIR) $(LOGS_DIR)
|
||||||
@echo "===========> End clean..."
|
@echo "===========> End clean..."
|
||||||
|
|
||||||
## copyright.help: Show copyright help
|
## go.help: Show go tools help
|
||||||
.PHONY: go.help
|
.PHONY: go.help
|
||||||
go.help: scripts/make-rules/golang.mk
|
go.help: scripts/make-rules/golang.mk
|
||||||
$(call smallhelp)
|
$(call smallhelp)
|
||||||
|
|||||||
@ -60,11 +60,11 @@ endif
|
|||||||
# - have enable BuildKit, More info: https://docs.docker.com/develop/develop-images/build_enhancements/
|
# - have enable BuildKit, More info: https://docs.docker.com/develop/develop-images/build_enhancements/
|
||||||
# - be able to push the image for your registry (i.e. if you do not inform a valid value via IMG=<myregistry/image:<tag>> then the export will fail)
|
# - be able to push the image for your registry (i.e. if you do not inform a valid value via IMG=<myregistry/image:<tag>> then the export will fail)
|
||||||
# To properly provided solutions that supports more than one platform you should use this option.
|
# To properly provided solutions that supports more than one platform you should use this option.
|
||||||
## Build and push docker image for the manager for cross-platform support
|
## image.docker-buildx: Build and push docker image for the manager for cross-platform support
|
||||||
PLATFORMS ?= linux/arm64,linux/amd64,linux/s390x,linux/ppc64le
|
PLATFORMS ?= linux/arm64,linux/amd64,linux/s390x,linux/ppc64le
|
||||||
# copy existing Dockerfile and insert --platform=${BUILDPLATFORM} into Dockerfile.cross, and preserve the original Dockerfile
|
# copy existing Dockerfile and insert --platform=${BUILDPLATFORM} into Dockerfile.cross, and preserve the original Dockerfile
|
||||||
.PHONY: docker-buildx
|
.PHONY: image.docker-buildx
|
||||||
docker-buildx:
|
image.docker-buildx:
|
||||||
sed -e '1 s/\(^FROM\)/FROM --platform=\$$\{BUILDPLATFORM\}/; t' -e ' 1,// s//FROM --platform=\$$\{BUILDPLATFORM\}/' Dockerfile > Dockerfile.cross
|
sed -e '1 s/\(^FROM\)/FROM --platform=\$$\{BUILDPLATFORM\}/; t' -e ' 1,// s//FROM --platform=\$$\{BUILDPLATFORM\}/' Dockerfile > Dockerfile.cross
|
||||||
- $(CONTAINER_TOOL) buildx create --name project-v3-builder
|
- $(CONTAINER_TOOL) buildx create --name project-v3-builder
|
||||||
$(CONTAINER_TOOL) buildx use project-v3-builder
|
$(CONTAINER_TOOL) buildx use project-v3-builder
|
||||||
|
|||||||
@ -26,7 +26,7 @@ set +o errexit
|
|||||||
openim::golang::check_openim_binaries
|
openim::golang::check_openim_binaries
|
||||||
if [[ $? -ne 0 ]]; then
|
if [[ $? -ne 0 ]]; then
|
||||||
openim::log::error "OpenIM binaries are not found. Please run 'make build' to build binaries."
|
openim::log::error "OpenIM binaries are not found. Please run 'make build' to build binaries."
|
||||||
${OPENIM_ROOT}/scripts/build_all_service.sh
|
${OPENIM_ROOT}/scripts/build-all-service.sh
|
||||||
fi
|
fi
|
||||||
set -o errexit
|
set -o errexit
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user