|
51 | 51 | TESTGEN_PULL_TIMEOUT = 5 |
52 | 52 | TESTGEN_PULL_RETRIES = 3 |
53 | 53 | TESTGEN_DEFAULT_PORT = 8501 |
| 54 | +TESTGEN_DEFAULT_API_PORT = 8530 |
54 | 55 | TESTGEN_LATEST_VERSIONS_URL = ( |
55 | 56 | "https://dk-support-external.s3.us-east-1.amazonaws.com/testgen-observability/testgen-latest-versions.json" |
56 | 57 | ) |
@@ -1728,17 +1729,38 @@ def pre_execute(self, action, args): |
1728 | 1729 |
|
1729 | 1730 | self.update_base_url = "TG_UI_BASE_URL" not in contents |
1730 | 1731 | if self.update_base_url: |
1731 | | - port_match = re.search(r"- (\d+):8501", contents) |
| 1732 | + port_match = re.search(rf"- (\d+):{TESTGEN_DEFAULT_PORT}", contents) |
1732 | 1733 | port = port_match.group(1) if port_match else str(TESTGEN_DEFAULT_PORT) |
1733 | 1734 | protocol = "https" if "SSL_CERT_FILE" in contents else "http" |
1734 | 1735 | self._base_url = f"{protocol}://localhost:{port}" |
1735 | 1736 |
|
1736 | | - if not any((self.update_version, self.update_analytics, self.update_token, self.update_base_url)): |
| 1737 | + self.update_api_port = bool( |
| 1738 | + re.search(rf"- \d+:{TESTGEN_DEFAULT_PORT}\b", contents) |
| 1739 | + and not re.search(rf"- \d+:{TESTGEN_DEFAULT_API_PORT}\b", contents) |
| 1740 | + ) |
| 1741 | + |
| 1742 | + if not any( |
| 1743 | + ( |
| 1744 | + self.update_version, |
| 1745 | + self.update_analytics, |
| 1746 | + self.update_token, |
| 1747 | + self.update_base_url, |
| 1748 | + self.update_api_port, |
| 1749 | + ) |
| 1750 | + ): |
1737 | 1751 | CONSOLE.msg("No changes will be applied.") |
1738 | 1752 | raise AbortAction |
1739 | 1753 |
|
1740 | 1754 | def execute(self, action, args): |
1741 | | - if not any((self.update_version, self.update_analytics, self.update_token, self.update_base_url)): |
| 1755 | + if not any( |
| 1756 | + ( |
| 1757 | + self.update_version, |
| 1758 | + self.update_analytics, |
| 1759 | + self.update_token, |
| 1760 | + self.update_base_url, |
| 1761 | + self.update_api_port, |
| 1762 | + ) |
| 1763 | + ): |
1742 | 1764 | raise SkipStep |
1743 | 1765 |
|
1744 | 1766 | contents = action.get_compose_file_path(args).read_text() |
@@ -1773,6 +1795,11 @@ def execute(self, action, args): |
1773 | 1795 | var = f"\n{match.group(1)}TG_UI_BASE_URL: {self._base_url}" |
1774 | 1796 | contents = contents[0 : match.end()] + var + contents[match.end() :] |
1775 | 1797 |
|
| 1798 | + if self.update_api_port: |
| 1799 | + match = re.search(rf"^([ \t]+)- \d+:{TESTGEN_DEFAULT_PORT}\b.*$", contents, flags=re.M) |
| 1800 | + new_mapping = f"\n{match.group(1)}- {TESTGEN_DEFAULT_API_PORT}:{TESTGEN_DEFAULT_API_PORT}" |
| 1801 | + contents = contents[0 : match.end()] + new_mapping + contents[match.end() :] |
| 1802 | + |
1776 | 1803 | action.get_compose_file_path(args).write_text(contents) |
1777 | 1804 |
|
1778 | 1805 |
|
@@ -1879,6 +1906,7 @@ def get_compose_file_contents(self, action, args): |
1879 | 1906 | {ssl_volumes} |
1880 | 1907 | ports: |
1881 | 1908 | - {args.port}:{TESTGEN_DEFAULT_PORT} |
| 1909 | + - {args.api_port}:{TESTGEN_DEFAULT_API_PORT} |
1882 | 1910 | extra_hosts: |
1883 | 1911 | - host.docker.internal:host-gateway |
1884 | 1912 | depends_on: |
@@ -2019,7 +2047,14 @@ def get_parser(self, sub_parsers): |
2019 | 2047 | dest="port", |
2020 | 2048 | action="store", |
2021 | 2049 | default=TESTGEN_DEFAULT_PORT, |
2022 | | - help="Which port will be used to access Testgen UI. Defaults to %(default)s", |
| 2050 | + help="Which port will be used to access TestGen UI. Defaults to %(default)s", |
| 2051 | + ) |
| 2052 | + parser.add_argument( |
| 2053 | + "--api-port", |
| 2054 | + dest="api_port", |
| 2055 | + action="store", |
| 2056 | + default=TESTGEN_DEFAULT_API_PORT, |
| 2057 | + help="Which port will be used to access TestGen's API and MCP server. Defaults to %(default)s", |
2023 | 2058 | ) |
2024 | 2059 | parser.add_argument( |
2025 | 2060 | "--image", |
|
0 commit comments