def testPortInvalidName(self): yaml_code = """ - name: 123abc containerPort: 123 """ with self.assertRaises(SystemExit): run_containers.LoadPorts(yaml.load(yaml_code), 'ctr_name')
def testPortWithInvalidProtocol(self): yaml_code = """ - containerPort: 123 protocol: IGMP """ with self.assertRaises(SystemExit): run_containers.LoadPorts(yaml.load(yaml_code), 'ctr_name')
def testPortTooHighHostPort(self): yaml_code = """ - containerPort: 123 hostPort: 65536 """ with self.assertRaises(SystemExit): run_containers.LoadPorts(yaml.load(yaml_code), 'ctr_name')
def testPortWithProtocolUdp(self): yaml_code = """ - containerPort: 123 protocol: UDP """ x = run_containers.LoadPorts(yaml.load(yaml_code), 'ctr_name') self.assertEqual(1, len(x)) self.assertEqual((123, 123, '/udp'), x[0])
def testPortWithHostPort(self): yaml_code = """ - containerPort: 123 hostPort: 456 """ x = run_containers.LoadPorts(yaml.load(yaml_code), 'ctr_name') self.assertEqual(1, len(x)) self.assertEqual((456, 123, ''), x[0])
def testPortWithName(self): yaml_code = """ - name: abc123 containerPort: 123 """ x = run_containers.LoadPorts(yaml.load(yaml_code), 'ctr_name') self.assertEqual(1, len(x)) self.assertEqual((123, 123, ''), x[0])
def testPortDupName(self): yaml_code = """ - name: abc123 containerPort: 123 - name: abc123 containerPort: 124 """ with self.assertRaises(SystemExit): run_containers.LoadPorts(yaml.load(yaml_code), 'ctr_name')
def testPortValidMinimal(self): yaml_code = """ - containerPort: 1 - containerPort: 65535 """ x = run_containers.LoadPorts(yaml.load(yaml_code), 'ctr_name') self.assertEqual(2, len(x)) self.assertEqual((1, 1, ''), x[0]) self.assertEqual((65535, 65535, ''), x[1])
def testPortTooLowContainerPort(self): yaml_code = """ - containerPort: 0 """ with self.assertRaises(SystemExit): run_containers.LoadPorts(yaml.load(yaml_code), 'ctr_name')