youtube 推荐频道(Non-tech)

自从到新公司有梯子后,外出运动的时间变少了,都奉献给了youtube.有些节目被查水表了,“此帐户已被终止,因为我们收到多份第三方提交的关于该用户发布的内容侵犯版权的声明。” 所以也不能保证下面罗列的节目在未来可以持续观看

频道 关键字 备注
梦觉教游泳 postman,测试
一本好书 devops,terraform
越哥说电影 电影解读
树根朽木 电影解读
宇哥讲电影 电影、剧集解读
看电影了没 电影
盗月社食遇记 美食
回形针PaperClip 科普
5分鐘DIY 生活小技巧
四季萌芽 火影
深夜讀書
PAPAYA 電腦教室 office三件套

如何下载youtube视频、音频

Terraform : terraform console

1.evaluating expressions

The terraform console command provides an interactive console for evaluating expressions.

For example:

1
2
3
4
5
6
7
8
9
10
11
# interactive console
➜ terraform console
> element(list("one","two","three"),1)
two

# non-interactive scripts
echo "list("1","2")" | terraform console
[
1,
2,
]

or

1
2
3
➜ terraform console
> aws_instance_demo.public_ip
54.152.62.34
2.test Terraform built-in functions locally

test Terraform built-in functions locally


More ref:
https://www.terraform.io/docs/commands/console.html
http://artemstar.com/2018/03/03/terraform-test-functions/

Import P12 file on Mac OS X with CLI

目的:通过命令行倒入p12证书

Apple为了安全,在ssh登录时,是不允许读取Keychains(钥匙串)的,所以 security unlock-keychain 这行命令就很重要了。比如在Pipeline构建打包前,先解锁Keychains。

1.解锁

1
2
3
4
5
6
7
#方式一: 命令行中不含密码,交互方式
➜ security unlock-keychain /Users/<Your_Name>/Library/Keychains/login.keychain-db
password to unlock /Users/<Your_Name>/Library/Keychains/login.keychain-db:

#或者命令行中包含密码的方式
➜ security unlock-keychain -p <Mac_Login_PWD> /Users/<Your_Name>/Library/Keychains/login.keychain-db
➜ security list-keychains -s /Users/<Your_Name>/Library/Keychains/login.keychain-db

2.导入

1
2
3
4
5
6
7
#方式一: 命令行中不含密码,交互方式
#会有弹窗,提示输入 P12文件的密码
➜ security import ~/Desktop/xxx.p12 -k /Users/<Your_Name>/Library/Keychains/login.keychain-db
1 identity imported.
#或者命令行中包含密码的方式
➜ security import ~/<Your_Path>/xxx.p12 -k /Users/<Your_Name>/Library/Keychains/login.keychain-db -P <P12_Password>
1 identity imported.

3.其他

删除

1
2
3
4
##先展示证书,获取SHA1值; -p 可指定类型
security find-identity -p codesigning /Users/<Your_Name>/Library/Keychains/login.keychain-db
##根据SHA1值删除对应的证书
security delete-certificate -Z <Your_SHA1>

更过 security 用法,查看 security --helpsecurity find-identity --help


More ref:
https://www.cnblogs.com/pixy/p/4817579.html

Anka tutorial xx: Upgrade Record

1.升级前

从2018年11月到如今2019年11月,已经使用现有的版本1年多;anka也经历了多个版本,此次升级算是跨度较大,升级到目前最新的版本1.5.0

1.1 节点信息

hostname (节点名称) IP OS 组件
node1 192.168.55.xx linux anka-controller、anka-registry、etcd、beanstalk、 jenkins、sonarqube
node2 192.168.22.xx mac OS anka build

1.2 节点组件版本信息

Name Current Ver Upgrade to Ver Note
anka-controller 1.0.14-e7cc50b 1.5.0-ca87f665 自制image
etcd quay.io/coreos/etcd:v3.1.6 N/A https://quay.io/repository/coreos/etcd?tab=tags, 新版本需要 自制image
beanstalk schickling/beanstalkd N/A 新版本可不使用
anka-registry same as controller 1.5.0-ca87f665 自制image
Anka Build 1.4.3 2.1.2 N/A

1.2 组件端口变更信息

组件 升级前端口 升级后端口
anka-controller 8090 80
anka-registry 80 8089

根据节点的OS,提前下载安装包及相关文件 Anka Build Download page

2. 升级步骤

官网升级步骤链接: https://ankadoc.bitbucket.io/#upgrade-steps, 但是不够详细

2.1) On the mac nodes - run sudo ankacluster disjoin.

node 2 上操作
node2 $ sudo ankacluster disjoin -g

2.2) Install the new anka pkg on all the mac nodes.

node 2 上操作, 找到安装包,双击安装即可

2.3) Upgrade the guest addons inside the VM templates with anka start -u. Check the upgrade notes to see if this step is necessary.

node 2 上操作

1
2
3
4
#先切换到root用户,方便操作
#这个命令执行后会等待3min左右
node2:~ root# anka stop -f <VM_NAME>
node2:~ root# anka start -u <VM_NAME>

2.4) Push the newly upgraded VM templates to registry with anka registry push vmname –tag.

node 2 上操作
node2:~ root# anka registry push <VM_NAME> -d '<Message>' -t v100

2.5) Go to the Controller/Registry and upgrade.

node 1 上操作 ,之前的启动方式是docker-compose,根据yaml文件启动

anka 经过一年的开发升级,这块变动较大,比如:

    1. beanstalk 可以不使用了 (starting from anka version 2.0 beanstalk is not required, please configure the controller with the configuration that doesn’t use beanstalk)
    1. 端口的变化
    1. etcd由之前的 quay.io/coreos/etcd 镜像改为自己制作

提前备份 docker-compose.yml;先将下载包解压,结合老版本的docker-compose.yml文件,替换 services/ 目录下的相关文件

注意事项:

- etcd、registry 挂载的文件目录不可变动,不然影响旧的数据正常读取
- 替换docker-compose.yml的一些值

2.6) On the mac nodes - run sudo ankacluster join.

node 2 上操作
ankacluster join -g -n mac-mini-01 http://controller.anka.intranet.in2e.com:80

以上是官网提及的,但是与jenkins 集成中还需要更多的操作,以下作为补充

2.7) Change jenkins configuration.

  • 2.7.1 修改controller地址

  • 2.7.2 修改 anka VM templates
    升级后,测试发现 jenkins 日志中找不到vm templates;需要重新配置 VM templates

2.8) Change registry

升级后一天,再更新一个VM template时遇到问题

发现问题:
报错如下, 根据提示修改了多次命令的格式,但还是没有作用

1
2
anka registry push <VM_NAME> -d 'update new cert' -t v28
-anka: Extra data: line 1 column 5 - line 2 column 1 (char 4 - 19)

思考问题:
在root用户下 使用 anka registry list 时发现也报错,于是怀疑是 registry 的问题;由于端口的变更,导致 anka push VM 会有问题;需要删除,重新添加

尝试解决问题:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# 先查看repo
node2:~ root# anka registry list-repos
++
++
anka (default)
+--------+-----------------------------------+
| host | controller.anka.intranet.xxx.com |
+--------+-----------------------------------+
| scheme | http |
+--------+-----------------------------------+
#删除
node2:~ root# anka registry delete anka
#新增
node2:~ root# anka registry add anka-repo http://192.168.55.xx:8089
#再次list,查看以下
node2:~ root# anka registry list-repos
++
++
anka-repo (default)
+--------+---------------+
| host | 192.168.55.xx |
+--------+---------------+
| scheme | http |
+--------+---------------+
| port | 8089 |
+--------+---------------+

一波操作后,终于可以正常 push VM, ~~~大坑


最后 —->记得修改Node上的 VM capacity
每次disjoin -> join 动作,这个值都会回到默认值 2;或者执行 ankacluster join 的时候可以用 -m 参数去指定
这个值的作用是,指定允许同时运行几个 mac OS 实例

主要记录 2019-11-20 左右升级 anka 的操作

Anka tutorial 02

1.Joining Nodes

在mac上(anka build 节点)执行 sudo ankacluster join http://localhost:80/

output:

1
2
3
4
5
6
➜  ~ sudo ankacluster join http://localhost:80/ -n demo-mac
Setting tls config
Testing connection to controller...: Ok
Testing connection to the registry...: Ok
Ok
Cluster join success

去页面 http://localhost/#/nodes 查看

先下载mac OS安装包 (安装包7G多,需要提前下载)
https://www.macworld.co.uk/how-to/mac-software/download-old-os-x-3629363/#el%20cap

1
2
3
➜  ~ anka create --ram-size 4G --cpu-count 2 --disk-size 40G --app /Applications/Install\ macOS\ Catalina.app CatalinaVm
Installing macOS 10.15.1...
Preparing target disk...

Note For Catalina Anka VMs, –ram-size value should be 4G and –disk-size should be 80G.
由于电脑空间不够了,于是报错了

清理电脑空间后,再来一次,大约 30min

1
2
3
4
5
6
7
➜  ~ anka create --ram-size 4G --cpu-count 2 --disk-size 80G --app /Applications/Install\ macOS\ Catalina.app  CatalinaVm
Installing macOS 10.15.1...
Preparing target disk...
Installing addons...
Converting to ANKA format...
Waiting for installation to complete in the guest (about thirty minutes approx.)...
vm created successfully with uuid: a23d5a05-xx89-4xx4-a8b7-6f7b9xxxxxx

3. Run VM

VM 状态之间的转换如下:

需要区别 VM 和后面提到的 instance 关系,VM 更准确点讲是 VM Template,是创建instance的模版,但模版需要通过上面的方法才可以修改;新建VM后,相当于有一个基础的模版,但是要满足其他要求,可以自行在running的 vm 中操作,然后随时保存,类似于docker container的commit操作,但anka build是suspend一个running的 vm 来保存。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#罗列仓库
➜ anka registry list-repos
++
++
#添加一个新仓库
➜ anka registry add demo-repo http://localhost:8089
➜ anka registry list-repos
++
++
demo-repo (default)
+--------+-----------+
| host | localhost |
+--------+-----------+
| scheme | http |
+--------+-----------+
| port | 8089 |
+--------+-----------+
#推送VM Templates 到新仓库,
➜ anka registry push CatalinaVm -d "first push" -t v1

Anka tutorial 01

1.Anka 是什么

前端,后端,包括安卓的持续集成的过程都可以轻松的基于docker命令构建、打包,最终产出 docker image镜像,非常方便搭建标准化的pipeline(流水线);但是对于iOS移动端的同学而言,似乎没有那么简单。每次打包的过程都是耗时、复杂的。另外一点由于macOS系统是捆绑在mac硬件上的,你没有苹果电脑就无法打包,相比而言docker则是纯免费开源的。针对以上问题和情况,anka就是这样一种类似于dock的针对macOS系统的虚拟化技术。

于是乎,想长期使用是需要收钱的。

官网介绍 https://ankadoc.bitbucket.io/#what-is-anka-build

费用介绍 https://ankadoc.bitbucket.io/licensing/

几个组件的关系
https://veertu.com/anka-technology/

Anka Hypervisor
Anka Controller
Anka Registry

2.安装

搭建的环境: MacBook Pro(version: 10.13.6)

下载地址:https://veertu.com/download-anka-build/
anka download page

2.1 Anka Package Install and Configuration

https://ankadoc.bitbucket.io/anka-build/#anka-package-install-and-configuration

双击 pkg 包,默认选项安装,最终显示安装成功即可。

安装完成后可以用过命令 anka config --list 查看所有的配置,比如 vm 的存储路径等

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
➜  anka config --list
+-----------------------------+-----------------------------------------------------------------------------+
| registry_remotes_file_path | /Users/xxx/.anka/remote |
+-----------------------------+-----------------------------------------------------------------------------+
| mac_random_bytes | 2 |
+-----------------------------+-----------------------------------------------------------------------------+
| disk_eraser_tool | /Library/Application Support/Veertu/Anka/tools/erase_disk_image.sh |
+-----------------------------+-----------------------------------------------------------------------------+
| process_type | Interactive |
+-----------------------------+-----------------------------------------------------------------------------+
| default_passwd | admin |
+-----------------------------+-----------------------------------------------------------------------------+
| nvram_path | /Library/Application Support/Veertu/Anka/uefi/anka_vars.fd |
+-----------------------------+-----------------------------------------------------------------------------+
| vm_lib_dir | /Users/xxxx/Library/Application Support/Veertu/Anka/vm_lib/ |
+-----------------------------+-----------------------------------------------------------------------------+
| anka_image_maker_executable | /Library/Application Support/Veertu/Anka/bin/anka_image |
+-----------------------------+-----------------------------------------------------------------------------+
省略100行
...
2.2 Controller/Registry Install and Configuration

https://ankadoc.bitbucket.io/anka-build/#controller-registry-install-and-configuration

同上,双击 .pkg 包,默认安装,看到提示安装成功即可。

设置一下 Registry Address 地址:

2.3 申请试用许可(trail license)

https://veertu.com/anka-build-trial

完善信息提交后,会有一个成功的提示,如图所示:

激活key

1
2
➜  ~ sudo anka license activate xxxx-3750-xxxx-2265
License activated

查看license信息

1
2
3
4
5
6
7
8
9
10
➜  ~ anka license show
+---------------------+---------------------+
| license_type | com.veertu.anka.ent |
+---------------------+---------------------+
| status | valid |
+---------------------+---------------------+
| expires | 20-dec-2019 |
+---------------------+---------------------+
| max_number_of_cores | 32 |
+---------------------+---------------------+

Test 02:Tools

测试种类与测试工具没有一对一的关系。

项目原因最近在学习以下几个工具:

1.Postman

可做api测试,newman

2.Selenium

Selenium is a suite of tools to automate web browsers across many platforms.

3.Cucumber

Cucumber 是 BDD(behaviour-driven development) 模式下实现可执行规范(Executable Specifications)的开源工具,但是它的使命并不局限于做自动化验收测试,更加重要的在于其能够在团队成员之间构建统一的交流基础(feature 文件)、规范交流用语(Domain Specific Language)、提高各个利益相关方(Business Stakeholders)沟通效率和效果,从而达到提升产品质量、做成客户期望得到的产品这一最终目标。
参考

  • Features介绍

    feature(功能),每一个feature文件都要开始于Feature(功能),Feature之后的描述可以随便写,直到出现Scenario(场景),一个feature中可以有多个 Scenario,每个Scenario包含(step)步骤列表,步骤使用Given、When、Then、But、And这些关键词,cucumber对这些关键词的处理是一样的,但是我们在使用的时候需要按照场景区分。

  • Step definitions介绍

    Cucumber中定义的每一个step(步骤)都需要有一个step definition对应,默认的话是使用Ruby来编写定义的脚本,支持通过正则表达式从step中传递参数。

  • Given When then(假如 当 那么)

    Cucumber的步骤中会包含Given、When、then这些词组,cucumber本身在技术实现上不区分这三个词组,但是在使用上推荐按照词组的意思来使用。

    • Given-用例开始执行前的一个前置条件,类似与编写代码setup中的一些步骤
    • When-用例开始执行的一些关键操作步骤,类似点击元素等
    • Then-观察结果,就是平时用例中的验证步骤
    • And-一个步骤中如果存在多个Given操作,后面的Given可以用And替代
    • But-一个步骤中如果存在多个Then操作,第二个开始后面的Then可以用But替代

工具情况统计

Tool-Name CLI HTML-Report
Postman newman
Selenium 结合javapython环境运行 HTML TestRunner
Cucumber cucumber

More Ref:

  • Copyrights © 2019-2024 John Doe
  • Visitors: | Views:

请我喝杯咖啡吧~