forked from ungleich-public/cdist
		
	tests and fixtures for emulator autorequire
Signed-off-by: Steven Armstrong <steven@icarus.ethz.ch>
This commit is contained in:
		
					parent
					
						
							
								6e7ebf6de1
							
						
					
				
			
			
				commit
				
					
						0d05e61b85
					
				
			
		
					 9 changed files with 56 additions and 1 deletions
				
			
		| 
						 | 
					@ -22,6 +22,7 @@
 | 
				
			||||||
import os
 | 
					import os
 | 
				
			||||||
import shutil
 | 
					import shutil
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import cdist
 | 
				
			||||||
from cdist import test
 | 
					from cdist import test
 | 
				
			||||||
from cdist.exec import local
 | 
					from cdist.exec import local
 | 
				
			||||||
from cdist import emulator
 | 
					from cdist import emulator
 | 
				
			||||||
| 
						 | 
					@ -29,7 +30,6 @@ from cdist import core
 | 
				
			||||||
 | 
					
 | 
				
			||||||
local_base_path = test.cdist_base_path
 | 
					local_base_path = test.cdist_base_path
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
class EmulatorTestCase(test.CdistTestCase):
 | 
					class EmulatorTestCase(test.CdistTestCase):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def setUp(self):
 | 
					    def setUp(self):
 | 
				
			||||||
| 
						 | 
					@ -73,3 +73,32 @@ class EmulatorTestCase(test.CdistTestCase):
 | 
				
			||||||
        os.environ['require'] = '__file/bad/id/with/.cdist/inside'
 | 
					        os.environ['require'] = '__file/bad/id/with/.cdist/inside'
 | 
				
			||||||
        emu = emulator.Emulator(argv)
 | 
					        emu = emulator.Emulator(argv)
 | 
				
			||||||
        self.assertRaises(core.IllegalObjectIdError, emu.run)
 | 
					        self.assertRaises(core.IllegalObjectIdError, emu.run)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import os.path as op
 | 
				
			||||||
 | 
					my_dir = op.abspath(op.dirname(__file__))
 | 
				
			||||||
 | 
					fixtures = op.join(my_dir, 'fixtures')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class AutoRequireEmulatorTestCase(test.CdistTestCase):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def setUp(self):
 | 
				
			||||||
 | 
					        self.temp_dir = self.mkdtemp()
 | 
				
			||||||
 | 
					        self.target_host = 'localhost'
 | 
				
			||||||
 | 
					        out_path = self.temp_dir
 | 
				
			||||||
 | 
					        _local_base_path = fixtures
 | 
				
			||||||
 | 
					        self.local = local.Local(self.target_host, _local_base_path, out_path)
 | 
				
			||||||
 | 
					        self.local.create_directories()
 | 
				
			||||||
 | 
					        self.local.link_emulator(cdist.test.cdist_exec_path)
 | 
				
			||||||
 | 
					        self.manifest = core.Manifest(self.target_host, self.local)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def tearDown(self):
 | 
				
			||||||
 | 
					        shutil.rmtree(self.temp_dir)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def test_autorequire(self):
 | 
				
			||||||
 | 
					        initial_manifest = os.path.join(self.local.manifest_path, "init")
 | 
				
			||||||
 | 
					        self.manifest.run_initial_manifest(initial_manifest)
 | 
				
			||||||
 | 
					        cdist_type = core.Type(self.local.type_path, '__saturn')
 | 
				
			||||||
 | 
					        cdist_object = core.Object(cdist_type, self.local.object_path, 'singleton')
 | 
				
			||||||
 | 
					        self.manifest.run_type_manifest(cdist_object)
 | 
				
			||||||
 | 
					        expected = ['__planet/Saturn', '__moon/Prometheus']
 | 
				
			||||||
 | 
					        self.assertEqual(sorted(cdist_object.requirements), sorted(expected))
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										3
									
								
								lib/cdist/test/emulator/fixtures/conf/manifest/init
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										3
									
								
								lib/cdist/test/emulator/fixtures/conf/manifest/init
									
										
									
									
									
										Executable file
									
								
							| 
						 | 
					@ -0,0 +1,3 @@
 | 
				
			||||||
 | 
					#!/bin/sh
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					__saturn
 | 
				
			||||||
							
								
								
									
										8
									
								
								lib/cdist/test/emulator/fixtures/conf/type/__moon/manifest
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										8
									
								
								lib/cdist/test/emulator/fixtures/conf/type/__moon/manifest
									
										
									
									
									
										Executable file
									
								
							| 
						 | 
					@ -0,0 +1,8 @@
 | 
				
			||||||
 | 
					#!/bin/sh
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if [ -f "$__object/parameter/name" ]; then
 | 
				
			||||||
 | 
					   name="(cat "$__object/parameter/name")"
 | 
				
			||||||
 | 
					else
 | 
				
			||||||
 | 
					   name="$__object_id"
 | 
				
			||||||
 | 
					   echo "$name" > "$__object/parameter/name"
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1 @@
 | 
				
			||||||
 | 
					name
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1 @@
 | 
				
			||||||
 | 
					planet
 | 
				
			||||||
							
								
								
									
										8
									
								
								lib/cdist/test/emulator/fixtures/conf/type/__planet/manifest
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										8
									
								
								lib/cdist/test/emulator/fixtures/conf/type/__planet/manifest
									
										
									
									
									
										Executable file
									
								
							| 
						 | 
					@ -0,0 +1,8 @@
 | 
				
			||||||
 | 
					#!/bin/sh
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if [ -f "$__object/parameter/name" ]; then
 | 
				
			||||||
 | 
					   name="(cat "$__object/parameter/name")"
 | 
				
			||||||
 | 
					else
 | 
				
			||||||
 | 
					   name="$__object_id"
 | 
				
			||||||
 | 
					   echo "$name" > "$__object/parameter/name"
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1 @@
 | 
				
			||||||
 | 
					name
 | 
				
			||||||
							
								
								
									
										4
									
								
								lib/cdist/test/emulator/fixtures/conf/type/__saturn/manifest
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										4
									
								
								lib/cdist/test/emulator/fixtures/conf/type/__saturn/manifest
									
										
									
									
									
										Executable file
									
								
							| 
						 | 
					@ -0,0 +1,4 @@
 | 
				
			||||||
 | 
					#!/bin/sh
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					__planet Saturn
 | 
				
			||||||
 | 
					require="__planet/Saturn" __moon Prometheus --planet Saturn
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue