https://linen.dev logo
#help
Title
v

Vlad Povolotzky

08/29/2023, 5:25 PM
Hey, I'm new to Wiremock. I'm using the Docker image in K8s and can't figure out how to set up the stubs backup. I created a dedicated volume in the root, but missing the last step. Any advice will be much appreciated šŸ™‚
o

Oleg Nenashev

08/29/2023, 6:57 PM
Hi! What do you mean under backup in these regards? Do you want to extract mappings from the server or what?
v

Vlad Povolotzky

08/30/2023, 7:37 AM
@Oleg Nenashev I want to save the mappings to the storage when the pod is terminating. And save all new mappings to /mappings as they are created
@Oleg Nenashev tried to set it up like this, doesn't work. /data is my persistent storage volume
Copy code
lifecycle:
          preStop:
            exec:
              command:
              - /bin/sh
              - -c
              - curl -X POST <http://wiremock:8080/__admin/mappings/save>
              - rm -rf /data/
              - cp -R /home/wiremock/ /data/
          postStart:
            exec:
              command:
              - /bin/sh
              - -c
              - cp -R /data/ /home/wiremock/
              - curl -X POST <http://wiremock:8080/__admin/mappings/reset>
o

Oleg Nenashev

08/30/2023, 10:25 AM
What does block you from just keeping the source of truth on the volume and back it using K8s tools up instead of relying ion
/data
?
v

Vlad Povolotzky

08/30/2023, 10:25 AM
Not sure I understand. Which volume are you referring to?
I'm not building the image, pulling it from the repository
o

Oleg Nenashev

08/30/2023, 10:27 AM
Copy code
apiVersion: v1
kind: Pod
metadata:
  name: wiremock
spec:
  containers:
  - name: wiremock
    image: wiremock/wiremock:2.35.0
    volumeMounts:
    - name: wiremock-storage
      mountPath: /home/wiremock
  volumes:
  - name: wiremock-storage
    emptyDir: {}
v

Vlad Povolotzky

08/30/2023, 10:30 AM
And Wiremock will use wiremock-storage as it's only storage?
o

Oleg Nenashev

08/30/2023, 10:34 AM
For Mappings and Files and everything under
/home/wiremock
- yes.
v

Vlad Povolotzky

08/30/2023, 10:36 AM
Will give it a try, thanks! I still need to use the
Copy code
<http://wiremock:8080/__admin/mappings/save>
to save the stubs, right?
o

Oleg Nenashev

08/30/2023, 10:37 AM
Yes, it does not sync to the disc without
save
v

Vlad Povolotzky

08/30/2023, 10:37 AM
Getting this when trying to save: <title>Error 500 java.lang.IllegalArgumentException: Invalid UUID string: save</title>
o

Oleg Nenashev

08/30/2023, 10:37 AM
Personally I recommend switching to the configuration-as-code approach and building your Docker image on the top of the official one, but that's up to you
It is a wrong endpoint. Lemme check
v

Vlad Povolotzky

08/30/2023, 10:38 AM
Totally new to all of this, will try to follow this advice in the future :)
šŸ‘ 1
o

Oleg Nenashev

08/30/2023, 10:41 AM
@Vlad Povolotzky Do you use POST for
__admin/mappings/save
? https://wiremock.org/docs/stubbing/#saving-stubs
With GET, it will try to get stub with UUID
save
v

Vlad Povolotzky

08/30/2023, 10:42 AM
It's POST, sure
o

Oleg Nenashev

08/30/2023, 10:43 AM
If you get
IllegalArgumentException
with POST, it is a bug. Could you please file one?
v

Vlad Povolotzky

08/30/2023, 10:43 AM
Screenshot 2023-08-30 at 13.42.47.png
šŸ™Œ 1
Where do I open bugs?
o

Oleg Nenashev

08/30/2023, 10:44 AM
v

Vlad Povolotzky

08/30/2023, 10:54 AM
o

Oleg Nenashev

08/30/2023, 11:03 AM
Thanks!
v

Vlad Povolotzky

08/31/2023, 12:35 PM
@Oleg Nenashev mounted the volume to home/mapping and now calling /save saves the stubs there as it should. How do I load the mappings from the /mappings folder? Currently after container restart a call to /mappings returns empty list.
o

Oleg Nenashev

08/31/2023, 12:46 PM
Do you have a startup log? If the volume is mapped and WireMock has the same home directory and no conflicting parameters, it should load them
v

Vlad Povolotzky

08/31/2023, 12:50 PM
That's all there is
o

Oleg Nenashev

08/31/2023, 1:14 PM
And with verbose options?
v

Vlad Povolotzky

08/31/2023, 1:42 PM
Do I need to edit the yamls for verbose option?
o

Oleg Nenashev

08/31/2023, 1:42 PM
Yes, it is a CLI argument
v

Vlad Povolotzky

09/03/2023, 12:58 PM
This is the log on verbose start:
Copy code
2023-09-03 09:31:57.156 Verbose logging enabled                                                                                                                                                 │
│                                                                                                                                                                                                 │
│ ā–ˆā–ˆ     ā–ˆā–ˆ ā–ˆā–ˆ ā–ˆā–ˆā–ˆā–ˆā–ˆā–ˆ  ā–ˆā–ˆā–ˆā–ˆā–ˆā–ˆā–ˆ ā–ˆā–ˆā–ˆ    ā–ˆā–ˆā–ˆ  ā–ˆā–ˆā–ˆā–ˆā–ˆā–ˆ   ā–ˆā–ˆā–ˆā–ˆā–ˆā–ˆ ā–ˆā–ˆ   ā–ˆā–ˆ                                                                                                                                │
│ ā–ˆā–ˆ     ā–ˆā–ˆ ā–ˆā–ˆ ā–ˆā–ˆ   ā–ˆā–ˆ ā–ˆā–ˆ      ā–ˆā–ˆā–ˆā–ˆ  ā–ˆā–ˆā–ˆā–ˆ ā–ˆā–ˆ    ā–ˆā–ˆ ā–ˆā–ˆ      ā–ˆā–ˆ  ā–ˆā–ˆ                                                                                                                                 │
│ ā–ˆā–ˆ  ā–ˆ  ā–ˆā–ˆ ā–ˆā–ˆ ā–ˆā–ˆā–ˆā–ˆā–ˆā–ˆ  ā–ˆā–ˆā–ˆā–ˆā–ˆ   ā–ˆā–ˆ ā–ˆā–ˆā–ˆā–ˆ ā–ˆā–ˆ ā–ˆā–ˆ    ā–ˆā–ˆ ā–ˆā–ˆ      ā–ˆā–ˆā–ˆā–ˆā–ˆ                                                                                                                                  │
│ ā–ˆā–ˆ ā–ˆā–ˆā–ˆ ā–ˆā–ˆ ā–ˆā–ˆ ā–ˆā–ˆ   ā–ˆā–ˆ ā–ˆā–ˆ      ā–ˆā–ˆ  ā–ˆā–ˆ  ā–ˆā–ˆ ā–ˆā–ˆ    ā–ˆā–ˆ ā–ˆā–ˆ      ā–ˆā–ˆ  ā–ˆā–ˆ                                                                                                                                 │
│  ā–ˆā–ˆā–ˆ ā–ˆā–ˆā–ˆ  ā–ˆā–ˆ ā–ˆā–ˆ   ā–ˆā–ˆ ā–ˆā–ˆā–ˆā–ˆā–ˆā–ˆā–ˆ ā–ˆā–ˆ      ā–ˆā–ˆ  ā–ˆā–ˆā–ˆā–ˆā–ˆā–ˆ   ā–ˆā–ˆā–ˆā–ˆā–ˆā–ˆ ā–ˆā–ˆ   ā–ˆā–ˆ                                                                                                                                │
│                                                                                                                                                                                                 │
│ ----------------------------------------------------------------                                                                                                                                │
│ |               Cloud: <https://wiremock.io/cloud>               |                                                                                                                                │
│ |                                                              |                                                                                                                                │
│ |               Slack: <https://slack.wiremock.org>              |                                                                                                                                │
│ ----------------------------------------------------------------                                                                                                                                │
│                                                                                                                                                                                                 │
│ port:                         8080                                                                                                                                                              │
│ enable-browser-proxying:      false                                                                                                                                                             │
│ disable-banner:               false                                                                                                                                                             │
│ no-request-journal:           false                                                                                                                                                             │
│ verbose:                      true                                                                                                                                                              │
│                                                                                                                                                                                                 │
│ 2023-09-03 09:32:26.244 Admin request received:                                                                                                                                                 │
│ 10.1.64.174 - GET /                                                                                                                                                                             │
│                                                                                                                                                                                                 │
│ Host: [10.1.76.89:8080]                                                                                                                                                                         │
│ User-Agent: [kube-probe/1.23+]                                                                                                                                                                  │
│ Accept: [*/*]                                                                                                                                                                                   │
│ Referer: [<http://10.1.76.89:8080/__admin>]                                                                                                                                                       │
│ Connection: [close]                                                                                                                                                                             │
│                                                                                                                                                                                                 │
│
Only see the healthcheck calls
The saved stubs aren't loading
The files are there, '/save' saves them as expected:
Copy code
root@wiremock-0:/home/wiremock/mappings# ll
total 32
drwxr-xr-x 2 root root 4096 Sep  3 13:54 ./
drwxr-xr-x 5 root root 4096 Aug 30 12:44 ../
-rw-r--r-- 1 root root  349 Aug 31 12:26 post-messagingjson-25f1b193-c1a8-4560-b4c9-4a0fa48db818
-rw-r--r-- 1 root root  349 Aug 31 10:58 post-messagingjson-551e7f3b-7fd7-46a5-a3ef-b560c7576b1c
-rw-r--r-- 1 root root  349 Sep  3 06:41 post-messagingjson-cd2d2762-3c96-469f-9d64-ad721921812c
-rw-r--r-- 1 root root  349 Sep  3 13:54 post-messagingjson-d02207ea-70c8-49f1-a4ee-76b504afafcc
-rw-r--r-- 1 root root  289 Aug 31 11:52 post-messagingjson-d518e1b7-910f-4777-a4c2-66ae710b1be7
-rw-r--r-- 1 root root  349 Sep  3 13:54 post-messagingtest-378e1e84-de1f-4f95-a6ba-e55c7d8a5e5c
@Oleg Nenashev Can you take a look, please? šŸ™
o

Oleg Nenashev

09/04/2023, 11:44 AM
What concerns me is that there is no
*.json
extension in the ls output
v

Vlad Povolotzky

09/04/2023, 11:50 AM
@Oleg Nenashev You're right, they don't have an extension:
Copy code
root@wiremock-0:/home/wiremock/mappings# ls -1
post-messagingjson-25f1b193-c1a8-4560-b4c9-4a0fa48db818
post-messagingjson-551e7f3b-7fd7-46a5-a3ef-b560c7576b1c
post-messagingjson-cd2d2762-3c96-469f-9d64-ad721921812c
post-messagingjson-d02207ea-70c8-49f1-a4ee-76b504afafcc
post-messagingjson-d518e1b7-910f-4777-a4c2-66ae710b1be7
post-messagingtest-378e1e84-de1f-4f95-a6ba-e55c7d8a5e5c
root@wiremock-0:/home/wiremock/mappings#
o

Oleg Nenashev

09/04/2023, 12:45 PM
So yes, they should be present if we want WireMock to load it by default
v

Vlad Povolotzky

09/04/2023, 12:47 PM
Got it, thanks, will check why it's saved this way
šŸ‘ 1
o

Oleg Nenashev

09/07/2023, 10:57 AM
FTR https://github.com/wiremock/wiremock/issues/2361 @Vlad Povolotzky. It was created recently
2 Views