AWS 에러

dawn·2021년 5월 29일
0

인프런

목록 보기
3/11

로컬에서는 테스트가 다 통과됐는데 EC2에서는 실패했다.
원인이 뭐지.....

  • 상황
    github에서 clone를 받고 ./gradlew test 실행
    다음과 같은 에러가 떴다.
HelloSpringApplicationTests > contextLoads() FAILED
    java.lang.IllegalStateException at DefaultCacheAwareContextLoaderDelegate.java:132        Caused by: org.springframework.beans.factory.BeanCreationException at AbstractAutowireCapableBeanFactory.java:1799
            Caused by: org.hibernate.service.spi.ServiceException at AbstractServiceRegistryImpl.java:275
                Caused by: org.hibernate.HibernateException at DialectFactoryImpl.java:100

MemberServiceIntegrationTest > join() FAILED
    java.lang.IllegalStateException at DefaultCacheAwareContextLoaderDelegate.java:13
        Caused by: org.springframework.beans.factory.BeanCreationException at AbstractAutowireCapableBeanFactory.java:1799
            Caused by: org.hibernate.service.spi.ServiceException at AbstractServiceRegistryImpl.java:275
                Caused by: org.hibernate.HibernateException at DialectFactoryImpl.java:100

MemberServiceIntegrationTest > 회원_중복_예외() FAILED
    java.lang.IllegalStateException at DefaultCacheAwareContextLoaderDelegate.java:13
        Caused by: org.springframework.beans.factory.BeanCreationException at AbstractAutowireCapableBeanFactory.java:1799
            Caused by: org.hibernate.service.spi.ServiceException at AbstractServiceRegistryImpl.java:275
                Caused by: org.hibernate.HibernateException at DialectFactoryImpl.java:100

10 tests completed, 3 failed

> Task :test FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':test'.
> There were failing tests. See the report at: file:///home/ec2-user/app/step1/hello-spring/build/reports/tests/test/index.html

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
package hello.hellospring;

import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;

@SpringBootTest
class HelloSpringApplicationTests {

	@Test
	void contextLoads() {
	}

}
package hello.hellospring.service;

import hello.hellospring.domain.Member;
import hello.hellospring.repository.MemberRepository;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.transaction.annotation.Transactional;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertThrows;

@SpringBootTest
@Transactional
class MemberServiceIntegrationTest {

    @Autowired
    MemberRepository memberRepository;
    @Autowired MemberService memberService;

    @Test
    void join() {
        //given
        Member member = new Member();
        member.setName("test1");

        //when
        Long saveId = memberService.join(member);

        //then
        Member findMember = memberService.findOne(saveId).get();
        assertThat(findMember.getName()).isEqualTo(member.getName());
    }

    @Test
    public void 회원_중복_예외() {
        //given
        Member member1 = new Member();
        member1.setName("test");

        Member member2 = new Member();
        member2.setName("test");

        //when
        memberService.join(member1);

        //then
        IllegalStateException e = assertThrows(IllegalStateException.class, () -> memberService.join(member2));
        assertThat(e.getMessage()).isEqualTo("이미 존재하는 회원입니다.");
    }

}

로컬에서는 h2로 연결해서 테스트 한건데 그러면 서버에서는 rds에 먼저 연결한 다음 테스트를 해야 하는건가...?

  • deploy.sh 만들어야함
    그전에 먼저 rds연결하고 되는지 확인해볼게

프로젝트에 RDS연결했더니 다음과 같은 에러


> Task :test
#
# There is insufficient memory for the Java Runtime Environment to continue.
OpenJDK 64-Bit Server VM warning: INFO: os::commit_memory(0x00000000ebcc0000, 8830976, 0) failed; error='Not enough space' (errno=12)
# Native memory allocation (mmap) failed to map 8830976 bytes for committing reserved memory.
# An error report file with more information is saved as:
# /home/ec2-user/app/step1/hello-spring/hs_err_pid10523.log

> Task :test FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':test'.
> Process 'Gradle Test Executor 2' finished with non-zero exit value 1
  This problem might be caused by incorrect test process configuration.
  Please refer to the test execution section in the User Manual at https://docs.gradle.org/6.9/userguide/java_testing.html#sec:test_execution

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.9/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 19s
4 actionable tasks: 1 executed, 3 up-to-date

살려줘...
https://transferhwang.tistory.com/506 을 통해 해결..
swap은 대체 또 뭐야ㅜㅜㅜ


2021-06-01 추가
swap

profile
안녕하세요

0개의 댓글