PluginPuppet implements PluginInterface { @Override public void update(Instance instance, Import importChanged, InstanceStatus statusChanged) throws PluginException { this.logger.fine( this.agentId + " is updating instance " + instance.getName()); File instanceDirectory = InstanceHelpers.findInstanceDirectoryOnAgent( instance ); try { callPuppetScript( instance, "update", PuppetState.UNDEF, importChanged, (statusChanged == InstanceStatus.DEPLOYED_STARTED), instanceDirectory ); } catch( Exception e ) { throw new PluginException( e ); } }  @Override String getPluginName(); @Override void setNames( String applicationName, String scopedInstancePath ); @Override void initialize( Instance instance ); @Override void deploy( Instance instance ); @Override void start( Instance instance ); @Override void update(Instance instance, Import importChanged, InstanceStatus statusChanged); @Override void stop( Instance instance ); @Override void undeploy( Instance instance ); static final String PLUGIN_NAME; }
@Test public void testPuppetPlugin_withInit_update() throws Exception { Assume.assumeTrue( isLinuxSystem()); copyResources( "/with-init" ); Map<String,String> variables = new HashMap<> (); variables.put( "ip", "127.0.0.1" ); this.plugin.update( this.inst, new Import( "/some/path", "component1", variables ), InstanceStatus.DEPLOYED_STARTED ); checkGeneratedFiles( "WithInit", "" ); }
@Test public void testPuppetPlugin_withOperations_update() throws Exception { Assume.assumeTrue( isLinuxSystem()); copyResources( "/with-operations" ); Map<String,String> variables = new HashMap<> (); variables.put( "ip", "127.0.0.1" ); this.plugin.update( this.inst, new Import( "/some/path", "component1", variables ), InstanceStatus.DEPLOYED_STOPPED ); checkGeneratedFiles( "WithOperations", "update" ); }
@Test( expected = PluginException.class ) public void testPuppetPlugin_withInit_exception_update() throws Exception { Assume.assumeTrue( isLinuxSystem()); copyResources( "/with-init-invalid" ); Map<String,String> variables = new HashMap<> (); variables.put( "ip", "127.0.0.1" ); this.plugin.update( this.inst, new Import( "/some/path", "component1", variables ), InstanceStatus.DEPLOYED_STARTED ); }
@Test( expected = PluginException.class ) public void testPuppetPlugin_withInit_nonZeroCode_update() throws Exception { Assume.assumeTrue( isLinuxSystem()); copyResources( "/with-init-exit-1" ); Map<String,String> variables = new HashMap<> (); variables.put( "ip", "127.0.0.1" ); this.plugin.update( this.inst, new Import( "/some/path", "component1", variables ), InstanceStatus.DEPLOYED_STARTED ); }