diff --git a/backend/src/test/java/wooteco/prolog/article/application/RssClientTest.java b/backend/src/test/java/wooteco/prolog/article/application/RssClientTest.java index 184ceb3d1..e213ff792 100644 --- a/backend/src/test/java/wooteco/prolog/article/application/RssClientTest.java +++ b/backend/src/test/java/wooteco/prolog/article/application/RssClientTest.java @@ -10,36 +10,40 @@ class RssClientTest { @Test void fromTistoryRssFeedBy() { RssClient rssClient = new RssClient(); - RssFeeds rssFeeds = rssClient.fromRssFeedBy("https://lazypazy.tistory.com/rss"); + String feedUrl = getClass().getClassLoader().getResource("rss/tistory-feed.xml").toString(); + + RssFeeds rssFeeds = rssClient.fromRssFeedBy(feedUrl); assertThat(rssFeeds.getRssFeeds()).isNotEmpty(); + assertThat(rssFeeds.getRssFeeds().get(0).getTitle()).isEqualTo("Test Article"); } @Test void fromYoutubeRssFeedBy() { - SSLUtil.disableSSLVerification(); - RssClient rssClient = new RssClient(); - RssFeeds rssFeeds = rssClient.fromRssFeedBy( - "https://www.youtube.com/feeds/videos.xml?channel_id=UC-mOekGSesms0agFntnQang"); + String feedUrl = getClass().getClassLoader().getResource("rss/youtube-feed.xml").toString(); + + RssFeeds rssFeeds = rssClient.fromRssFeedBy(feedUrl); assertThat(rssFeeds.getRssFeeds()).isNotEmpty(); + assertThat(rssFeeds.getRssFeeds().get(0).getTitle()).isEqualTo("Test Video"); } @Test - void fromVelogRssFeedBy() { - SSLUtil.disableSSLVerification(); - + void fromInvalidRssFeedBy() { RssClient rssClient = new RssClient(); - RssFeeds rssFeeds = rssClient.fromRssFeedBy("https://brunch.co.kr/rss/@@7vZS"); - assertThat(rssFeeds.getRssFeeds()).isNotEmpty(); + RssFeeds rssFeeds = rssClient.fromRssFeedBy("https://invalid.example.com/nonexistent-feed"); + + assertThat(rssFeeds.getRssFeeds()).isEmpty(); } @Test - void fromInvalidRssFeedBy() { + void fromEmptyRssFeedBy() { RssClient rssClient = new RssClient(); - RssFeeds rssFeeds = rssClient.fromRssFeedBy("https://v2.velog.io/rss/junho5336asdfasdf"); + String feedUrl = getClass().getClassLoader().getResource("rss/empty-feed.xml").toString(); + + RssFeeds rssFeeds = rssClient.fromRssFeedBy(feedUrl); assertThat(rssFeeds.getRssFeeds()).isEmpty(); } diff --git a/backend/src/test/resources/rss/empty-feed.xml b/backend/src/test/resources/rss/empty-feed.xml new file mode 100644 index 000000000..f84ca8f5d --- /dev/null +++ b/backend/src/test/resources/rss/empty-feed.xml @@ -0,0 +1,8 @@ + + + + Empty Blog + https://example.com + No articles + + diff --git a/backend/src/test/resources/rss/tistory-feed.xml b/backend/src/test/resources/rss/tistory-feed.xml new file mode 100644 index 000000000..e7d0e97b3 --- /dev/null +++ b/backend/src/test/resources/rss/tistory-feed.xml @@ -0,0 +1,17 @@ + + + + Test Tistory Blog + https://example.tistory.com + Test blog + + https://example.com/blog-image.png + + + Test Article + https://example.tistory.com/1 + Test description

]]>
+ Mon, 14 Apr 2025 10:00:00 +0900 +
+
+
diff --git a/backend/src/test/resources/rss/youtube-feed.xml b/backend/src/test/resources/rss/youtube-feed.xml new file mode 100644 index 000000000..b973a2a5b --- /dev/null +++ b/backend/src/test/resources/rss/youtube-feed.xml @@ -0,0 +1,14 @@ + + + Test YouTube Channel + + + Test Video + + 2025-04-14T10:00:00+00:00 + + Test video description + + + + diff --git a/terraform/environments/dev/main.tf b/terraform/environments/dev/main.tf index e25e1f579..fca322a26 100644 --- a/terraform/environments/dev/main.tf +++ b/terraform/environments/dev/main.tf @@ -68,20 +68,9 @@ module "application" { public_subnet_ids = module.network.public_subnet_ids service_worker_tags = module.tags.service_worker_tags server_tags = module.tags.server_tags -} - -module "database" { - source = "../../modules/database" - - vpc_id = module.network.vpc_id - project_name = var.project_name - db_name = var.db_name - secret_name = var.db_secret_name - ingress_security_group_ids = [module.application.application_sg_id, module.bastion.bastion_sg_id] - - private_subnet_ids = module.network.private_subnet_ids - server_tags = module.tags.server_tags - database_tags = module.tags.database_tags + asg_min_size = 1 + asg_max_size = 4 + asg_desired_capacity = 1 } diff --git a/terraform/environments/dev/outputs.tf b/terraform/environments/dev/outputs.tf index f00afaffa..53b1f33f7 100644 --- a/terraform/environments/dev/outputs.tf +++ b/terraform/environments/dev/outputs.tf @@ -62,19 +62,3 @@ output "application_launch_template_id" { description = "Launch Template ID for application instances" value = module.application.launch_template_id } - -# Database -output "database_endpoint" { - description = "Endpoint of the RDS database" - value = module.database.db_instance_endpoint -} - -output "database_id" { - description = "ID of the RDS database instance" - value = module.database.db_instance_id -} - -output "database_sg_id" { - description = "Security Group ID for the database" - value = module.database.database_sg_id -} diff --git a/terraform/environments/dev/variables.tf b/terraform/environments/dev/variables.tf index 04bbb23c5..226ed1d9e 100644 --- a/terraform/environments/dev/variables.tf +++ b/terraform/environments/dev/variables.tf @@ -13,9 +13,3 @@ variable "bucket_name" { variable "key_pair_name" { default = "prolog-dev" } -variable "db_name" { - default = "prolog" -} -variable "db_secret_name" { - default = "secrets/prolog_dev" -} diff --git a/terraform/environments/prod/main.tf b/terraform/environments/prod/main.tf index e25e1f579..5fca058f4 100644 --- a/terraform/environments/prod/main.tf +++ b/terraform/environments/prod/main.tf @@ -68,20 +68,9 @@ module "application" { public_subnet_ids = module.network.public_subnet_ids service_worker_tags = module.tags.service_worker_tags server_tags = module.tags.server_tags -} - -module "database" { - source = "../../modules/database" - - vpc_id = module.network.vpc_id - project_name = var.project_name - db_name = var.db_name - secret_name = var.db_secret_name - ingress_security_group_ids = [module.application.application_sg_id, module.bastion.bastion_sg_id] - - private_subnet_ids = module.network.private_subnet_ids - server_tags = module.tags.server_tags - database_tags = module.tags.database_tags + asg_min_size = 2 + asg_max_size = 4 + asg_desired_capacity = 2 } diff --git a/terraform/environments/prod/outputs.tf b/terraform/environments/prod/outputs.tf index f00afaffa..53b1f33f7 100644 --- a/terraform/environments/prod/outputs.tf +++ b/terraform/environments/prod/outputs.tf @@ -62,19 +62,3 @@ output "application_launch_template_id" { description = "Launch Template ID for application instances" value = module.application.launch_template_id } - -# Database -output "database_endpoint" { - description = "Endpoint of the RDS database" - value = module.database.db_instance_endpoint -} - -output "database_id" { - description = "ID of the RDS database instance" - value = module.database.db_instance_id -} - -output "database_sg_id" { - description = "Security Group ID for the database" - value = module.database.database_sg_id -} diff --git a/terraform/environments/prod/variables.tf b/terraform/environments/prod/variables.tf index a17fee6e7..f847bb88e 100644 --- a/terraform/environments/prod/variables.tf +++ b/terraform/environments/prod/variables.tf @@ -13,9 +13,3 @@ variable "bucket_name" { variable "key_pair_name" { default = "prolog-prod" } -variable "db_name" { - default = "prolog" -} -variable "db_secret_name" { - default = "secrets/prolog_prod" -} diff --git a/terraform/modules/application/main.tf b/terraform/modules/application/main.tf index ad5e4e3c3..8ea863eef 100644 --- a/terraform/modules/application/main.tf +++ b/terraform/modules/application/main.tf @@ -109,9 +109,9 @@ resource "aws_autoscaling_group" "asg" { version = "$Latest" } - max_size = 4 - min_size = 0 - desired_capacity = 0 + max_size = var.asg_max_size + min_size = var.asg_min_size + desired_capacity = var.asg_desired_capacity vpc_zone_identifier = var.private_subnet_ids // Note: 이후 target_group_arns는 CodeDeploy에서 알아서 관리 예정 @@ -137,6 +137,10 @@ resource "aws_autoscaling_group" "asg" { value = var.project_name propagate_at_launch = true } + + lifecycle { + ignore_changes = [desired_capacity] + } } data "aws_ami" "ec2_ami" { diff --git a/terraform/modules/application/variables.tf b/terraform/modules/application/variables.tf index 9feb963f5..2d6e8b31c 100644 --- a/terraform/modules/application/variables.tf +++ b/terraform/modules/application/variables.tf @@ -20,3 +20,15 @@ variable "service_worker_tags" { variable "server_tags" { type = map(string) } +variable "asg_min_size" { + type = number + default = 1 +} +variable "asg_max_size" { + type = number + default = 4 +} +variable "asg_desired_capacity" { + type = number + default = 1 +} diff --git a/terraform/modules/database/main.tf b/terraform/modules/database/main.tf deleted file mode 100644 index ecac90d81..000000000 --- a/terraform/modules/database/main.tf +++ /dev/null @@ -1,58 +0,0 @@ -module "secret" { - source = "../../modules/secret" - - secret_name = var.secret_name -} - -locals { - username = module.secret.value["spring.datasource.username"] - password = module.secret.value["spring.datasource.password"] -} - -resource "aws_security_group" "database_sg" { - vpc_id = var.vpc_id - - ingress { - from_port = 3306 - to_port = 3306 - protocol = "tcp" - security_groups = var.ingress_security_group_ids - } - - egress { - from_port = 0 - to_port = 0 - protocol = "-1" - cidr_blocks = ["0.0.0.0/0"] - } - tags = merge(var.server_tags, { - Name = "${var.project_name}_database_sg" - }) -} - -resource "aws_db_subnet_group" "database_subnet_group" { - name = "${var.project_name}-subnet-group" - subnet_ids = var.private_subnet_ids - - // Note: Tag not required -} - -resource "aws_db_instance" "database" { - identifier = var.project_name - allocated_storage = 20 - engine = "mysql" - engine_version = "8.0" - instance_class = "db.t4g.micro" - db_name = var.db_name - username = local.username - password = local.password - parameter_group_name = "default.mysql8.0" - skip_final_snapshot = true - publicly_accessible = false - vpc_security_group_ids = [aws_security_group.database_sg.id] - db_subnet_group_name = aws_db_subnet_group.database_subnet_group.name - - tags = merge(var.database_tags, { - Name = "${var.project_name}_database" - }) -} diff --git a/terraform/modules/database/outputs.tf b/terraform/modules/database/outputs.tf deleted file mode 100644 index b8641b4e6..000000000 --- a/terraform/modules/database/outputs.tf +++ /dev/null @@ -1,39 +0,0 @@ -output "database_sg_id" { - description = "Security Group ID for the database" - value = aws_security_group.database_sg.id -} - -output "database_sg_name" { - description = "Name of the Security Group for the database" - value = aws_security_group.database_sg.tags["Name"] -} - -output "db_subnet_group_name" { - description = "Name of the DB Subnet Group" - value = aws_db_subnet_group.database_subnet_group.name -} - -output "db_instance_id" { - description = "ID of the DB instance" - value = aws_db_instance.database.id -} - -output "db_instance_arn" { - description = "ARN of the DB instance" - value = aws_db_instance.database.arn -} - -output "db_instance_endpoint" { - description = "Endpoint of the DB instance" - value = aws_db_instance.database.endpoint -} - -output "db_instance_username" { - description = "Username for the DB instance" - value = aws_db_instance.database.username -} - -output "db_instance_name" { - description = "Name of the database created on the DB instance" - value = aws_db_instance.database.db_name -} diff --git a/terraform/modules/database/variables.tf b/terraform/modules/database/variables.tf deleted file mode 100644 index 4f2f61f7c..000000000 --- a/terraform/modules/database/variables.tf +++ /dev/null @@ -1,16 +0,0 @@ -variable "vpc_id" {} -variable "project_name" {} -variable "db_name" {} -variable "secret_name" {} -variable "ingress_security_group_ids" { - type = list(string) -} -variable "private_subnet_ids" { - type = list(string) -} -variable "server_tags" { - type = map(string) -} -variable "database_tags" { - type = map(string) -} diff --git a/terraform/modules/secret/main.tf b/terraform/modules/secret/main.tf deleted file mode 100644 index 2a0fbce42..000000000 --- a/terraform/modules/secret/main.tf +++ /dev/null @@ -1,7 +0,0 @@ -data "aws_secretsmanager_secret" "secret" { - name = var.secret_name -} - -data "aws_secretsmanager_secret_version" "secret_version" { - secret_id = data.aws_secretsmanager_secret.secret.id -} diff --git a/terraform/modules/secret/outputs.tf b/terraform/modules/secret/outputs.tf deleted file mode 100644 index 986dfd51f..000000000 --- a/terraform/modules/secret/outputs.tf +++ /dev/null @@ -1,3 +0,0 @@ -output "value" { - value = jsondecode(data.aws_secretsmanager_secret_version.secret_version.secret_string) -} diff --git a/terraform/modules/secret/variables.tf b/terraform/modules/secret/variables.tf deleted file mode 100644 index e59fa63c4..000000000 --- a/terraform/modules/secret/variables.tf +++ /dev/null @@ -1 +0,0 @@ -variable "secret_name" {} diff --git a/terraform/modules/tags/main.tf b/terraform/modules/tags/main.tf index dd172fcc8..3c161e861 100644 --- a/terraform/modules/tags/main.tf +++ b/terraform/modules/tags/main.tf @@ -12,9 +12,6 @@ locals { storage_tags = merge(local.common_tags, { Role = "${var.project_name}-storage" }) - database_tags = merge(local.common_tags, { - Role = "${var.project_name}-db" - }) service_worker_tags = merge(local.common_tags, { Role = "service-worker" }) diff --git a/terraform/modules/tags/outputs.tf b/terraform/modules/tags/outputs.tf index 2882144fa..7d8961c7a 100644 --- a/terraform/modules/tags/outputs.tf +++ b/terraform/modules/tags/outputs.tf @@ -18,11 +18,6 @@ output "storage_tags" { value = local.storage_tags } -output "database_tags" { - description = "Tags for database resources" - value = local.database_tags -} - output "service_worker_tags" { description = "Tags for service worker resources" value = local.service_worker_tags