首页 > 其他分享 >Pytest测试框架(一):Pytest介绍与安装,Pytest编写规则及pytest.main()的参数

Pytest测试框架(一):Pytest介绍与安装,Pytest编写规则及pytest.main()的参数

时间:2022-12-15 13:23:12浏览次数:67  
标签:runner image pytest access Pytest entrypoint Docker main

Override the entrypoint of an image

Introduced in GitLab and GitLab Runner 9.4. Read more about the extended configuration options.

Before explaining the available entrypoint override methods, let’s describe how the runner starts. It uses a Docker image for the containers used in the CI/CD jobs:

  1. The runner starts a Docker container using the defined entrypoint. The default from Dockerfile that may be overridden in the .gitlab-ci.yml file.
  2. The runner attaches itself to a running container.
  3. The runner prepares a script (the combination of before_scriptscript, and after_script).
  4. The runner sends the script to the container’s shell stdin and receives the output.

To override the entrypoint of a Docker image, define an empty entrypoint in the .gitlab-ci.yml file, so the runner does not start a useless shell layer. However, that does not work for all Docker versions.

  • For Docker 17.06 and later, the entrypoint can be set to an empty value.
  • For Docker 17.03 and earlier, the entrypoint can be set to /bin/sh -c/bin/bash -c, or an equivalent shell available in the image.

The syntax of image:entrypoint is similar to Dockerfile’s ENTRYPOINT.

Let’s assume you have a super/sql:experimental image with a SQL database in it. You want to use it as a base image for your job because you want to execute some tests with this database binary. Let’s also assume that this image is configured with /usr/bin/super-sql run as an entrypoint. When the container starts without additional options, it runs the database’s process. The runner expects that the image has no entrypoint or that the entrypoint is prepared to start a shell command.

With the extended Docker configuration options, instead of:

  • Creating your own image based on super/sql:experimental.
  • Setting the ENTRYPOINT to a shell.
  • Using the new image in your CI job.

You can now define an entrypoint in the .gitlab-ci.yml file.

For Docker 17.06 and later:

image:
  name: super/sql:experimental
  entrypoint: [""]

For Docker 17.03 and earlier:

image:
  name: super/sql:experimental
  entrypoint: ["/bin/sh", "-c"]

Define image and services in config.toml

Look for the [runners.docker] section:

[runners.docker]
  image = "ruby:latest"
  services = ["mysql:latest", "postgres:latest"]

The image and services defined this way are added to all jobs run by that runner.

Access an image from a private Container Registry

To access private container registries, the GitLab Runner process can use:

To define which option should be used, the runner process reads the configuration in this order:

  • DOCKER_AUTH_CONFIG CI/CD variable.
  • DOCKER_AUTH_CONFIG environment variable set in the runner’s config.toml file.
  • config.json file in $HOME/.docker directory of the user running the process. If the --user flag is provided to run the child processes as unprivileged user, the home directory of the main runner process user is used.

Requirements and limitations

  • Available for Kubernetes executor in GitLab Runner 13.1 and later.
  • Credentials Store and Credential Helpers require binaries to be added to the GitLab Runner $PATH, and require access to do so. Therefore, these features are not available on shared runners, or any other runner where the user does not have access to the environment where the runner is installed.

Use statically-defined credentials

There are two approaches that you can take to access a private registry. Both require setting the CI/CD variable DOCKER_AUTH_CONFIG with appropriate authentication information.

  1. Per-job: To configure one job to access a private registry, add DOCKER_AUTH_CONFIG as a CI/CD variable.
  2. Per-runner: To configure a runner so all its jobs can access a private registry, add DOCKER_AUTH_CONFIG as an environment variable in the runner’s configuration.

标签:runner,image,pytest,access,Pytest,entrypoint,Docker,main
From: https://www.cnblogs.com/sdfasdf/p/16984783.html

相关文章

  • DDD Domain-Driven Design
    商品中心答疑​​http://www.nmalls.com/public/help.htm​​阿里高级技术专家方法论:如何写复杂业务代码?​​https://mp.weixin.qq.com/s/pdjlf9I73sXDr30t-5KewA​​以商品......
  • 新装Eclipse运行Java程序报错Exception in thread "main" java.lang.UnsupportedClass
    错误现象:  Exceptioninthread"main"java.lang.UnsupportedClassVersionError:views/LoginFramehasbeencompiledbyamorerecentversionoftheJavaRunt......
  • pytest + yaml 框架 -14.钉钉机器人通知测试结果
    前言当用例执行完成后,希望能给报告反馈,常见的报告反馈有:邮箱/钉钉群/飞书/企业微信等。pip安装插件pipinstallpytest-yaml-yoyo钉钉机器人通知测试结果功能在v1.1......
  • pytest + yaml 框架 -13.多环境配置切换
    前言前言当我们在测试环境写好自动化的代码,领导说你把代码部署到联调环境再测一测,这时候去改用例里面的配置是很痛苦的。所以我们在设计自动化用例的时候,就先要想到多环......
  • pytest + yaml 框架 -12.支持执行sql 和 断言sql
    前言当我们在测试环境写好自动化的代码,领导说你把代码部署到联调环境再测一测,这时候去改用例里面的配置是很痛苦的。所以我们在设计自动化用例的时候,就先要想到多环境的......
  • KingbaseES垃圾回收参数优化之maintenance_work_mem
    maintenance_work_mem参数说明与vacuum过程maintenance_work_mem,autovacuum_work_mem。如果没有设置autovacuum_work_mem,默认值是-1,则使用maintenance_work_mem的设......
  • pytest在linux系统中报编码错误
    pytest项目在windows环境中可以正常运行,但是在linux中运行时,会报编码错误UnicodeDecodeError:'utf-8'codeccan'tdecodebyte0xbcinposition2:invalidstartbyt......
  • Exception in thread "main" kafka.zookeeper.ZooKeeperClientTimeoutException: Time
    遇到问题:今天在启动kafka后创建topic时遇到如下错误:[root@localhostconfig]#kafka-topics.sh--create--zookeeper192.168.68.110:2181,192.168.68.111:2181,192.16......
  • pytest.exit()方法
    测试过程中,常常需要在session级别的setup中校验数据是否正确,若不正确,则需要直接停止当前测试用例后续的运行此时,可使用pytest.exit()方法源码: msg:退出测试进程时显......
  • 快速上手 Pytest + Requests + Allure2 测试框架实战技能
    随着分层测试策略和自动化测试的普及,测试框架和接口测试成为测试工程师需重点掌握的底层核心技能。在Python自动化测试领域,Pytest由于入门简单,扩展丰富,功能强大,易于维护......