작성
·
368
0
안녕하세요. 해당 강의를 듣고 있는 수강생입니다.
제가 작성한 코드에서는 계속 테스트가 실패하여 강사님이 올려주신 코드를 기반으로 테스트를 재수행하였습니다.
그런데 여전히 해당 화면처럼 테스트가 실패하여서 어떤 문제일까하여 질문드립니다.
이슈
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.7.0)
2024-03-24 19:26:47.245 INFO 5004 --- [ main] c.e.s.facade.NamedLockStockFacadeTest : Starting NamedLockStockFacadeTest using Java 17.0.10 on windows with PID 5004 (started by ac2di in C:\Users\ac2di\Desktop\vscode\stock-example-main)
2024-03-24 19:26:47.247 INFO 5004 --- [ main] c.e.s.facade.NamedLockStockFacadeTest : No active profile set, falling back to 1 default profile: "default"
2024-03-24 19:26:48.250 INFO 5004 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode!
2024-03-24 19:26:48.252 INFO 5004 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2024-03-24 19:26:48.519 INFO 5004 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 257 ms. Found 2 JPA repository interfaces.
2024-03-24 19:26:48.532 INFO 5004 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode!
2024-03-24 19:26:48.535 INFO 5004 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data Redis repositories in DEFAULT mode.
2024-03-24 19:26:48.553 INFO 5004 --- [ main] .RepositoryConfigurationExtensionSupport : Spring Data Redis - Could not safely identify store assignment for repository candidate interface com.example.stock.repository.LockRepository. If you want this repository to be a Redis repository, consider annotating your entities with one of these annotations: org.springframework.data.redis.core.RedisHash (preferred), or consider extending one of the following types with your repository: org.springframework.data.keyvalue.repository.KeyValueRepository.
2024-03-24 19:26:48.554 INFO 5004 --- [ main] .RepositoryConfigurationExtensionSupport : Spring Data Redis - Could not safely identify store assignment for repository candidate interface com.example.stock.repository.StockRepository. If you want this repository to be a Redis repository, consider annotating your entities with one of these annotations: org.springframework.data.redis.core.RedisHash (preferred), or consider extending one of the following types with your repository: org.springframework.data.keyvalue.repository.KeyValueRepository.
2024-03-24 19:26:48.554 INFO 5004 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 8 ms. Found 0 Redis repository interfaces.
2024-03-24 19:26:49.201 INFO 5004 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2024-03-24 19:26:49.275 INFO 5004 --- [ main] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.6.9.Final
2024-03-24 19:26:49.465 INFO 5004 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
2024-03-24 19:26:49.622 INFO 5004 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2024-03-24 19:26:49.962 INFO 5004 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2024-03-24 19:26:49.986 INFO 5004 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQL8Dialect
2024-03-24 19:26:50.663 DEBUG 5004 --- [ main] org.hibernate.SQL : drop table if exists stock
Hibernate: drop table if exists stock
2024-03-24 19:26:50.708 DEBUG 5004 --- [ main] org.hibernate.SQL : create table stock (id bigint not null auto_increment, product_id bigint, quantity bigint, version bigint, primary key (id)) engine=InnoDB
Hibernate: create table stock (id bigint not null auto_increment, product_id bigint, quantity bigint, version bigint, primary key (id)) engine=InnoDB
2024-03-24 19:26:50.762 INFO 5004 --- [ main] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2024-03-24 19:26:50.775 INFO 5004 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2024-03-24 19:26:51.083 INFO 5004 --- [ main] org.redisson.Version : Redisson 3.17.4
2024-03-24 19:26:51.313 INFO 5004 --- [isson-netty-2-6] o.r.c.pool.MasterPubSubConnectionPool : 1 connections initialized for localhost/127.0.0.1:6379
2024-03-24 19:26:51.468 INFO 5004 --- [sson-netty-2-20] o.r.c.pool.MasterConnectionPool : 24 connections initialized for localhost/127.0.0.1:6379
2024-03-24 19:26:52.949 WARN 5004 --- [ main] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
2024-03-24 19:26:54.634 INFO 5004 --- [ main] o.s.b.a.e.web.EndpointLinksResolver : Exposing 1 endpoint(s) beneath base path '/actuator'
2024-03-24 19:26:54.714 INFO 5004 --- [ main] c.e.s.facade.NamedLockStockFacadeTest : Started NamedLockStockFacadeTest in 7.788 seconds (JVM running for 9.06)
2024-03-24 19:26:55.040 DEBUG 5004 --- [ main] org.hibernate.SQL : insert into stock (product_id, quantity, version) values (?, ?, ?)
Hibernate: insert into stock (product_id, quantity, version) values (?, ?, ?)
2024-03-24 19:26:55.051 TRACE 5004 --- [ main] o.h.type.descriptor.sql.BasicBinder : binding parameter [1] as [BIGINT] - [1]
2024-03-24 19:26:55.052 TRACE 5004 --- [ main] o.h.type.descriptor.sql.BasicBinder : binding parameter [2] as [BIGINT] - [100]
2024-03-24 19:26:55.052 TRACE 5004 --- [ main] o.h.type.descriptor.sql.BasicBinder : binding parameter [3] as [BIGINT] - [0]
2024-03-24 19:26:55.251 DEBUG 5004 --- [ main] org.hibernate.SQL : select stock0_.id as id1_0_0_, stock0_.product_id as product_2_0_0_, stock0_.quantity as quantity3_0_0_, stock0_.version as version4_0_0_ from stock stock0_ where stock0_.id=?
Hibernate: select stock0_.id as id1_0_0_, stock0_.product_id as product_2_0_0_, stock0_.quantity as quantity3_0_0_, stock0_.version as version4_0_0_ from stock stock0_ where stock0_.id=?
2024-03-24 19:26:55.253 TRACE 5004 --- [ main] o.h.type.descriptor.sql.BasicBinder : binding parameter [1] as [BIGINT] - [1]
2024-03-24 19:26:55.316 DEBUG 5004 --- [ main] org.hibernate.SQL : select stock0_.id as id1_0_, stock0_.product_id as product_2_0_, stock0_.quantity as quantity3_0_, stock0_.version as version4_0_ from stock stock0_
Hibernate: select stock0_.id as id1_0_, stock0_.product_id as product_2_0_, stock0_.quantity as quantity3_0_, stock0_.version as version4_0_ from stock stock0_
2024-03-24 19:26:55.334 DEBUG 5004 --- [ main] org.hibernate.SQL : delete from stock where id=? and version=?
Hibernate: delete from stock where id=? and version=?
2024-03-24 19:26:55.335 TRACE 5004 --- [ main] o.h.type.descriptor.sql.BasicBinder : binding parameter [1] as [BIGINT] - [1]
2024-03-24 19:26:55.335 TRACE 5004 --- [ main] o.h.type.descriptor.sql.BasicBinder : binding parameter [2] as [BIGINT] - [0]
2024-03-24 19:26:55.437 INFO 5004 --- [ionShutdownHook] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2024-03-24 19:26:55.441 INFO 5004 --- [ionShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated...
2024-03-24 19:26:55.514 INFO 5004 --- [ionShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed.
테스트 수행 시 콘솔 출력 창도 같이 첨부드립니다.
감사합니다.
답변 2
0
0
안녕하세요, 인프런 AI 인턴입니다. 이승훈님께서 질문하신 “테스트 수행 결과가 항상 에러가 발생합니다.“와 연관된 정보를 찾아드리려고 합니다.
테스트 실패의 원인이 다양할 수 있으나, 질문자님의 상황에서는 “동시성 처리 과정에서 예상된 결과값과 실제 결과값의 불일치”로 보입니다. 질문자님이 공유해주신 코드와 에러 로그를 통해, 여러 스레드를 통한 동시 요청 처리 과정에서 흐름 제어나 동시성 처리에 관련된 이슈가 발생했을 가능성이 높아 보입니다. 특히 ExecutorService
와 CountDownLatch
의 사용을 보면, 여러 스레드를 사용하여 동시성을 테스트하는 경우인데, 이 때 동시성 관리가 적절히 이루어지지 않아 기대한 결과와 다른 결과를 얻은 것으로 추측됩니다.
이와 유사한 문제를 겪고 계신 다른 수강생의 질문과 답변이 있어 링크를 공유드립니다:
NamedLock
사용시 감소 로직이 실행되지 않는 문제에 대해 질문하였습니다. 주어진 문제 상황과 비슷하게 ExecutorService와 CountDownLatch를 활용한 동시성 테스트 중 문제가 발생하였으며, 이에 대해 지식공유자님이 직접 답변을 제공하셨습니다.문제의 원인과 해결 방법을 다룬 이 질문은 질문자님의 케이스와 유사할 수 있어, 참고하셔서 문제를 해결하는 데 도움이 되길 바랍니다.
질문자님의 상황에 대해 직접적인 문제 해결을 제공하는 정보를 찾는 데에는 한계가 있으므로, 상기 링크를 통해 유사한 문제 상황과 그에 대한 해결책을 확인하여 보시는 것을 추천드립니다.
저는 질문자님의 이해를 돕고자 지식공유자님의 기존 답변을 참고하여 유사한 답변 링크를 추천해드리고 있습니다.
현재 베타 기능으로 답변이 만족스럽지 않을 수 있는 점 양해 부탁드립니다. 🙏
추가적으로 궁금한 점이 있으시면, 이어서 질문해 주세요. 곧 지식공유자께서 답변해 주실 것입니다.