@@ -30,27 +30,13 @@ has es_client => (
3030 builder => ' _build_es_client' ,
3131);
3232
33- has es_server => (
34- is => ' ro' ,
35- isa => ' Search::Elasticsearch::TestServer' ,
36- lazy => 1,
37- builder => ' _build_es_server' ,
38- );
39-
4033has _config => (
4134 is => ' ro' ,
4235 isa => HashRef,
4336 lazy => 1,
4437 builder => ' _build_config' ,
4538);
4639
47- has _es_home => (
48- is => ' ro' ,
49- isa => Str,
50- lazy => 1,
51- builder => ' _build_es_home' ,
52- );
53-
5440has _cpan_dir => (
5541 is => ' ro' ,
5642 isa => Path,
@@ -63,8 +49,6 @@ sub setup {
6349 my $self = shift ;
6450
6551 $self -> es_client;
66-
67- # Deploy project mappings
6852 $self -> put_mappings;
6953}
7054
@@ -79,69 +63,11 @@ sub _build_config {
7963 return $config ;
8064}
8165
82- sub _build_es_home {
83- my $self = shift ;
84-
85- my $es_home = MetaCPAN::Config::config()-> {elasticsearch_servers };
86-
87- if ( !$es_home ) {
88- die <<'USAGE' ;
89- Please set elasticsearch_servers to a running instance of Elasticsearch, eg
90- 'localhost:9200'
91- USAGE
92- }
93-
94- return $es_home ;
95- }
96-
97- =head2 _build_es_server
98-
99- This starts an Elastisearch server on the fly. It should only be called if the
100- ES env var contains a path to Elasticsearch. If the variable contains a port
101- number then we'll assume the server has already been started on this port.
102-
103- =cut
104-
105- sub _build_es_server {
106- my $self = shift ;
107-
108- my $server = Search::Elasticsearch::TestServer-> new(
109- conf => [ ' cluster.name' => ' metacpan-test' ],
110- es_home => $self -> _es_home,
111- es_port => 9700,
112- http_port => 9900,
113- instances => 1,
114- );
115-
116- diag ' Connecting to Elasticsearch on ' . $self -> _es_home;
117-
118- try {
119- $server -> start-> [0];
120- }
121- catch {
122- diag(<<"EOF" );
123- Failed to connect to the Elasticsearch test instance on ${\$ self->_es_home}.
124- Did you start one up? See https://github.com/metacpan/metacpan-api/wiki/Installation
125- for more information.
126- Error: $_
127- EOF
128- BAIL_OUT(' Test environment not set up properly' );
129- };
130-
131- diag( ' Connected to the Elasticsearch test instance on '
132- . $self -> _es_home );
133- }
134-
13566sub _build_es_client {
13667 my $self = shift ;
13768
138- # Don't try to start a test server if we've been passed the port number of
139- # a running instance.
140-
141- $self -> es_server unless $self -> _es_home =~ m { :} ;
142-
14369 my $es = Search::Elasticsearch-> new(
144- nodes => $self -> _es_home ,
70+ nodes => MetaCPAN::Config::config() -> { elasticsearch_servers } ,
14571 ( $ENV {ES_TRACE } ? ( trace_to => [ ' File' , ' es.log' ] ) : () )
14672 );
14773
@@ -212,7 +138,7 @@ sub check_mappings {
212138sub put_mappings {
213139 my $self = shift ;
214140
215- local @ARGV = qw( mapping --delete) ;
141+ local @ARGV = qw( mapping --delete --all ) ;
216142 ok( MetaCPAN::Script::Mapping-> new_with_options( $self -> _config )-> run,
217143 ' put mapping' );
218144 $self -> check_mappings;
0 commit comments