您可以手动或使用 Helm 图表部署 SOAtest 与 Virtualize 服务器(SOAVirt 服务器)。
在 Kubernetes 中手动部署 SOAVirt 服务器
要在 Kubernetes 中部署 SOAVirt 服务器,请遵循以下流程。
前提条件
首先,为 SOAVirt 服务器创建一个命名空间:
kubectl create namespace parasoft-sv-namespace
授权 SOAVirt 服务器后,删除命名空间将使单机许可证失效,即使重新创建相同的命名空间也是如此。
接下来,需要一个持久卷和一个持久卷声明。创建可由多个节点共享的持久卷。应为其配置 300GB 的空间,并且必须具有 ReadWriteMany 访问模式。该空间将用于 SOAVirt 服务器的工作空间,并存储配置设置以及虚拟资产。
默认持久卷声明的名称为“soavirt-pvc”,可通过更新 SOAVirt 服务器的 yaml 定义进行自定义。以下示例展示了设置 NFS 持久卷和持久卷声明的配置。虽然示例中使用的是 NFS,但这并不是必需的;可根据需要使用任何持久卷类型。
警告:卷必须提供 Parasoft 用户读写卷的权限。例如,执行 chown 1000:1000 <shared_path>
命令。
apiVersion: v1 kind: PersistentVolume metadata: name: nfs-pv namespace: parasoft-sv-namespace spec: capacity: storage: 300Gi volumeMode: Filesystem accessModes: - ReadWriteMany persistentVolumeReclaimPolicy: Retain storageClassName: nfs mountOptions: - hard - nfsvers=4.1 nfs: path: <path> server: <ip_address> --- apiVersion: v1 kind: PersistentVolumeClaim metadata: name: soavirt-pvc namespace: parasoft-sv-namespace spec: storageClassName: nfs accessModes: - ReadWriteMany resources: requests: storage: 300Gi
使用 yaml 文件创建持久卷和持久卷声明:
kubectl create -f soavirt-pv.yaml
SOAVirt 设置
创建用于访问 Kubernetes 中 SOAVirt 服务器的服务。以下示例使用节点端口将其公开,为应用程序访问虚拟资产提供了一个稳定的端点。
kind: Service apiVersion: v1 metadata: name: soavirt-service namespace: parasoft-sv-namespace spec: selector: tag: soavirt type: NodePort ports: - name: http protocol: TCP port: 9080 targetPort: 9080 nodePort: 30080 - name: events protocol: TCP port: 9617 targetPort: 9617 nodePort: 30617 - name: statistics protocol: TCP port: 9618 targetPort: 9618 nodePort: 30618
使用 yaml 文件创建用于访问 Kubernetes 中 SOAVirt 服务器的服务:
kubectl create -f soavirt-service.yaml
Ingress 用户可选:要使用 Ingress 公开服务,可根据 Ingress 设置稍作修改后使用以下规则。请注意,事件和统计需要 TCP 连接,但并非所有 Ingress 控制器都支持 TCP 连接。
apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: soavirt-ingress namespace: parasoft-sv-namespace spec: rules: - host: soavirt.company.example.com http: paths: - path: / pathType: Prefix backend: service: name: soavirt-service port: number: 9080
使用 yaml 文件创建 Ingress 规则:
kubectl create -f soavirt-ingress.yaml
创建服务后,您需要为 SOAVirt 服务器创建配置映射,并配置网络许可证或本地许可证。注意:使用单个副本集时,可使用本地许可证,但使用多个副本集时,则需要许可证服务器。有关获取和应用本地许可证的更多信息,请参阅使用本地许可证。
必须在 ConfigMap 中设置 'parasoft.eula.accepted=true' 来接受服务器 EULA。
警告:连接 CTP 时,应使用服务的地址设置 'server.hostname' 属性。
apiVersion: v1 kind: ConfigMap metadata: name: soavirt-config namespace: parasoft-sv-namespace data: config.properties: | # Configuration properties for soavirt server # === END USER LICENSE AGREEMENT === # Set to true to accept the end user license agreement # Please review the EULA.txt file included in the distribution zip for soavirt.war parasoft.eula.accepted=false # === WORKING DIRECTORY === # Specifies workspace location #working.dir=C:/Users/../workspace # === LOGGING CONFIGURATION === # Specifies configuration file for logging logging.config.file=/WEB-INF/default.logging.xml # Replace with the following line to enable debug information #logging.config.file=/WEB-INF/debug.logging.xml # === CTP SERVER === # Specifies CTP server endpoint #env.manager.server=http\://[CTP Server Host]\:8080 # Specifies the server name that will be displayed in CTP #env.manager.server.name=[Server Name] # Specifies username for CTP authentication #env.manager.username=[CTP Server Username] # Specifies password for CTP authentication #env.manager.password=[CTP Server Password] # Enables notifications to CTP for deployments #env.manager.notify=true # === SERVLET CONTAINER === # Specifies the hostname to use for remote access to this server # Useful when a name or address must be strictly used for CTP connectivity # If empty, the address will be auto-detected #server.hostname=[Server Hostname] # Specifies port for http # Port should match your servlet container server.port.http=9080 # Specifies port for https # Port should match your servlet container #server.port.https=8443 # === PRODUCT LICENSING === # Enables virtualize functionality virtualize.license.enabled=true # Enables soatest functionality soatest.license.enabled=true # === NODE-LOCK LICENSE === # Specifies password for virtualize local license #virtualize.license.local.password=[Virtualize License Password] # Specifies password for soatest local license #soatest.license.local.password=[Soatest License Password] # === NETWORK LICENSE === # Enables network licensing for virtualize virtualize.license.use_network=true # Specifies the type of network license for virtualize ['performance_server_edition', 'runtime_server_edition', 'custom_edition'] virtualize.license.network.edition=custom_edition # Specifies features for virtualize 'custom_edition' license virtualize.license.custom_edition_features=Service Enabled, Performance, Extension Pack, Validate, Message Packs, Developer Sandbox 1000 Hits/Day, 10000 Hits/Day, 25000 Hits/Day, 50000 Hits/Day, 100000 Hits/Day, 500000 Hits/Day, 1 Million Hits/Day, Unlimited Hits/Day, 30 HPS, 100 HPS # Enables network licensing for soatest soatest.license.use_network=true # Specifies the type of network license for soatest ['server_edition', 'custom_edition'] soatest.license.network.edition=custom_edition # Specifies features for soatest 'custom_edition' license soatest.license.custom_edition_features=RuleWizard, Command Line, SOA, Web, Server API Enabled, Message Packs, Advanced Test Generation Desktop, Advanced Test Generation 5 Users, Advanced Test Generation 25 Users, Advanced Test Generation 100 Users, Requirements Traceability, API Security Testing # === LICENSE SERVER === # Enables using a specific license server # If true, the license network properties below will be used to retrieve a license # If false, the DTP server properties will be used to retrieve a license license.network.use.specified.server=true # Specifies license server URL, e.g., https://host[:port][/context-path] license.network.url=https\://[License Server Host]\:8443 # Enables http authentication for the license server license.network.auth.enabled=false # Specifies username for license server authentication #license.network.user=[License Server Username] # Specifies password for license server authentication #license.network.password=[License Server Password] # === DTP SERVER === # Specifies DTP server URL, e.g., https://host[:port][/context-path] #dtp.url=https\://[DTP Server Host]\:8443 # Specifies username for DTP authentication #dtp.user=[DTP Server Username] # Specifies password for DTP authentication #dtp.password=[DTP Server Password] # Specifies the name of the DTP project that you want to link to #dtp.project=[DTP Project] # === MISC === # Specifies scripting timeout in minutes #scripting.timeout.minutes=10 # Enables logging telemetry data #usage.reporting.enabled=true # === OIDC === # Enables or disables user authentication via OpenID Connect #oidc.enabled=false # Specifies the URI of the OpenID Connect server #oidc.issuer.uri= # Specifies the ID provided by your OpenID Connect server #oidc.client.id= # Specifies the method that will be used to authenticate the user on the OpenID Connect server #oidc.cli.mode=devicecode # Specifies the path to the token file containing user authentication information #oidc.devicecode.token.file= # === REPORTS === # Specifies a tag that represents a unique identifier for each run # e.g., ${config_name}-${project_module}-${scontrol_branch}-${exec_env} #session.tag=${config_name} # Specifies a build identifier used to label results #build.id=${dtp_project}-yyyy-MM-dd # Specifies data that should be included in the report #report.developer_errors=true #report.developer_reports=true #report.authors_details=true #report.testcases_details=false #report.test_suites_only=true #report.failed_tests_only=false #report.output_details=false #report.env_details=false #report.organize_security_findings_by=CWE #report.associations=false #report.assoc.url.pr= #report.assoc.url.fr= #report.assoc.url.task= #report.assoc.url.req= #report.assoc.url.test= # Specifies report format configuration ['html', 'pdf', 'xml', 'custom'] report.format=html #report.custom.extension= #report.custom.xsl.file= # Specifies installation directory for Jtest or dotTEST that generates coverage report #jtest.install.dir= #dottest.install.dir=
使用 yaml 文件为 SOAVirt 服务器创建配置映射:
kubectl create -f soavirt-config.yaml
创建配置映射后,需创建服务账户和所需权限。
apiVersion: v1 kind: ServiceAccount metadata: name: parasoft-account namespace: parasoft-sv-namespace --- apiVersion: rbac.authorization.k8s.io/v1 kind: Role metadata: name: parasoft-read namespace: parasoft-sv-namespace rules: - apiGroups: - "*" resources: - "*" verbs: - get - read - list --- apiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding metadata: name: parasoft-read-bind namespace: parasoft-sv-namespace roleRef: apiGroup: rbac.authorization.k8s.io kind: Role name: parasoft-read subjects: - kind: ServiceAccount name: parasoft-account namespace: parasoft-sv-namespace
使用 yaml 文件创建服务账户和所需权限:
kubectl create -f parasoft-permissions.yaml
您可以在控制台中看到与以下内容类似的输出:
serviceaccount/parasoft-account created role.rbac.authorization.k8s.io/parasoft-read created rolebinding.rbac.authorization.k8s.io/parasoft-read-bind created
接下来是创建 SOAVirt 服务器。如果在之前的步骤中使用了自定义的持久卷声明名称,请确保更新 'claimName' 字段以匹配自定义名称。
警告:扩展超过一个副本时,应禁用事件和统计服务。
注意:不支持 kind: Deployment
。请使用支持的 kind: Pod
或 kind: StatefulSet
。
apiVersion: apps/v1 kind: StatefulSet metadata: name: soavirt namespace: parasoft-sv-namespace labels: tag: soavirt spec: replicas: 1 selector: matchLabels: tag: soavirt serviceName: soavirt template: metadata: labels: tag: soavirt spec: serviceAccountName: parasoft-account volumes: - name: soavirt-pv persistentVolumeClaim: claimName: soavirt-pvc - name: soavirt-config configMap: name: soavirt-config containers: - name: soavirt image: parasoft/soavirt-server imagePullPolicy: IfNotPresent volumeMounts: - name: soavirt-pv mountPath: /usr/local/parasoft/soavirt/webapps/ROOT/workspace - name: soavirt-config mountPath: /usr/local/parasoft/soavirt/webapps/config.properties subPath: config.properties ports: - name: http containerPort: 9080 - name: events containerPort: 9617 - name: statistics containerPort: 9618 startupProbe: httpGet: path: /soavirt/api/v6/healthcheck port: 9080 initialDelaySeconds: 30 periodSeconds: 30 timeoutSeconds: 30 failureThreshold: 3 livenessProbe: httpGet: path: /soavirt/api/v6/healthcheck port: 9080 initialDelaySeconds: 30 periodSeconds: 30 timeoutSeconds: 30 env: - name: CATALINA_OPTS value: "-Dparasoft.auto.deploy.new=false -Dparasoft.event.monitoring.broker.port=9617 -Dparasoft.server.statistics.broker.port=9618 -Dparasoft.cloudvm=true -Dparasoft.cloudvm.config=Kubernetes" - name: PARASOFT_POD_NAME valueFrom: fieldRef: fieldPath: metadata.name - name: PARASOFT_POD_NAMESPACE valueFrom: fieldRef: fieldPath: metadata.namespace
使用 yaml 文件创建 SOAVirt 服务器:
kubectl create -f soavirt.yaml
使用本地许可证: 要使用单机许可证,您需要从部署的服务器获取机器码,以便从 Parasoft 获取许可证。
为运行中的容器打开 shell:
kubectl exec --stdin --tty soavirt-0 -n parasoft-sv-namespace -- /bin/bash
对 SOAVirt REST API 进行 curl 调用,以检索机器码:
curl http://localhost:9080/soavirt/api/v6/status?fields=machineId
- 请记下响应中的机器码并提供给 Parasoft 代表,Parasoft 代表将向您发送许可证密码。
- 收到许可证密码后,将其应用到 soavirt-config.yaml 中。
将更新后的 soavirt-config.yaml 应用到运行的容器:
kubectl apply -f soavirt-config.yaml
许可证将在 pod 自动重启后应用。或者,您也可以删除并重新创建 pod,使更改生效。
kubectl delete -f soavirt.yaml kubectl create -f soavirt.yaml
使用 Helm 图表在 Kubernetes 中部署 SOAVirt 服务器
您可以利用 Helm 图表简化 SOAVirt 服务器的部署。Helm 是一个客户端软件包,使用 Helm 图表来协调 Kubernetes 部署。使用 Helm 图表可以对 yaml 文件进行分组和协调,这样只需一条命令就能创建或删除这些文件。有关使用 Helm 的更多信息,请参阅 Helm 文档。
前提条件
在开始前,需安装 Docker、Kubernetes 和 Helm。
首先,为 SOAVirt 服务器创建一个命名空间:
kubectl create namespace parasoft-sv-namespace
授权 SOAVirt 服务器后,删除命名空间或更改发布名称将使单机许可证失效,即使重新创建相同的命名空间也是如此。
接下来,需要一个持久卷和一个持久卷声明。创建可由多个节点共享的持久卷。应为其配置 300GB 的空间,并且必须具有 ReadWriteMany 访问模式。该空间将用于 SOAVirt 服务器的工作空间,并存储配置设置以及虚拟资产。
警告:卷必须提供 Parasoft 用户读写卷的权限。例如,执行 chown 1000:1000 <shared_path>
命令。
SOAVirt 设置
- 下载并提取 parasoft_soavirt_server_2023.1.1_helm_chart.zip。此压缩文件包含该步骤中所需的所有 yaml 文件。
更新提取的
soavirt-server-helm
目录中的 values.yaml。至少必须更改persistence
值,使其与上文前提条件中配置的持久卷声明名称相匹配。persistence: name: soavirt-pvc
如有必要,还可以更改其他值,如
replica count
和namespace
。更新提取的
soavirt-server-helm/templates
目录中的 config.yaml。至少必须将parasoft.eula.accepted
值更新为true
以接受 EULA:parasoft.eula.accepted: false
如有必要,可更改其他值。例如,如果使用的是网络许可证,请更新这些字段:
# === PRODUCT LICENSING === # Enables virtualize functionality #virtualize.license.enabled: true # Enables soatest functionality #soatest.license.enabled: true # === NETWORK LICENSE === # Enables network licensing for virtualize #virtualize.license.use_network: true # Specifies the type of network license for virtualize ['performance_server_edition', 'runtime_server_edition', 'custom_edition'] #virtualize.license.network.edition: custom_edition # Specifies features for virtualize 'custom_edition' license #virtualize.license.custom_edition_features: Service Enabled, Performance, Extension Pack, Validate, Message Packs, Extension Framework, Developer Sandbox 1000 Hits/Day, 10000 Hits/Day, 25000 Hits/Day, 50000 Hits/Day, 100000 Hits/Day, 500000 Hits/Day, 1 Million Hits/Day, Unlimited Hits/Day, 30 HPS, 100 HPS # Enables network licensing for soatest #soatest.license.use_network: true # Specifies the type of network license for soatest ['server_edition', 'custom_edition'] #soatest.license.network.edition: custom_edition # Specifies features for soatest 'custom_edition' license #soatest.license.custom_edition_features: RuleWizard, Command Line, SOA, Web, Server API Enabled, Message Packs, Advanced Test Generation Desktop, Advanced Test Generation 5 Users, Advanced Test Generation 25 Users, Advanced Test Generation 100 Users, Requirements Traceability, API Security Testing, Extension Framework # === LICENSE SERVER === # Enables using a specific license server # If true, the license network properties below will be used to retrieve a license # If false, the DTP server properties will be used to retrieve a license #license.network.use.specified.server: false # Specifies license server URL, e.g., https://host[:port][/context-path] #license.network.url: https\://[License Server Host]\:8443 # Enables http authentication for the license server #license.network.auth.enabled: false # Specifies username for license server authentication #license.network.user: [License Server Username] # Specifies password for license server authentication #license.network.password: [License Server Password]
安装 Helm 图表:
helm install my-release soavirt-server-helm
使用本地许可证:要使用单机许可证,您需要从部署的服务器获取机器码,以便从 Parasoft 获取许可证并更新 config.yaml。
为运行中的容器打开 shell:
kubectl exec --stdin --tty my-release-soavirt-server-0 -n parasoft-sv-namespace -- /bin/bash
对 SOAVirt REST API 进行 curl 调用,以检索机器码:
curl http://localhost:9080/soavirt/api/v6/status?fields=machineId
- 请记下响应中的机器码并提供给 Parasoft 代表,Parasoft 代表将向您发送许可证密码。
收到许可证密码后,更新之前提取的
soavirt-server-helm/templates
目录中的 config.yaml,以接受单机许可证:# === NODE-LOCK LICENSE === # Specifies password for virtualize local license #virtualize.license.local.password: [Virtualize License Password] # Specifies password for soatest local license #soatest.license.local.password: [Soatest License Password] # === NETWORK LICENSE === # Enables network licensing for virtualize #virtualize.license.use_network: true # Enables network licensing for soatest #soatest.license.use_network: true
重新安装 Helm 图表,使更改生效。
helm uninstall my-release helm install my-release soavirt-server-helm