@@ -26,7 +26,7 @@ import (
26
26
"k8s.io/client-go/dynamic/fake"
27
27
"k8s.io/client-go/rest"
28
28
testcore "k8s.io/client-go/testing"
29
- "k8s.io/klog/v2/klogr "
29
+ "k8s.io/klog/v2/textlogger "
30
30
31
31
"github.com/argoproj/gitops-engine/pkg/diff"
32
32
"github.com/argoproj/gitops-engine/pkg/health"
@@ -63,7 +63,7 @@ func newTestSyncCtx(getResourceFunc *func(ctx context.Context, config *rest.Conf
63
63
namespace : FakeArgoCDNamespace ,
64
64
revision : "FooBarBaz" ,
65
65
disco : fakeDisco ,
66
- log : klogr . New ( ).WithValues ("application" , "fake-app" ),
66
+ log : textlogger . NewLogger ( textlogger . NewConfig () ).WithValues ("application" , "fake-app" ),
67
67
resources : map [kube.ResourceKey ]reconciledResource {},
68
68
syncRes : map [string ]synccommon.ResourceSyncResult {},
69
69
validate : true ,
@@ -1431,23 +1431,26 @@ func Test_syncContext_hasCRDOfGroupKind(t *testing.T) {
1431
1431
}
1432
1432
1433
1433
func Test_setRunningPhase_healthyState (t * testing.T ) {
1434
- sc := syncContext {log : klogr .New ().WithValues ("application" , "fake-app" )}
1434
+ var sc syncContext
1435
+ sc .log = textlogger .NewLogger (textlogger .NewConfig ()).WithValues ("application" , "fake-app" )
1435
1436
1436
1437
sc .setRunningPhase ([]* syncTask {{targetObj : NewPod ()}, {targetObj : NewPod ()}, {targetObj : NewPod ()}}, false )
1437
1438
1438
1439
assert .Equal (t , "waiting for healthy state of /Pod/my-pod and 2 more resources" , sc .message )
1439
1440
}
1440
1441
1441
1442
func Test_setRunningPhase_runningHooks (t * testing.T ) {
1442
- sc := syncContext {log : klogr .New ().WithValues ("application" , "fake-app" )}
1443
+ var sc syncContext
1444
+ sc .log = textlogger .NewLogger (textlogger .NewConfig ()).WithValues ("application" , "fake-app" )
1443
1445
1444
1446
sc .setRunningPhase ([]* syncTask {{targetObj : newHook (synccommon .HookTypeSyncFail )}}, false )
1445
1447
1446
1448
assert .Equal (t , "waiting for completion of hook /Pod/my-pod" , sc .message )
1447
1449
}
1448
1450
1449
1451
func Test_setRunningPhase_pendingDeletion (t * testing.T ) {
1450
- sc := syncContext {log : klogr .New ().WithValues ("application" , "fake-app" )}
1452
+ var sc syncContext
1453
+ sc .log = textlogger .NewLogger (textlogger .NewConfig ()).WithValues ("application" , "fake-app" )
1451
1454
1452
1455
sc .setRunningPhase ([]* syncTask {{targetObj : NewPod ()}, {targetObj : NewPod ()}, {targetObj : NewPod ()}}, true )
1453
1456
@@ -1653,7 +1656,7 @@ func TestSyncContext_GetDeleteOptions_WithPrunePropagationPolicy(t *testing.T) {
1653
1656
1654
1657
func TestSetOperationFailed (t * testing.T ) {
1655
1658
sc := syncContext {}
1656
- sc .log = klogr . New ( ).WithValues ("application" , "fake-app" )
1659
+ sc .log = textlogger . NewLogger ( textlogger . NewConfig () ).WithValues ("application" , "fake-app" )
1657
1660
1658
1661
tasks := make ([]* syncTask , 0 )
1659
1662
tasks = append (tasks , & syncTask {message : "namespace not found" })
@@ -1666,7 +1669,7 @@ func TestSetOperationFailed(t *testing.T) {
1666
1669
1667
1670
func TestSetOperationFailedDuplicatedMessages (t * testing.T ) {
1668
1671
sc := syncContext {}
1669
- sc .log = klogr . New ( ).WithValues ("application" , "fake-app" )
1672
+ sc .log = textlogger . NewLogger ( textlogger . NewConfig () ).WithValues ("application" , "fake-app" )
1670
1673
1671
1674
tasks := make ([]* syncTask , 0 )
1672
1675
tasks = append (tasks , & syncTask {message : "namespace not found" })
@@ -1680,7 +1683,7 @@ func TestSetOperationFailedDuplicatedMessages(t *testing.T) {
1680
1683
1681
1684
func TestSetOperationFailedNoTasks (t * testing.T ) {
1682
1685
sc := syncContext {}
1683
- sc .log = klogr . New ( ).WithValues ("application" , "fake-app" )
1686
+ sc .log = textlogger . NewLogger ( textlogger . NewConfig () ).WithValues ("application" , "fake-app" )
1684
1687
1685
1688
sc .setOperationFailed (nil , nil , "one or more objects failed to apply" )
1686
1689
@@ -1771,11 +1774,11 @@ func TestWaveReorderingOfPruneTasks(t *testing.T) {
1771
1774
// no change in wave order
1772
1775
expectedWaveOrder : map [string ]int {
1773
1776
// new wave // original wave
1774
- ns .GetName (): 0 , // 0
1775
- pod1 .GetName (): 1 , // 1
1776
- pod2 .GetName (): 2 , // 2
1777
- pod3 .GetName (): 3 , // 3
1778
- pod4 .GetName (): 4 , // 4
1777
+ ns .GetName (): 0 , // 0
1778
+ pod1 .GetName (): 1 , // 1
1779
+ pod2 .GetName (): 2 , // 2
1780
+ pod3 .GetName (): 3 , // 3
1781
+ pod4 .GetName (): 4 , // 4
1779
1782
},
1780
1783
},
1781
1784
{
@@ -1785,11 +1788,11 @@ func TestWaveReorderingOfPruneTasks(t *testing.T) {
1785
1788
// change in prune wave order
1786
1789
expectedWaveOrder : map [string ]int {
1787
1790
// new wave // original wave
1788
- ns .GetName (): 4 , // 0
1789
- pod1 .GetName (): 3 , // 1
1790
- pod2 .GetName (): 2 , // 2
1791
- pod3 .GetName (): 1 , // 3
1792
- pod4 .GetName (): 0 , // 4
1791
+ ns .GetName (): 4 , // 0
1792
+ pod1 .GetName (): 3 , // 1
1793
+ pod2 .GetName (): 2 , // 2
1794
+ pod3 .GetName (): 1 , // 3
1795
+ pod4 .GetName (): 0 , // 4
1793
1796
},
1794
1797
},
1795
1798
{
@@ -1799,13 +1802,13 @@ func TestWaveReorderingOfPruneTasks(t *testing.T) {
1799
1802
// change in prune wave order
1800
1803
expectedWaveOrder : map [string ]int {
1801
1804
// new wave // original wave
1802
- pod1 .GetName (): 4 , // 1
1803
- pod3 .GetName (): 3 , // 3
1804
- pod4 .GetName (): 1 , // 4
1805
+ pod1 .GetName (): 4 , // 1
1806
+ pod3 .GetName (): 3 , // 3
1807
+ pod4 .GetName (): 1 , // 4
1805
1808
1806
1809
// no change since non prune tasks
1807
- ns .GetName (): 0 , // 0
1808
- pod2 .GetName (): 2 , // 2
1810
+ ns .GetName (): 0 , // 0
1811
+ pod2 .GetName (): 2 , // 2
1809
1812
},
1810
1813
},
1811
1814
}
@@ -1830,13 +1833,13 @@ func TestWaveReorderingOfPruneTasks(t *testing.T) {
1830
1833
// change in prune wave order
1831
1834
expectedWaveOrder : map [string ]int {
1832
1835
// new wave // original wave
1833
- pod1 .GetName (): 5 , // 1
1834
- pod2 .GetName (): 5 , // 2
1835
- pod3 .GetName (): 5 , // 3
1836
- pod4 .GetName (): 5 , // 4
1836
+ pod1 .GetName (): 5 , // 1
1837
+ pod2 .GetName (): 5 , // 2
1838
+ pod3 .GetName (): 5 , // 3
1839
+ pod4 .GetName (): 5 , // 4
1837
1840
1838
1841
// no change since non prune tasks
1839
- ns .GetName (): 0 , // 0
1842
+ ns .GetName (): 0 , // 0
1840
1843
},
1841
1844
},
1842
1845
{
@@ -1847,13 +1850,13 @@ func TestWaveReorderingOfPruneTasks(t *testing.T) {
1847
1850
// change in wave order
1848
1851
expectedWaveOrder : map [string ]int {
1849
1852
// new wave // original wave
1850
- pod1 .GetName (): 4 , // 1
1851
- pod2 .GetName (): 5 , // 2
1852
- pod3 .GetName (): 2 , // 3
1853
- pod4 .GetName (): 1 , // 4
1853
+ pod1 .GetName (): 4 , // 1
1854
+ pod2 .GetName (): 5 , // 2
1855
+ pod3 .GetName (): 2 , // 3
1856
+ pod4 .GetName (): 1 , // 4
1854
1857
1855
1858
// no change since non prune tasks
1856
- ns .GetName (): 0 , // 0
1859
+ ns .GetName (): 0 , // 0
1857
1860
},
1858
1861
},
1859
1862
}
@@ -1877,11 +1880,11 @@ func TestWaveReorderingOfPruneTasks(t *testing.T) {
1877
1880
// change in prune wave order
1878
1881
expectedWaveOrder : map [string ]int {
1879
1882
// new wave // original wave
1880
- pod1 .GetName (): 5 , // 1
1881
- pod3 .GetName (): 4 , // 3
1882
- pod4 .GetName (): 4 , // 3
1883
- pod5 .GetName (): 3 , // 4
1884
- pod7 .GetName (): 1 , // 5
1883
+ pod1 .GetName (): 5 , // 1
1884
+ pod3 .GetName (): 4 , // 3
1885
+ pod4 .GetName (): 4 , // 3
1886
+ pod5 .GetName (): 3 , // 4
1887
+ pod7 .GetName (): 1 , // 5
1885
1888
1886
1889
// no change since non prune tasks
1887
1890
ns .GetName (): - 1 , // -1
@@ -1941,8 +1944,8 @@ func TestWaitForCleanUpBeforeNextWave(t *testing.T) {
1941
1944
1942
1945
// simulate successful delete of pod3
1943
1946
syncCtx .resources = groupResources (ReconciliationResult {
1944
- Target : []* unstructured.Unstructured {nil , nil , },
1945
- Live : []* unstructured.Unstructured {pod1 , pod2 , },
1947
+ Target : []* unstructured.Unstructured {nil , nil },
1948
+ Live : []* unstructured.Unstructured {pod1 , pod2 },
1946
1949
})
1947
1950
1948
1951
// next sync should prune only pod2
@@ -1966,8 +1969,8 @@ func TestWaitForCleanUpBeforeNextWave(t *testing.T) {
1966
1969
1967
1970
// simulate successful delete of pod2
1968
1971
syncCtx .resources = groupResources (ReconciliationResult {
1969
- Target : []* unstructured.Unstructured {nil , },
1970
- Live : []* unstructured.Unstructured {pod1 , },
1972
+ Target : []* unstructured.Unstructured {nil },
1973
+ Live : []* unstructured.Unstructured {pod1 },
1971
1974
})
1972
1975
1973
1976
// next sync should proceed with next wave
0 commit comments