def test_machine_env_success(self): try: manager.create_default(autostart=True) result = manager.env() self.assertTrue(result is not None) self.assertTrue(len(result) >= 1) print("Docker machine env: " + str(result)) ''' example result export DOCKER_TLS_VERIFY="1" export DOCKER_HOST="tcp://192.168.99.100:2376" export DOCKER_CERT_PATH="/home/sergio/.docker/machine/machines/default" export DOCKER_MACHINE_NAME="default" # Run this command to configure your shell: # eval $(docker-machine env) ''' values = [ 'export DOCKER_TLS_VERIFY=', 'export DOCKER_HOST="tcp://', 'export DOCKER_CERT_PATH="', 'export DOCKER_MACHINE_NAME="', '# Run this command to configure your shell:', '# eval $(/' ] for i in range(len(result) - 1): line = str(result[i]) match = values[i] print(line + " " + match) self.assertTrue(line.startswith(match)) except MachineError as e: self.assertTrue(e is None)
def test_machine_url_success(self): try: manager.create_default(autostart=True) url = manager.get_url() print("Machine url is : "+url) self.assertTrue(len(url) > 0) except MachineError as m: self.assertTrue(m is not None)
def test_machine_upgrade_success(self): try: manager.create_default(autostart=True) result = manager.upgrade() self.assertTrue(result is not None) self.assertTrue(len(result) >= 1) except MachineError as e: self.assertTrue(e is None)
def test_machine_active_success(self): try: manager.create_default(autostart=True) result = manager.active() self.assertTrue(result is not None) self.assertTrue(len(result) >= 1) print("Docker machine active list: " + result) except MachineError as e: self.assertTrue(e is None)
def test_machine_config_swarm_success(self): try: manager.create_default(autostart=True) result = manager.config(swarm_config=True) self.assertTrue(result is not None) self.assertTrue(len(result) >= 1) print("Docker machine swarm configuration: " + str(result)) self.assertTrue(False) except MachineError as e: self.assertTrue(e is None)
def test_machine_stop_twice_success(self): """ Test that tries to stop the same machine twice :return: """ try: manager.create_default() manager.stop() result = manager.stop() self.assertTrue(result is not None) self.assertTrue(len(result) >= 1) except MachineError as e: self.assertTrue(type(e) is MachineAlreadyStoppedError)
def test_machine_ip_success(self): try: manager.create_default(autostart=True) result = manager.ip() self.assertTrue(result is not None) self.assertTrue(len(result) >= 1) print("Docker machine ip: " + str(result)) ''' example result 192.168.99.100 ''' self.assertTrue(len(str(result).split(".")) == 4) except MachineError as e: self.assertTrue(e is None)
def test_machine_inspect_success(self): try: manager.create_default(autostart=True) result = manager.inspect() self.assertTrue(result is not None) self.assertTrue(len(result) >= 1) print("Docker machine inspect: " + str(result)) ''' example result big json ''' self.assertTrue(str(result).index('"ConfigVersion":') != -1) self.assertTrue(str(result).index('"EngineOptions": {') != -1) self.assertTrue(str(result).index('"SwarmOptions": {') != -1) self.assertTrue(str(result).index('"AuthOptions": {') != -1) except MachineError as e: self.assertTrue(e is None)
def test_machine_config_success(self): try: manager.create_default(autostart=True) result = manager.config() self.assertTrue(result is not None) self.assertTrue(len(result) >= 1) print("Docker machine configuration: " + str(result)) values = [ '--tlsverify', '--tlscacert=', '--tlscert=', '--tlskey=', '-H=tcp://' ] for i in range(len(result) - 1): line = str(result[i]) match = values[i] print(line + " " + match) self.assertTrue(line.startswith(match)) except MachineError as e: self.assertTrue(e is None)
def test_machine_stop_success(self): manager.create_default(autostart=True) result = manager.stop() self.assertTrue(result is not None) self.assertTrue(len(result) >= 1)
def test_machine_default_create(self): result = manager.create_default() print(result) self.assertTrue(result is not None) self.assertTrue(len(result) >= 1)