无法在 Ubuntu 上使用 rspec 和 elasticsearch-extensions 进行测试
Posted
技术标签:
【中文标题】无法在 Ubuntu 上使用 rspec 和 elasticsearch-extensions 进行测试【英文标题】:Can't test with rspec and elasticsearch-extensions on Ubuntu 【发布时间】:2017-03-22 15:37:07 【问题描述】:我已经按照 this guide 在 rspec 中使用 elasticsearch-extensions
gem 运行集成测试,但在我运行 Elasticsearch::Extensions::Test::Cluster.start(port: 9250, nodes: 1, timeout: 120)
的那一刻,抛出以下错误:
Starting 2 Elasticsearch nodes...Exception in thread "main" ElasticsearchException[Failed to load logging configuration]; nested: NoSuchFileException[/usr/share/elasticsearch/config];
Likely root cause: java.nio.file.NoSuchFileException: /usr/share/elasticsearch/config
at sun.nio.fs.UnixException.translateToIOException(UnixException.java:86)
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
at sun.nio.fs.UnixFileAttributeViews$Basic.readAttributes(UnixFileAttributeViews.java:55)
at sun.nio.fs.UnixFileSystemProvider.readAttributes(UnixFileSystemProvider.java:144)
at sun.nio.fs.LinuxFileSystemProvider.readAttributes(LinuxFileSystemProvider.java:99)
at java.nio.file.Files.readAttributes(Files.java:1737)
at java.nio.file.FileTreeWalker.getAttributes(FileTreeWalker.java:225)
at java.nio.file.FileTreeWalker.visit(FileTreeWalker.java:276)
at java.nio.file.FileTreeWalker.walk(FileTreeWalker.java:322)
at java.nio.file.Files.walkFileTree(Files.java:2662)
at org.elasticsearch.common.logging.log4j.LogConfigurator.resolveConfig(LogConfigurator.java:142)
at org.elasticsearch.common.logging.log4j.LogConfigurator.configure(LogConfigurator.java:103)
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:259)
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:35)
Refer to the log for complete error details.
Exception in thread "main" ElasticsearchException[Failed to load logging configuration]; nested: NoSuchFileException[/usr/share/elasticsearch/config];
Likely root cause: java.nio.file.NoSuchFileException: /usr/share/elasticsearch/config
at sun.nio.fs.UnixException.translateToIOException(UnixException.java:86)
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
at sun.nio.fs.UnixFileAttributeViews$Basic.readAttributes(UnixFileAttributeViews.java:55)
at sun.nio.fs.UnixFileSystemProvider.readAttributes(UnixFileSystemProvider.java:144)
at sun.nio.fs.LinuxFileSystemProvider.readAttributes(LinuxFileSystemProvider.java:99)
at java.nio.file.Files.readAttributes(Files.java:1737)
at java.nio.file.FileTreeWalker.getAttributes(FileTreeWalker.java:225)
at java.nio.file.FileTreeWalker.visit(FileTreeWalker.java:276)
at java.nio.file.FileTreeWalker.walk(FileTreeWalker.java:322)
at java.nio.file.Files.walkFileTree(Files.java:2662)
at org.elasticsearch.common.logging.log4j.LogConfigurator.resolveConfig(LogConfigurator.java:142)
at org.elasticsearch.common.logging.log4j.LogConfigurator.configure(LogConfigurator.java:103)
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:259)
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:35)
Refer to the log for complete error details.
我猜是因为我在我的 Ubuntu 机器上安装了 ES,它将配置文件添加到 /etc/elasticsearch/
并且已经作为服务运行。我试图对文件夹进行符号链接,但文件夹权限是:
drwxr-x--- 3 root elasticsearch 4,0K nov 8 17:32 elasticsearch
所以我尝试将我的用户添加到elasticsearch
组,但我没有运气。有什么想法吗?
【问题讨论】:
【参考方案1】:我刚刚复制完文件并更改了所有者:
sudo cp -r /etc/elasticsearch/ /usr/share/elasticsearch/config
sudo chown $(whoami):$(whoami) /usr/share/elasticsearch/config/*
也许不是最好的解决方案,但很有效。
【讨论】:
以上是关于无法在 Ubuntu 上使用 rspec 和 elasticsearch-extensions 进行测试的主要内容,如果未能解决你的问题,请参考以下文章
我无法使用 'bundle exec rspec' 执行 rspec
Capybara-webkit、rspec 集成规范和 xvfb:webkit_server:致命 IO 错误:客户端被杀死