import os
import unittest
from framework import VppTestCase, VppTestRunner
from vpp_papi import VppEnum
import json


class TestJsonApiTrace(VppTestCase):
    """ JSON API trace related tests """

    @classmethod
    def setUpClass(cls):
        super(TestJsonApiTrace, cls).setUpClass()

    def setUp(self):
        self.vapi.cli("api trace free")
        self.vapi.cli("api trace on")
        self.vapi.cli("api trace tx on")

    @classmethod
    def tearDownClass(cls):
        super(TestJsonApiTrace, cls).tearDownClass()

    def test_json_api_trace_save(self):
        self.vapi.show_version()

        fname = 'test_api_trace-%d.json' % self.vpp.pid
        tmp_api_trace = "/tmp/%s" % fname
        fpath = '%s/%s' % (self.tempdir, fname)
        self.vapi.cli("api trace save-json {}".format(fname))
        os.rename(tmp_api_trace, fpath)
        with open(fpath, encoding='utf-8') as f:
            s = f.read()
        trace = json.loads(s)
        found = False
        for o in trace:
            if o['_msgname'] == 'show_version':
                found = True
                break
        self.assertTrue(found)
        self.assertEquals(o['_msgname'], 'show_version')

    def test_json_api_trace_replay(self):
        fname = '/tmp/create_loop.json'
        req = """
[
{
        "_msgname": "create_loopback",
        "_crc": "42bb5d22",
        "mac_address": "00:00:00:00:00:00"
}]
"""
        with open(fname, 'w') as f:
            f.write(req)
        self.vapi.cli("api trace replay-json {}".format(fname))
        r = self.vapi.sw_interface_dump(name_filter='loop',
                                        name_filter_valid=True)
        self.assertEqual(len(r), 1)
        self.assertEqual(r[0].interface_name, 'loop0')


if __name__ == '__main__':
    unittest.main(testRunner=VppTestRunner)
