@cryptotaxi247 / netdata-1 / commits / cabfd5271

test(go.d dyncfg): fix tests (#19676)

Ilya Mashchenko committed Feb 19, 2025 at 12:39 UTC cabfd5271edfa456e932ed841df0b54f65210a74
1 file changed +45 -22
src/go/plugin/go.d/agent/jobmgr/manager_test.go
+45 -22
@@ -567,6 +567,7 @@ FUNCTION_RESULT_END
567 do: func(mgr *Manager, _ chan []*confgroup.Group) {
568 mgr.dyncfgConfig(functions.Function{
569 UID: "1-add",
570 + Source: "type=dyncfg",
571 Args: []string{dyncfgModID(cfg.Module()), "add", cfg.Name()},
572 Payload: bs,
573 })
@@ -589,7 +590,7 @@ FUNCTION_RESULT_BEGIN 1-add 202 application/json
590 {"status":202,"message":""}
591 FUNCTION_RESULT_END
592
592 -CONFIG go.d:collector:success:test create accepted job /collectors/jobs dyncfg 'type=dyncfg,module=success,job=test' 'schema get enable disable update restart test userconfig remove' 0x0000 0x0000
593 +CONFIG go.d:collector:success:test create accepted job /collectors/jobs dyncfg 'type=dyncfg' 'schema get enable disable update restart test userconfig remove' 0x0000 0x0000
594
595 FUNCTION_RESULT_BEGIN 2-get 200 application/json
596 {"option_str":"1","option_int":1}
@@ -684,6 +685,7 @@ func TestManager_Run_Dyncfg_Add(t *testing.T) {
685 do: func(mgr *Manager, _ chan []*confgroup.Group) {
686 mgr.dyncfgConfig(functions.Function{
687 UID: "1-add",
688 + Source: "type=dyncfg",
689 Args: []string{dyncfgModID(cfg.Module()), "add", cfg.Name()},
690 Payload: []byte("{}"),
691 })
@@ -702,7 +704,7 @@ FUNCTION_RESULT_BEGIN 1-add 202 application/json
704 {"status":202,"message":""}
705 FUNCTION_RESULT_END
706
705 -CONFIG go.d:collector:success:test create accepted job /collectors/jobs dyncfg 'type=dyncfg,module=success,job=test' 'schema get enable disable update restart test userconfig remove' 0x0000 0x0000
707 +CONFIG go.d:collector:success:test create accepted job /collectors/jobs dyncfg 'type=dyncfg' 'schema get enable disable update restart test userconfig remove' 0x0000 0x0000
708 `,
709 }
710 },
@@ -715,6 +717,7 @@ CONFIG go.d:collector:success:test create accepted job /collectors/jobs dyncfg '
717 do: func(mgr *Manager, _ chan []*confgroup.Group) {
718 mgr.dyncfgConfig(functions.Function{
719 UID: "1-add",
720 + Source: "type=dyncfg",
721 Args: []string{dyncfgModID(cfg.Module()), "add", cfg.Name()},
722 Payload: []byte("{}"),
723 })
@@ -733,7 +736,7 @@ FUNCTION_RESULT_BEGIN 1-add 202 application/json
736 {"status":202,"message":""}
737 FUNCTION_RESULT_END
738
736 -CONFIG go.d:collector:fail:test create accepted job /collectors/jobs dyncfg 'type=dyncfg,module=fail,job=test' 'schema get enable disable update restart test userconfig remove' 0x0000 0x0000
739 +CONFIG go.d:collector:fail:test create accepted job /collectors/jobs dyncfg 'type=dyncfg' 'schema get enable disable update restart test userconfig remove' 0x0000 0x0000
740 `,
741 }
742 },
@@ -746,11 +749,13 @@ CONFIG go.d:collector:fail:test create accepted job /collectors/jobs dyncfg 'typ
749 do: func(mgr *Manager, _ chan []*confgroup.Group) {
750 mgr.dyncfgConfig(functions.Function{
751 UID: "1-add",
752 + Source: "type=dyncfg",
753 Args: []string{dyncfgModID(cfg.Module()), "add", cfg.Name()},
754 Payload: []byte("{}"),
755 })
756 mgr.dyncfgConfig(functions.Function{
757 UID: "2-add",
758 + Source: "type=dyncfg",
759 Args: []string{dyncfgModID(cfg.Module()), "add", cfg.Name()},
760 Payload: []byte("{}"),
761 })
@@ -769,13 +774,13 @@ FUNCTION_RESULT_BEGIN 1-add 202 application/json
774 {"status":202,"message":""}
775 FUNCTION_RESULT_END
776
772 -CONFIG go.d:collector:success:test create accepted job /collectors/jobs dyncfg 'type=dyncfg,module=success,job=test' 'schema get enable disable update restart test userconfig remove' 0x0000 0x0000
777 +CONFIG go.d:collector:success:test create accepted job /collectors/jobs dyncfg 'type=dyncfg' 'schema get enable disable update restart test userconfig remove' 0x0000 0x0000
778
779 FUNCTION_RESULT_BEGIN 2-add 202 application/json
780 {"status":202,"message":""}
781 FUNCTION_RESULT_END
782
778 -CONFIG go.d:collector:success:test create accepted job /collectors/jobs dyncfg 'type=dyncfg,module=success,job=test' 'schema get enable disable update restart test userconfig remove' 0x0000 0x0000
783 +CONFIG go.d:collector:success:test create accepted job /collectors/jobs dyncfg 'type=dyncfg' 'schema get enable disable update restart test userconfig remove' 0x0000 0x0000
784 `,
785 }
786 },
@@ -826,6 +831,7 @@ FUNCTION_RESULT_END
831 do: func(mgr *Manager, _ chan []*confgroup.Group) {
832 mgr.dyncfgConfig(functions.Function{
833 UID: "1-add",
834 + Source: "type=dyncfg",
835 Args: []string{dyncfgModID(cfg.Module()), "add", cfg.Name()},
836 Payload: []byte("{}"),
837 })
@@ -848,7 +854,7 @@ FUNCTION_RESULT_BEGIN 1-add 202 application/json
854 {"status":202,"message":""}
855 FUNCTION_RESULT_END
856
851 -CONFIG go.d:collector:success:test create accepted job /collectors/jobs dyncfg 'type=dyncfg,module=success,job=test' 'schema get enable disable update restart test userconfig remove' 0x0000 0x0000
857 +CONFIG go.d:collector:success:test create accepted job /collectors/jobs dyncfg 'type=dyncfg' 'schema get enable disable update restart test userconfig remove' 0x0000 0x0000
858
859 FUNCTION_RESULT_BEGIN 2-enable 200 application/json
860 {"status":200,"message":""}
@@ -867,6 +873,7 @@ CONFIG go.d:collector:success:test status running
873 do: func(mgr *Manager, _ chan []*confgroup.Group) {
874 mgr.dyncfgConfig(functions.Function{
875 UID: "1-add",
876 + Source: "type=dyncfg",
877 Args: []string{dyncfgModID(cfg.Module()), "add", cfg.Name()},
878 Payload: []byte("{}"),
879 })
@@ -893,7 +900,7 @@ FUNCTION_RESULT_BEGIN 1-add 202 application/json
900 {"status":202,"message":""}
901 FUNCTION_RESULT_END
902
896 -CONFIG go.d:collector:success:test create accepted job /collectors/jobs dyncfg 'type=dyncfg,module=success,job=test' 'schema get enable disable update restart test userconfig remove' 0x0000 0x0000
903 +CONFIG go.d:collector:success:test create accepted job /collectors/jobs dyncfg 'type=dyncfg' 'schema get enable disable update restart test userconfig remove' 0x0000 0x0000
904
905 FUNCTION_RESULT_BEGIN 2-enable 200 application/json
906 {"status":200,"message":""}
@@ -918,6 +925,7 @@ CONFIG go.d:collector:success:test status running
925 do: func(mgr *Manager, _ chan []*confgroup.Group) {
926 mgr.dyncfgConfig(functions.Function{
927 UID: "1-add",
928 + Source: "type=dyncfg",
929 Args: []string{dyncfgModID(cfg.Module()), "add", cfg.Name()},
930 Payload: []byte("{}"),
931 })
@@ -940,7 +948,7 @@ FUNCTION_RESULT_BEGIN 1-add 202 application/json
948 {"status":202,"message":""}
949 FUNCTION_RESULT_END
950
943 -CONFIG go.d:collector:fail:test create accepted job /collectors/jobs dyncfg 'type=dyncfg,module=fail,job=test' 'schema get enable disable update restart test userconfig remove' 0x0000 0x0000
951 +CONFIG go.d:collector:fail:test create accepted job /collectors/jobs dyncfg 'type=dyncfg' 'schema get enable disable update restart test userconfig remove' 0x0000 0x0000
952
953 FUNCTION_RESULT_BEGIN 2-enable 200 application/json
954 {"status":200,"message":"Job enable failed: mock failed init."}
@@ -959,6 +967,7 @@ CONFIG go.d:collector:fail:test status failed
967 do: func(mgr *Manager, _ chan []*confgroup.Group) {
968 mgr.dyncfgConfig(functions.Function{
969 UID: "1-add",
970 + Source: "type=dyncfg",
971 Args: []string{dyncfgModID(cfg.Module()), "add", cfg.Name()},
972 Payload: []byte("{}"),
973 })
@@ -985,7 +994,7 @@ FUNCTION_RESULT_BEGIN 1-add 202 application/json
994 {"status":202,"message":""}
995 FUNCTION_RESULT_END
996
988 -CONFIG go.d:collector:fail:test create accepted job /collectors/jobs dyncfg 'type=dyncfg,module=fail,job=test' 'schema get enable disable update restart test userconfig remove' 0x0000 0x0000
997 +CONFIG go.d:collector:fail:test create accepted job /collectors/jobs dyncfg 'type=dyncfg' 'schema get enable disable update restart test userconfig remove' 0x0000 0x0000
998
999 FUNCTION_RESULT_BEGIN 2-enable 200 application/json
1000 {"status":200,"message":"Job enable failed: mock failed init."}
@@ -1048,6 +1057,7 @@ FUNCTION_RESULT_END
1057 do: func(mgr *Manager, _ chan []*confgroup.Group) {
1058 mgr.dyncfgConfig(functions.Function{
1059 UID: "1-add",
1060 + Source: "type=dyncfg",
1061 Args: []string{dyncfgModID(cfg.Module()), "add", cfg.Name()},
1062 Payload: []byte("{}"),
1063 })
@@ -1070,7 +1080,7 @@ FUNCTION_RESULT_BEGIN 1-add 202 application/json
1080 {"status":202,"message":""}
1081 FUNCTION_RESULT_END
1082
1073 -CONFIG go.d:collector:success:test create accepted job /collectors/jobs dyncfg 'type=dyncfg,module=success,job=test' 'schema get enable disable update restart test userconfig remove' 0x0000 0x0000
1083 +CONFIG go.d:collector:success:test create accepted job /collectors/jobs dyncfg 'type=dyncfg' 'schema get enable disable update restart test userconfig remove' 0x0000 0x0000
1084
1085 FUNCTION_RESULT_BEGIN 2-disable 200 application/json
1086 {"status":200,"message":""}
@@ -1089,6 +1099,7 @@ CONFIG go.d:collector:success:test status disabled
1099 do: func(mgr *Manager, _ chan []*confgroup.Group) {
1100 mgr.dyncfgConfig(functions.Function{
1101 UID: "1-add",
1102 + Source: "type=dyncfg",
1103 Args: []string{dyncfgModID(cfg.Module()), "add", cfg.Name()},
1104 Payload: []byte("{}"),
1105 })
@@ -1115,7 +1126,7 @@ FUNCTION_RESULT_BEGIN 1-add 202 application/json
1126 {"status":202,"message":""}
1127 FUNCTION_RESULT_END
1128
1118 -CONFIG go.d:collector:success:test create accepted job /collectors/jobs dyncfg 'type=dyncfg,module=success,job=test' 'schema get enable disable update restart test userconfig remove' 0x0000 0x0000
1129 +CONFIG go.d:collector:success:test create accepted job /collectors/jobs dyncfg 'type=dyncfg' 'schema get enable disable update restart test userconfig remove' 0x0000 0x0000
1130
1131 FUNCTION_RESULT_BEGIN 2-disable 200 application/json
1132 {"status":200,"message":""}
@@ -1140,6 +1151,7 @@ CONFIG go.d:collector:success:test status disabled
1151 do: func(mgr *Manager, _ chan []*confgroup.Group) {
1152 mgr.dyncfgConfig(functions.Function{
1153 UID: "1-add",
1154 + Source: "type=dyncfg",
1155 Args: []string{dyncfgModID(cfg.Module()), "add", cfg.Name()},
1156 Payload: []byte("{}"),
1157 })
@@ -1162,7 +1174,7 @@ FUNCTION_RESULT_BEGIN 1-add 202 application/json
1174 {"status":202,"message":""}
1175 FUNCTION_RESULT_END
1176
1165 -CONFIG go.d:collector:fail:test create accepted job /collectors/jobs dyncfg 'type=dyncfg,module=fail,job=test' 'schema get enable disable update restart test userconfig remove' 0x0000 0x0000
1177 +CONFIG go.d:collector:fail:test create accepted job /collectors/jobs dyncfg 'type=dyncfg' 'schema get enable disable update restart test userconfig remove' 0x0000 0x0000
1178
1179 FUNCTION_RESULT_BEGIN 2-disable 200 application/json
1180 {"status":200,"message":""}
@@ -1181,6 +1193,7 @@ CONFIG go.d:collector:fail:test status disabled
1193 do: func(mgr *Manager, _ chan []*confgroup.Group) {
1194 mgr.dyncfgConfig(functions.Function{
1195 UID: "1-add",
1196 + Source: "type=dyncfg",
1197 Args: []string{dyncfgModID(cfg.Module()), "add", cfg.Name()},
1198 Payload: []byte("{}"),
1199 })
@@ -1207,7 +1220,7 @@ FUNCTION_RESULT_BEGIN 1-add 202 application/json
1220 {"status":202,"message":""}
1221 FUNCTION_RESULT_END
1222
1210 -CONFIG go.d:collector:fail:test create accepted job /collectors/jobs dyncfg 'type=dyncfg,module=fail,job=test' 'schema get enable disable update restart test userconfig remove' 0x0000 0x0000
1223 +CONFIG go.d:collector:fail:test create accepted job /collectors/jobs dyncfg 'type=dyncfg' 'schema get enable disable update restart test userconfig remove' 0x0000 0x0000
1224
1225 FUNCTION_RESULT_BEGIN 2-disable 200 application/json
1226 {"status":200,"message":""}
@@ -1270,6 +1283,7 @@ FUNCTION_RESULT_END
1283 do: func(mgr *Manager, _ chan []*confgroup.Group) {
1284 mgr.dyncfgConfig(functions.Function{
1285 UID: "1-add",
1286 + Source: "type=dyncfg",
1287 Args: []string{dyncfgModID(cfg.Module()), "add", cfg.Name()},
1288 Payload: []byte("{}"),
1289 })
@@ -1292,7 +1306,7 @@ FUNCTION_RESULT_BEGIN 1-add 202 application/json
1306 {"status":202,"message":""}
1307 FUNCTION_RESULT_END
1308
1295 -CONFIG go.d:collector:success:test create accepted job /collectors/jobs dyncfg 'type=dyncfg,module=success,job=test' 'schema get enable disable update restart test userconfig remove' 0x0000 0x0000
1309 +CONFIG go.d:collector:success:test create accepted job /collectors/jobs dyncfg 'type=dyncfg' 'schema get enable disable update restart test userconfig remove' 0x0000 0x0000
1310
1311 FUNCTION_RESULT_BEGIN 2-restart 405 application/json
1312 {"status":405,"message":"Restarting data collection job is not allowed in 'accepted' state."}
@@ -1311,6 +1325,7 @@ CONFIG go.d:collector:success:test status accepted
1325 do: func(mgr *Manager, _ chan []*confgroup.Group) {
1326 mgr.dyncfgConfig(functions.Function{
1327 UID: "1-add",
1328 + Source: "type=dyncfg",
1329 Args: []string{dyncfgModID(cfg.Module()), "add", cfg.Name()},
1330 Payload: []byte("{}"),
1331 })
@@ -1337,7 +1352,7 @@ FUNCTION_RESULT_BEGIN 1-add 202 application/json
1352 {"status":202,"message":""}
1353 FUNCTION_RESULT_END
1354
1340 -CONFIG go.d:collector:success:test create accepted job /collectors/jobs dyncfg 'type=dyncfg,module=success,job=test' 'schema get enable disable update restart test userconfig remove' 0x0000 0x0000
1355 +CONFIG go.d:collector:success:test create accepted job /collectors/jobs dyncfg 'type=dyncfg' 'schema get enable disable update restart test userconfig remove' 0x0000 0x0000
1356
1357 FUNCTION_RESULT_BEGIN 2-enable 200 application/json
1358 {"status":200,"message":""}
@@ -1362,6 +1377,7 @@ CONFIG go.d:collector:success:test status running
1377 do: func(mgr *Manager, _ chan []*confgroup.Group) {
1378 mgr.dyncfgConfig(functions.Function{
1379 UID: "1-add",
1380 + Source: "type=dyncfg",
1381 Args: []string{dyncfgModID(cfg.Module()), "add", cfg.Name()},
1382 Payload: []byte("{}"),
1383 })
@@ -1388,7 +1404,7 @@ FUNCTION_RESULT_BEGIN 1-add 202 application/json
1404 {"status":202,"message":""}
1405 FUNCTION_RESULT_END
1406
1391 -CONFIG go.d:collector:success:test create accepted job /collectors/jobs dyncfg 'type=dyncfg,module=success,job=test' 'schema get enable disable update restart test userconfig remove' 0x0000 0x0000
1407 +CONFIG go.d:collector:success:test create accepted job /collectors/jobs dyncfg 'type=dyncfg' 'schema get enable disable update restart test userconfig remove' 0x0000 0x0000
1408
1409 FUNCTION_RESULT_BEGIN 2-disable 200 application/json
1410 {"status":200,"message":""}
@@ -1413,6 +1429,7 @@ CONFIG go.d:collector:success:test status disabled
1429 do: func(mgr *Manager, _ chan []*confgroup.Group) {
1430 mgr.dyncfgConfig(functions.Function{
1431 UID: "1-add",
1432 + Source: "type=dyncfg",
1433 Args: []string{dyncfgModID(cfg.Module()), "add", cfg.Name()},
1434 Payload: []byte("{}"),
1435 })
@@ -1443,7 +1460,7 @@ FUNCTION_RESULT_BEGIN 1-add 202 application/json
1460 {"status":202,"message":""}
1461 FUNCTION_RESULT_END
1462
1446 -CONFIG go.d:collector:success:test create accepted job /collectors/jobs dyncfg 'type=dyncfg,module=success,job=test' 'schema get enable disable update restart test userconfig remove' 0x0000 0x0000
1463 +CONFIG go.d:collector:success:test create accepted job /collectors/jobs dyncfg 'type=dyncfg' 'schema get enable disable update restart test userconfig remove' 0x0000 0x0000
1464
1465 FUNCTION_RESULT_BEGIN 2-enable 200 application/json
1466 {"status":200,"message":""}
@@ -1607,6 +1624,7 @@ FUNCTION_RESULT_END
1624 do: func(mgr *Manager, _ chan []*confgroup.Group) {
1625 mgr.dyncfgConfig(functions.Function{
1626 UID: "1-add",
1627 + Source: "type=dyncfg",
1628 Args: []string{dyncfgModID(cfg.Module()), "add", cfg.Name()},
1629 Payload: []byte("{}"),
1630 })
@@ -1625,7 +1643,7 @@ FUNCTION_RESULT_BEGIN 1-add 202 application/json
1643 {"status":202,"message":""}
1644 FUNCTION_RESULT_END
1645
1628 -CONFIG go.d:collector:success:test create accepted job /collectors/jobs dyncfg 'type=dyncfg,module=success,job=test' 'schema get enable disable update restart test userconfig remove' 0x0000 0x0000
1646 +CONFIG go.d:collector:success:test create accepted job /collectors/jobs dyncfg 'type=dyncfg' 'schema get enable disable update restart test userconfig remove' 0x0000 0x0000
1647
1648 FUNCTION_RESULT_BEGIN 2-remove 200 application/json
1649 {"status":200,"message":""}
@@ -1644,6 +1662,7 @@ CONFIG go.d:collector:success:test delete
1662 do: func(mgr *Manager, _ chan []*confgroup.Group) {
1663 mgr.dyncfgConfig(functions.Function{
1664 UID: "1-add",
1665 + Source: "type=dyncfg",
1666 Args: []string{dyncfgModID(cfg.Module()), "add", cfg.Name()},
1667 Payload: []byte("{}"),
1668 })
@@ -1666,7 +1685,7 @@ FUNCTION_RESULT_BEGIN 1-add 202 application/json
1685 {"status":202,"message":""}
1686 FUNCTION_RESULT_END
1687
1669 -CONFIG go.d:collector:success:test create accepted job /collectors/jobs dyncfg 'type=dyncfg,module=success,job=test' 'schema get enable disable update restart test userconfig remove' 0x0000 0x0000
1688 +CONFIG go.d:collector:success:test create accepted job /collectors/jobs dyncfg 'type=dyncfg' 'schema get enable disable update restart test userconfig remove' 0x0000 0x0000
1689
1690 FUNCTION_RESULT_BEGIN 2-enable 200 application/json
1691 {"status":200,"message":""}
@@ -1735,6 +1754,7 @@ FUNCTION_RESULT_END
1754 do: func(mgr *Manager, _ chan []*confgroup.Group) {
1755 mgr.dyncfgConfig(functions.Function{
1756 UID: "1-add",
1757 + Source: "type=dyncfg",
1758 Args: []string{dyncfgModID(origCfg.Module()), "add", origCfg.Name()},
1759 Payload: origBs,
1760 })
@@ -1744,6 +1764,7 @@ FUNCTION_RESULT_END
1764 })
1765 mgr.dyncfgConfig(functions.Function{
1766 UID: "3-update",
1767 + Source: "type=dyncfg",
1768 Args: []string{dyncfgJobID(origCfg), "update"},
1769 Payload: updBs,
1770 })
@@ -1762,7 +1783,7 @@ FUNCTION_RESULT_BEGIN 1-add 202 application/json
1783 {"status":202,"message":""}
1784 FUNCTION_RESULT_END
1785
1765 -CONFIG go.d:collector:success:test create accepted job /collectors/jobs dyncfg 'type=dyncfg,module=success,job=test' 'schema get enable disable update restart test userconfig remove' 0x0000 0x0000
1786 +CONFIG go.d:collector:success:test create accepted job /collectors/jobs dyncfg 'type=dyncfg' 'schema get enable disable update restart test userconfig remove' 0x0000 0x0000
1787
1788 FUNCTION_RESULT_BEGIN 2-enable 200 application/json
1789 {"status":200,"message":""}
@@ -1792,6 +1813,7 @@ CONFIG go.d:collector:success:test status running
1813 do: func(mgr *Manager, _ chan []*confgroup.Group) {
1814 mgr.dyncfgConfig(functions.Function{
1815 UID: "1-add",
1816 + Source: "type=dyncfg",
1817 Args: []string{dyncfgModID(origCfg.Module()), "add", origCfg.Name()},
1818 Payload: origBs,
1819 })
@@ -1801,6 +1823,7 @@ CONFIG go.d:collector:success:test status running
1823 })
1824 mgr.dyncfgConfig(functions.Function{
1825 UID: "3-update",
1826 + Source: "type=dyncfg",
1827 Args: []string{dyncfgJobID(origCfg), "update"},
1828 Payload: updBs,
1829 })
@@ -1819,7 +1842,7 @@ FUNCTION_RESULT_BEGIN 1-add 202 application/json
1842 {"status":202,"message":""}
1843 FUNCTION_RESULT_END
1844
1822 -CONFIG go.d:collector:success:test create accepted job /collectors/jobs dyncfg 'type=dyncfg,module=success,job=test' 'schema get enable disable update restart test userconfig remove' 0x0000 0x0000
1845 +CONFIG go.d:collector:success:test create accepted job /collectors/jobs dyncfg 'type=dyncfg' 'schema get enable disable update restart test userconfig remove' 0x0000 0x0000
1846
1847 FUNCTION_RESULT_BEGIN 2-disable 200 application/json
1848 {"status":200,"message":""}
@@ -1886,7 +1909,7 @@ func prepareDyncfgCfg(module, job string) confgroup.Config {
1909 return confgroup.Config{}.
1910 SetSourceType(confgroup.TypeDyncfg).
1911 SetProvider("dyncfg").
1889 - SetSource(fmt.Sprintf("type=dyncfg,module=%s,job=%s", module, job)).
1912 + SetSource("type=dyncfg").
1913 SetModule(module).
1914 SetName(job)
1915 }