nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: matrixorigin/matrixone
Pull request #3652 (2022-07-02 04:18:49)

logservice: fix TestHandleRemoveReplica
**What type of PR is this?**

- [ ] API-change
- [ ] BUG
- [ ] Improvement
- [ ] Documentation
- [ ] Feature
- [x] Test and CI
- [ ] Code Refactoring

**Which issue(s) this PR fixes:**

issue #

**What this PR does / why we need it:**

TestHandleRemoveReplica was flaky

**Special notes for your reviewer:**

Not Available

**Additional documentation (e.g. design docs, usage docs, etc.):**

Not Available



Patch:
diff --git a/pkg/logservice/store.go b/pkg/logservice/store.go
index 59d2fbe54..4f6a66ea1 100644
--- a/pkg/logservice/store.go
+++ b/pkg/logservice/store.go
@@ -169,6 +169,10 @@ func (l *store) stopReplica(shardID uint64, replicaID uint64) error {
 	return l.nh.StopReplica(shardID, replicaID)
 }
 
+func (l *store) requestLeaderTransfer(shardID uint64, targetReplicaID uint64) error {
+	return l.nh.RequestLeaderTransfer(shardID, targetReplicaID)
+}
+
 func (l *store) addReplica(shardID uint64, replicaID uint64,
 	target dragonboat.Target, cci uint64) error {
 	ctx, cancel := context.WithTimeout(context.Background(), time.Second)


Test patch:
diff --git a/pkg/logservice/store_test.go b/pkg/logservice/store_test.go
index c97fa4dac..fed6e57f8 100644
--- a/pkg/logservice/store_test.go
+++ b/pkg/logservice/store_test.go
@@ -382,13 +382,18 @@ func getTestStores() (*store, *store, error) {
 	}
 
 	for i := 0; i <= 30000; i++ {
-		_, _, ok, err := store1.nh.GetLeaderID(1)
+		leaderID, _, ok, err := store1.nh.GetLeaderID(1)
 		if err != nil {
 			return nil, nil, err
 		}
-		if ok {
+		if ok && leaderID == 1 {
 			break
 		}
+		if ok && leaderID != 1 {
+			if err := store1.requestLeaderTransfer(1, 1); err != nil {
+				plog.Errorf("failed to transfer leader")
+			}
+		}
 		time.Sleep(time.Millisecond)
 		if i == 30000 {
 			panic("failed to have leader elected in 30 seconds")
Repository: googlefonts/glyphsLib
Pull request #933 (2023-07-29 17:34:40)

Load UIState.plist file from .glyphspackage
It contains DisplayStrings, and possibly other data. The DisplayStrings key starts with a lowercase, which is unfortunate, so I added a hack for it.


Patch:
diff --git a/Lib/glyphsLib/parser.py b/Lib/glyphsLib/parser.py
index 85655443..1b2e191c 100644
--- a/Lib/glyphsLib/parser.py
+++ b/Lib/glyphsLib/parser.py
@@ -104,6 +104,7 @@ def load_glyphspackage(package_dir):
     package = Path(package_dir)
     infofile = package / "fontinfo.plist"
     orderfile = package / "order.plist"
+    uistatefile = package / "UIState.plist"
 
     glyphorder = []
     if orderfile.exists():
@@ -112,6 +113,14 @@ def load_glyphspackage(package_dir):
 
     with open(infofile, "r", encoding="utf-8") as info_fh:
         data = openstep_plist.load(info_fh, use_numbers=True)
+
+    if uistatefile.exists():
+        with open(uistatefile, "r", encoding="utf-8") as uistate_fh:
+            uistate = openstep_plist.load(uistate_fh, use_numbers=True)
+            if "displayStrings" in uistate and "DisplayStrings" not in uistate:
+                uistate["DisplayStrings"] = uistate.pop("displayStrings")
+            data.update(uistate)
+
     data["glyphs"] = []
     for glyphfile in (package / "glyphs").glob("*.glyph"):
         with open(glyphfile, "r") as fh:


Test patch:
diff --git a/tests/data/GlyphsUnitTestSans3.glyphspackage/UIState.plist b/tests/data/GlyphsUnitTestSans3.glyphspackage/UIState.plist
new file mode 100644
index 00000000..1424cd68
--- /dev/null
+++ b/tests/data/GlyphsUnitTestSans3.glyphspackage/UIState.plist
@@ -0,0 +1,6 @@
+{
+displayStrings = (
+A,
+hhhmmmnnnnnn
+);
+}
diff --git a/tests/glyphs3_test.py b/tests/glyphs3_test.py
index 28917ceb..b2f7479d 100644
--- a/tests/glyphs3_test.py
+++ b/tests/glyphs3_test.py
@@ -33,13 +33,11 @@ def test_glyphspackage_load(datadir):
         "_part.stem",  # Deliberately removed from glyph order file
     ]
     font1 = glyphsLib.load(str(datadir.join("GlyphsUnitTestSans3.glyphs")))
-    font1.DisplayStrings = ""  # glyphspackages, rather sensibly, don't store user state
     font2 = glyphsLib.load(str(datadir.join("GlyphsUnitTestSans3.glyphspackage")))
     assert [glyph.name for glyph in font2.glyphs] == expected
     assert glyphsLib.dumps(font1) == glyphsLib.dumps(font2)
 
     font1 = glyphsLib.load(str(datadir.join("GlyphsUnitTestSans3.glyphs")))
-    font1.DisplayStrings = ""  # glyphspackages, rather sensibly, don't store user state
     font2 = GSFont(str(datadir.join("GlyphsUnitTestSans3.glyphspackage")))
     assert [glyph.name for glyph in font2.glyphs] == expected
     assert glyphsLib.dumps(font1) == glyphsLib.dumps(font2)