Navigation

    SOFTWARE TESTING

    • Register
    • Login
    • Search
    • Job Openings
    • Freelance Jobs
    • Companies
    • Conferences
    • Courses
    1. Home
    2. Laycee
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups

    Laycee

    @Laycee

    1
    Reputation
    29949
    Posts
    2
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    Laycee Follow

    Best posts made by Laycee

    • Create and delete users before and after each API integration test

      There are endpoints in a simplified form on the server:

      GET / users
      POST / users - create a user
      GET / users / {id}
      DELETE / users / {id}

      Server and client are on the same server. They have a common database for testing sqlite. Let's say I have a test for each endpoint. In each test, an http request is sent to the endpoint using the http client, as if it were a consumer (consumer), and the response is checked for correctness. Before the very beginning of the tests, an empty database is created and the migration is rolled. After finishing the tests, the database is deleted.

      My problem is that before each test I need to create 7 users with fake data. And after the test, so that they are "deleted".

      First, I did the database through transactions, the test starts and a transaction is started on the client, 7 users are created, in the test there is an http request for GET / users, but there is no transaction on the server and an empty database. Therefore, this option is eliminated.

      If you do without a transaction, then shared database data is the same on the client and the server due to the fact, but I need only 7 users before each test so that previous manipulations with the database do not distort the data. Therefore, this option is also eliminated.

      I tried the option where the database is deleted and migrated before each test. It works but for a very long time (it takes a minute to check 4 endpoints). Database in memory would speed up a lot here, but here is the same problem as with a transaction.

      I just can't find a solution. What can you advise? I want to test all endpoints not through functional tests inside the code, but as if from the outside (as an interface is tested using selenium).

      posted in API Testing
      Laycee
      Laycee

    Latest posts made by Laycee

    • RE: Docker containers are being restarted after logging in via SSH

      Apparently rootless mode runs Docker only when a user session starts. After stopping the session, Docker stops too.

      I had to enable lingering: https://stackoverflow.com/questions/73299883/docker-containers-terminate-on-shell-logout

      $ loginctl enable-linger $UID

      posted in Continuous Integration and Delivery (CI
      Laycee
      Laycee
    • RE: Ansible jinja2 if/elif/else construct not working anymore

      Fix the condition

      {% if production_env == "prod" or
            production_env == "stage" %}
        password: "{{ group_token }}"
        username: usernamedoesntmatterhere
      {% elif production_env == "dev" %}
        password: "{{ mytoken }}"
        username: "{{ mytokenname }}"
      {% else %}
          NONE
      {% endif %}
      
      posted in Continuous Integration and Delivery (CI
      Laycee
      Laycee
    • RE: How Can I Escape Backspace Using Set_Fact In Ansible With Jinja Conditional

      Put the template into a https://yaml.org/spec/1.2.2/#chapter-8-block-style-productions . For example,

          - set_fact:
              email_machine_list: |-
                {% for host in ansible_play_batch %}
                {{ hostvars[host]['ansible_hostname']|upper }}:
      {% endfor %}

      Example of a complete playbook for testing

      Given the inventory

      shell> cat hosts
      host_1 ansible_hostname=10.1.0.11
      host_2 ansible_hostname=10.1.0.12
      host_3 ansible_hostname=10.1.0.13
      

      The playbook

      - hosts: host_1,host_2,host_3
        gather_facts: false
        tasks:
          - set_fact:
              email_machine_list: |-
                {% for host in ansible_play_batch %}
                {{ hostvars[host]['ansible_hostname']|upper }}:
      {% endfor %} run_once: true - debug: var: test run_once: true

      gives (abridged)

      TASK [debug] *************************************************
      ok: [host_1] => 
        email_machine_list: |-
          10.1.0.11:
      10.1.0.12:
      10.1.0.13:

      Email

      Put the body of the email into the block as well. For example,

          - name: email the list
            mail:
              to: Me 
              from: Ansible 
              subject: "Ansible Notification"
              subtype: html
              body: |-
                
                
                
                

      {{ email_machine_list }}



      host: localhost port: 25 run_once: true delegate_to: localhost

      The email was delivered as expected. I had to turn off the rendering of HTML to text in the email client.

      Return-Path: 
      X-Original-To: admin@localhost
      Delivered-To: admin@localhost
      Received: from [127.0.0.1] (localhost [127.0.0.1])
       by test.example.org (Postfix) with ESMTPS id 3664C180493
       for ; Thu,  8 Sep 2022 23:48:00 +0200 (CEST)
      Content-Type: multipart/mixed; -charset="utf-8"; boundary="===============4465080980945319992=="
      MIME-Version: 1.0
      From: Ansible 
      Date: Thu, 08 Sep 2022 23:48:00 +0200
      Subject: Ansible Notification
      X-Mailer: Ansible mail module
      To: Me 
      Cc: 
      Message-Id: 
      
      
      
      

      10.1.0.11:
      10.1.0.12:
      10.1.0.13:



      Enabled rendering of HTML to text works as well

      10.1.0.11:
      10.1.0.12:
      10.1.0.13:
      
      posted in Continuous Integration and Delivery (CI
      Laycee
      Laycee
    • RE: Jenkins JDK17 Docker still using JDK9?

      Actually looks like I haven't done a great build-setup here. The way to correctly do this is not trying to change the default JDK (even though I still think there's an issue in the Docker..). What really required is a "Tool" section under JDK section for the builds to work with the custom JDK. So the notion from Jenkins, the Agent JDK is what I need, and not to worry about the Controller JDK really.

      A great video that I came across that helped:

      https://www.youtube.com/watch?v=qx3XK82BZPk

      posted in Continuous Integration and Delivery (CI
      Laycee
      Laycee
    • HorizontalPodAutoscaler scales up pods but then terminates them instantly

      So I have a HorizontalPodAutoscaler set up for my backend (an fpm-server and an Nginx server for a Laravel application).

      The problem is that when the HPA is under load, it scales up the pods but it terminates them instantly, not even letting them get into the Running state.

      The metrics are good, the scale-up behavior is as expected the only problem is that the pods get terminated right after scaling.

      What could be the problem?

      Edit: The same HPA is used on the frontend and it's working as expected, the problem seems to be only on the backend.

      Edit 2: I have Cluster Autoscaler enabled, it does it's job, nodes get added when they are needed and then cleaned up so it's not an issue about available resources.

      deployment.yaml

      apiVersion: apps/v1
      kind: Deployment
      metadata:
        name: fpm-server
        labels:
          tier: backend
          layer: fpm
      spec:
        replicas: {{ .Values.replicaCount }}
        selector:
          matchLabels:
            tier: backend
            layer: fpm
        template:
          metadata:
            labels:
              tier: backend
              layer: fpm
          spec:
            {{- with .Values.imagePullSecrets }}
            imagePullSecrets:
              {{- toYaml . | nindent 8 }}
            {{- end }}           
            containers:
              - name: fpm
                image: "{{ .Values.fpm.image.repository }}:{{ .Values.fpm.image.tag }}"
                ports:
                  - name: http
                    containerPort: 9000
                    protocol: TCP
                env:
                {{- range $name, $value := .Values.env }}
                - name: {{ $name }}
                  value: "{{ $value }}" 
                {{- end }}             
                envFrom:
                  - secretRef:
                      name: backend-secrets
                resources:
                  {{- toYaml .Values.resources | nindent 12 }}
      

      hpa.yaml

      apiVersion: autoscaling/v2beta1
      kind: HorizontalPodAutoscaler
      metadata:
        name: fpm-server-hpa
        labels:
          tier: backend
          layer: fpm
      spec:
        scaleTargetRef:
          apiVersion: apps/v1
          kind: Deployment
          name: fpm-server
        minReplicas: {{ .Values.autoscaling.minReplicas }}
        maxReplicas: {{ .Values.autoscaling.maxReplicas }}
        metrics:
          {{- if .Values.autoscaling.targetCPUUtilizationPercentage }}
          - type: Resource
            resource:
              name: cpu
              targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
          {{- end }}
          {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }}
          - type: Resource
            resource:
              name: memory
              targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
          {{- end }}
      
      posted in Continuous Integration and Delivery (CI
      Laycee
      Laycee
    • How do I disable ICMP echo responses within a Docker container?

      I want to be able to change the /proc/sys/net/ipv4/icmp_echo_ignore_all file from within my Docker container, but I get the

      bash: /proc/sys/net/ipv4/icmp_echo_ignore_all: Read-only file system

      error when attempting to do so, and running Docker with the --privileged flag is not an option.

      Is there any way I can disable (and preferably also reenable) ICMP echo requests from within my container?

      posted in Continuous Integration and Delivery (CI
      Laycee
      Laycee
    • RE: gitlab container registry: how to test that it's set up and working?

      It looks to me like you're not pushing to the right port.

      When you go to the project space, and then go to your container registry /container_registry (or click under Packages & Registries → Container Registry

      Menus hove

      Or, like this if you prefer to click on Packages & Registries

      Menu click

      On this page you should see a bunch of links, one of them should have something like this,

      docker push domain:5050/myusername/pipelinetests
      

      You want to be sure you're including that :5050. That's the defualt port for the https://docs.gitlab.com/ee/administration/packages/container_registry.html . It looks like from that error, that you're targeting the actual project page.

      posted in Continuous Integration and Delivery (CI
      Laycee
      Laycee
    • RE: In Ubuntu, how do I authenticate to trigger a Jenkins job remotely using the CLI?

      This is covered https://www.jenkins.io/doc/book/system-administration/authenticating-scripted-clients/ . In short, if you are triggering via HTTP, you need to generate an authentication token and use it with HTTP Basic auth, for instance:

      curl -X POST -L --user your-user-name:apiToken https://jenkins.example.com/job/your_job/build
      
      posted in Continuous Integration and Delivery (CI
      Laycee
      Laycee
    • RE: Which CI/CD tool(s) should a DevOps newbie learn?

      Just some freeform thoughts from your question.

      For perspective, I run a large enterprise DevOps team that has automated build & deployment for a wide range of large scale services (which run over k8s/AWS primarily). That doesn't necessarily mean I'm good at things, haha (always check your sources) - but I think we're in a very good spot personally =). But the advice comes from practical experience and lots of time spent iterating at least.

      • When we hire people we really don't care what CI/CD tool they knew, or what "automation" tool they knew. We just care that they know one well and can explain some pipelines and their challenges in depth.
        • Note that if you're not in k8s, deployment usually involves terraform, cloud formation, ansible, or one of many other tools on top of your CI/CD engine.
      • So, rather than overthinking which tool to learn (they evolve constantly), my recommendation is pick a mainstream one and focus on a "hard use case" so that you have to do something complex in it that forces you to learn.
      • We use GitLab CI, and previously Jenkins. People in the industry also seem to like Spinnaker, CircleCI, and the equivalent cloud tools (AWS and Azure have all their own). GitHub Actions is also huge now.
      • I don't think tools just do CI or CD. That's a very arbitrary line. CD just means your pipeline pushed to production (in a hopefully validated and safe manner). Jenkins can do that, GitLab can do that, any of those tools can. They're free form and you tell them what to do.
      • Having everything in one tool is revolutionary and makes life 1000 times easier. E.g. GitLab, GitHub, etc are going all in to do code, wikis, testing, container and artifact registries, deployment, monitoring, even things like incident management. It's amazingly helpful and goes far beyond "CI and CD". More tools = more integration issues and more sprawl and a greater chance you miss or get lazy about something / waste time coding integrations.
      • For getting started, anything really works again. I might recommend GitHub actions, GitLab, or Jenkins. The first 2 may be a little better as they have more tools in them. With Jenkins you'll need external artifact registries and such. But Jenkins is good as it is super common still.

      FYI, I don't know much about Jenkins vs JenkinsX, so ignoring that part :).

      posted in Continuous Integration and Delivery (CI
      Laycee
      Laycee
    • RE: How to only allow vanilla/Optifine players to join a Minecraft server?

      If you want to check if a player is using Fabric or Forge when they try to join your Minecraft server, you can use a plugin to do this. There are several plugins available that can check the mods a player is using and block them from joining if they are using certain mods.

      To use a plugin to block players using Fabric or Forge, you will first need to install a plugin management system on your Minecraft server. The most commonly used plugin management system is called Bukkit, but there are also other options available such as Spigot and Paper.

      Once you have installed a plugin management system, you can search for a plugin that will check for players using Fabric or Forge and block them from joining the server. Some popular plugins for this purpose include ModControl, AntiForge, and ModBlocker.

      posted in Game Testing
      Laycee
      Laycee