Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Chapter 11] 331p, 일래스틱 빈스토크에서 애플리케이션 배포하기 문제 #46

Closed
yeongjuleee opened this issue Jan 19, 2024 · 9 comments

Comments

@yeongjuleee
Copy link

Gradle 탭을 누르고 Tasks 에서 build를 실행하면 그전까지 잘 실행되었던 테스트가 다 실패가 되면서 build가 실패합니다.
혹시나 싶어 따로 테스트를 실행해보았을 때 그전까지 잘 실행 되었던 것들이 모두 실패함을 알 수 있었습니다.
내용에는 그래들 9.0과 호환이 되지 않는 기능들이 있다고 하는데 해결방법을 찾지 못하였습니다.

1_tasks 실행시 오류내역
2_tasks실행 시 오류내역 원인
3_tasks 실행 시 그래들 호환 내용 알 수 없음

@shinsunyoung
Copy link
Owner

안녕하세요. file:///C:/dev/intelJ-20231109/bootBlog/build/reports/tests/test/index.html 경로에 테스트 실패 report가 있을텐데 확인해보시겠어요? 무슨 테스트가 왜 실패했는지 나옵니다!

@shinsunyoung shinsunyoung changed the title [Chapter11] 331p, 일래스틱 빈스토크에서 애플리케이션 배포하기 문제 [Chapter 11] 331p, 일래스틱 빈스토크에서 애플리케이션 배포하기 문제 Jan 21, 2024
@yeongjuleee
Copy link
Author

file:///C:/dev/intelJ-20231109/bootBlog/build/reports/tests/test/index.html 에 들어가 테스트 실패 이유를 찾아보았습니다. 알맞게 찾은건지 모르겠지만, 가장 상단 오류내용은

java.lang.IllegalStateException: Failed to load ApplicationContext for [WebMergedContextConfiguration@1a14fdf0 testClass = study.blog.bootBlog.BootBlogApplicationTests, locations = [], classes = [study.blog.bootBlog.BootBlogApplication], contextInitializerClasses = [], activeProfiles = [], propertySourceDescriptors = [], propertySourceProperties = ["org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true"], contextCustomizers = [org.springframework.boot.test.autoconfigure.actuate.observability.ObservabilityContextCustomizerFactory$DisableObservabilityContextCustomizer@1f, org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizer@0, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizer@68fa0ba8, org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizer@640f11a1, org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory$DuplicateJsonObjectContextCustomizer@3f6db3fb, org.springframework.boot.test.mock.mockito.MockitoContextCustomizer@0, org.springframework.boot.test.web.client.TestRestTemplateContextCustomizer@5286c33a, org.springframework.boot.test.context.SpringBootTestAnnotation@24d5151f], resourceBasePath = "src/main/webapp", contextLoader = org.springframework.boot.test.context.SpringBootContextLoader, parent = null]
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:180)

이었습니다.
테스트 애플리케이션을 불러오지 못해서 일어난 일 같습니다.

그리고 오류 내역 가장 하단에 있는 내용은

Caused by: org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Failed to determine a suitable driver class
at app//org.springframework.boot.autoconfigure.jdbc.DataSourceProperties.determineDriverClassName(DataSourceProperties.java:186)

이었습니다. 검색해 보았을 때 AWS에서 작업 중 프로퍼티스에서 DB를 가져오지 못해서 그렇다는 내용을 보았습니다.
자세한 내용은 AWS에서 로그를 보고 파악했다는 글도 보았는데 AWS에서 지표를 보는 방법을 알지 못해 이용해볼 수 없었습니다.

해당 오류에 관한 전체 오류 내역입니다.

Task :test

BootBlogApplicationTests > contextLoads() FAILED
java.lang.IllegalStateException at DefaultCacheAwareContextLoaderDelegate.java:180
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException at ConstructorResolver.java:802
Caused by: org.springframework.beans.factory.BeanCreationException at ConstructorResolver.java:655
Caused by: org.springframework.beans.BeanInstantiationException at SimpleInstantiationStrategy.java:178
Caused by: org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException at DataSourceProperties.java:186

TokenProviderTest > validToken() : 유효한 토큰일 때에 유효성 검증에 성공한다. FAILED
java.lang.IllegalStateException at DefaultCacheAwareContextLoaderDelegate.java:145

TokenProviderTest > validToken() : 만료된 토큰인 때에 유효성 검증에 실패한다. FAILED
java.lang.IllegalStateException at DefaultCacheAwareContextLoaderDelegate.java:145

TokenProviderTest > getAuthentication() : 토큰 기반으로 인증 정보를 가져올 수 있다. FAILED
java.lang.IllegalStateException at DefaultCacheAwareContextLoaderDelegate.java:145

TokenProviderTest > getUserId() : 토큰으로 유저 ID를 가져올 수 있다. FAILED
java.lang.IllegalStateException at DefaultCacheAwareContextLoaderDelegate.java:145

TokenProviderTest > generateToken(): 유저 정보와 만료 기간을 전달해 토큰을 만들 수 있음 FAILED
java.lang.IllegalStateException at DefaultCacheAwareContextLoaderDelegate.java:145

BlogApiControllerTest > deleteArticle: 블로그 글 삭제에 성공한다. FAILED
java.lang.IllegalStateException at DefaultCacheAwareContextLoaderDelegate.java:180
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException at ConstructorResolver.java:802
Caused by: org.springframework.beans.factory.BeanCreationException at ConstructorResolver.java:655
Caused by: org.springframework.beans.BeanInstantiationException at SimpleInstantiationStrategy.java:178
Caused by: org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException at DataSourceProperties.java:186

BlogApiControllerTest > findArticle: 블로그 글 조회에 성공한다. FAILED
java.lang.IllegalStateException at DefaultCacheAwareContextLoaderDelegate.java:145

BlogApiControllerTest > findAllArticles: 블로그 글 목록 조회에 성공한다 FAILED
java.lang.IllegalStateException at DefaultCacheAwareContextLoaderDelegate.java:145

BlogApiControllerTest > addArticle: 블로그 글 추가에 성공한다. FAILED
java.lang.IllegalStateException at DefaultCacheAwareContextLoaderDelegate.java:145

BlogApiControllerTest > deleteArticle: 블로그 글 수정에 성공! FAILED
java.lang.IllegalStateException at DefaultCacheAwareContextLoaderDelegate.java:145

TokenApiControllerTest > createNewAccessToken : 새로운 액세스 토큰을 발급한다. FAILED
java.lang.IllegalStateException at DefaultCacheAwareContextLoaderDelegate.java:145

12 tests completed, 12 failed

Task :test FAILED

Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

For more on this, please refer to https://docs.gradle.org/8.5/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.
7 actionable tasks: 1 executed, 6 up-to-date

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':test'.

There were failing tests. See the report at: file:///C:/dev/intelJ-20231109/bootBlog/build/reports/tests/test/index.html

BUILD FAILED in 15s

Publishing a build scan to scans.gradle.com requires accepting the Gradle Terms of Service defined at https://gradle.com/terms-of-service. Do you accept these terms? [yes, no]

@yeongjuleee
Copy link
Author

yeongjuleee commented Jan 22, 2024

application.yml 에서

spring:

security:
oauth2:
client:
registration:
google:
client-id: 아이디
client-secret: 비번
scope:
- email
- profile

로 되어있던 것을 드라이버가 없다고 하여서

spring:

datasource:
url: AWS에서 설정한 url
driver-class-name: com.mysql.cj.jdbc.Driver
username: AWS에서 설정한 유저네임
password: AWS에서 설정한 비밀번호

security:
oauth2:
client:
registration:
google:
client-id: 아이디
client-secret: 비번
scope:
- email
- profile

로 변경했더니 task > build > build 가 계속 로딩 상태로 run이 되고 있는데 해결이 된 상태인지 아닌지 모르겠습니다.

4_tasks 실행 시 run 상태

@shinsunyoung
Copy link
Owner

혹시 전체 코드를 깃허브에 올려주실 수 있으신가요? 처음에 라이브러리를 다운로드 받기 때문에 로딩 상태가 지속될 수 있으나 끝나야 하는게 정상입니다. 올리실 때 google client-id, secret 내용이 포함되지 않게 주의해주시고 올려주시면 확인해보겠습니다.

@yeongjuleee
Copy link
Author

yeongjuleee commented Feb 2, 2024

깃으로 올렸습니다 !
https://github.com/yeongjuleee/springboot-developer.git

@shinsunyoung
Copy link
Owner

늦게 확인해서 죄송합니다 🙇 연휴동안 노트북을 가져가지 않아 이제 확인했네요 ㅠㅠ
확인해보니 테스트를 돌리는 DB가 H2가 아닌 것 같아요. build.gradle에 H2를 추가하고 https://github.com/shinsunyoung/springboot-developer/blob/main/chapter12/src/main/resources/application.yml 참고해서 yml 파일 설정한 뒤에 시도해보시겠어요??

저는 이렇게 수정하니 잘 되는 것을 확인했습니다.

image

@yeongjuleee
Copy link
Author

저는 프로젝트 시작할 때 DB를 H2로 하려다 오류가 나서 mariaDB로 해서 다 맞췄는데 H2로 바꿔야할까요 ㅠㅠ?

@shinsunyoung
Copy link
Owner

테스트는 H2로 돌리는 것을 추천드립니다! 어느 에러가 나시는건가요?

@shinsunyoung
Copy link
Owner

오랫동안 active한 comment가 안 달려서 일단 close 해두겠습니다. 추가적인 질문 있으시면 reopen 해주시거나 새롭게 이슈 등록 부탁드립니다. 감사합니다!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants