Skip to content

Commit

Permalink
merge office
Browse files Browse the repository at this point in the history
  • Loading branch information
banrieen committed Oct 12, 2021
2 parents 5d8a407 + 7477754 commit 4a39cb2
Show file tree
Hide file tree
Showing 27 changed files with 223 additions and 42 deletions.
Empty file modified .gitignore 100755 → 100644
Empty file.
Empty file modified CONTRIBUTING.md 100755 → 100644
Empty file.
Empty file modified LICENSE 100755 → 100644
Empty file.
Empty file modified RELEASE.md 100755 → 100644
Empty file.
31 changes: 26 additions & 5 deletions docs/zh_CN/install/组建性能自动化测试服务.md
Expand Up @@ -3,6 +3,27 @@
## 性能测试服务器初始化






## Upgrade GPU Driver
https://en.opensuse.org/SDB:NVIDIA_drivers#:~:text=Procedure%201%20Add%20the%20Nvidia%20Repository.%20The%20NVIDIA,your%20hardware%20information%20into%20Nvidia%27s%20driver%20search%20engine.

## Enable SSH
https://en.opensuse.org/SDB:OpenSSH_basics#:~:text=OpenSSH%2C%20SSHD%2C%20is%20installed%20in%20openSUSE%20by%20default.,it%20to%20the%20list.%20Save%20configuration%20and%20exit.


## Revert network manager to wicked

https://doc.opensuse.org/documentation/leap/reference/html/book-reference/cha-network.html#sec-network-nm

## Config network config
https://unix.stackexchange.com/questions/280552/static-ip-configuration-on-opensuse


## Install application (font, browser, editor, screenshot)

* 参考


Expand Down Expand Up @@ -706,11 +727,11 @@ remote_port = 7002
WantedBy=multi-user.target

# 启动 frp 并设置开机启动
systemctl stop frpc
systemctl disable frpc
systemctl start frpc
systemctl enable frpc
systemctl status frpc
sudo systemctl stop frpc
sudo systemctl disable frpc
sudo systemctl start frpc
sudo systemctl enable frpc
sudo systemctl status frpc
```

* 参考链接:
Expand Down
Empty file modified example/jmeter/trace_user_footprint.jmx 100755 → 100644
Empty file.
Empty file modified ops/conf/argo_install.yaml 100755 → 100644
Empty file.
Empty file modified ops/conf/env_info.yaml 100755 → 100644
Empty file.
Empty file modified ops/conf/kubernetes_dashboard_recommended.yaml 100755 → 100644
Empty file.
Empty file modified ops/conf/metrics-server-components.yaml 100755 → 100644
Empty file.
Empty file modified ops/conf/workflow-controller-configmap.yaml 100755 → 100644
Empty file.
Empty file modified ops/docker_proxy.sh 100755 → 100644
Empty file.
106 changes: 69 additions & 37 deletions ops/init_env.sh
Expand Up @@ -16,15 +16,52 @@
# install GPU driver and toolkit
# Install git

zypper install -y git
git clone https://github.com/discourse/discourse.git
tmux, moning brew, timeshift,htop,MCDU,timetrap

# Install docker
sudo zypper install -y docker python3-docker-compose
sudo systemctl enable docker
sudo usermod -G docker -a $USER
sudo systemctl restart docker
docker version
ventoy 多系统 启动盘
# Uninstall old versions
sudo zypper remove -y docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine \
runc
# Get opensuse version id
# if [ -e /etc/os-release ]; then
# VERSION_ID=$(cat /etc/os-release | grep VERSION_ID | grep -Eo '[0-9]+\.[0-9]+')
# else
# VERSION_ID=$(cat /usr/lib/os-release | grep VERSION_ID | grep -Eo '[0-9]+\.[0-9]+')
# fi

# Install GPU Driver
zypper addrepo --refresh 'https://download.nvidia.com/opensuse/leap/$releasever' NVIDIA
# Get hardware information
sudo hwinfo --gfxcard | grep Model
sudo hwinfo --arch
# Install
sudo zypper se -s x11-video-nvidiaG0*
sudo zypper se nvidia-glG0*
sudo zypper in x11-video-nvidiaG05
sudo zypper in nvidia-glG05


# Add the package repositories
# accept the overwrite of /etc/docker/daemon.json

distribution=$(. /etc/os-release;echo $ID$VERSION_ID) \
&& sudo zypper ar https://nvidia.github.io/nvidia-docker/${distribution}/nvidia-docker.repo \
&& sudo zypper ar https://download.opensuse.org/repositories/Virtualization:/containers/${distribution}/Virtualization:containers.repo \
&& sudo zypper ref \
&& sudo zypper install -y --allow-vendor-change 'docker >= 19.03' python3-docker-compose \
&& docker version \
&& sudo usermod -G docker -a $USER \
&& sudo systemctl --now enable docker \
&& sudo systemctl start docker \
&& sudo zypper install nvidia-docker2 \
&& sudo docker run --rm --gpus all nvidia/cuda:11.0-base nvidia-smi

mkfs -t btrfs /dev/sda1

Expand All @@ -39,33 +76,28 @@ sudo mkdir -p /mnt/storage/discourse/discourse

# deploy discourse
# https://github.com/discourse/discourse.git
curl -sSL https://raw.githubusercontent.com/bitnami/bitnami-docker-discourse/master/docker-compose.yml > docker-compose.yml
docker-compose up -d

# Install Deno

# Install minio server
curl http://dl.minio.org.cn/server/minio/release/linux-amd64/minio \
--create-dirs \
-o $HOME/minio-binaries/minio

chmod +x $HOME/minio-binaries/minio
export PATH=$PATH:$HOME/minio-binaries/

# Create new local crt
## 生成私钥
openssl genrsa -out local_ssl.key 4096
## 生成签名请求
openssl req -new -key local_ssl.key -out local_ssl.csr
## 生成CA证书
openssl x509 -req -in local_ssl.csr -signkey local_ssl.key -out local_ssl.crt
## 导出PKCS12格式文件
openssl pkcs12 -export -in local_sign.crt -inkey local_sign.key -out local_sign.p12

# Mount new disk
# cat uuid: blkid /dev/sda1
sudo chmod +w /etc/fstab
sudo echo "UUID=67bfe2bb-6dd5-4123-b838-e2e8bb93b6cb /data/disk2 btrfs defaults 0 0" >> /etc/fstab
sudo echo "UUID=f8f29b38-6c4b-4df6-9c8d-7f33f26747e3 /data/disk1 btrfs defaults 0 0" >> /etc/fstab
sudo chmod -w /etc/fstab
# curl -sSL https://raw.githubusercontent.com/bitnami/bitnami-docker-discourse/master/docker-compose.yml > docker-compose.yml
# docker-compose up -d

## config network
/etc/sysconfig/network/ifcfg-eth0
BOOTPROTO='static'
IPADDR='192.168.2.77'
MTU='1500'
NAME=''
NETMASK='255.255.255.0'
STARTMODE='auto'
USERCONTROL='no'

/etc/sysconfig/network/routes
default 192.168.2.1 - -

# Install cuda
wget https://developer.download.nvidia.com/compute/cuda/11.4.1/local_installers/cuda_11.4.1_470.57.02_linux.run
sudo sh cuda_11.4.1_470.57.02_linux.run

# Install OBS
sudo zypper ar -cfp 90 'https://ftp.gwdg.de/pub/linux/misc/packman/suse/openSUSE_Leap_$releasever/' packman
sudo zypper dup --from packman --allow-vendor-chang
sudo zypper in obs-studio

Empty file modified ops/init_k8s.sh 100755 → 100644
Empty file.
Empty file modified ops/metrix_dashboard/user_metrix.yaml 100755 → 100644
Empty file.
128 changes: 128 additions & 0 deletions ops/pause_codeEnv_job.py
@@ -0,0 +1,128 @@
#!/usr/bin/python3
# -*- coding: UTF-8 -*-
""" pause current CODE-DEVELOPMENT jobs
# INFO: 暂停代码开发环境中的任务
# VERSION: 1.0.0
# EDITOR: thomas
# UPDATE: 2021-09-22
"""
import http.client as client
import json
import hashlib
import time
import sys, getopt

TEST_DATAS = {
"host": "aiarts.apulis.cn",
"https": "http",
"web_admin": {"userName":"admin","password":"4owfQN"},
"token": "",
"header": {"Content-Type":"application/json;charset=UTF-8", "Accept-Language":"en-US,en;q=0.9,zh-TW;q=0.8,zh;q=0.7", "Accept":"application/json", "User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36"},
"cookie": "",
"homepage": "/",
"login": "/custom-user-dashboard-backend/auth/login",
"logout": "/custom-user-dashboard-backend/auth/logout",
"get_codeEnv_summary": "/ai_arts/api/common/job/summary?jobType={job_type}&vcName={vc_name}",
"get_codeEnv_list": "/api/v2/clusters/DLWS/teams/{vc_name}/jobs?user=all&limit=9999",
"pause_job": "/api/clusters/DLWS/jobs/{job_id}/status"
}

def security_passwd(passwd="DEFAULT"):
Md5Passwd = hashlib.md5()
Md5Passwd.update(passwd.encode("utf-8"))
SecurityPasswd = (Md5Passwd.hexdigest()).lower()
return SecurityPasswd

def on_start(host="aiarts.apulis.cn", account={"userName":"admin","password":"4owfQN"}):
platform_host = host if host else client.HTTPConnection(TEST_DATAS["host"])
admin_account = account if account else TEST_DATAS["web_admin"]["password"]
admin_account["password"] = security_passwd(admin_account["password"])
data = json.dumps(admin_account)
conn = client.HTTPConnection(platform_host)
conn.request("POST", TEST_DATAS["login"], data, headers=TEST_DATAS["header"])
response = json.load(conn.getresponse())
try:
if response["success"]:
TEST_DATAS["token"] = response["token"]
TEST_DATAS["currentRole_id"] = response["currentRole"][0]["id"]
TEST_DATAS["header"]["Authorization"] = "Bearer " + TEST_DATAS["token"]
TEST_DATAS["header"]["cookie"] = "language=zh-CN; token={}".format(TEST_DATAS["token"])
except KeyError:
response.raise_for_status()
return conn

def on_stop(conn):
conn.request("GET", url=TEST_DATAS["logout"])
conn.close()


def get_codeDev_jobs(conn, vc_name="platform"):
params = json.dumps({"limit":999,"user":"all",})
headers = TEST_DATAS["header"]
url = TEST_DATAS["get_codeEnv_list"].format(vc_name=vc_name)
conn.request("GET", url, params, headers )
response = json.load(conn.getresponse())
return [iEnv["jobId"] for iEnv in response if (iEnv["jobType"] == u"codeEnv") and (iEnv["jobStatus"] != u"paused") and (iEnv["jobStatus"] != u"killed")]

def pause_job(conn, job_id):
params = json.dumps({"status": "pausing"})
headers = TEST_DATAS["header"]
url = TEST_DATAS["pause_job"].format(job_id=job_id)
conn.request("PUT", url, params, headers )
response = json.load(conn.getresponse())
print("=================================>>> Pause {} {} on time: {}".format(job_id, response["result"], time.asctime( time.localtime(time.time()) )))

def parse_opt(argv):
try:
opts, args = getopt.getopt(argv,"?h:u:p:",["host=","username=","passwd="])
except getopt.GetoptError:
sys.exit(2)
for opt, arg in opts:
if opt == '-?':
print(
"""
暂停代码开发环境中的任务
-h : 设置平台访问地址(域名或IP)
-u : 设置平台管理员账号
-p : 设置平台管理员账号
-? : 显示帮助
Example:
python3 ./pause_codeEnv_job.py -h aiarts.apulis.cn -u admin -p 4owfQN
"""
)
sys.exit(2)
elif opt in ("-h", "--host"):
host = arg
elif opt in ("-u", "--username"):
username = arg
elif opt in ("-p", "--passwd"):
passwd = arg
else:
continue
return host, {"userName":username,"password":passwd}

def main(argv):
host, account = parse_opt(argv)
conn = on_start(host, account)
for i in range(5):
job_list = get_codeDev_jobs(conn)
if len(job_list):
for iJob in job_list:
pause_job(conn, iJob)
on_stop(conn)
break
else:
time.sleep(3)
continue

if __name__ == "__main__":
# 在主机系统设置定时任务
# chmod +w /etc/crontab
## 测试使用每5min备份一次
## echo "*/5 * * * * root python3 /root/ops_env/pause_codeEnv_job.py -h aiarts.apulis.cn -u admin -p 4owfQN>> /var/log/pause-codeEnv.log" >> /etc/crontab
# 每天晚上12点执行
# echo "59 23 * * * root python3 /root/ops_env/pause_codeEnv_job.py -h aiarts.apulis.cn -u admin -p 4owfQN>> /var/log/pause-codeEnv.log" >> /etc/crontab
# chmod -w /etc/crontab
# service cron restart
## python3 ./pause_codeEnv_job.py -h aiarts.apulis.cn -u admin -p 4owfQN
main(sys.argv[1:])
Empty file modified ops/sync_public_repo/github_action_sync_backend.yml 100755 → 100644
Empty file.
Empty file modified ops/sync_public_repo/github_action_sync_dashboard.yml 100755 → 100644
Empty file.
Empty file modified ops/sync_public_repo/github_action_sync_public.yml 100755 → 100644
Empty file.
Empty file modified ops/sync_public_repo/sync_release.sh 100755 → 100644
Empty file.
Empty file modified ops/update_packages.sh 100755 → 100644
Empty file.
Empty file modified ops/update_packages_reset_harbor.sh 100755 → 100644
Empty file.
Empty file modified ops/update_platform.sh 100755 → 100644
Empty file.
Empty file modified requirements.ini 100755 → 100644
Empty file.
Empty file modified testhub/testlib/csv_client.py 100755 → 100644
Empty file.
Empty file modified testhub/testlib/fake_users.py 100755 → 100644
Empty file.
Empty file modified testhub/testlib/postgres_client.py 100755 → 100644
Empty file.

0 comments on commit 4a39cb2

Please sign in to comment.