anchor.diff:                     not_allowed_publish_close_qos1_mqtt_3_1_1,
                      not_allowed_publish_close_qos2_mqtt_3_1_1,
                      message_size_exceeded_close,
  -                   shared_subscription_offline,
  -                   shared_subscription_online_first,
                      publish_c2b_retry_qos2_test,
                      publish_b2c_retry_qos1_test,
                      publish_b2c_retry_qos2_test
  
positive.code:          publish_c2b_disconnect_qos2_test,
           pattern_matching_test,
           drop_dollar_topic_publish,
           message_size_exceeded_close
          ],
      [
       {mqttv3, [shuffle], [
  
negative.code:     vmq_config:set_env(max_message_size, OldLimit, false),
      disable_on_publish().
  
  shared_subscription_offline(Cfg) ->
      enable_on_publish(),
      enable_on_subscribe(),
      Connack = mqtt5_v4compat:gen_connack(success, Cfg),
      Prefix = vmq_cth:ustr(Cfg),
      PubConnect = mqtt5_v4compat:gen_connect(Prefix ++ "single-offline-pub", [{keepalive, 60}], Cfg),
      SubConnectOffline = mqtt5_v4compat:gen_connect(Prefix ++ "single-offline-sha-sub",
                                                     [{keepalive, 60},
                                                      {clean_session, false}], Cfg),
      Subscription = "$share/singleofflinesub/shared_sub_topic",
      {ok, PubSocket} = mqtt5_v4compat:do_client_connect(PubConnect, Connack, [], Cfg),
      {ok, SubSocketOffline} = mqtt5_v4compat:do_client_connect(SubConnectOffline, Connack, [], Cfg),
      Subscribe = mqtt5_v4compat:gen_subscribe(1, Subscription, 1, Cfg),
      Suback = mqtt5_v4compat:gen_suback(1, 1, Cfg),
      ok = gen_tcp:send(SubSocketOffline, Subscribe),
      ok = mqtt5_v4compat:expect_packet(SubSocketOffline, "suback", Suback, Cfg),
      Disconnect = mqtt5_v4compat:gen_disconnect(Cfg),
      ok = gen_tcp:send(SubSocketOffline, Disconnect),
  
      PubFun
          = fun(Socket, Mid) ->
                    Publish = mqtt5_v4compat:gen_publish("shared_sub_topic", 1,
                                                         vmq_test_utils:rand_bytes(1024),
                                                         [{mid, Mid}], Cfg),
                    Puback = mqtt5_v4compat:gen_puback(Mid, Cfg),
                    ok = gen_tcp:send(Socket, Publish),
                    ok = mqtt5_v4compat:expect_packet(Socket, "puback", Puback, Cfg),
                    {Mid, Publish}
            end,
      Published = [PubFun(PubSocket, Mid) || Mid <- lists:seq(1,10)],
      ConnackSP = mqtt5_v4compat:gen_connack(true, success, Cfg),
      {ok, SubSocketOffline2} = mqtt5_v4compat:do_client_connect(SubConnectOffline, ConnackSP, [], Cfg),
      [begin
           ok = mqtt5_v4compat:expect_packet(SubSocketOffline2, "publish", Expect, Cfg),
           Puback = mqtt5_v4compat:gen_puback(Mid, Cfg),
           ok = gen_tcp:send(SubSocketOffline2, Puback)
       end || {Mid, Expect} <- Published ],
      disable_on_publish(),
      disable_on_subscribe().
  
  shared_subscription_online_first(Cfg) ->
      enable_on_publish(),
      enable_on_subscribe(),
      Connack = mqtt5_v4compat:gen_connack(success, Cfg),
      Prefix = vmq_cth:ustr(Cfg),
      PubConnect = mqtt5_v4compat:gen_connect(Prefix ++ "shared-sub-pub", [{keepalive, 60}], Cfg),
      SubConnectOnline = mqtt5_v4compat:gen_connect(Prefix ++ "shared-sub-sub-online",
                                                    [{keepalive, 60},
                                                     {clean_session, false}], Cfg),
      SubConnectOffline = mqtt5_v4compat:gen_connect(Prefix ++ "shared-sub-sub-offline",
                                                     [{keepalive, 60},
                                                      {clean_session, false}],
                                                     Cfg),
      Subscription = "$share/group/shared_sub_topic",
      {ok, PubSocket} = mqtt5_v4compat:do_client_connect(PubConnect, Connack, [], Cfg),
      {ok, SubSocketOnline} = mqtt5_v4compat:do_client_connect(SubConnectOnline, Connack, [], Cfg),
      {ok, SubSocketOffline} = mqtt5_v4compat:do_client_connect(SubConnectOffline, Connack, [], Cfg),
      Subscribe = mqtt5_v4compat:gen_subscribe(1, Subscription, 1, Cfg),
      Suback = mqtt5_v4compat:gen_suback(1, 1, Cfg),
      ok = gen_tcp:send(SubSocketOffline, Subscribe),
      ok = mqtt5_v4compat:expect_packet(SubSocketOffline, "suback", Suback, Cfg),
      ok = gen_tcp:send(SubSocketOnline, Subscribe),
      ok = mqtt5_v4compat:expect_packet(SubSocketOnline, "suback", Suback, Cfg),
      Disconnect = mqtt5_v4compat:gen_disconnect(Cfg),
      ok = gen_tcp:send(SubSocketOffline, Disconnect),
  
      PubFun
          = fun(Socket, Mid) ->
                    Publish = mqtt5_v4compat:gen_publish("shared_sub_topic", 1,
                                                 vmq_test_utils:rand_bytes(1024),
                                                 [{mid, Mid}], Cfg),
                    Puback = mqtt5_v4compat:gen_puback(Mid, Cfg),
                    ok = gen_tcp:send(Socket, Publish),
                    ok = mqtt5_v4compat:expect_packet(Socket, "puback", Puback, Cfg),
                    {Mid, Publish}
            end,
      Published = [PubFun(PubSocket, Mid) || Mid <- lists:seq(1,10)],
      %% since all messages should end up with the online subscriber, we
      %% can check they arrived one by one in the publish order.
      [begin
           ok = mqtt5_v4compat:expect_packet(SubSocketOnline, "publish", Expect, Cfg),
           Puback = mqtt5_v4compat:gen_puback(Mid, Cfg),
           ok = gen_tcp:send(SubSocketOnline, Puback)
       end || {Mid, Expect} <- Published ],
      disable_on_publish(),
  