NAME Test::Clustericious::Cluster - Test an imaginary beowulf cluster of Clustericious services VERSION version 0.05 SYNOPSIS use Test::Clustericious::Cluster; my $cluster = Test::Clustericious::Cluster->new; $cluster->create_cluster_ok('MyApp1', 'MyApp2'); my @urls = @{ $cluster->urls }; my $t = $cluster->t; # an instance of Test::Mojo $t->get_ok("$url[0]/arbitrary_path"); # tests against MyApp1 $t->get_ok("$url[1]/another_path"); # tests against MyApp2 DESCRIPTION This module allows you to test an entire cluster of Clustericious services (or just one or two). The only prerequisites are Mojolicious and File::HomeDir, so you can mix and match Mojolicious, Mojolicious::Lite and full Clustericious apps and test how they interact. If you are testing against Clustericious applications, it is important to either use this module as early as possible, or use File::HomeDir::Test as the very first module in your test, as testing Clustericious configurations depend on the testing home directory being setup by File::HomeDir::Test. CONSTRUCTOR Test::Clustericious::Cluster->new( %args ) Arguments: t The Test::Mojo object to use. If not provided, then a new one will be created. lite_path List reference of paths to search for Mojolicious::Lite apps. ATTRIBUTES t The instance of Test::Mojo used in testing. urls The URLs for the various services. Returned as an array ref. apps The application objects for the various services. Returned as an array ref. index The index of the current app (used from within a Clustericious::Config configuration. url The url of the current app (used from within a Clustericious::Config configuration. auth_url The URL for the PlugAuth::Lite service, if one has been started. METHODS $cluster->create_cluster_ok( @services ) Adds the given services to the test cluster. Each element in the services array may be either string The string is taken to be the Mojolicious or Clustericious application class name. No configuration is created or passed into the App. This can also be the name of a Mojolicious::Lite application. The PATH environment variable will be used to search for the lite application. The script for the lite app must be executable. You can specify additional directories to search using the "lite_path" argument to the constructor. list reference in the form: [ string, hashref ] The string is taken to be the Mojolicious application name. The hashref is the configuration passed into the constructor of the app. This form should NOT be used for Clustericious apps (see the third form). list reference in the form: [ string, string ] The first string is taken to be the Clustericious application name. The second string is the configuration in either YAML or JSON format (may include Mojo::Template templating in it, see Clustericious::Config for details). This form requires that you have Clustericous installed, and of course should not be used for non-Clustericious Mojolicious applications. $cluster->create_plugauth_lite_ok( %args ) Add a PlugAuth::Lite service to the test cluster. The %args are passed directly into the PlugAuth::Lite constructor. You can retrieve the URL for the PlugAuth::Lite service using the "auth_url" attribute. This feature requires PlugAuth::Lite and Clustericious 0.9925 or better, though neither are a prerequisite of this module. If you are using this method you need to either require PlugAuth::Lite and Clustericious 0.9925 or better, or skip your test in the event that the user has an earlier version. For example: use strict; use warnings; use Test::Clustericious::Cluster; use Test::More; BEGIN { plan skip_all => 'test requires Clustericious 0.9925' unless eval q{ use Clustericious 0.9925; 1 }; plan skip_all => 'test requires PlugAuth::Lite' unless eval q{ use PlugAuth::Lite; 1 }; }; $cluster->stop_ok( $index, [ $test_name ]) Stop the given service. The service is specified by an index, the first application when you created the cluster is 0, the second is 1, and so on. $cluster->start_ok( $index, [ $test_name ] ) Start the given service. The service is specified by an index, the first application when you created the cluster is 0, the second is 1, and so on. $cluster->create_ua Create a new instance of Mojo::UserAgent which can be used to connect to nodes in the test cluster. AUTHOR Graham Ollis COPYRIGHT AND LICENSE This software is copyright (c) 2013 by Graham Ollis. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.