generating remote users
authorAlex S <alex.strizhakov@gmail.com>
Fri, 6 Sep 2019 17:14:02 +0000 (20:14 +0300)
committerAlex S <alex.strizhakov@gmail.com>
Fri, 6 Sep 2019 17:14:02 +0000 (20:14 +0300)
lib/load_testing/fetcher.ex
lib/load_testing/generator.ex
lib/pleroma/user.ex

index b92b6e04ff55e68b70ecf48f71ed5ef2538e4c94..0ff2f28c0da9a349e8d98cadcd9e80d687351c36 100644 (file)
@@ -215,7 +215,7 @@ defmodule Pleroma.LoadTesting.Fetcher do
           for: user
         })
       end,
-      "Render context ancestors" => fn ->
+      "Render context" => fn ->
         Pleroma.Web.MastodonAPI.StatusView.render(
           "index.json",
           for: user,
index 7ad68dcc16d63a0c29e5a14e2f842797e90e6287..61e3d8686869d6fc9f94703ebeda8552a53f48e5 100644 (file)
@@ -22,6 +22,8 @@ defmodule Pleroma.LoadTesting.Generator do
   end
 
   defp generate_user_data(i) do
+    remote = Enum.random([true, false])
+
     user = %User{
       name: "Test ใƒ†ใ‚นใƒˆ User #{i}",
       email: "user#{i}@example.com",
@@ -29,16 +31,32 @@ defmodule Pleroma.LoadTesting.Generator do
       password_hash: Comeonin.Pbkdf2.hashpwsalt("test"),
       bio: "Tester Number #{i}",
       info: %{},
-      local: Enum.random([true, false])
+      local: remote
     }
 
-    user = %{
-      user
-      | ap_id: User.ap_id(user),
-        follower_address: User.ap_followers(user),
-        following_address: User.ap_following(user),
-        following: [User.ap_id(user)]
-    }
+    user_urls =
+      if remote do
+        base_url =
+          Enum.random(["https://domain1.com", "https://domain2.com", "https://domain3.com"])
+
+        ap_id = "#{base_url}/users/#{user.nickname}"
+
+        %{
+          ap_id: ap_id,
+          follower_address: ap_id <> "/followers",
+          following_address: ap_id <> "/following",
+          following: [ap_id]
+        }
+      else
+        %{
+          ap_id: User.ap_id(user),
+          follower_address: User.ap_followers(user),
+          following_address: User.ap_following(user),
+          following: [User.ap_id(user)]
+        }
+      end
+
+    user = Map.merge(user, user_urls)
 
     Repo.insert!(user)
   end
index 3aa245f2aa43f60389fc8a8f43023de09a39268e..37e59a651415757fc50d8bf739779401092d071b 100644 (file)
@@ -429,7 +429,9 @@ defmodule Pleroma.User do
         {:error, "Could not follow user: #{followed.nickname} blocked you."}
 
       true ->
-        if !followed.local && follower.local && !ap_enabled?(followed) do
+        benchmark? = Pleroma.Config.get([:env]) == :benchmark
+
+        if !followed.local && follower.local && !ap_enabled?(followed) && !benchmark? do
           Websub.subscribe(follower, followed)
         end