TestNetmapHealthIntegration checks that we get the expected health warnings from processing a [tailcfg.MapResponse] containing health messages and passing the [netmap.NetworkMap] to a [health.Tracker].
(t *testing.T)
| 1795 | // from processing a [tailcfg.MapResponse] containing health messages and passing the |
| 1796 | // [netmap.NetworkMap] to a [health.Tracker]. |
| 1797 | func TestNetmapHealthIntegration(t *testing.T) { |
| 1798 | ms := newTestMapSession(t, nil) |
| 1799 | ht := health.NewTracker(eventbustest.NewBus(t)) |
| 1800 | |
| 1801 | ht.SetIPNState("NeedsLogin", true) |
| 1802 | ht.GotStreamedMapResponse() |
| 1803 | |
| 1804 | nm := ms.netmapForResponse(&tailcfg.MapResponse{ |
| 1805 | Health: []string{ |
| 1806 | "Test message", |
| 1807 | "Another message", |
| 1808 | }, |
| 1809 | }) |
| 1810 | ht.SetControlHealth(nm.DisplayMessages) |
| 1811 | |
| 1812 | want := map[health.WarnableCode]health.UnhealthyState{ |
| 1813 | "control-health.health-c0719e9a8d5d838d861dc6f675c899d2b309a3a65bb9fe6b11e5afcbf9a2c0b1": { |
| 1814 | WarnableCode: "control-health.health-c0719e9a8d5d838d861dc6f675c899d2b309a3a65bb9fe6b11e5afcbf9a2c0b1", |
| 1815 | Title: "Coordination server reports an issue", |
| 1816 | Severity: health.SeverityMedium, |
| 1817 | Text: "The coordination server is reporting a health issue: Test message", |
| 1818 | }, |
| 1819 | "control-health.health-1dc7017a73a3c55c0d6a8423e3813c7ab6562d9d3064c2ec6ac7822f61b1db9c": { |
| 1820 | WarnableCode: "control-health.health-1dc7017a73a3c55c0d6a8423e3813c7ab6562d9d3064c2ec6ac7822f61b1db9c", |
| 1821 | Title: "Coordination server reports an issue", |
| 1822 | Severity: health.SeverityMedium, |
| 1823 | Text: "The coordination server is reporting a health issue: Another message", |
| 1824 | }, |
| 1825 | } |
| 1826 | |
| 1827 | got := maps.Clone(ht.CurrentState().Warnings) |
| 1828 | for k := range got { |
| 1829 | if !strings.HasPrefix(string(k), "control-health") { |
| 1830 | delete(got, k) |
| 1831 | } |
| 1832 | } |
| 1833 | |
| 1834 | if d := cmp.Diff(want, got, cmpopts.IgnoreFields(health.UnhealthyState{}, "ETag")); d != "" { |
| 1835 | t.Fatalf("CurrentStatus().Warnings[\"control-health*\"] different than expected (-want +got)\n%s", d) |
| 1836 | } |
| 1837 | } |
| 1838 | |
| 1839 | // TestNetmapDisplayMessageIntegration checks that we get the expected health |
| 1840 | // warnings from processing a [tailcfg.MapResponse] that contains DisplayMessages and |
nothing calls this directly
no test coverage detected
searching dependent graphs…