示例#1
0
 def testPortInvalidName(self):
     yaml_code = """
   - name: 123abc
     containerPort: 123
   """
     with self.assertRaises(SystemExit):
         run_containers.LoadPorts(yaml.load(yaml_code), 'ctr_name')
示例#2
0
 def testPortWithInvalidProtocol(self):
     yaml_code = """
   - containerPort: 123
     protocol: IGMP
   """
     with self.assertRaises(SystemExit):
         run_containers.LoadPorts(yaml.load(yaml_code), 'ctr_name')
示例#3
0
 def testPortTooHighHostPort(self):
     yaml_code = """
   - containerPort: 123
     hostPort: 65536
   """
     with self.assertRaises(SystemExit):
         run_containers.LoadPorts(yaml.load(yaml_code), 'ctr_name')
示例#4
0
 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])
示例#5
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])
示例#6
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])
示例#7
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')
示例#8
0
 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])
示例#9
0
 def testPortTooLowContainerPort(self):
     yaml_code = """
   - containerPort: 0
   """
     with self.assertRaises(SystemExit):
         run_containers.LoadPorts(yaml.load(yaml_code), 'ctr_name')