Skip to contentSkip to conversation

support/testing: add memcached test

PATCH Applied Franciszek Stachura 2 participants 3 messages Feb 5 – Apr 3

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 support/testing: add memcached test

Add a basic runtime test for memcached. The test starts memcached and checks if it responds to a basic set/get request.

---
 DEVELOPERS                                    |  3 ++
 .../testing/tests/package/test_memcached.py   | 35 +++++++++++++++++++
 2 files changed, 38 insertions(+)
 create mode 100644 support/testing/tests/package/test_memcached.py
DEVELOPERS +3 -0
index 8290ccc281..f2f3bb8e44 100644
@@ -1160,6 +1160,9 @@ F:	package/tbb/
 N:	Francisco Gonzalez <[email protected]>
 F:	package/ser2net/
 
+N:	Franciszek Stachura <[email protected]>
+F:	support/testing/tests/package/test_memcached.py
+
 N:	Francois Dugast <[email protected]>
 F:	board/sipeed/licheepi_nano/
 F:	board/visionfive2/
support/testing/tests/package/test_memcached.py new file +35 -0
new file mode 100644
index 0000000000..2d00e47ab4
@@ -0,0 +1,35 @@
+import os
+
+import infra.basetest
+
+
+class TestMemcached(infra.basetest.BRTest):
+    config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + """
+    BR2_TARGET_ROOTFS_CPIO=y
+    BR2_PACKAGE_MEMCACHED=y
+    BR2_PACKAGE_NETCAT=y
+    BR2_PACKAGE_BUSYBOX_SHOW_OTHERS=y
+    """
+
+    def test_run(self):
+        cpio_file = os.path.join(self.builddir, "images", "rootfs.cpio")
+        self.emulator.boot(arch="armv5",
+                           kernel="builtin",
+                           options=["-initrd", cpio_file])
+        self.emulator.login()
+
+        output, exit_code = self.emulator.run("memcached -u root &")
+
+        set_key_cmd = "set test_key 0 100 10\\r\\ntest_value\\r\\nquit\\r\\n"
+        output, exit_code = self.emulator.run(
+            f"echo -ne '{set_key_cmd}' | nc localhost 11211"
+        )
+        self.assertEqual(exit_code, 0)
+        self.assertEqual(output[0].strip(), 'STORED')
+
+        get_key_cmd = "get test_key\\r\\nquit\\r\\n"
+        output, exit_code = self.emulator.run(
+            f"echo -ne '{get_key_cmd}' | nc localhost 11211"
+        )
+        self.assertEqual(exit_code, 0)
+        self.assertEqual(output[2].strip(), 'test_value')
Signature · 6 lines
2.53.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#2 lore raw
In reply to Franciszek Stachura

In reply of:

Quoted 4 lines

Add a basic runtime test for memcached. The test starts memcached and checks if it responds to a basic set/get request.

Applied to 2025.02.x & 2026.02.x. Thanks

Quoted 68 lines
---
 DEVELOPERS                                    |  3 ++
 .../testing/tests/package/test_memcached.py   | 35 +++++++++++++++++++
 2 files changed, 38 insertions(+)
 create mode 100644 support/testing/tests/package/test_memcached.py
DEVELOPERS +3 -0
index 8290ccc281..f2f3bb8e44 100644
@@ -1160,6 +1160,9 @@ F:	package/tbb/
 N:	Francisco Gonzalez <[email protected]>
 F:	package/ser2net/
 
+N:	Franciszek Stachura <[email protected]>
+F:	support/testing/tests/package/test_memcached.py
+
 N:	Francois Dugast <[email protected]>
 F:	board/sipeed/licheepi_nano/
 F:	board/visionfive2/
support/testing/tests/package/test_memcached.py new file +35 -0
new file mode 100644
index 0000000000..2d00e47ab4
@@ -0,0 +1,35 @@
+import os
+
+import infra.basetest
+
+
+class TestMemcached(infra.basetest.BRTest):
+    config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + """
+    BR2_TARGET_ROOTFS_CPIO=y
+    BR2_PACKAGE_MEMCACHED=y
+    BR2_PACKAGE_NETCAT=y
+    BR2_PACKAGE_BUSYBOX_SHOW_OTHERS=y
+    """
+
+    def test_run(self):
+        cpio_file = os.path.join(self.builddir, "images", "rootfs.cpio")
+        self.emulator.boot(arch="armv5",
+                           kernel="builtin",
+                           options=["-initrd", cpio_file])
+        self.emulator.login()
+
+        output, exit_code = self.emulator.run("memcached -u root &")
+
+        set_key_cmd = "set test_key 0 100 10\\r\\ntest_value\\r\\nquit\\r\\n"
+        output, exit_code = self.emulator.run(
+            f"echo -ne '{set_key_cmd}' | nc localhost 11211"
+        )
+        self.assertEqual(exit_code, 0)
+        self.assertEqual(output[0].strip(), 'STORED')
+
+        get_key_cmd = "get test_key\\r\\nquit\\r\\n"
+        output, exit_code = self.emulator.run(
+            f"echo -ne '{get_key_cmd}' | nc localhost 11211"
+        )
+        self.assertEqual(exit_code, 0)
+        self.assertEqual(output[2].strip(), 'test_value')
Signature · 6 lines
2.53.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot