Navigation

    SOFTWARE TESTING

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

    meriah

    @meriah

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

    meriah Follow

    Best posts made by meriah

    • Why Mockito and Mockmvc don't work together?

      I'm trying to some basic mock tests. I want to return my ApiResponse when Mockmvc call the API but it doesn't.

      @RunWith(MockitoJUnitRunner.class)
      public class AuthControllerTest {
      
          @Autowired
          private MockMvc mockMvc;
      
          @InjectMocks
          AuthController authController;
      
          @Mock
          private AuthService authService;
      
          @Before
          public void init() {
              mockMvc = MockMvcBuilders.standaloneSetup(authController).build();
          }
      
          @Test
          public void authenticateUserShouldReturnStatusOk() throws Exception {
              LoginRequest loginRequest = TestUtils.createLoginRequest();
      
              AuthResponse authResponse = new AuthResponse("token", loginRequest.getUsername(), HttpStatus.OK);
      
              when(authService.authenticateUser(loginRequest)).thenReturn(authResponse);
      
              mockMvc.perform(post("/api/auth/login")
                      .contentType(APPLICATION_JSON)
                      .content(TestUtils.convertObjectToJsonBytes(loginRequest)))
                      .andExpect(status().isOk())
                      .andDo(print());
      
              verify(authService, times(1)).authenticateUser(refEq(loginRequest));
          }
      
      }
      

      MockMvc print result:

      MockHttpServletRequest:
            HTTP Method = POST
            Request URI = /api/auth/login
             Parameters = {}
                Headers = [Content-Type:"application/json", Content-Length:"49"]
                   Body = <no character encoding set>
          Session Attrs = {}
      
      MockHttpServletResponse:
                 Status = 200
          Error message = null
                Headers = []
           Content type = null
                   Body = 
          Forwarded URL = null
         Redirected URL = null
                Cookies = []
      
      Process finished with exit code 0
      

      Why isn't that ApiResponse called? I want mockmvc to return the answer I gave, but nothing changes.

      Can you help me?

      posted in Automated Testing
      M
      meriah
    • What is the difference between test strategy and test plan?

      As per lot of articles/google it is very hard to understand or explain the exact difference between test plan & strategy. Recently have gone through one of the interview and seems my answer didn't convince to the interviewer. So if anyone can help me in answering this to understand the thin line between Test plan & strategy please. Thanks.

      posted in Automated Testing
      M
      meriah

    Latest posts made by meriah

    • Port forwarding rules with Traefik and Docker.Compose

      I'm trying to use Traefik to route to a number of services all running using docker-compose. What I'd like to do is access each service with a prefix, eg: 10.20.30.40/u10/xyz and 10.20.30.40/a10/abc instead of 10.20.30.40:8000/xyz and 10.20.30.40:8001/abc.

      I have a `docker-compose.yml file where I'm starting my services a10,u10,x10, mongo,mosquitto and all are exposed on their own ports - this works. I'm now stuck with the correct parameters for Traefik. You can see some of the attempts and commenting out of parameters.

      The services a10,u10 etc should only be accessible using a prefix and all over port 80. Load balancing should be possible, eg: docker-compose -f dc.yml --scale u10=3 --scale a10=5

      When I run this if I try on my local machine: http://127.0.0.1/u10/somepage.html I get a gateway timeout error, or, if I don't try using --scale then I'll get a 404.

      Internally these services communicate with each other over the specified ports (REST) without the prefix and this works internally.

      version: "3"
      services:
         reverse-proxy:
           image: traefik:v2.9
           command:
             - "--log.level=DEBUG"
             - "--api.insecure=true"
             - "--providers.docker=true"
             - "--providers.docker.exposedByDefault=true"
             - "--entrypoints.web.address=:80"
             - "--accesslog=true"
           ports:
             - "80:80"
             - "8080:8080"
           volumes:
             - /var/run/docker.sock:/var/run/docker.sock
      

      u10:
      image: "u10"

      container_name: u10

      ports:

      - 8540:8540 # !!!

       depends_on:
         - messagebus
       restart: always
       networks:
        - attestationnetwork
       volumes:
        - ./a10.conf:/etc/a10.conf      # !!!
       labels:
         - "traefik.enable=true"
      

      - "traefik.port=8540"

         - "traefik.docker.network=my-internal-network"
         - "traefik.http.routers.u10.rule=PathPrefix(`/u10`)"
         - "traefik.http.routers.u10.entrypoints=web"
         - "traefik.http.routers.u10.middlewares=u10"
         - "traefik.http.middlewares.u10.stripprefix.prefixes=/u10" 
         - "traefik.http.middlewares.u10.stripprefix.forceSlash=false"
         - "traefik.http.routers.u10.service=u10"       
         - "traefik.http.services.u10.loadbalancer.server.port=8540"
      

      networks:
      my-internal-network:
      driver: bridge

      posted in Continuous Integration and Delivery (CI
      M
      meriah
    • RE: port forward ssh from traefik reverse proxy on docker to a k3s container

      Your ip show does mention 10.42.0.0/32, 10.42.0.200/32. No traces of 10.42.0.232, though.

      From LAN/outside SDN: can you connect any TCP port, or ping that address? anything that answers? I suspect nothing would.

      In addition to that Traefik rule, you mentioned creating a Service ... Are you sure you did it right? Look at kubectl get svc -A | grep 10.42.0.200, that would give you a working example -- something with an externalIP/externalIPs set, or some status.loadbalancer.ingress array ... configuration may vary, depending on how external IPs were implemented and kube version, ..

      And by the way, creating such Services: are you pointing to your application directly, or is it sent to Traefik instead? Assuming the latter: are you sure Traefik actually listens on such port.

      Also, while Traefik should be able to process TCP or UDP trafic, unless you can easily have several Services & backends accessible through the same proto/port combination: involving your ingress controller here might not be necessary.

      posted in Continuous Integration and Delivery (CI
      M
      meriah
    • RE: Value of succeeded() in Azure DevOps pipeline before first stage is run

      Five minutes later I found this dealt with at https://github.com/MicrosoftDocs/azure-devops-docs/issues/7738 . Indeed, it appears that the Succeed outcome is not set until a stage has actually been executed. One respondent in the discussion indicates that this has worked for them:

      As a work-around, our team has had success (no pun intended) using:

      condition: not(or(failed(), canceled())

      This works because the previous stage being skipped does not set a failed status.

      posted in Continuous Integration and Delivery (CI
      M
      meriah
    • How to set reserved concurrency of a lambda function

      I have serveral lambda functions (all in the same region) and I want to limit the concurrency of one of them to a very small value. Specifically, I do not want more than 3 instances of this function running concurrently. This function is not expected to receive a lot of traffic so setting its Reserve concurrency to a low value makes a lot of sense.

      When I try to set this function's Reserve concurrency I get a rejection message (screeshot below) as follows: The unreserved account concurrency can't go below 100.

      What should I do to be able to restrict the concurrency of this function?

      (FWIW, the Unreserved account concurrency of my account is 100)

      enter image description here

      posted in Continuous Integration and Delivery (CI
      M
      meriah
    • How do I supply a professional license to a Docker image?

      I’m using Windows Server Core as part of an image I’m working on. When it's deployed to production, how do I supply a license to it?

      Besides that, is this license needed to be bought for each image it's mounted on?

      I've already mounted an image without an issue, so is simply having the license enough to avoid trouble?

      posted in Continuous Integration and Delivery (CI
      M
      meriah
    • bind mount from host not appearing in docker container when using compose

      I have a bind mount at /home/quant/mounted_folder with a fstab like this:

      /mnt/d/some_folder /home/quant/mounted_folder none bind
      

      I can confirm that the folder mounts correctly on the host:

      DESKTOP-NHBC022@quant: ~/mounted_folder $ ls
      foo.txt bar.txt
      

      Reproducing the problem:

      Take this docker-compose.yml file:

      version: "3.3"
      services:
        env:
          image: debian:latest
          volumes:
            - "/home/quant:/root/host"
      

      The contents of /root/host/code appears empty inside the container:

      DESKTOP-NHBC022@quant: ~ $ docker compose run env bash -c 'ls -al /root/host/code'
      total 28
      drwxr-xr-x  2 1000 1000  4096 Jun 18 12:28 .
      drwxr-xr-x 17 1000 1000 24576 Jun 18 12:56 ..
      

      Workaround:

      If I skip the docker-compose and use just docker run, it seems to work:

      DESKTOP-NHBC022@quant: ~ $ docker run -v /home/quant/:/root/host debian:latest bash -c 'ls -al /root/host/code'
      total 24
      drwxrwxrwx  1 1000 1000  4096 Jun 18 08:59 .
      drwxr-xr-x 17 1000 1000 24576 Jun 18 13:00 ..
      -rwxrwxrwx  1 1000 1000     0 Feb 11  2021 foo.txt
      -rwxrwxrwx  1 1000 1000     0 Jun 18 08:59 bar.txt
      

      How can I make sure that mounted paths on the host correctly appear inside the docker container if they're subdirectories of paths mounted in the container?

      I'm running docker 20.10.1 on windows 10 WSL.

      posted in Continuous Integration and Delivery (CI
      M
      meriah
    • How do I get k3s to authenticate with Docker Hub?

      In jornalctl -u k3s, I see a bunch of errors like this

      429 Too Many Requests - Server message: toomanyrequests: You have reached your pull rate limit. You may increase the limit by authenticating and upgrading: https://www.docker.com/increase-rate-limit

      When I check the associate pods, I see

      Error from server (BadRequest): container "foo" in pod "bar" is waiting to start: trying and failing to pull image

      How can I set up k3s to use an authenticate login to DockerHub? I don't see a docker login, and I've tried probably 20 different things none of which worked. I can confirm this username and password works with https://devops.stackexchange.com/q/16152/18965 . But it doesn't work when I try to put it in a config file. I've tried to playing with

      • /etc/rancher/k3s/registries.yaml and restarting.
      • that seems to generate a new /var/lib/rancher/k3s/agent/etc/containerd/config.toml, I've tried playing with that file too directly

      None of this seems to make any difference. I've tried testing with k3s kubectl run and also with https://devops.stackexchange.com/q/16152/18965 , and none of these change the error that's returned.

      My token has full access at https://hub.docker.com/settings/security

      posted in Continuous Integration and Delivery (CI
      M
      meriah
    • RE: Why does php-fpm show nginx's IP while they are on different containers?

      The SERVER_ADDR is a FastCGI variable that is being set inside the fastcgi_params file as

      fastcgi_param  SERVER_ADDR        $server_addr;
      

      The https://nginx.org/en/docs/http/ngx_http_core_module.html#var_server_addr nginx variable description says it contains an address of the server which accepted a request, which is obviously an nginx server address. If you want to determine an address of upstream server that is chosen to handle the request, you can try to pass an additional FastCGI variable to your PHP-FPM backend using the https://nginx.org/en/docs/http/ngx_http_upstream_module.html#var_upstream_addr nginx internal variable value, e.g.

      fastcgi_param  UPSTREAM_ADDR  $upstream_addr;
      

      and check its value via the $_SERVER['UPSTREAM_ADDR'] array item value (I didn't check if this would work, so if you'd check it, any positive or negative feedback is welcome).

      Alternatively you can check https://stackoverflow.com/a/17053582/7121513 StackOverflow answer.

      posted in Continuous Integration and Delivery (CI
      M
      meriah
    • RE: How to apply k8s manifest without scaling replicas

      The application boot up might be using resources above your set utilisation target before settling down. What you can do is to either:

      • give it a bit more resource request
      • increase the threshold of the HPA utilisation target
      • increase the autoscaler interval check
      posted in Continuous Integration and Delivery (CI
      M
      meriah
    • Is it normal to build a lot of bases in Subnautica?

      I am a new player of Subnautica and I find myself building a lot of bases. Already I have 4 bases and it looks like more are on the way. I seem to want to build them about 500m from each other, otherwise I have to travel long distances to get to things. However, if I start building bases every 500m, I am going to be building a LOT of bases eventually. Is this normal, or is there some way people are able to play the game with only a few bases?

      posted in Game Testing
      M
      meriah