Ejemplo n.º 1
0
 def testMarathonAppNot404(self):
     with patch('lighter.util.jsonRequest', wraps=self._createJsonRequestWrapper('http://defaultmarathon:2')) as m_urlopen:
         resp = Mock()
         resp.read.return_value = '{"message": "no app"}'
         m_urlopen.side_effect = urllib2.HTTPError('', 504, 'no app', {'Content-Type': 'application/json'}, resp)
         with self.assertRaises(RuntimeError):
             lighter.deploy(marathonurl=None, filenames=['src/resources/yaml/integration/myservice.yml'])
Ejemplo n.º 2
0
 def testDeprecatedResolveTag(self):
     """
     Checks that version ranges can be resolved in the "version: " tag as well
     """
     with patch('lighter.util.jsonRequest', wraps=self._createJsonRequestWrapper()):
         lighter.deploy('http://localhost:1/', filenames=['src/resources/yaml/integration/myservice-version-range.yml'])
         self.assertTrue(self._called)
Ejemplo n.º 3
0
 def testResolveMavenJson(self):
     with patch('lighter.util.jsonRequest',
                wraps=self._createJsonRequestWrapper()):
         lighter.deploy(
             'http://localhost:1/',
             filenames=['src/resources/yaml/integration/myservice.yml'])
         self.assertTrue(self._called)
Ejemplo n.º 4
0
 def testDefaultMarathonUrl(self):
     with patch('lighter.util.jsonRequest',
                wraps=self._createJsonRequestWrapper(
                    'http://defaultmarathon:2')):
         lighter.deploy(
             marathonurl=None,
             filenames=['src/resources/yaml/integration/myservice.yml'])
         self.assertTrue(self._called)
Ejemplo n.º 5
0
 def testParseError(self):
     with patch('lighter.util.jsonRequest', wraps=self._parseErrorPost):
         with self.assertRaises(RuntimeError):
             lighter.deploy(
                 'http://localhost:1/',
                 filenames=[
                     'src/resources/yaml/staging/myservice.yml',
                     'src/resources/yaml/staging/myservice-broken.yml'
                 ])
Ejemplo n.º 6
0
    def testDefaultTags(self):
        with patch("lighter.util.jsonRequest", wraps=self._createJsonRequestWrapper()) as mock_jsonRequest:
            lighter.deploy("http://localhost:1/", filenames=["src/resources/yaml/integration/datadog-default-tags.yml"])
            mock_jsonRequest.assert_any_call(
                "https://app.datadoghq.com/api/v1/events?api_key=abc", data=ANY, method="POST"
            )

            expected = ["environment:default", u"service:/myproduct/myservice", "source:lighter", "type:change"]
            self.assertEquals(expected, mock_jsonRequest.call_args[1]["data"]["tags"])
Ejemplo n.º 7
0
 def testMarathonAppURLError(self):
     with patch('lighter.util.jsonRequest',
                wraps=self._createJsonRequestWrapper(
                    'http://defaultmarathon:2')) as m_urlopen:
         m_urlopen.side_effect = urllib2.URLError("hello")
         with self.assertRaises(RuntimeError):
             lighter.deploy(
                 marathonurl=None,
                 filenames=['src/resources/yaml/integration/myservice.yml'])
Ejemplo n.º 8
0
 def testNoMarathonUrlDefined(self):
     with patch('lighter.util.jsonRequest',
                wraps=self._createJsonRequestWrapper()):
         with self.assertRaises(RuntimeError) as cm:
             lighter.deploy(
                 marathonurl=None,
                 filenames=['src/resources/yaml/staging/myservice.yml'])
         self.assertEqual(
             "No Marathon URL defined for service src/resources/yaml/staging/myservice.yml",
             cm.exception.message)
Ejemplo n.º 9
0
 def testDeprecatedResolveTag(self):
     """
     Checks that version ranges can be resolved in the "version: " tag as well
     """
     with patch('lighter.util.jsonRequest',
                wraps=self._createJsonRequestWrapper()):
         lighter.deploy(
             'http://localhost:1/',
             filenames=[
                 'src/resources/yaml/integration/myservice-version-range.yml'
             ])
         self.assertTrue(self._called)
Ejemplo n.º 10
0
 def testMarathonAppNot404(self):
     with patch('lighter.util.jsonRequest',
                wraps=self._createJsonRequestWrapper(
                    'http://defaultmarathon:2')) as m_urlopen:
         resp = Mock()
         resp.read.return_value = '{"message": "no app"}'
         m_urlopen.side_effect = urllib2.HTTPError(
             '', 504, 'no app', {'Content-Type': 'application/json'}, resp)
         with self.assertRaises(RuntimeError):
             lighter.deploy(
                 marathonurl=None,
                 filenames=['src/resources/yaml/integration/myservice.yml'])
Ejemplo n.º 11
0
 def testParseError(self):
     with patch("lighter.util.jsonRequest", wraps=self._parseErrorPost) as mock_jsonRequest:
         try:
             lighter.deploy(
                 "http://localhost:1/",
                 filenames=[
                     "src/resources/yaml/staging/myservice.yml",
                     "src/resources/yaml/staging/myservice-broken.yml",
                 ],
             )
         except yaml.scanner.ScannerError:
             pass
         else:
             self.fail("Expected yaml.ScannerError")
Ejemplo n.º 12
0
    def testDefaultTags(self):
        with patch('lighter.util.jsonRequest',
                   wraps=self._createJsonRequestWrapper()) as mock_jsonRequest:
            lighter.deploy(
                'http://localhost:1/',
                filenames=[
                    'src/resources/yaml/integration/datadog-default-tags.yml'
                ])
            mock_jsonRequest.assert_any_call(
                'https://app.datadoghq.com/api/v1/events?api_key=abc',
                data=ANY,
                method='POST')

            expected = [
                'environment:default', u'service:/myproduct/myservice',
                'source:lighter', 'type:change'
            ]
            self.assertEquals(expected,
                              mock_jsonRequest.call_args[1]['data']['tags'])
Ejemplo n.º 13
0
    def testDeploymentMetric(self):
        with patch("lighter.util.jsonRequest", wraps=self._createJsonRequestWrapper()) as mock_jsonRequest:
            lighter.deploy("http://localhost:1/", filenames=["src/resources/yaml/integration/datadog-config-tags.yml"])
            mock_jsonRequest.assert_any_call(
                "https://app.datadoghq.com/api/v1/series?api_key=abc", data=ANY, method="POST"
            )

            tags = [
                "environment:default",
                u"service:/myproduct/myservice",
                "somekey:someval",
                "anotherkey:anotherval",
                "justakey",
                "source:lighter",
                "type:change",
                "status:success",
            ]
            data = mock_jsonRequest.call_args_list[-2][1]["data"]["series"][0]
            self.assertEquals("datadog.events", data["metric"])
            self.assertEquals(1, data["points"][0][1])
            self.assertEquals(tags, data["tags"])
Ejemplo n.º 14
0
    def testDeploymentMetric(self):
        with patch('lighter.util.jsonRequest',
                   wraps=self._createJsonRequestWrapper()) as mock_jsonRequest:
            lighter.deploy(
                'http://localhost:1/',
                filenames=[
                    'src/resources/yaml/integration/datadog-config-tags.yml'
                ])
            mock_jsonRequest.assert_any_call(
                'https://app.datadoghq.com/api/v1/series?api_key=abc',
                data=ANY,
                method='POST')

            tags = [
                'environment:default', u'service:/myproduct/myservice',
                'somekey:someval', 'anotherkey:anotherval', 'justakey',
                'source:lighter', 'type:change', 'status:success'
            ]
            data = mock_jsonRequest.call_args_list[-2][1]['data']['series'][0]
            self.assertEquals('datadog.events', data['metric'])
            self.assertEquals(1, data['points'][0][1])
            self.assertEquals(tags, data['tags'])
Ejemplo n.º 15
0
 def testResolve(self):
     with patch("lighter.util.jsonRequest", wraps=self._resolvePost) as mock_jsonRequest:
         lighter.deploy("http://localhost:1/", filenames=["src/resources/yaml/integration/myservice.yml"])
         self.assertTrue(self._resolvePostCalled)
Ejemplo n.º 16
0
 def testResolveMavenJson(self):
     with patch('lighter.util.jsonRequest', wraps=self._createJsonRequestWrapper()):
         lighter.deploy('http://localhost:1/', filenames=['src/resources/yaml/integration/myservice.yml'])
         self.assertTrue(self._called)
Ejemplo n.º 17
0
 def testMarathonAppURLError(self):
     with patch('lighter.util.jsonRequest', wraps=self._createJsonRequestWrapper('http://defaultmarathon:2')) as m_urlopen:
         m_urlopen.side_effect = urllib2.URLError("hello")
         with self.assertRaises(RuntimeError):
             lighter.deploy(marathonurl=None, filenames=['src/resources/yaml/integration/myservice.yml'])
Ejemplo n.º 18
0
 def testDefaultMarathonUrl(self):
     with patch('lighter.util.jsonRequest', wraps=self._createJsonRequestWrapper('http://defaultmarathon:2')):
         lighter.deploy(marathonurl=None, filenames=['src/resources/yaml/integration/myservice.yml'])
         self.assertTrue(self._called)
Ejemplo n.º 19
0
 def testNoMarathonUrlDefined(self):
     with patch('lighter.util.jsonRequest', wraps=self._createJsonRequestWrapper()):
         with self.assertRaises(RuntimeError) as cm:
             lighter.deploy(marathonurl=None, filenames=['src/resources/yaml/staging/myservice.yml'])
         self.assertEqual("No Marathon URL defined for service src/resources/yaml/staging/myservice.yml", cm.exception.message)
Ejemplo n.º 20
0
 def testParseError(self):
     with patch('lighter.util.jsonRequest', wraps=self._parseErrorPost):
         with self.assertRaises(RuntimeError):
             lighter.deploy('http://localhost:1/', filenames=['src/resources/yaml/staging/myservice.yml', 'src/resources/yaml/staging/myservice-broken.yml'])