PluginPuppet implements PluginInterface { @Override public void undeploy( Instance instance ) throws PluginException { this.logger.fine( this.agentId + " is undeploying instance " + instance.getName()); File instanceDirectory = InstanceHelpers.findInstanceDirectoryOnAgent( instance ); try { callPuppetScript( instance, "undeploy", PuppetState.UNDEF, null, false, 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_undeploy() throws Exception { Assume.assumeTrue( isLinuxSystem()); copyResources( "/with-init" ); this.plugin.undeploy( this.inst ); checkGeneratedFiles( "WithInit", "" ); }
@Test public void testPuppetPlugin_withOperations_undeploy() throws Exception { Assume.assumeTrue( isLinuxSystem()); copyResources( "/with-operations" ); this.plugin.undeploy( this.inst ); checkGeneratedFiles( "WithOperations", "undeploy" ); }
@Test( expected = PluginException.class ) public void testPuppetPlugin_withInit_exception_undeploy() throws Exception { Assume.assumeTrue( isLinuxSystem()); copyResources( "/with-init-invalid" ); this.plugin.undeploy( this.inst ); }
@Test( expected = PluginException.class ) public void testNoModuleDirectory() throws Exception { Assume.assumeTrue( isLinuxSystem()); Assert.assertTrue( new File( this.instanceDirectory, "whatever" ).mkdirs()); Assert.assertTrue( new File( this.instanceDirectory, "whatever.txt" ).createNewFile()); this.plugin.undeploy( this.inst ); }
@Test public void testNoScriptToExecute() throws Exception { Assume.assumeTrue( isLinuxSystem()); Assert.assertTrue( new File( this.instanceDirectory, "roboconf_empty_puppet_module" ).mkdirs()); this.plugin.undeploy( this.inst ); }
@Test( expected = PluginException.class ) public void testPuppetPlugin_withInit_nonZeroCode_undeploy() throws Exception { Assume.assumeTrue( isLinuxSystem()); copyResources( "/with-init-exit-1" ); this.plugin.undeploy( this.inst ); }
@Test public void testPuppetPlugin_withInit_nonZeroCode_changesAndErrors() throws Exception { Assume.assumeTrue( isLinuxSystem()); copyResources( "/with-init-changes-and-errors" ); this.plugin.undeploy( this.inst ); }