github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/cmd/roachtest/hibernate.go (about) 1 // Copyright 2018 The Cockroach Authors. 2 // 3 // Use of this software is governed by the Business Source License 4 // included in the file licenses/BSL.txt. 5 // 6 // As of the Change Date specified in that file, in accordance with 7 // the Business Source License, use of this software will be governed 8 // by the Apache License, Version 2.0, included in the file 9 // licenses/APL.txt. 10 11 package main 12 13 import "context" 14 15 // TODO(rafi): Once our fork is merged into the main repo, go back to using 16 // latest release tag. 17 //var hibernateReleaseTagRegex = regexp.MustCompile(`^(?P<major>\d+)\.(?P<minor>\d+)\.(?P<point>\d+)$`) 18 19 // This test runs hibernate-core's full test suite against a single cockroach 20 // node. 21 22 func registerHibernate(r *testRegistry) { 23 runHibernate := func( 24 ctx context.Context, 25 t *test, 26 c *cluster, 27 ) { 28 if c.isLocal() { 29 t.Fatal("cannot be run in local mode") 30 } 31 node := c.Node(1) 32 t.Status("setting up cockroach") 33 c.Put(ctx, cockroach, "./cockroach", c.All()) 34 c.Start(ctx, t, c.All()) 35 36 version, err := fetchCockroachVersion(ctx, c, node[0]) 37 if err != nil { 38 t.Fatal(err) 39 } 40 41 if err := alterZoneConfigAndClusterSettings(ctx, version, c, node[0]); err != nil { 42 t.Fatal(err) 43 } 44 45 // TODO(rafi): Once our fork is merged into the main repo, go back to 46 // fetching the latest tag. For now, always use the 47 // `HHH-13724-cockroachdb-dialects` branch, where we are building the 48 // dialect. 49 latestTag := "HHH-13724-cockroachdb-dialects" 50 //t.Status("cloning hibernate and installing prerequisites") 51 //latestTag, err := repeatGetLatestTag( 52 // ctx, c, "hibernate", "hibernate-orm", hibernateReleaseTagRegex, 53 //) 54 //if err != nil { 55 // t.Fatal(err) 56 //} 57 //c.l.Printf("Latest Hibernate release is %s.", latestTag) 58 59 if err := repeatRunE( 60 ctx, c, node, "update apt-get", `sudo apt-get -qq update`, 61 ); err != nil { 62 t.Fatal(err) 63 } 64 65 if err := repeatRunE( 66 ctx, 67 c, 68 node, 69 "install dependencies", 70 `sudo apt-get -qq install default-jre openjdk-8-jdk-headless gradle`, 71 ); err != nil { 72 t.Fatal(err) 73 } 74 75 if err := repeatRunE( 76 ctx, c, node, "remove old Hibernate", `rm -rf /mnt/data1/hibernate`, 77 ); err != nil { 78 t.Fatal(err) 79 } 80 81 // TODO(rafi): Switch back to using the main hibernate/hibernate-orm repo 82 // once the CockroachDB dialect is merged into it. For now, we are using 83 // a fork so we can make incremental progress on building the dialect. 84 if err := repeatGitCloneE( 85 ctx, 86 t.l, 87 c, 88 "https://github.com/cockroachdb/hibernate-orm.git", 89 "/mnt/data1/hibernate", 90 latestTag, 91 node, 92 ); err != nil { 93 t.Fatal(err) 94 } 95 96 t.Status("building hibernate (without tests)") 97 // Build hibernate and run a single test, this step involves some 98 // downloading, so it needs a retry loop as well. Just building was not 99 // enough as the test libraries are not downloaded unless at least a 100 // single test is invoked. 101 if err := repeatRunE( 102 ctx, 103 c, 104 node, 105 "building hibernate (without tests)", 106 `cd /mnt/data1/hibernate/hibernate-core/ && ./../gradlew test -Pdb=cockroachdb `+ 107 `--tests org.hibernate.jdbc.util.BasicFormatterTest.*`, 108 ); err != nil { 109 t.Fatal(err) 110 } 111 112 blacklistName, expectedFailures, _, _ := hibernateBlacklists.getLists(version) 113 if expectedFailures == nil { 114 t.Fatalf("No hibernate blacklist defined for cockroach version %s", version) 115 } 116 c.l.Printf("Running cockroach version %s, using blacklist %s", version, blacklistName) 117 118 t.Status("running hibernate test suite, will take at least 3 hours") 119 // When testing, it is helpful to run only a subset of the tests. To do so 120 // add "--tests org.hibernate.test.annotations.lob.*" to the end of the 121 // test run command. 122 // Note that this will take upwards of 3 hours. 123 // Also note that this is expected to return an error, since the test suite 124 // will fail. And it is safe to swallow it here. 125 _ = c.RunE(ctx, node, 126 `cd /mnt/data1/hibernate/hibernate-core/ && `+ 127 `HIBERNATE_CONNECTION_LEAK_DETECTION=true ./../gradlew test -Pdb=cockroachdb`, 128 ) 129 130 t.Status("collecting the test results") 131 // Copy all of the test results to the cockroach logs directory to be 132 // copied to the artifacts. 133 134 // Copy the html report for the test. 135 if err := repeatRunE( 136 ctx, 137 c, 138 node, 139 "copy html report", 140 `cp /mnt/data1/hibernate/hibernate-core/target/reports/tests/test ~/logs/report -a`, 141 ); err != nil { 142 t.Fatal(err) 143 } 144 145 // Copy the individual test result files. 146 if err := repeatRunE( 147 ctx, 148 c, 149 node, 150 "copy test result files", 151 `cp /mnt/data1/hibernate/hibernate-core/target/test-results/test ~/logs/report/results -a`, 152 ); err != nil { 153 t.Fatal(err) 154 } 155 156 // Load the list of all test results files and parse them individually. 157 // Files are here: /mnt/data1/hibernate/hibernate-core/target/test-results/test 158 output, err := repeatRunWithBuffer( 159 ctx, 160 c, 161 t.l, 162 node, 163 "get list of test files", 164 `ls /mnt/data1/hibernate/hibernate-core/target/test-results/test/*.xml`, 165 ) 166 if err != nil { 167 t.Fatal(err) 168 } 169 if len(output) == 0 { 170 t.Fatal("could not find any test result files") 171 } 172 173 parseAndSummarizeJavaORMTestsResults( 174 ctx, t, c, node, "hibernate" /* ormName */, output, 175 blacklistName, expectedFailures, nil /* ignorelist */, version, latestTag, 176 ) 177 } 178 179 r.Add(testSpec{ 180 Name: "hibernate", 181 Owner: OwnerAppDev, 182 Cluster: makeClusterSpec(1), 183 Tags: []string{`default`, `orm`}, 184 Run: func(ctx context.Context, t *test, c *cluster) { 185 runHibernate(ctx, t, c) 186 }, 187 }) 188 }