在带有嵌入式mongodb的jenkins中,集成测试失败

时间:2019-05-21 05:02:12

标签: mongodb jenkins integration-testing

我在本地运行集成测试,效果很好。但是,当尝试运行jenkins时,它会失败。 该集成测试包含嵌入式mongodb。集成测试如下:

@RunWith(SpringRunner.class)
@SpringBootTest
@EnableAutoConfiguration
public class MongoDbSpringUnitTest {

    @Autowired
    PriceRepository priceRepository;

    @Test
    public void testSavePriceMongoRepo() {
        priceRepository.deleteAll();
        Price price = priceRepository.save(new Price("1234productId", 24.5f));

       // System.out.println("id : "+price);
        assertEquals(0,24.5f, price.getCost());
        assertNotNull("id is autogenerate", price.getId());
    }

得到以下错误:

java.lang.IllegalStateException: Failed to load ApplicationContext
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'priceController': Unsatisfied dependency expressed through field 'priceRepository'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'priceRepository': Cannot resolve reference to bean 'mongoTemplate' while setting bean property 'mongoOperations'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'mongoTemplate' defined in class path resource [org/springframework/boot/autoconfigure/data/mongo/MongoDataAutoConfiguration.class]: Unsatisfied dependency expressed through method 'mongoTemplate' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mongoDbFactory' defined in class path resource [org/springframework/boot/autoconfigure/data/mongo/MongoDataAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.mongodb.core.MongoDbFactorySupport]: Factory method 'mongoDbFactory' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'embeddedMongoServer' defined in class path resource 

[org/springframework/boot/autoconfigure/mongo/embedded/EmbeddedMongoAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [de.flapdoodle.embed.mongo.MongodExecutable]: Factory method 'embeddedMongoServer' threw exception; nested exception is java.lang.IllegalArgumentException: this version does not support 32Bit: Version{3.5.5}:Windows:B32

以上错误表明,嵌入式数据库服务器无法安装在32位计算机上。我不确定jenkins仅支持32位。我正在使用jenkins 2.164.2。

完整的代码位于github下面: https://github.com/ranjit5311/MicroServiceCode

请让我知道以解决此问题。

谢谢, 兰吉特·库玛(Ranjit Kumar)

1 个答案:

答案 0 :(得分:0)

在安装新版本的Jenkins 2.164.3之后,解决了此问题。