Ejemplo n.º 1
0
 def test_load_bootstrap_no_file_specified(self):
     """
     Testing that load_bootstrap loads defaults into config object without bootstrap.yml
     """
     master_config = {
         'analysis':
             'common',
         'workload_setup':
             'common',
         'infrastructure_provisioning':
             'single',
         'mongodb_setup':
             'standalone',
         'platform':
             'linux',
         'production':
             False,
         'storageEngine':
             'wiredTiger',
         'terraform_linux_download':
             'https://releases.hashicorp.com/terraform/0.12.16/terraform_0.12.16_linux_amd64.zip',
         'terraform_mac_download':
             'https://releases.hashicorp.com/terraform/0.12.16/terraform_0.12.16_darwin_amd64.zip',
         'terraform_version_check':
             'Terraform v0.12.16',
         'test_control':
             'core'
     }
     test_config = {}
     bootstrap.load_bootstrap(test_config, '.')
     self.assertEqual(test_config, master_config)
Ejemplo n.º 2
0
 def execute_file(self, source):
     #print (source)
     env = new_environment()
     load_bootstrap(self.program, self.parser, self.evaluator, env)
     self.parser.reset(source=source)
     self.program.reset()
     self.parser.build_program_statements(self.program)
     self.evaluator.eval(self.program, env)
Ejemplo n.º 3
0
 def test_load_bootstrap_local_file_makedir(self):
     """
     Testing that load_bootstrap makes nonexistent directory and copies into it
     """
     bootstrap_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'bootstrap.yml')
     directory = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'testdir/')
     config = {'bootstrap_file': bootstrap_path, 'production': False}
     with open(bootstrap_path, 'w') as bootstrap_file:
         bootstrap_file.write('owner: test_owner')
     bootstrap.load_bootstrap(config, directory)
     self.assertEqual(config['owner'], 'test_owner')
Ejemplo n.º 4
0
 def test_load_bootstrap_different_filename(self):
     """
     Testing that load_bootstrap works with alternate file names
     """
     bootstrap_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'bootstrap2.yml')
     directory = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'testdir/')
     config = {'bootstrap_file': bootstrap_path, 'production': False}
     with open(bootstrap_path, 'w') as bootstrap_file:
         bootstrap_file.write('owner: test_owner')
     bootstrap.load_bootstrap(config, directory)
     self.assertEqual(config['owner'], 'test_owner')
Ejemplo n.º 5
0
 def loop(self):
     signal.signal(signal.SIGINT, signal_ctrl_c_handler)
     print("Ad interpreter [Python]... v1.1")
     env = new_environment()
     load_bootstrap(self.program, self.parser, self.evaluator, env)
     while True:
         line = input('>> ')
         self.parser.reset(source=line)
         self.program.reset()
         self.parser.build_program_statements(self.program)
         self.evaluator.eval(self.program, env)
Ejemplo n.º 6
0
 def test_load_bootstrap_no_file(self):
     """
     Testing that load_bootstrap fails when file doesn't exist
     """
     config = {'bootstrap_file': './notarealpath/bootstrap.yml', 'production': False}
     directory = os.getcwd()
     with LogCapture(level=logging.CRITICAL) as crit:
         with self.assertRaises(AssertionError):
             bootstrap.load_bootstrap(config, directory)
         crit.check(
             ('bootstrap', 'CRITICAL',
              u'[critical ] Location specified for bootstrap.yml is invalid. [bootstrap] '))
Ejemplo n.º 7
0
    def test_load_bootstrap_copy_file_to_local(self):
        """
        Testing that load_bootstrap copies specified file in 'testdir' to local directory
        """
        bootstrap_path = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                      'testdir/bootstrap.yml')
        bootstrap_directory = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'testdir/')
        os.mkdir(bootstrap_directory)
        config = {'bootstrap_file': bootstrap_path, 'production': False}
        with open(bootstrap_path, 'w') as bootstrap_file:
            bootstrap_file.write('owner: test_owner')
        bootstrap.load_bootstrap(config, os.path.dirname(os.path.abspath(__file__)))

        # confirms that load_bootstrap copies file into working directory correctly
        self.assertEqual(config['owner'], 'test_owner')
Ejemplo n.º 8
0
    def test_load_bootstrap_copy_file_default_to_local(self):
        """
        Testing that load_bootstrap uses local file if --bootstrap-file flag not used
        """
        bootstrap_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'bootstrap.yml')
        bootstrap_directory = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'testdir/')
        os.mkdir(bootstrap_directory)
        config = {'production': False}
        with open(bootstrap_path, 'w') as bootstrap_file:
            bootstrap_file.write('owner: test_owner')
        current_path = os.getcwd()
        os.chdir(os.path.join(bootstrap_directory, '..'))
        bootstrap.load_bootstrap(config, bootstrap_directory)
        os.chdir(current_path)

        # confirms that load_bootstrap copies local file into working directory if not specified
        self.assertEqual(config['owner'], 'test_owner')
Ejemplo n.º 9
0
 def test_load_bootstrap_copy_same_file(self):
     """
     Testing that load_bootstrap copies specified file in 'testdir' to
     local directory and fails on collision
     """
     bootstrap_path = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                   'testdir/bootstrap.yml')
     wrong_bootstrap_path = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                         './bootstrap.yml')
     bootstrap_directory = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'testdir/')
     os.mkdir(bootstrap_directory)
     config = {'bootstrap_file': bootstrap_path, 'production': False}
     with open(bootstrap_path, 'w') as bootstrap_file:
         bootstrap_file.write('owner: test_owner')
     with open(wrong_bootstrap_path, 'w') as wrong_bootstrap_file:
         wrong_bootstrap_file.write('owner: test_owner')
     with self.assertRaises(AssertionError):
         bootstrap.load_bootstrap(config, os.path.dirname(os.path.abspath(__file__)))
Ejemplo n.º 10
0
    def test_load_bootstrap_given_file_and_dir(self):
        """
        Testing that load_bootstrap copies file from 'test_old_dir' into
        'test_new_dir' without collisions
        """
        bootstrap_path = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                      'test_old_dir/bootstrap.yml')
        bootstrap_new_directory = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                               'test_new_dir/')
        bootstrap_old_directory = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                               'test_old_dir/')
        os.mkdir(bootstrap_new_directory)
        os.mkdir(bootstrap_old_directory)
        config = {'bootstrap_file': bootstrap_path, 'production': False}
        with open(bootstrap_path, 'w') as bootstrap_file:
            bootstrap_file.write('platform: test_platform')
        bootstrap.load_bootstrap(config, bootstrap_new_directory)

        # confirms that load_bootstrap copies file into working directory correctly
        self.assertEqual(config['platform'], 'test_platform')