|
10 | 10 | "import tarfile\n", |
11 | 11 | "from pathlib import Path\n", |
12 | 12 | "\n", |
| 13 | + "\n", |
13 | 14 | "def extract_cli_archive():\n", |
14 | 15 | " src = \"archive.tar.gz\"\n", |
15 | 16 | " dst = Path(\"/tmp/cli_archive\")\n", |
|
19 | 20 | "\n", |
20 | 21 | " print(f\"Extracted {src} to {dst}\")\n", |
21 | 22 | "\n", |
| 23 | + "\n", |
22 | 24 | "extract_cli_archive()" |
23 | 25 | ] |
24 | 26 | }, |
|
46 | 48 | "import subprocess\n", |
47 | 49 | "import multiprocessing\n", |
48 | 50 | "\n", |
| 51 | + "\n", |
49 | 52 | "class Runner:\n", |
50 | 53 | " def __init__(self, archive_dir):\n", |
51 | 54 | " # Load environment variables to set in the test runner.\n", |
|
73 | 76 | " self.terraform_dir = os.getcwd() + \"/terraform\"\n", |
74 | 77 | "\n", |
75 | 78 | " def run(self, prefix):\n", |
76 | | - " cmd = [\"go\", \"tool\", \"gotestsum\", \"--format\", \"testname\", \"--no-summary=skipped\", \"--\",\n", |
77 | | - " \"-timeout\", \"7200s\", \"-test.v\", \"-run\", prefix, \"github.com/databricks/cli/acceptance\",\n", |
78 | | - " \"-workspace-tmp-dir\", \"-terraform-dir\", self.terraform_dir, \"-tail\"]\n", |
| 79 | + " cmd = [\n", |
| 80 | + " \"go\",\n", |
| 81 | + " \"tool\",\n", |
| 82 | + " \"gotestsum\",\n", |
| 83 | + " \"--format\",\n", |
| 84 | + " \"testname\",\n", |
| 85 | + " \"--no-summary=skipped\",\n", |
| 86 | + " \"--\",\n", |
| 87 | + " \"-timeout\",\n", |
| 88 | + " \"7200s\",\n", |
| 89 | + " \"-test.v\",\n", |
| 90 | + " \"-run\",\n", |
| 91 | + " prefix,\n", |
| 92 | + " \"github.com/databricks/cli/acceptance\",\n", |
| 93 | + " \"-workspace-tmp-dir\",\n", |
| 94 | + " \"-terraform-dir\",\n", |
| 95 | + " self.terraform_dir,\n", |
| 96 | + " \"-tail\",\n", |
| 97 | + " ]\n", |
79 | 98 | "\n", |
80 | 99 | " subprocess.run(cmd, env=self.env, check=True, cwd=self.exec_dir)\n", |
81 | 100 | "\n", |
82 | | - " # Debug helper to run commands and see the output.\n", |
| 101 | + " # Debug helper to run commands and see the output.\n", |
83 | 102 | " def run_script_with_logs(self, name, input_script):\n", |
84 | | - " cmd = [\"go\", \"tool\", \"gotestsum\", \"--format\", \"testname\", \"--no-summary=skipped\", \"--\",\n", |
85 | | - " \"-timeout\", \"7200s\", \"-test.v\", \"-run\", \"TestAccept/\" + name, \"github.com/databricks/cli/acceptance\", \"-workspace-tmp-dir\", \"-terraform-dir\", self.terraform_dir, \"-tail\"]\n", |
| 103 | + " cmd = [\n", |
| 104 | + " \"go\",\n", |
| 105 | + " \"tool\",\n", |
| 106 | + " \"gotestsum\",\n", |
| 107 | + " \"--format\",\n", |
| 108 | + " \"testname\",\n", |
| 109 | + " \"--no-summary=skipped\",\n", |
| 110 | + " \"--\",\n", |
| 111 | + " \"-timeout\",\n", |
| 112 | + " \"7200s\",\n", |
| 113 | + " \"-test.v\",\n", |
| 114 | + " \"-run\",\n", |
| 115 | + " \"TestAccept/\" + name,\n", |
| 116 | + " \"github.com/databricks/cli/acceptance\",\n", |
| 117 | + " \"-workspace-tmp-dir\",\n", |
| 118 | + " \"-terraform-dir\",\n", |
| 119 | + " self.terraform_dir,\n", |
| 120 | + " \"-tail\",\n", |
| 121 | + " ]\n", |
86 | 122 | "\n", |
87 | 123 | " with open(self.exec_dir / \"acceptance\" / name / \"script\", \"w\") as f:\n", |
88 | 124 | " f.write(input_script)\n", |
89 | 125 | "\n", |
90 | 126 | " subprocess.run(cmd, env=self.env, check=True, cwd=self.exec_dir)\n", |
91 | 127 | "\n", |
92 | | - " # Debug helper to run commands and see the output.\n", |
| 128 | + " # Debug helper to run commands and see the output.\n", |
93 | 129 | " def run_with_script(self, name, input_script):\n", |
94 | | - " cmd = [\"go\", \"test\",\n", |
95 | | - " \"-timeout\", \"7200s\", \"-test.v\", \"-run\",\"TestAccept/\" + name, \"github.com/databricks/cli/acceptance\", \"-update\", \"-workspace-tmp-dir\", \"-terraform-dir\", self.terraform_dir]\n", |
| 130 | + " cmd = [\n", |
| 131 | + " \"go\",\n", |
| 132 | + " \"test\",\n", |
| 133 | + " \"-timeout\",\n", |
| 134 | + " \"7200s\",\n", |
| 135 | + " \"-test.v\",\n", |
| 136 | + " \"-run\",\n", |
| 137 | + " \"TestAccept/\" + name,\n", |
| 138 | + " \"github.com/databricks/cli/acceptance\",\n", |
| 139 | + " \"-update\",\n", |
| 140 | + " \"-workspace-tmp-dir\",\n", |
| 141 | + " \"-terraform-dir\",\n", |
| 142 | + " self.terraform_dir,\n", |
| 143 | + " ]\n", |
96 | 144 | "\n", |
97 | 145 | " with open(self.exec_dir / \"acceptance\" / name / \"script\", \"w\") as f:\n", |
98 | 146 | " f.write(input_script)\n", |
99 | 147 | "\n", |
100 | 148 | " try:\n", |
101 | | - " subprocess.run(cmd, env=self.env, check=True, cwd=self.exec_dir, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)\n", |
| 149 | + " subprocess.run(\n", |
| 150 | + " cmd, env=self.env, check=True, cwd=self.exec_dir, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL\n", |
| 151 | + " )\n", |
102 | 152 | " except subprocess.CalledProcessError:\n", |
103 | 153 | " pass\n", |
104 | 154 | "\n", |
105 | 155 | " with open(self.exec_dir / \"acceptance\" / name / \"output.txt\", \"r\") as f:\n", |
106 | | - " print(f.read())\n" |
| 156 | + " print(f.read())" |
107 | 157 | ] |
108 | 158 | }, |
109 | 159 | { |
|
114 | 164 | "outputs": [], |
115 | 165 | "source": [ |
116 | 166 | "runner = Runner(\"/tmp/cli_archive\")\n", |
117 | | - "runner.run_with_script(\"bundle/deploy/dashboard/simple_syncroot\", r\"\"\"\n", |
| 167 | + "runner.run_with_script(\n", |
| 168 | + " \"selftest/dbr\",\n", |
| 169 | + " r\"\"\"\n", |
118 | 170 | "echo \"========================= START OF SCRIPT =====================\"\n", |
119 | 171 | "DASHBOARD_DISPLAY_NAME=\"test bundle-deploy-dashboard $(uuid)\"\n", |
120 | 172 | "export DASHBOARD_DISPLAY_NAME\n", |
|
125 | 177 | "\n", |
126 | 178 | "trace cat databricks.yml\n", |
127 | 179 | "echo \"========================= END OF SCRIPT =====================\"\n", |
128 | | - "\"\"\")" |
| 180 | + "\"\"\",\n", |
| 181 | + ")" |
129 | 182 | ] |
130 | 183 | }, |
131 | 184 | { |
|
139 | 192 | "\n", |
140 | 193 | "# Example:\n", |
141 | 194 | "runner = Runner(\"/tmp/cli_archive\")\n", |
142 | | - "runner.run(\"TestAccept/bundle/deploy/dashboard/simple_syncroot\")" |
| 195 | + "runner.run(\"selftest/dbr\")" |
143 | 196 | ] |
144 | 197 | } |
145 | 198 | ], |
|
0 commit comments