From 43ec59f922fc891a40e3cd1dc7046bec8da5ec91 Mon Sep 17 00:00:00 2001 From: Ayush Ranjan Date: Mon, 20 May 2024 17:36:06 -0700 Subject: [PATCH] Bump Python runtime tests to Python 3.12.3. Also reduce the parallelism on BuildKite for this test. It should suffice to run on just 2 agents. PiperOrigin-RevId: 635619602 --- .buildkite/pipeline.yaml | 8 +- .../Dockerfile.x86_64 | 4 +- test/runtimes/BUILD | 4 +- test/runtimes/README.md | 2 +- .../exclude/{python3.10.2.csv => python.csv} | 0 test/runtimes/proctor/lib/python.go | 96 ++++--------------- 6 files changed, 30 insertions(+), 84 deletions(-) rename images/runtimes/{python3.10.2 => python3.12.3}/Dockerfile.x86_64 (92%) rename test/runtimes/exclude/{python3.10.2.csv => python.csv} (100%) diff --git a/.buildkite/pipeline.yaml b/.buildkite/pipeline.yaml index 9f1849d8a..06fec84ad 100644 --- a/.buildkite/pipeline.yaml +++ b/.buildkite/pipeline.yaml @@ -534,8 +534,8 @@ steps: - <<: *common <<: *docker label: ":python: Python runtime tests" - command: make python3.10.2-runtime-tests RUNTIME_ARGS=--directfs - parallelism: 10 + command: make python3.12.3-runtime-tests RUNTIME_ARGS=--directfs + parallelism: 2 agents: <<: *platform_specific_agents arch: "amd64" @@ -580,8 +580,8 @@ steps: - <<: *common <<: *docker label: ":python: Python runtime tests (goferfs)" - command: make python3.10.2-runtime-tests RUNTIME_ARGS=--directfs=false - parallelism: 10 + command: make python3.12.3-runtime-tests RUNTIME_ARGS=--directfs=false + parallelism: 2 if: build.branch == "master" agents: <<: *platform_specific_agents diff --git a/images/runtimes/python3.10.2/Dockerfile.x86_64 b/images/runtimes/python3.12.3/Dockerfile.x86_64 similarity index 92% rename from images/runtimes/python3.10.2/Dockerfile.x86_64 rename to images/runtimes/python3.12.3/Dockerfile.x86_64 index 4406865eb..65cf1eeff 100644 --- a/images/runtimes/python3.10.2/Dockerfile.x86_64 +++ b/images/runtimes/python3.12.3/Dockerfile.x86_64 @@ -1,4 +1,4 @@ -FROM ubuntu:bionic +FROM ubuntu:jammy RUN apt-get update && apt-get install -y \ curl \ gcc \ @@ -12,7 +12,7 @@ RUN apt-get update && apt-get install -y \ # Use flags -LJO to follow the html redirect and download .tar.gz. WORKDIR /root -ARG VERSION=3.10.2 +ARG VERSION=3.12.3 RUN curl -LJO https://github.com/python/cpython/archive/v${VERSION}.tar.gz RUN tar -zxf cpython-${VERSION}.tar.gz diff --git a/test/runtimes/BUILD b/test/runtimes/BUILD index fbdaab534..310bd4ea2 100644 --- a/test/runtimes/BUILD +++ b/test/runtimes/BUILD @@ -36,8 +36,8 @@ runtime_test( ) runtime_test( - name = "python3.10.2", - exclude_file = "exclude/python3.10.2.csv", + name = "python3.12.3", + exclude_file = "exclude/python.csv", lang = "python", shard_count = more_shards, ) diff --git a/test/runtimes/README.md b/test/runtimes/README.md index ccef8a078..24eaefe47 100644 --- a/test/runtimes/README.md +++ b/test/runtimes/README.md @@ -32,7 +32,7 @@ Go | 1.22 | `make go1.22-runtime-tests` Java | 21 | `make java21-runtime-tests` NodeJS | 16.13.2 | `make nodejs16.13.2-runtime-tests` Php | 8.3.7 | `make php8.3.7-runtime-tests` -Python | 3.10.2 | `make python3.10.2-runtime-tests` +Python | 3.12.3 | `make python3.12.3-runtime-tests` You can modify the runtime test behaviors by passing in the following `make` variables: diff --git a/test/runtimes/exclude/python3.10.2.csv b/test/runtimes/exclude/python.csv similarity index 100% rename from test/runtimes/exclude/python3.10.2.csv rename to test/runtimes/exclude/python.csv diff --git a/test/runtimes/proctor/lib/python.go b/test/runtimes/proctor/lib/python.go index 3be4235a4..74a555825 100644 --- a/test/runtimes/proctor/lib/python.go +++ b/test/runtimes/proctor/lib/python.go @@ -43,19 +43,14 @@ var exclude = map[string][]string{ "test_asyncio.test_base_events": []string{ "BaseEventLoopWithSelectorTests.test_create_connection_service_name", }, - // TODO(b/271950879): Un-exclude once this bug is fixed. - "test_asyncio.test_events": []string{ - "EPollEventLoopTests.test_bidirectional_pty", - "PollEventLoopTests.test_bidirectional_pty", - "SelectEventLoopTests.test_bidirectional_pty", - }, - // TODO(b/162973328): Un-exclude once this bug is fixed. - "test_asyncore": []string{ - "TestAPI_UseIPv4Poll.test_handle_expt", - "TestAPI_UseIPv4Select.test_handle_expt", - }, // TODO(b/162978767): Un-exclude once this bug is fixed. "test_fcntl": []string{"TestFcntl.test_fcntl_64_bit"}, + // TODO(b/341776233): Un-exclude once this bug is fixed. + "test_pathlib": []string{ + "PathSubclassTest.test_is_mount", + "PathTest.test_is_mount", + "PosixPathTest.test_is_mount", + }, // TODO(b/76174079): Un-exclude once this bug is fixed. "test_posix": []string{ "PosixTester.test_sched_priority", @@ -64,14 +59,6 @@ var exclude = map[string][]string{ "TestPosixSpawn.test_setscheduler_only_param", "TestPosixSpawnP.test_setscheduler_only_param", }, - // TODO(b/162979921): Un-exclude once this bug is fixed. - "test_pty": []string{ - "PtyTest.test_fork", - "PtyTest.test_master_read", - "PtyTest.test_spawn_doesnt_hang", - }, - // TODO(b/162980389): Un-exclude once this bug is fixed. - "test_readline": []string{"TestReadline.*"}, // TODO(b/76174079): Un-exclude once this bug is fixed. "test_resource": []string{"ResourceTest.test_prlimit"}, // TODO(b/271949964): Un-exclude test cases as they are fixed. @@ -79,8 +66,8 @@ var exclude = map[string][]string{ "BasicUDPLITETest.testRecvFrom", "BasicUDPLITETest.testRecvFromNegative", "BasicUDPLITETest.testSendtoAndRecv", - "GeneralModuleTests.testGetServBy", - "GeneralModuleTests.testGetaddrinfo", + "GeneralModuleTests.testGetServBy", // Broken test. + "GeneralModuleTests.testGetaddrinfo", // Broken test. "RecvmsgIntoUDPLITETest.testRecvmsg", "RecvmsgIntoUDPLITETest.testRecvmsgAfterClose", "RecvmsgIntoUDPLITETest.testRecvmsgExplicitDefaults", @@ -120,16 +107,15 @@ var exclude = map[string][]string{ "UDPLITETimeoutTest.testTimeoutZero", "UDPLITETimeoutTest.testUDPLITETimeout", }, - // TODO(b/274167897): Un-exclude test cases once this is patched upstream. - // The test is broken: https://github.com/python/cpython/issues/102795 - "test_epoll": []string{"TestEPoll.test_control_and_wait"}, -} - -// Some python test libraries contain other test libraries that have test cases -// that need to be excluded. We need to expand such libraries so that the test -// case exclusion can work correctly. -var expand = []string{ - "test_asyncio", + // TODO(b/341780803): Un-exclude once this bug is fixed. + "test_termios": []string{ + "TestFunctions.test_tcdrain", + "TestFunctions.test_tcflow", + "TestFunctions.test_tcflush", + "TestFunctions.test_tcsendbreak", + "TestFunctions.test_tcflow_errors", + "TestFunctions.test_tcflush_errors", + }, } // pythonRunner implements TestRunner for Python. @@ -146,60 +132,20 @@ func (pythonRunner) ListTests() ([]string, error) { if err != nil { return nil, fmt.Errorf("failed to list: %v", err) } - testLibs := make(map[string]struct{}) + var res []string for _, testLib := range strings.Split(string(out), "\n") { if len(testLib) == 0 { continue } - testLibs[testLib] = struct{}{} - } - for _, libToExpand := range expand { - if _, ok := testLibs[libToExpand]; !ok { - return nil, fmt.Errorf("%s test library was not listed", libToExpand) - } - delete(testLibs, libToExpand) - subLibs, err := subTestLibs(libToExpand) - if err != nil { - return nil, err - } - for subLib := range subLibs { - testLibs[fmt.Sprintf("%s.%s", libToExpand, subLib)] = struct{}{} - } - } - res := make([]string, 0, len(testLibs)) - for lib := range testLibs { - res = append(res, lib) + // Some test libraries (like "test_asyncio") have sub-libraries which are + // expanded in the output with a "test." prefix. Remove it. + res = append(res, strings.TrimPrefix(testLib, "test.")) } // Sort to have deterministic results across shards. sort.Strings(res) return res, nil } -func subTestLibs(testLib string) (map[string]struct{}, error) { - // --list-{tests/cases} is only implemented by the 'test' library. - // Running './python -m test {X} --list-tests' does not list libraries inside - // X library. We need to list all test cases and extract sub libraries. - args := []string{"-m", "test", testLib, "--list-cases"} - cmd := exec.Command("./python", args...) - cmd.Stderr = os.Stderr - out, err := cmd.Output() - if err != nil { - return nil, fmt.Errorf("failed to list: %v", err) - } - subLibs := make(map[string]struct{}) - for _, tc := range strings.Split(string(out), "\n") { - if len(tc) == 0 { - continue - } - idx := strings.Index(tc, testLib) - if idx < 0 { - return nil, fmt.Errorf("could not find %q library in test case %q", testLib, tc) - } - subLibs[strings.Split(tc[idx:], ".")[1]] = struct{}{} - } - return subLibs, nil -} - // TestCmds implements TestRunner.TestCmds. func (pythonRunner) TestCmds(tests []string) []*exec.Cmd { var cmds []*exec.Cmd