Skip to content

Commit

Permalink
テスト
Browse files Browse the repository at this point in the history
  • Loading branch information
nakagawa1022 committed Sep 13, 2024
1 parent 3d95ea8 commit e8180f0
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
23 changes: 23 additions & 0 deletions glue-job/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
.DEFAULT_GOAL := help

CREDENTIAL = tpo-$(ENV)
AWS_VAULT_CMD = aws-vault exec $(CREDENTIAL) --
SUFFIX_WORKSPACE = '-$(WORKSPACE)'

JOB_NAME =
RUN_ID =

# Glueジョブをテストモードで実行
test-job: ## make test-job WORKSPACE=beta JOB_NAME=touchgift-event-transfer ENV=staging
$(AWS_VAULT_CMD) aws glue start-job-run --job-name '$(JOB_NAME)$(SUFFIX_WORKSPACE)' --arguments '{"--mode":"test"}'

# Glueジョブのテスト結果を表示
show-test-result: ## make show-test-result WORKSPACE=beta JOB_NAME=touchgift-event-transfer RUN_ID=jr_e9cd37c4b9481ad6a6d17d1e5032d05a7c30975307e9af83a185ef1bad735a5d ENV=staging
@id=$$($(AWS_VAULT_CMD) aws glue get-job-run --job-name '$(JOB_NAME)$(SUFFIX_WORKSPACE)' --run-id $(RUN_ID) | jq -r '.JobRun.Id'); \
log_group_name=$$($(AWS_VAULT_CMD) aws glue get-job-run --job-name '$(JOB_NAME)$(SUFFIX_WORKSPACE)' --run-id $(RUN_ID) | jq -r '.JobRun.LogGroupName'); \
full_log_group_name=$$log_group_name/output; \
$(AWS_VAULT_CMD) aws logs get-log-events --log-group-name $$full_log_group_name --log-stream-name $$id

help: ## Help
@grep -E '^[0-9a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort |\
awk 'BEGIN {FS = ":[^:]*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
14 changes: 12 additions & 2 deletions glue-job/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

[source,text]
----
baroque
baroque(組織)
└── staging(環境) ex)staging, production
└── beta(workspace) ex) beta, e ②
└── evserver アプリケーション
Expand All @@ -30,5 +30,15 @@ baroque
- テスト環境でのジョブ実行:
[source,bash]
----
aws-vault exec tpo-staging -- aws glue start-job-run --job-name <glue-job-name> --arguments '{"--mode":"test"}'
## RunIDが取得できるので取得する
make test-job WORKSPACE=(workspace) JOB_NAME=(job名) ENV=(環境名)
----

4. **テストの確認**
[source,bash]
----
# 3で実行した後にジョブランIDはわかる
make show-test-result WORKSPACE=beta JOB_NAME=(job名) RUN_ID=(run_id) ENV=(環境名) | grep -C 2 "テストが完了しました"
# テスト完了というログがあれば成功
# DataFrame constructor is internal. Do not directly use itこの警告は無視して良い。
----

0 comments on commit e8180f0

Please sign in to comment.